working screen UI but broken throttling
This commit is contained in:
parent
90693e8c2a
commit
20281ad17a
1 changed files with 51 additions and 12 deletions
|
|
@ -45,6 +45,10 @@ unsigned long screenLastUpdate = 0;
|
||||||
const unsigned long screenThrottle = 200;
|
const unsigned long screenThrottle = 200;
|
||||||
byte forceScreenUpdate = 1;
|
byte forceScreenUpdate = 1;
|
||||||
|
|
||||||
|
byte currentScreen = 0;
|
||||||
|
byte editMode = 0;
|
||||||
|
int mainScreenCursorPos = 0;
|
||||||
|
byte maxMainScreenPos = 8;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
@ -58,6 +62,7 @@ void setup() {
|
||||||
|
|
||||||
// screen setup
|
// screen setup
|
||||||
u8g2.begin();
|
u8g2.begin();
|
||||||
|
u8g2.setFontMode(1);
|
||||||
|
|
||||||
// display.clearDisplay();
|
// display.clearDisplay();
|
||||||
// display.setTextSize(2);
|
// display.setTextSize(2);
|
||||||
|
|
@ -150,16 +155,39 @@ void updateScreen() {
|
||||||
if (currentTime - screenLastUpdate >= screenThrottle && forceScreenUpdate == 1) {
|
if (currentTime - screenLastUpdate >= screenThrottle && forceScreenUpdate == 1) {
|
||||||
screenLastUpdate = currentTime;
|
screenLastUpdate = currentTime;
|
||||||
forceScreenUpdate = 0;
|
forceScreenUpdate = 0;
|
||||||
// The firstPage()/nextPage() loop manages where the drawing commands go
|
|
||||||
u8g2.firstPage();
|
u8g2.firstPage();
|
||||||
do {
|
do {
|
||||||
// --- Drawing Commands for the CURRENT Page ---
|
// 12px - nonbold
|
||||||
// All drawing commands must live INSIDE this do/while loop.
|
if (mainScreenCursorPos == 0) {
|
||||||
u8g2.setFont(u8g2_font_helvR08_tf);
|
u8g2.setFont(u8g2_font_7x14B_mf);
|
||||||
u8g2.setCursor(0, 10);
|
} else {
|
||||||
u8g2.print(F("BPM: "));
|
u8g2.setFont(u8g2_font_7x14_mf);
|
||||||
u8g2.print(BPM); // Example of dynamic data
|
}
|
||||||
|
|
||||||
|
u8g2.setCursor(0, 15);
|
||||||
|
u8g2.print(F("BPM: "));
|
||||||
|
u8g2.print(BPM);
|
||||||
|
|
||||||
|
u8g2.setFont(u8g2_font_7x14_mf);
|
||||||
|
u8g2.setCursor(0, 45);
|
||||||
|
|
||||||
|
char buffer[5];
|
||||||
|
for (byte i = 1; i < 9; i++) {
|
||||||
|
if (i == 5) {
|
||||||
|
u8g2.setCursor(0, 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mainScreenCursorPos == i) {
|
||||||
|
u8g2.setFont(u8g2_font_7x14B_mf);
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(buffer, "[%d] ", i);
|
||||||
|
u8g2.print(buffer);
|
||||||
|
|
||||||
|
if (mainScreenCursorPos == i) {
|
||||||
|
u8g2.setFont(u8g2_font_7x14_mf);
|
||||||
|
}
|
||||||
|
};
|
||||||
} while (u8g2.nextPage());
|
} while (u8g2.nextPage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -187,10 +215,21 @@ void checkRPot() {
|
||||||
Serial.print("Encoder Position: ");
|
Serial.print("Encoder Position: ");
|
||||||
Serial.println(currentPos);
|
Serial.println(currentPos);
|
||||||
|
|
||||||
|
// on home screen
|
||||||
|
if (currentScreen == 0) {
|
||||||
|
if (editMode == 0) {
|
||||||
if (currentPos > previousPos) {
|
if (currentPos > previousPos) {
|
||||||
handleBPMChange(1);
|
mainScreenCursorPos++;
|
||||||
|
if (mainScreenCursorPos > maxMainScreenPos) {
|
||||||
|
mainScreenCursorPos = 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
handleBPMChange(0);
|
mainScreenCursorPos--;
|
||||||
|
if (mainScreenCursorPos < 0) {
|
||||||
|
mainScreenCursorPos = maxMainScreenPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
forceScreenUpdate = 1;
|
forceScreenUpdate = 1;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue