PortaMob
PortaMob.h
Go to the documentation of this file.
1 /*
2  * This file is part of the PortaMob Shield Arduino library.
3  * Copyright (c) 2023 Nathanne Isip
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this software and associated documentation files (the "Software"), to deal
7  * in the Software without restriction, including without limitation the rights
8  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9  * copies of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21  * THE SOFTWARE.
22  */
23 
42 #ifndef PORTAMOB_H
43 #define PORTAMOB_H
44 
45 #include <Arduino.h>
46 #include <Adafruit_SSD1306.h>
47 
48 #define PORTAMOB_KEY_1 2
49 #define PORTAMOB_KEY_2 5
50 #define PORTAMOB_KEY_3 8
51 #define PORTAMOB_KEY_4 9
52 #define PORTAMOB_KEY_5 3
53 #define PORTAMOB_KEY_6 6
54 #define PORTAMOB_KEY_7 4
55 #define PORTAMOB_KEY_8 7
56 #define PORTAMOB_KEY_9 10
57 
58 #define PORTAMOB_EEPROM_ADDR 0x50
59 #define PORTAMOB_SCREEN_ADDRESS 0x3C
60 
70 class PortaMob {
71 public:
90  static Adafruit_SSD1306 portamob_display(
91  void (*on_error)()
92  );
93 
106  static void init_buttons(void);
107 
126  static bool is_button_pressed(uint8_t button);
127 
138  static void init_i2c();
139 
154  static void eeprom_write(
155  uint8_t addr,
156  uint8_t value
157  );
158 
176  static uint8_t eeprom_read(uint8_t addr);
177 
191  static bool has_eeprom();
192 };
193 
194 #endif
A class that provides comprehensive functionalities to interact with the PortaMob Shield components.
Definition: PortaMob.h:70
static void init_i2c()
Initializes the I2C communication.
Definition: PortaMob.cpp:59
static Adafruit_SSD1306 portamob_display(void(*on_error)())
Initializes the PortaMob display.
Definition: PortaMob.cpp:31
static void init_buttons(void)
Initializes the push buttons on the PortaMob Shield.
Definition: PortaMob.cpp:43
static bool is_button_pressed(uint8_t button)
Checks if a specific button is pressed.
Definition: PortaMob.cpp:55
static void eeprom_write(uint8_t addr, uint8_t value)
Writes a value to the EEPROM memory.
Definition: PortaMob.cpp:63
static bool has_eeprom()
Checks if the EEPROM memory is present.
Definition: PortaMob.cpp:91
static uint8_t eeprom_read(uint8_t addr)
Reads a value from the EEPROM memory.
Definition: PortaMob.cpp:76