58 lines
948 B
C++
58 lines
948 B
C++
#include "twinmax.h"
|
|
|
|
#include <Arduino.h>
|
|
#include <SoftwareSerial.h>
|
|
#include <Wire.h>
|
|
|
|
Display oled(4);
|
|
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();
|
|
oled.clear();
|
|
oled.apply();
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
if( btn.tap() ){
|
|
mode = (mode == RELATIVE) ? ABSOLUTE : RELATIVE;
|
|
}
|
|
|
|
oled.clear();
|
|
if( mode == RELATIVE ){
|
|
const int16_t left = pleft.value();
|
|
const int16_t right = pright.value();
|
|
|
|
// print absolute
|
|
oled.progress(left, 10, 15);
|
|
oled.progress(right, 20, 25);
|
|
|
|
// relative
|
|
double diff = (right - left);
|
|
diff = diff * slider.range() / 128.0;
|
|
oled.progress(512 + diff, 0, 5, false);
|
|
oled.apply();
|
|
}
|
|
|
|
if( mode == ABSOLUTE ){
|
|
oled.apply();
|
|
}
|
|
|
|
// delay(100);
|
|
}
|