fixes that made it work

This commit is contained in:
Mikkeli Matlock
2026-02-15 04:15:30 +09:00
parent 19db125619
commit 610f776ecf
33 changed files with 1271 additions and 516 deletions

View File

@@ -1,4 +1,4 @@
idf_component_register(
SRCS "main.cpp"
PRIV_REQUIRES user_app app_bsp port_bsp esp_wifi_bsp
INCLUDE_DIRS "./")

View File

@@ -1,19 +1,6 @@
## IDF Component Manager Manifest File
dependencies:
## Required IDF version
idf:
version: '>=4.1.0'
# # Put list of dependencies here
# # For components maintained by Espressif:
# component: "~1.0.0"
# # For 3rd party components:
# username/component: ">=1.0.0,<2.0.0"
# username2/component2:
# version: "~1.0.0"
# # For transient dependencies `public` flag can be set.
# # `public` flag doesn't have an effect dependencies of the `main` component.
# # All dependencies of `main` are public by default.
# public: true
lvgl/lvgl: ^8.4.0
espressif/avi_player: ^1.0.0
espressif/esp_new_jpeg: ^0.6.1
espressif/esp_websocket_client: "*"

View File

@@ -6,34 +6,80 @@
#include "display_bsp.h"
#include "lvgl_bsp.h"
#include "esp_wifi_bsp.h"
#include "user_app.h"
DisplayPort RlcdPort(12,11,5,40,41,400,300);
static const char *TAG = "main";
DisplayPort RlcdPort(12, 11, 5, 40, 41, 400, 300);
static void Lvgl_FlushCallback(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map)
{
uint16_t *buffer = (uint16_t *)color_map;
for(int y = area->y1; y <= area->y2; y++)
{
for(int x = area->x1; x <= area->x2; x++)
{
uint8_t color = (*buffer < 0x7fff) ? ColorBlack : ColorWhite;
RlcdPort.RLCD_SetPixel(x, y, color);
buffer++;
}
}
RlcdPort.RLCD_Display();
lv_disp_flush_ready(drv);
uint16_t *buffer = (uint16_t *)color_map;
for (int y = area->y1; y <= area->y2; y++) {
for (int x = area->x1; x <= area->x2; x++) {
uint8_t color = (*buffer < 0x7fff) ? ColorBlack : ColorWhite;
RlcdPort.RLCD_SetPixel(x, y, color);
buffer++;
}
}
RlcdPort.RLCD_Display();
lv_disp_flush_ready(drv);
}
extern "C" void app_main(void)
{
UserApp_AppInit();
RlcdPort.RLCD_Init();
Lvgl_PortInit(400,300,Lvgl_FlushCallback);
if(Lvgl_lock(-1)) {
UserApp_UiInit();
Lvgl_unlock();
}
UserApp_TaskInit();
/* --- Hardware init (non-WiFi) --- */
UserApp_AppInit();
/* --- Display + LVGL --- */
RlcdPort.RLCD_Init();
Lvgl_PortInit(400, 300, Lvgl_FlushCallback);
/* --- Boot screen: show WiFi connection status --- */
lv_obj_t *boot_label = NULL;
if (Lvgl_lock(-1)) {
boot_label = lv_label_create(lv_scr_act());
lv_obj_set_style_text_font(boot_label, &lv_font_montserrat_16, 0);
lv_obj_set_style_text_color(boot_label, lv_color_black(), 0);
lv_label_set_text(boot_label, "Connecting to WiFi...");
lv_obj_center(boot_label);
Lvgl_unlock();
}
/* --- Start WiFi --- */
wifi_sta_init();
ESP_LOGI(TAG, "Waiting for WiFi connection (15s timeout)...");
bool connected = wifi_sta_wait_connected(15000);
/* --- Update boot screen with result --- */
if (Lvgl_lock(-1)) {
if (connected) {
char ip_buf[20];
wifi_sta_get_ip_str(ip_buf, sizeof(ip_buf));
char msg[48];
snprintf(msg, sizeof(msg), "Connected: %s", ip_buf);
lv_label_set_text(boot_label, msg);
ESP_LOGI(TAG, "WiFi connected: %s", ip_buf);
} else {
lv_label_set_text(boot_label, "WiFi Failed - Retrying...");
ESP_LOGW(TAG, "WiFi connection timed out, continuing...");
}
Lvgl_unlock();
}
/* Brief pause so the user can read the boot status */
vTaskDelay(pdMS_TO_TICKS(1000));
/* --- Transition to full dashboard UI --- */
if (Lvgl_lock(-1)) {
lv_obj_del(boot_label);
UserApp_UiInit();
Lvgl_unlock();
}
/* --- Start background tasks --- */
UserApp_TaskInit();
ESP_LOGI(TAG, "Pi Dashboard running");
}

View File

@@ -1,7 +0,0 @@
#include <stdio.h>
#include "user_app.h"
void app_main(void)
{
user_top_init();
}