Files
libGravity/gravity.h
Adam Wonak d12764313b Introduce StateManager to persist state between power cycles (#6)
- add reset state menu option to return all settings back to default values.
- add reverse encoder menu option and save state
- make saving to EEPROM safer by wrapping put calls with noInterrupts()
- improve save state behavior by using a mutex flag and update check with debounce in main loop
- refactor gravity.h global const definitions to be static and more readable.
- improve usage of EncoderDir in ISR with pointer to instance and static isr() method.
- reduce u8g2 memory usage by using single page buffer

Reviewed-on: https://git.pinkduck.xyz/adam/libGravity/pulls/6
Co-authored-by: Adam Wonak <adam.wonak@gmail.com>
Co-committed-by: Adam Wonak <adam.wonak@gmail.com>
2025-06-16 02:47:25 +00:00

51 lines
1.2 KiB
C++

#ifndef GRAVITY_H
#define GRAVITY_H
#include <Arduino.h>
#include <U8g2lib.h>
#include "analog_input.h"
#include "button.h"
#include "clock.h"
#include "digital_output.h"
#include "encoder_dir.h"
#include "peripherials.h"
// Hardware abstraction wrapper for the Gravity module.
class Gravity {
public:
static const uint8_t OUTPUT_COUNT = 6;
// Constructor
Gravity()
: display(U8G2_R2, SCL, SDA, U8X8_PIN_NONE) {}
// Deconstructor
~Gravity() {}
// Initializes the Arduino, and Gravity hardware.
void Init();
// Polling check for state change of inputs and outputs.
void Process();
U8G2_SSD1306_128X64_NONAME_1_HW_I2C display; // OLED display object.
Clock clock; // Clock source wrapper.
DigitalOutput outputs[OUTPUT_COUNT]; // An array containing each Output object.
EncoderDir encoder; // Rotary encoder with button instance
Button shift_button;
Button play_button;
AnalogInput cv1;
AnalogInput cv2;
private:
void initClock();
void initDisplay();
void initInputs();
void initOutputs();
};
extern Gravity gravity;
#endif