Skip to content

Commit

Permalink
keira: fix v1 regressions
Browse files Browse the repository at this point in the history
lib: fix v1 regressions
lib: fix FreeRTOS includes not working for C3
  • Loading branch information
and3rson committed Mar 17, 2024
1 parent 61c00e5 commit 0ba0f1a
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 16 deletions.
8 changes: 8 additions & 0 deletions firmware/keira/legacy/v1_partitions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Таблиця розділів для Лілки 1.0
# (В ній лише 4 МБ флеш-пам'яті, тому app1 відсутній, і, як наслідок, OTA не підтримується)
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x280000,
spiffs, data, spiffs, 0x290000,0x160000,
coredump, data, coredump,0x3F0000,0x10000,
15 changes: 3 additions & 12 deletions firmware/keira/platformio.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
; Це - конфігураційний файл PlatformIO. Він використовується для налаштування проєкту та його залежностей.
; Докладніше про конфігурацію PlatformIO можна прочитати тут: https://docs.platformio.org/en/latest/projectconf/index.html

[platformio]
boards_dir = ../../sdk/boards
Expand All @@ -21,6 +14,7 @@ lib_deps =
mischief/lua @ ^0.1.1
https://github.com/moononournation/arduino-nofrendo.git
build_flags = -D LILKA_VERSION=1
board_build.partitions = ./legacy/v1_partitions.csv

[env:v2]
platform = espressif32
Expand All @@ -30,6 +24,3 @@ lib_deps =
lilka
mischief/lua @ ^0.1.1
https://github.com/moononournation/arduino-nofrendo.git
; Define LILKA_BREADBOARD to lower SPI speed to 40 MHz (instead of normal 80)
; TODO: Remove this when we have PCBs!
; build_flags = -D LILKA_BREADBOARD
9 changes: 9 additions & 0 deletions firmware/keira/src/apps/demos/scan_i2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ScanI2CApp::ScanI2CApp() : App("I2C Scanner") {
}

void ScanI2CApp::run() {
#if LILKA_VERSION >= 2
lilka::Canvas buffer(canvas->width(), canvas->height());
buffer.begin();
buffer.fillScreen(0);
Expand Down Expand Up @@ -47,4 +48,12 @@ void ScanI2CApp::run() {
while (!lilka::controller.getState().a.justPressed) {
taskYIELD();
}
#else
lilka::Alert alert("Помилка", "Ця програма потребує Лілку версії 2 або вище.");
alert.draw(canvas);
queueDraw();
while (!alert.isDone()) {
alert.update();
}
#endif
}
9 changes: 9 additions & 0 deletions firmware/keira/src/apps/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ void LauncherApp::selectFile(String path) {
if (path.endsWith(".rom") || path.endsWith(".nes")) {
AppManager::getInstance()->runApp(new NesApp(path));
} else if (path.endsWith(".bin")) {
#if LILKA_VERSION < 2
lilka::Alert alert("Помилка", "Ця операція потребує Лілку 2.0");
alert.draw(canvas);
queueDraw();
while (!alert.isDone()) {
alert.update();
}
#else
int error;
error = lilka::multiboot.start(path);
if (error) {
Expand Down Expand Up @@ -267,6 +275,7 @@ void LauncherApp::selectFile(String path) {
alert("Помилка", String("Етап: 3\nКод: ") + error);
return;
}
#endif
} else if (path.endsWith(".lua")) {
AppManager::getInstance()->runApp(new LuaFileRunnerApp(path));
} else if (path.endsWith(".js")) {
Expand Down
2 changes: 1 addition & 1 deletion firmware/keira/src/apps/nes/osd.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <esp_heap_caps.h>
#include <lilka.h>

#include <FreeRTOS.h>
#include <freertos/FreeRTOS.h>
#include <freertos/timers.h>

#include "driver.h"
Expand Down
9 changes: 9 additions & 0 deletions sdk/lib/lilka/platformio.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
[platformio]
boards_dir = ../../boards

[env:v1]
platform = espressif32
board = adafruit_qtpy_esp32c3
framework = arduino
lib_deps =
moononournation/GFX Library for Arduino@^1.4.5
olikraus/U8g2@^2.35.9
build_flags = -D LILKA_VERSION=1

[env:v2]
platform = espressif32
board = lilka_v2
Expand Down
8 changes: 8 additions & 0 deletions sdk/lib/lilka/src/lilka/buzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ void Buzzer::playMelody(const Tone* melody, uint32_t length, uint32_t tempo) {

void Buzzer::melodyTask(void* arg) {
Buzzer* buzzer = static_cast<Buzzer*>(arg);
#if LILKA_VERSION < 2
serial_err("Buzzer is not supported on this board");
#else
// Serial.println("Melody task started");
for (uint32_t i = 0; i < buzzer->currentMelodyLength; i++) {
// Serial.println("Playing note " + String(i) + " with frequency " + String(buzzer->currentMelody[i].frequency));
Expand All @@ -91,8 +94,11 @@ void Buzzer::melodyTask(void* arg) {
xSemaphoreGive(buzzer->buzzerMutex);
vTaskDelay(duration / portTICK_PERIOD_MS);
}
#endif
xSemaphoreTake(buzzer->buzzerMutex, portMAX_DELAY);
#if LILKA_VERSION >= 2
noTone(LILKA_BUZZER);
#endif
// Release the mutex & delete task.
buzzer->melodyTaskHandle = NULL;
xSemaphoreGive(buzzer->buzzerMutex);
Expand All @@ -110,7 +116,9 @@ void Buzzer::stop() {
}

void Buzzer::_stop() {
#if LILKA_VERSION >= 2
noTone(LILKA_BUZZER);
#endif
TaskHandle_t handle = melodyTaskHandle;
if (handle != NULL) {
melodyTaskHandle = NULL;
Expand Down
2 changes: 1 addition & 1 deletion sdk/lib/lilka/src/lilka/buzzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define LILKA_BUZZER_H

#include <stdint.h>
#include <FreeRTOS.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <freertos/semphr.h>

Expand Down
4 changes: 2 additions & 2 deletions sdk/lib/lilka/src/lilka/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include "config.h"

#include <stdint.h>
#include <FreeRTOS.h>
#include <semphr.h>
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>

namespace lilka {

Expand Down

0 comments on commit 0ba0f1a

Please sign in to comment.