-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix WebUI currency converter, reorganize some code
- Loading branch information
Showing
14 changed files
with
228 additions
and
195 deletions.
There are no files selected for viewing
Submodule data
updated
4 files
+1 −0 | package.json | |
+1 −1 | src/lib/style/app.scss | |
+35 −16 | src/routes/convert/+page.svelte | |
+49 −21 | yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#include "timers.hpp" | ||
|
||
esp_timer_handle_t screenRotateTimer; | ||
esp_timer_handle_t minuteTimer; | ||
|
||
void setupTimeUpdateTimer(void *pvParameters) { | ||
const esp_timer_create_args_t minuteTimerConfig = { | ||
.callback = &minuteTimerISR, .name = "minute_timer"}; | ||
|
||
esp_timer_create(&minuteTimerConfig, &minuteTimer); | ||
|
||
time_t currentTime; | ||
struct tm timeinfo; | ||
time(¤tTime); | ||
localtime_r(¤tTime, &timeinfo); | ||
uint32_t secondsUntilNextMinute = 60 - timeinfo.tm_sec; | ||
|
||
if (secondsUntilNextMinute > 0) | ||
vTaskDelay(pdMS_TO_TICKS((secondsUntilNextMinute * 1000))); | ||
|
||
esp_timer_start_periodic(minuteTimer, usPerMinute); | ||
|
||
WorkItem timeUpdate = {TASK_TIME_UPDATE, 0}; | ||
xQueueSend(workQueue, &timeUpdate, portMAX_DELAY); | ||
// xTaskNotifyGive(timeUpdateTaskHandle); | ||
|
||
vTaskDelete(NULL); | ||
} | ||
|
||
void setupScreenRotateTimer(void *pvParameters) { | ||
const esp_timer_create_args_t screenRotateTimerConfig = { | ||
.callback = &screenRotateTimerISR, .name = "screen_rotate_timer"}; | ||
|
||
esp_timer_create(&screenRotateTimerConfig, &screenRotateTimer); | ||
|
||
if (preferences.getBool("timerActive", DEFAULT_TIMER_ACTIVE)) { | ||
esp_timer_start_periodic(screenRotateTimer, | ||
getTimerSeconds() * usPerSecond); | ||
} | ||
|
||
vTaskDelete(NULL); | ||
} | ||
|
||
uint getTimerSeconds() { return preferences.getUInt("timerSeconds", DEFAULT_TIMER_SECONDS); } | ||
|
||
bool isTimerActive() { return esp_timer_is_active(screenRotateTimer); } | ||
|
||
void setTimerActive(bool status) { | ||
if (status) { | ||
esp_timer_start_periodic(screenRotateTimer, | ||
getTimerSeconds() * usPerSecond); | ||
queueLedEffect(LED_EFFECT_START_TIMER); | ||
preferences.putBool("timerActive", true); | ||
} else { | ||
esp_timer_stop(screenRotateTimer); | ||
queueLedEffect(LED_EFFECT_PAUSE_TIMER); | ||
preferences.putBool("timerActive", false); | ||
} | ||
|
||
if (eventSourceTaskHandle != NULL) xTaskNotifyGive(eventSourceTaskHandle); | ||
} | ||
|
||
void toggleTimerActive() { setTimerActive(!isTimerActive()); } | ||
|
||
void IRAM_ATTR minuteTimerISR(void *arg) { | ||
BaseType_t xHigherPriorityTaskWoken = pdFALSE; | ||
// vTaskNotifyGiveFromISR(timeUpdateTaskHandle, &xHigherPriorityTaskWoken); | ||
WorkItem timeUpdate = {TASK_TIME_UPDATE, 0}; | ||
xQueueSendFromISR(workQueue, &timeUpdate, &xHigherPriorityTaskWoken); | ||
|
||
if (bitaxeFetchTaskHandle != NULL) { | ||
vTaskNotifyGiveFromISR(bitaxeFetchTaskHandle, &xHigherPriorityTaskWoken); | ||
} | ||
|
||
if (xHigherPriorityTaskWoken == pdTRUE) { | ||
portYIELD_FROM_ISR(); | ||
} | ||
} | ||
|
||
void IRAM_ATTR screenRotateTimerISR(void *arg) { | ||
BaseType_t xHigherPriorityTaskWoken = pdFALSE; | ||
vTaskNotifyGiveFromISR(taskScreenRotateTaskHandle, &xHigherPriorityTaskWoken); | ||
if (xHigherPriorityTaskWoken == pdTRUE) { | ||
portYIELD_FROM_ISR(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include <esp_timer.h> | ||
#include <freertos/FreeRTOS.h> | ||
#include <freertos/task.h> | ||
|
||
#include "lib/shared.hpp" | ||
#include "lib/screen_handler.hpp" | ||
|
||
extern esp_timer_handle_t screenRotateTimer; | ||
extern esp_timer_handle_t minuteTimer; | ||
|
||
void setupTimeUpdateTimer(void *pvParameters); | ||
void setupScreenRotateTimer(void *pvParameters); | ||
|
||
void IRAM_ATTR minuteTimerISR(void *arg); | ||
void IRAM_ATTR screenRotateTimerISR(void *arg); | ||
|
||
uint getTimerSeconds(); | ||
bool isTimerActive(); | ||
void setTimerActive(bool status); | ||
void toggleTimerActive(); |
Oops, something went wrong.