소스 검색

time_display: Correct sleep interval and reset time zone

Helmut Pozimski 1 년 전
부모
커밋
4551509d47
2개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 2
      main/time_display.c
  2. 1 1
      main/time_sync.c

+ 4 - 2
main/time_display.c

@@ -45,11 +45,11 @@ static uint8_t max(uint8_t a, uint8_t b) {
     return (a > b) ? a : b;
 }
 
-static uint8_t determine_sleep_time(struct tm *local_time) {
+static uint16_t determine_sleep_time(struct tm *local_time) {
     uint8_t wakeup_time_sec;
     wakeup_time_sec = 60 - local_time->tm_sec;
     wakeup_time_sec = max(wakeup_time_sec, 1);
-    return wakeup_time_sec;
+    return wakeup_time_sec * 1000;
 }
 
 void display_update_task(void *pvParameters) {
@@ -57,6 +57,8 @@ void display_update_task(void *pvParameters) {
 	while(1) {
 		ds3231_read_date_time(&current_time);
 		struct tm *local_time = convert_to_local(&current_time);
+		setenv("TZ", "GMT+0GMT+0", 1);
+		tzset();
 		update_display(local_time->tm_hour, local_time->tm_min);
 		vTaskDelay(determine_sleep_time(local_time) / portTICK_PERIOD_MS);
 	}

+ 1 - 1
main/time_sync.c

@@ -27,7 +27,7 @@ void sntp_start(uint32_t sync_interval) {
 
 void await_sntp_sync() {
     while (sntp_get_sync_status() == SNTP_SYNC_STATUS_RESET) {
-        ESP_LOGI(TAG, "Waiting for system time to be set...)");
+        ESP_LOGI(TAG, "Waiting for system time to be set...");
         vTaskDelay(2000 / portTICK_PERIOD_MS);
     }