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:
parent
c368a1f209
commit
b68416af99
|
@ -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
|
|
@ -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);
|
||||||
|
}
|
Loading…
Reference in New Issue