Skip to content

Commit 43c78c6

Browse files
Thread, Timer and flash.sh improvements (#165)
- Various improvements to Thread and Timer: - Remove "mark as static" option as it is unused - Implemented core pinning for ESP32 platforms - Use `TickType_t` consistently (instead of `uint32_t`) - Use `enum class` instead of `enum` - Fix for `flash.sh` not working when using `pip` to install `esptool`
1 parent 5d189fe commit 43c78c6

File tree

20 files changed

+151
-198
lines changed

20 files changed

+151
-198
lines changed

Boards/LilygoTdeck/Source/Lvgl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
bool tdeck_init_lvgl() {
1515
static lv_disp_t* display = nullptr;
1616
const lvgl_port_cfg_t lvgl_cfg = {
17-
.task_priority = tt::THREAD_PRIORITY_RENDER,
17+
.task_priority = static_cast<UBaseType_t>(tt::THREAD_PRIORITY_RENDER),
1818
.task_stack = TDECK_LVGL_TASK_STACK_DEPTH,
1919
.task_affinity = -1, // core pinning
2020
.task_max_sleep_ms = 500,

Boards/M5stackCore2/Source/InitLvgl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
bool initLvgl() {
1414
const lvgl_port_cfg_t lvgl_cfg = {
15-
.task_priority = tt::THREAD_PRIORITY_RENDER,
15+
.task_priority = static_cast<UBaseType_t>(tt::THREAD_PRIORITY_RENDER),
1616
.task_stack = CORE2_LVGL_TASK_STACK_DEPTH,
1717
.task_affinity = -1, // core pinning
1818
.task_max_sleep_ms = 500,

Boards/M5stackCoreS3/Source/InitLvgl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
bool initLvgl() {
1414
const lvgl_port_cfg_t lvgl_cfg = {
15-
.task_priority = tt::THREAD_PRIORITY_RENDER,
15+
.task_priority = static_cast<UBaseType_t>(tt::THREAD_PRIORITY_RENDER),
1616
.task_stack = CORE2_LVGL_TASK_STACK_DEPTH,
1717
.task_affinity = -1, // core pinning
1818
.task_max_sleep_ms = 500,

Boards/Simulator/Source/LvglTask.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void lvgl_task_start() {
6565
"lvgl",
6666
8192,
6767
nullptr,
68-
tt::Thread::PriorityHigh, // Should be higher than main app task
68+
static_cast<UBaseType_t>(tt::Thread::Priority::High), // Should be higher than main app task
6969
nullptr
7070
);
7171

Boards/Simulator/Source/Main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void freertosMain() {
2929
"main",
3030
8192,
3131
nullptr,
32-
tt::Thread::PriorityNormal,
32+
static_cast<UBaseType_t>(tt::Thread::Priority::Normal),
3333
nullptr
3434
);
3535

Boards/YellowBoard/Source/Lvgl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
bool twodotfour_lvgl_init() {
99
const lvgl_port_cfg_t lvgl_cfg = {
10-
.task_priority = tt::THREAD_PRIORITY_RENDER,
10+
.task_priority = static_cast<UBaseType_t>(tt::THREAD_PRIORITY_RENDER),
1111
.task_stack = 8096,
1212
.task_affinity = -1, // core pinning
1313
.task_max_sleep_ms = 500,

Buildscripts/Flashing/flash.sh

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,35 @@ function is_bin_in_path {
2121

2222
function require_bin {
2323
program=$1
24-
tip=$2
2524
if ! is_bin_in_path $program; then
26-
echo -e "\e[31m⚠️ $program not found!\n\t$tip\e[0m"
25+
exit 1
26+
else
27+
exit 0
2728
fi
2829
}
2930

30-
require_bin esptool.py "install esptool from your package manager or install python and run 'pip install esptool'"
31-
require_bin jq "install jq from your package manager or install python and run 'pip install jq'"
31+
# Find either esptool (installed via system package manager) or esptool.py (installed via pip)
32+
if ! is_bin_in_path esptool; then
33+
if ! is_bin_in_path esptool.py; then
34+
echo "\e[31m⚠️ esptool not found! Install it from your package manager or install python and run 'pip install esptool'\e[0m"
35+
exit 1
36+
else
37+
esptoolPath=esptool.py
38+
fi
39+
else
40+
esptoolPath=esptool
41+
fi
3242

33-
if [[ $1 -eq 0 ]]; then
43+
# Ensure the port was specified
44+
if [ -z "$1" ]; then
3445
echo -e "\e[31m⚠️ Must Specify port as argument. For example:\n\tflash.sh /dev/ttyACM0\n\tflash.sh /dev/ttyUSB0\e[0m"
3546
exit -1
3647
fi
3748

49+
# Take the flash_arg file contents and join each line in the file into a single line
50+
flash_args=`grep \n Binaries/flash_args | awk '{print}' ORS=' '`
3851
cd Binaries
39-
# Create flash command based on partitions
40-
KEY_VALUES=`jq -r '.flash_files | keys[] as $k | "\($k) \(.[$k])"' flasher_args.json | tr "\n" " "`
41-
esptool.py --port $1 erase_flash
42-
esptool.py --port $1 --connect-attempts 10 -b 460800 write_flash $KEY_VALUES
52+
$esptoolPath --port $1 erase_flash
53+
$esptoolPath --port $1 write_flash $flash_args
54+
cd -
55+

Documentation/ideas.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,9 @@
2828
- Attach ELF data to wrapper app (as app data) (check that app state is "running"!) so you can run more than 1 external apps at a time.
2929
We'll need to keep track of all manifest instances, so that the wrapper can look up the relevant manifest for the relevant callbacks.
3030
- T-Deck: Clear screen before turning on blacklight
31-
- Audio player app
32-
- Audio recording app
3331
- T-Deck: Use knob for UI selection
3432
- Crash monitoring: Keep track of which system phase the app crashed in (e.g. which app in which state)
3533
- AppContext's onResult should pass the app id (or launch request id!) that was started, so we can differentiate between multiple types of apps being launched
36-
- Loader: Use main dispatcher instead of Thread
3734
- Create more unit tests for `tactility-core` and `tactility` (PC-only for now)
3835
- Show a warning screen if firmware encryption or secure boot are off when saving WiFi credentials.
3936
- Show a warning screen when a user plugs in the SD card on a device that only supports mounting at boot.
@@ -45,6 +42,8 @@
4542
- Support hot-plugging SD card
4643

4744
# Nice-to-haves
45+
- Audio player app
46+
- Audio recording app
4847
- OTA updates
4948
- Web flasher
5049
- T-Deck Plus: Create separate board config?

TactilityC/Source/tt_init.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ const struct esp_elfsym elf_symbols[] {
7474
ESP_ELFSYM_EXPORT(tt_thread_alloc_ext),
7575
ESP_ELFSYM_EXPORT(tt_thread_free),
7676
ESP_ELFSYM_EXPORT(tt_thread_set_name),
77-
ESP_ELFSYM_EXPORT(tt_thread_mark_as_static),
78-
ESP_ELFSYM_EXPORT(tt_thread_is_marked_as_static),
7977
ESP_ELFSYM_EXPORT(tt_thread_set_stack_size),
8078
ESP_ELFSYM_EXPORT(tt_thread_set_callback),
8179
ESP_ELFSYM_EXPORT(tt_thread_set_priority),

TactilityC/Source/tt_thread.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@ void tt_thread_set_name(ThreadHandle handle, const char* name) {
3131
HANDLE_AS_THREAD(handle)->setName(name);
3232
}
3333

34-
void tt_thread_mark_as_static(ThreadHandle handle) {
35-
HANDLE_AS_THREAD(handle)->markAsStatic();
36-
}
37-
38-
bool tt_thread_is_marked_as_static(ThreadHandle handle) {
39-
return HANDLE_AS_THREAD(handle)->isMarkedAsStatic();
40-
}
41-
4234
void tt_thread_set_stack_size(ThreadHandle handle, size_t size) {
4335
HANDLE_AS_THREAD(handle)->setStackSize(size);
4436
}

0 commit comments

Comments
 (0)