Skip to content

Commit 39113a7

Browse files
authored
feature: improve performance and small improvements. (#9)
* feature: improve performance and small improvements. * chores: Added missing pins and remove unused lvgl functions.
1 parent 0dd9f2c commit 39113a7

File tree

9 files changed

+259
-290
lines changed

9 files changed

+259
-290
lines changed

webscreen/dynamic_js.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
String g_script_filename = "/app.js";
1313

1414
void dynamic_js_setup() {
15-
Serial.println("DYNAMIC_JS: Setting up Elk + script scenario...");
15+
LOG("DYNAMIC_JS: Setting up Elk + script scenario...");
1616

1717
// If needed, mount the SD again (or confirm it’s already mounted):
1818
SD_MMC.setPins(PIN_SD_CLK, PIN_SD_CMD, PIN_SD_D0);
1919
if(!SD_MMC.begin("/sdcard", true, false, 1000000)) {
20-
Serial.println("Card Mount Failed => can't run dynamic JS code properly");
20+
LOG("Card Mount Failed => can't run dynamic JS code properly");
2121
return;
2222
}
2323

@@ -44,14 +44,13 @@ void dynamic_js_setup() {
4444
NULL,
4545
1,
4646
NULL,
47-
1
47+
0
4848
);
4949

50-
Serial.println("DYNAMIC_JS: setup done!");
50+
LOG("DYNAMIC_JS: setup done!");
5151
}
5252

5353
void dynamic_js_loop() {
54-
// The Elk code runs in the FreeRTOS task (elk_task),
55-
// so we typically only do minimal work here
56-
delay(500);
54+
// The Elk code runs in the FreeRTOS task (elk_task).
55+
vTaskDelay(pdMS_TO_TICKS(50));
5756
}

webscreen/fallback.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "rm67162.h" // LCD driver
55
#include <lvgl.h> // Ensure you have LVGL
66
#include "notification.h" // For the GIF data
7+
#include "globals.h"
8+
#include "tick.h"
79

810
// We'll store references to the fallback label + gif
911
static lv_obj_t* fb_label = nullptr;
@@ -48,12 +50,13 @@ static void create_scroll_animation(lv_obj_t *obj, int32_t start, int32_t end, u
4850
}
4951

5052
void fallback_setup() {
51-
Serial.println("FALLBACK: Setting up scrolling label + GIF...");
53+
LOG("FALLBACK: Setting up scrolling label + GIF...");
5254

5355
// 1) Minimal LVGL init (only if not already done).
5456
// If your main code calls lv_init() elsewhere,
5557
// you might skip or check if it’s safe to call again.
5658
lv_init();
59+
start_lvgl_tick();
5760

5861
// 2) Power on the screen, set backlight
5962
pinMode(PIN_LED, OUTPUT);
@@ -66,7 +69,7 @@ void fallback_setup() {
6669
// 4) Allocate a buffer for fallback usage
6770
fbBuf = (lv_color_t*) ps_malloc(sizeof(lv_color_t) * LVGL_LCD_BUF_SIZE);
6871
if(!fbBuf) {
69-
Serial.println("FALLBACK: Failed to allocate buffer");
72+
LOG("FALLBACK: Failed to allocate buffer");
7073
return;
7174
}
7275

webscreen/globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22
#include <Arduino.h>
3+
#include "log.h"
34

45
// Declare the global script filename variable
56
extern String g_script_filename;

webscreen/log.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#pragma once
2+
#include <Arduino.h>
3+
4+
/* ------------------------------------------------------------------
5+
Compile‑time switch:
6+
* 0 → completely strip all logging from the image (no flash, no RAM, no cycles)
7+
* 1 → keep logging enabled
8+
------------------------------------------------------------------*/
9+
#ifndef WEBSCREEN_LOG_LEVEL // let the build system override
10+
#define WEBSCREEN_LOG_LEVEL 1 // 1 = on, 0 = off
11+
#endif
12+
13+
/* ------------------------------------------------------------------
14+
Macros
15+
------------------------------------------------------------------*/
16+
#if WEBSCREEN_LOG_LEVEL
17+
#define LOGF(...) Serial.printf(__VA_ARGS__)
18+
#define LOG(...) Serial.println(__VA_ARGS__)
19+
#else
20+
/* compile to nothing */
21+
#define LOGF(...) do { } while (0)
22+
#define LOG(...) do { } while (0)
23+
#endif

0 commit comments

Comments
 (0)