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
This commit is contained in:
Adrien Marquès 2020-05-30 19:08:02 +02:00
parent c368a1f209
commit b68416af99
Signed by: xdrm-brackets
GPG Key ID: D75243CA236D825E
2 changed files with 66 additions and 0 deletions

22
twinmax/twinmax.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef _TWINMAX_H_DEF_
#define _TWINMAX_H_DEF_
#include "sensors.h"
#include <Wire.h>
#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

44
twinmax/twinmax.ino Normal file
View File

@ -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);
}