diff --git a/twinmax/twinmax.h b/twinmax/twinmax.h new file mode 100644 index 0000000..84290a1 --- /dev/null +++ b/twinmax/twinmax.h @@ -0,0 +1,22 @@ +#ifndef _TWINMAX_H_DEF_ +#define _TWINMAX_H_DEF_ + + #include "sensors.h" + + #include + #include "SSD1306Ascii.h" + #include "SSD1306AsciiWire.h" + + #define PUSH_BTN_PIN 7 + #define POTENTIOMETER_PIN A0 + #define PRESSURE_LEFT A1 + #define PRESSURE_RIGHT A2 + + #define DISP_DATA A4 + #define DISP_CLCK A5 + #define DISP_ADDR 0x3C + + enum Mode { RELATIVE, ABSOLUTE }; + Mode mode = ABSOLUTE; + +#endif diff --git a/twinmax/twinmax.ino b/twinmax/twinmax.ino new file mode 100644 index 0000000..cc58cd2 --- /dev/null +++ b/twinmax/twinmax.ino @@ -0,0 +1,44 @@ +#include "twinmax.h" + +SSD1306AsciiWire oled; +Pressure pleft; +Pressure pright; +PushButton btn; +Potentiometer slider; + +void setup() +{ + Wire.begin(); + Wire.setClock(400000L); + + pleft.setup(PRESSURE_LEFT); + pright.setup(PRESSURE_RIGHT); + btn.setup(PUSH_BTN_PIN); + slider.setup(POTENTIOMETER_PIN); + + Serial.begin(9600); + + oled.begin(&Adafruit128x32, DISP_ADDR); + oled.clear(); +} + +void loop() +{ + if( btn.tap() ){ + mode = (mode == RELATIVE) ? ABSOLUTE : RELATIVE; + } + + oled.clear(); + oled.setFont(); + if( mode == RELATIVE ) oled.println(" relative "); + if( mode == ABSOLUTE ) oled.println(" absolute "); + + + oled.setFont(Callibri11); + oled.print(slider.range()); + oled.print(": "); + oled.print(pleft.value()); oled.print("-"); + oled.println(pright.value()); + + delay(100); +}