fix display
This commit is contained in:
parent
daa3cff439
commit
5bf3870869
@ -34,7 +34,7 @@ const int VIBRATION_PIN = 4;
|
|||||||
|
|
||||||
// OLED display settings
|
// OLED display settings
|
||||||
#define SCREEN_WIDTH 128
|
#define SCREEN_WIDTH 128
|
||||||
#define SCREEN_HEIGHT 64
|
#define SCREEN_HEIGHT 32
|
||||||
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
|
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
|
||||||
#define SCREEN_ADDRESS 0x3C
|
#define SCREEN_ADDRESS 0x3C
|
||||||
#ifdef ENABLE_DISPLAY
|
#ifdef ENABLE_DISPLAY
|
||||||
@ -67,7 +67,9 @@ unsigned long lightLowStartTime = 0;
|
|||||||
String displayData[4];
|
String displayData[4];
|
||||||
int currentDisplayLine = 0;
|
int currentDisplayLine = 0;
|
||||||
unsigned long lastDisplayScrollTime = 0;
|
unsigned long lastDisplayScrollTime = 0;
|
||||||
const unsigned long DISPLAY_SCROLL_INTERVAL = 1000; // 1000 = 1 second
|
const unsigned long DISPLAY_SCROLL_INTERVAL = 2000; // 1000 = 1 second
|
||||||
|
const int displayTextLines = 5;
|
||||||
|
int displayDataLines = displayTextLines;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Notification queue
|
// Notification queue
|
||||||
@ -76,7 +78,8 @@ String queuedTitle = "";
|
|||||||
String queuedPriority = "";
|
String queuedPriority = "";
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(9600);
|
||||||
|
Serial.println("Setup started.");
|
||||||
|
|
||||||
#if defined(ENABLE_SENSORS) || defined(ENABLE_DISPLAY)
|
#if defined(ENABLE_SENSORS) || defined(ENABLE_DISPLAY)
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
@ -129,6 +132,9 @@ void setup() {
|
|||||||
display.display();
|
display.display();
|
||||||
delay(1000);
|
delay(1000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Serial.println("Setup finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sendNotification(String message, String title, String priority);
|
bool sendNotification(String message, String title, String priority);
|
||||||
@ -242,6 +248,7 @@ void loop() {
|
|||||||
displayData[1] = "Light: " + String(currentLightLevel) + " lx";
|
displayData[1] = "Light: " + String(currentLightLevel) + " lx";
|
||||||
displayData[2] = "Light Active: " + String(isLightActive ? "ON" : "OFF");
|
displayData[2] = "Light Active: " + String(isLightActive ? "ON" : "OFF");
|
||||||
displayData[3] = "Device: " + String(isDeviceActive ? "ACTIVE" : "INACTIVE");
|
displayData[3] = "Device: " + String(isDeviceActive ? "ACTIVE" : "INACTIVE");
|
||||||
|
displayDataLines = 4;
|
||||||
|
|
||||||
// Update display
|
// Update display
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
@ -285,9 +292,9 @@ void updateDisplay() {
|
|||||||
unsigned long currentTime = millis();
|
unsigned long currentTime = millis();
|
||||||
|
|
||||||
// Scroll logic
|
// Scroll logic
|
||||||
if (currentTime - lastDisplayScrollTime > DISPLAY_SCROLL_INTERVAL) {
|
if ((displayDataLines > displayTextLines) && (currentTime - lastDisplayScrollTime > DISPLAY_SCROLL_INTERVAL)) {
|
||||||
lastDisplayScrollTime = currentTime;
|
lastDisplayScrollTime = currentTime;
|
||||||
currentDisplayLine = (currentDisplayLine + 1) % 4;
|
currentDisplayLine = (currentDisplayLine + 1) % displayDataLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
@ -295,8 +302,8 @@ void updateDisplay() {
|
|||||||
display.setTextColor(WHITE);
|
display.setTextColor(WHITE);
|
||||||
display.setCursor(0, 0);
|
display.setCursor(0, 0);
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < displayDataLines; i++) {
|
||||||
int lineIndex = (currentDisplayLine + i) % 4;
|
int lineIndex = (currentDisplayLine + i) % displayDataLines;
|
||||||
display.println(displayData[lineIndex]);
|
display.println(displayData[lineIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user