From b68416af99785ce855883698ad6397a849bfa9a2 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 30 May 2020 19:08:02 +0200 Subject: [PATCH] add default main with temporary 'SSD1306Ascii' library - official library takes 132% of the arduino uno memory so no way we use it; it is mainly due to the buffer which is 32x128 bytes - the next step is to reverse-engineer it to keep no buffer and rely on a state according to our very own usage --- twinmax/twinmax.h | 22 ++++++++++++++++++++++ twinmax/twinmax.ino | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 twinmax/twinmax.h create mode 100644 twinmax/twinmax.ino 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); +}