add screensaver and optimize performance
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -4,7 +4,8 @@ idf_component_register(SRCS
|
||||
"button_handling.c"
|
||||
"hal/u8g2_esp32_hal.c"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES
|
||||
PRIV_REQUIRES
|
||||
bob
|
||||
insa
|
||||
ruth
|
||||
u8g2
|
||||
|
@@ -7,6 +7,8 @@
|
||||
#include "u8g2.h"
|
||||
|
||||
#include "button_handling.h"
|
||||
#include "common/InactivityTracker.h"
|
||||
#include "ui/ScreenSaver.h"
|
||||
#include "ui/SplashScreen.h"
|
||||
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
@@ -28,6 +30,7 @@ uint8_t received_signal;
|
||||
|
||||
std::shared_ptr<Widget> m_widget;
|
||||
std::vector<std::shared_ptr<Widget>> m_history;
|
||||
std::unique_ptr<InactivityTracker> m_inactivityTracker;
|
||||
|
||||
extern QueueHandle_t buttonQueue;
|
||||
|
||||
@@ -88,10 +91,16 @@ static void init_ui(void)
|
||||
.persistence = nullptr,
|
||||
};
|
||||
m_widget = std::make_shared<SplashScreen>(&options);
|
||||
m_inactivityTracker = std::make_unique<InactivityTracker>(60000, []() {
|
||||
auto screensaver = std::make_shared<ScreenSaver>(&options);
|
||||
options.pushScreen(screensaver);
|
||||
});
|
||||
}
|
||||
|
||||
static void handle_button(uint8_t button)
|
||||
{
|
||||
m_inactivityTracker->reset();
|
||||
|
||||
if (m_widget)
|
||||
{
|
||||
switch (button)
|
||||
@@ -133,19 +142,24 @@ void app_task(void *args)
|
||||
setup_buttons();
|
||||
init_ui();
|
||||
|
||||
auto oldTime = esp_timer_get_time();
|
||||
|
||||
while (true)
|
||||
{
|
||||
u8g2_ClearBuffer(&u8g2);
|
||||
|
||||
auto oldTime = esp_timer_get_time();
|
||||
if (m_widget != nullptr)
|
||||
{
|
||||
auto currentTime = esp_timer_get_time();
|
||||
auto delta = currentTime - oldTime;
|
||||
oldTime = currentTime;
|
||||
|
||||
m_widget->update(delta);
|
||||
uint64_t deltaMs = delta / 1000;
|
||||
|
||||
m_widget->update(deltaMs);
|
||||
m_widget->render();
|
||||
|
||||
m_inactivityTracker->update(deltaMs);
|
||||
}
|
||||
|
||||
u8g2_SendBuffer(&u8g2);
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#define I2C_MASTER_TX_BUF_DISABLE 0 // I2C master do not need buffer
|
||||
#define I2C_MASTER_RX_BUF_DISABLE 0 // I2C master do not need buffer
|
||||
#define I2C_MASTER_FREQ_HZ 50000 // I2C master clock frequency
|
||||
#define I2C_MASTER_FREQ_HZ 400000 // I2C master clock frequency
|
||||
#define ACK_CHECK_EN 0x1 // I2C master will check ack from slave
|
||||
#define ACK_CHECK_DIS 0x0 // I2C master will not check ack from slave
|
||||
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#include "app_task.h"
|
||||
#include "bob.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@@ -7,7 +9,9 @@ extern "C"
|
||||
#endif
|
||||
void app_main(void)
|
||||
{
|
||||
xTaskCreatePinnedToCore(app_task, "main_loop", 4096, NULL, 5, NULL, tskIDLE_PRIORITY + 1);
|
||||
bob_init();
|
||||
|
||||
xTaskCreatePinnedToCore(app_task, "main_loop", 4096, NULL, tskIDLE_PRIORITY + 1, NULL, portNUM_PROCESSORS - 1);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Reference in New Issue
Block a user