mirror of
https://github.com/KevinMidboe/oled_workout_tracker.git
synced 2025-10-29 09:40:28 +00:00
Define new inputs.
This commit is contained in:
@@ -30,19 +30,25 @@
|
|||||||
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
|
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
|
||||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||||
|
|
||||||
#define NUMFLAKES 10 // Number of snowflakes in the animation example
|
#define CLK 2
|
||||||
|
#define DT 3
|
||||||
|
#define SW 4
|
||||||
|
|
||||||
// input pin definition
|
int counter = 0;
|
||||||
int buttonModePin = 2;
|
int currentStateCLK;
|
||||||
int potPin = 2;
|
int lastStateCLK;
|
||||||
|
String currentDir ="";
|
||||||
|
unsigned long lastButtonPress = 0;
|
||||||
|
|
||||||
|
bool mode = false;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
// Setup button interrupt for changing modes
|
// Set encoder pins as inputs
|
||||||
pinMode(buttonModePin, INPUT_PULLUP);
|
pinMode(CLK,INPUT);
|
||||||
attachInterrupt(digitalPinToInterrupt(2), changeMode, FALLING);
|
pinMode(DT,INPUT);
|
||||||
|
pinMode(SW, INPUT_PULLUP);
|
||||||
|
|
||||||
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
||||||
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
|
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
|
||||||
@@ -50,6 +56,9 @@ void setup() {
|
|||||||
for(;;); // Don't proceed, loop forever
|
for(;;); // Don't proceed, loop forever
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read the initial state of CLK
|
||||||
|
lastStateCLK = digitalRead(CLK);
|
||||||
|
|
||||||
// Clear the buffer
|
// Clear the buffer
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setTextColor(SSD1306_WHITE);
|
display.setTextColor(SSD1306_WHITE);
|
||||||
|
|||||||
Reference in New Issue
Block a user