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;
|
||||
byte forceScreenUpdate = 1;
|
||||
|
||||
byte currentScreen = 0;
|
||||
byte editMode = 0;
|
||||
int mainScreenCursorPos = 0;
|
||||
byte maxMainScreenPos = 8;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
|
@ -58,6 +62,7 @@ void setup() {
|
|||
|
||||
// screen setup
|
||||
u8g2.begin();
|
||||
u8g2.setFontMode(1);
|
||||
|
||||
// display.clearDisplay();
|
||||
// display.setTextSize(2);
|
||||
|
|
@ -150,16 +155,39 @@ void updateScreen() {
|
|||
if (currentTime - screenLastUpdate >= screenThrottle && forceScreenUpdate == 1) {
|
||||
screenLastUpdate = currentTime;
|
||||
forceScreenUpdate = 0;
|
||||
// The firstPage()/nextPage() loop manages where the drawing commands go
|
||||
u8g2.firstPage();
|
||||
do {
|
||||
// --- Drawing Commands for the CURRENT Page ---
|
||||
// All drawing commands must live INSIDE this do/while loop.
|
||||
u8g2.setFont(u8g2_font_helvR08_tf);
|
||||
u8g2.setCursor(0, 10);
|
||||
u8g2.print(F("BPM: "));
|
||||
u8g2.print(BPM); // Example of dynamic data
|
||||
// 12px - nonbold
|
||||
if (mainScreenCursorPos == 0) {
|
||||
u8g2.setFont(u8g2_font_7x14B_mf);
|
||||
} else {
|
||||
u8g2.setFont(u8g2_font_7x14_mf);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
@ -187,10 +215,21 @@ void checkRPot() {
|
|||
Serial.print("Encoder Position: ");
|
||||
Serial.println(currentPos);
|
||||
|
||||
// on home screen
|
||||
if (currentScreen == 0) {
|
||||
if (editMode == 0) {
|
||||
if (currentPos > previousPos) {
|
||||
handleBPMChange(1);
|
||||
mainScreenCursorPos++;
|
||||
if (mainScreenCursorPos > maxMainScreenPos) {
|
||||
mainScreenCursorPos = 0;
|
||||
}
|
||||
} else {
|
||||
handleBPMChange(0);
|
||||
mainScreenCursorPos--;
|
||||
if (mainScreenCursorPos < 0) {
|
||||
mainScreenCursorPos = maxMainScreenPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
forceScreenUpdate = 1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue