Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
41b0b45
Format display_js.cpp
Tawank Apr 15, 2025
a45316a
Move core js functions to functions_js file
Tawank Apr 15, 2025
5aa6664
Remove sprites and gifs vector from display_js module
Tawank Apr 15, 2025
f106193
Fix build errors
Tawank Apr 16, 2025
2df7cdb
Fix ESP32-S3 build
Tawank Apr 16, 2025
aec3493
Fix spritePointer in display_js module
Tawank Apr 16, 2025
f091a94
Fix display_js module
Tawank Apr 17, 2025
dbfbf6a
Add task manager
Tawank Apr 27, 2025
bd4440f
Remove cannot bind non-const lvalue reference error
Tawank Apr 27, 2025
5b2c3df
Remove cannot bind non-const lvalue reference error v2
Tawank Apr 27, 2025
a19aa42
Add taskmanager to main.cpp
Tawank Apr 27, 2025
c452109
Fix task manager
Tawank Apr 28, 2025
3eb5383
Fix LITE_VERSION build
Tawank Apr 28, 2025
422ea64
Move native_delay and native_sleep js functions to interpreter.cpp
Tawank Apr 28, 2025
2a10168
Fix LITE_VERSION build v2
Tawank Apr 28, 2025
b0d742c
Fix LITE_VERSION build v3
Tawank Apr 28, 2025
e200bb7
Remove interpreter_start boolean, Fix task manager
Tawank Apr 28, 2025
79310bb
Remove interpreter loopOptions helper
Tawank Jun 5, 2025
ae39215
Merge branch 'main' into js_task_manager
Tawank Jun 5, 2025
e6ad88c
Merge branch 'main' into js_task_manager
Tawank Jun 30, 2025
1c37bc6
Fix ESP-32 Headless build
Tawank Jun 30, 2025
d91dbc4
Fix ESP-32 Headless build v2
Tawank Jun 30, 2025
202a314
Fix ESP-32 Headless build v3
Tawank Jun 30, 2025
be55727
Merge branch 'main' into js_task_manager
Tawank Jul 11, 2025
0f1b67c
Merge branch 'main' into js_task_manager
Tawank Sep 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "core/configPins.h"
#include "core/serial_commands/cli.h"
#include "core/startup_app.h"
#include "modules/bjs_interpreter/task_manager.h"
#include <Arduino.h>
#include <ArduinoJson.h>
#include <ESP32Time.h>
Expand Down Expand Up @@ -53,13 +54,15 @@ extern BQ27220 bq;
extern XPowersPPM PPM;
#endif

extern bool interpreter_start;

extern BruceConfig bruceConfig;
extern BruceConfigPins bruceConfigPins;
extern SerialCli serialCli;
extern StartupApp startupApp;

#if !defined(LITE_VERSION) && defined(HAS_SCREEN)
extern TaskManager taskManager;
#endif

extern char timeStr[10];
extern SPIClass sdcardSPI;
extern SPIClass CC_NRF_SPI;
Expand Down
34 changes: 34 additions & 0 deletions lib/Mallocator/mallocator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <cstdlib>
#include <limits>
#include <new>
#include <vector>

template <class T> struct Mallocator {
typedef T value_type;

Mallocator() = default;

template <class U> constexpr Mallocator(const Mallocator<U> &) noexcept {}

[[nodiscard]] T *allocate(std::size_t n) {
if (n > std::numeric_limits<std::size_t>::max() / sizeof(T)) throw std::bad_array_new_length();

if (auto p = static_cast<T *>(std::malloc(n * sizeof(T)))) {
report(p, n);
return p;
}

throw std::bad_alloc();
}

void deallocate(T *p, std::size_t n) noexcept {
report(p, n, 0);
std::free(p);
}

private:
void report(T *p, std::size_t n, bool alloc = true) const {
std::cout << (alloc ? "Alloc: " : "Dealloc: ") << sizeof(T) * n << " bytes at " << std::hex
<< std::showbase << reinterpret_cast<void *>(p) << std::dec << '\n';
}
};
3 changes: 0 additions & 3 deletions src/core/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,6 @@ int loopOptions(
options[chosen].operation();
break;
}
// interpreter_start -> running the interpreter
// interpreter -> loopOptions helper inside the Javascript
if (interpreter_start && !interpreter) { break; }

#ifdef HAS_KEYBOARD
if (check(EscPress)) {
Expand Down
25 changes: 5 additions & 20 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ SerialCli serialCli;
StartupApp startupApp;
MainMenu mainMenu;
SPIClass sdcardSPI;

#if !defined(LITE_VERSION) && defined(HAS_SCREEN)
TaskManager taskManager;
#endif

#ifdef USE_HSPI_PORT
SPIClass CC_NRF_SPI(VSPI);
#else
Expand Down Expand Up @@ -81,7 +86,6 @@ void __attribute__((weak)) taskInputHandler(void *parameter) {
unsigned long previousMillis = millis();
int prog_handler; // 0 - Flash, 1 - LittleFS, 3 - Download
String cachedPassword = "";
bool interpreter_start = false;
bool sdcardMounted = false;
bool gpsConnected = false;

Expand Down Expand Up @@ -456,25 +460,6 @@ void setup() {
**********************************************************************/
#if defined(HAS_SCREEN)
void loop() {
// Interpreter must be ran in the loop() function, otherwise it breaks
// called by 'stack canary watchpoint triggered (loopTask)'
#if !defined(LITE_VERSION)
if (interpreter_start) {
TaskHandle_t interpreterTaskHandler = NULL;
xTaskCreate(
interpreterHandler, // Task function
"interpreterHandler", // Task Name
16384, // Stack size
NULL, // Task parameters
2, // Task priority (0 to 3), loopTask has priority 2.
&interpreterTaskHandler // Task handle
);

while (interpreter_start == true) { vTaskDelay(pdMS_TO_TICKS(500)); }
interpreter_start = false;
previousMillis = millis(); // ensure that will not dim screen when get back to menu
}
#endif
tft.fillScreen(bruceConfig.bgColor);

mainMenu.begin();
Expand Down
Loading