improvement display state

This commit is contained in:
2025-10-18 18:44:56 +02:00
parent 719701bc55
commit 32e05989f5
3 changed files with 34 additions and 25 deletions

View File

@@ -21,8 +21,8 @@
#define COMMAND "FDFCFBFA0800120000000200000004030203" //Normal mode command, see documentation waveshare sensor
#define PRESENCE_DISTANCE 200 // in cm
#define DELAY_STATUS_CHECK 1000 // delay (in ms) between two checks of the presence
#define SLEEP_DELAY 10000 // delay (in ms) until sleep mode
#define POWER_DELAY 30000 // delay (in ms) until turning off the screen
#define SLEEP_DELAY 30000 // delay (in ms) until sleep mode
#define POWER_DELAY 100000 // delay (in ms) until turning off the screen
byte configCommand[] = {
0xFD, 0xFC, 0xFB, 0xFA, 0x08, 0x00, 0x12, 0x00,
@@ -85,6 +85,7 @@ void loop() {
flag_bl = 1;
lv_delay_ms(500);
ui_begin();
lv_msg_send(MSG_NEW_VOLT, "");
}
}
}
@@ -112,6 +113,8 @@ void initSerial() {
// Start Serial2 for the HMMD Sensor
Serial2.begin(BAUD, SERIAL_8N1, RX2_PIN, TX2_PIN);
Serial.println("Serial2 Initialized on RX:" + String(RX2_PIN) + ", TX:" + String(TX2_PIN));
Serial.println("Sending configuration to the sensor");
delay(2000);
Serial2.write(configCommand, sizeof(configCommand));
}
@@ -228,17 +231,17 @@ void readAndProcessSensorLines() {
if (currentStatus && state != 0) {
state = 0;
Serial.println("Motion detected, turning screen on.");
update_display_state(state);
lv_msg_send(MSG_NEW_VOLT, "0");
//restApiAction(0);
} else if (!currentStatus && state == 1 && (millis() - lastMotionDetected >= POWER_DELAY)) {
state = 2;
Serial.printf("No motion detected for %d seconds, turning screen off.\n", POWER_DELAY);
update_display_state(state);
Serial.printf("No motion detected for %d ms, turning screen off.\n", POWER_DELAY);
lv_msg_send(MSG_NEW_VOLT, "2");
//restApiAction(2);
} else if (!currentStatus && state == 0 && (millis() - lastMotionDetected >= SLEEP_DELAY)) {
state = 1;
Serial.printf("No motion detected for %d seconds, turning screen screensaver on.\n", SLEEP_DELAY);
update_display_state(state);
Serial.printf("No motion detected for %d ms, turning screen screensaver on.\n", SLEEP_DELAY);
lv_msg_send(MSG_NEW_VOLT, "1");
//restApiAction(1);
}
}