Initial Demo OS

This commit is contained in:
dark98
2026-09-03 00:46:04 +01:00
commit 1491821e96
45 changed files with 2908 additions and 0 deletions
+88
View File
@@ -0,0 +1,88 @@
#include "apps.h"
#include "os_gfx.h"
#include "os_status.h"
#include <stdio.h>
#include <time.h>
#include "esp_timer.h"
static uint8_t s_view_mode = 0;
static void clock_init(void)
{
s_view_mode = 0;
}
static void clock_enter(void)
{
}
static void clock_update(uint32_t delta_ms)
{
sys_status_t status;
sys_status_get(&status);
sys_gfx_draw_status_bar(&status);
uint32_t sec = status.uptime_sec % 60;
uint32_t min = (status.uptime_sec / 60) % 60;
uint32_t hrs = (status.uptime_sec / 3600);
char time_str[16];
char sub_str[20];
if (s_view_mode == 0) {
snprintf(time_str, sizeof(time_str), "%02lu:%02lu:%02lu", (unsigned long)hrs, (unsigned long)min, (unsigned long)sec);
sys_gfx_draw_str_5x7(12, 11, time_str, COLOR_WHITE);
snprintf(sub_str, sizeof(sub_str), "RAM:%luK", (unsigned long)(status.free_heap / 1024));
sys_gfx_draw_str_3x5(4, 21, sub_str, COLOR_WHITE);
snprintf(sub_str, sizeof(sub_str), "CPU:160M");
sys_gfx_draw_str_3x5(40, 21, sub_str, COLOR_WHITE);
sys_gfx_draw_progress_bar(4, 27, 64, 4, (uint8_t)((sec * 100) / 59));
sys_gfx_draw_action_bar("C:MODE", "H:HOME");
} else if (s_view_mode == 1) {
snprintf(time_str, sizeof(time_str), "%02lu:%02lu", (unsigned long)min, (unsigned long)sec);
sys_gfx_draw_str_5x7(18, 14, time_str, COLOR_WHITE);
sys_gfx_draw_str_5x7(19, 14, time_str, COLOR_WHITE);
snprintf(sub_str, sizeof(sub_str), "UP:%luh %lum", (unsigned long)hrs, (unsigned long)min);
sys_gfx_draw_str_3x5(12, 24, sub_str, COLOR_WHITE);
sys_gfx_draw_action_bar("C:MODE", "H:HOME");
} else {
snprintf(sub_str, sizeof(sub_str), "UP:%02lu:%02lu:%02lu", (unsigned long)hrs, (unsigned long)min, (unsigned long)sec);
sys_gfx_draw_str_3x5(3, 10, sub_str, COLOR_WHITE);
snprintf(sub_str, sizeof(sub_str), "HEAP:%lu B", (unsigned long)status.free_heap);
sys_gfx_draw_str_3x5(3, 17, sub_str, COLOR_WHITE);
snprintf(sub_str, sizeof(sub_str), "MINH:%lu B", (unsigned long)status.min_free_heap);
sys_gfx_draw_str_3x5(3, 24, sub_str, COLOR_WHITE);
sys_gfx_draw_action_bar("C:MODE", "H:HOME");
}
}
static void clock_handle_input(input_action_t action)
{
if (action == INPUT_ACTION_CLICK) {
s_view_mode = (s_view_mode + 1) % 3;
} else if (action == INPUT_ACTION_LONG_PRESS) {
sys_gfx_show_toast("Mode Saved", 600);
}
}
static void clock_exit(void)
{
}
const sys_app_t g_app_clock = {
.id = "clock",
.name = "Clock",
.init = clock_init,
.enter = clock_enter,
.update = clock_update,
.handle_input = clock_handle_input,
.exit = clock_exit,
};