Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions Apps/Breakout/main/Source/Breakout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include <esp_random.h>
#include <tt_lvgl_keyboard.h>

#include <tactility/lvgl_module.h>
#include <tactility/lvgl_fonts.h>
#include <lvgl/lvgl.h>
#include <lvgl/lvgl_fonts.h>

constexpr auto* TAG = "Breakout";

Expand Down
4 changes: 2 additions & 2 deletions Apps/Breakout/manifest.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ manifest.version=0.2
target.sdk=0.8.0-dev
target.platforms=esp32,esp32s3,esp32c6,esp32p4
app.id=one.tactility.breakout
app.version.name=0.5.0
app.version.code=5
app.version.name=0.6.0
app.version.code=6
app.name=Breakout
app.description=Classic brick-breaking arcade game
6 changes: 3 additions & 3 deletions Apps/Diceware/main/Source/Diceware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <tt_app_alertdialog.h>
#include <tt_lock.h>
#include <tt_lvgl.h>
#include <lvgl/lvgl.h>
#include <tt_lvgl_toolbar.h>

#include <esp_random.h>
Expand Down Expand Up @@ -87,9 +87,9 @@ void Diceware::startJob(uint32_t jobWordCount) {
}

void Diceware::onFinishJob(std::string result) {
tt_lvgl_lock(tt::kernel::MAX_TICKS);
lvgl_lock();
lv_label_set_text(resultLabel, result.c_str());
tt_lvgl_unlock();
lvgl_unlock();
}

void Diceware::onClickGenerate(lv_event_t* e) {
Expand Down
4 changes: 2 additions & 2 deletions Apps/Diceware/manifest.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ manifest.version=0.2
target.sdk=0.8.0-dev
target.platforms=esp32,esp32s3,esp32c6,esp32p4
app.id=one.tactility.diceware
app.version.name=0.6.0
app.version.code=6
app.version.name=0.7.0
app.version.code=7
app.name=Diceware
10 changes: 6 additions & 4 deletions Apps/EspNowBridge/main/Source/EspNowBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <tt_app_fileselection.h>
#include <tt_bundle.h>
#include <tt_lock.h>
#include <tt_lvgl.h>
#include <lvgl/lvgl.h>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
#include <tt_lvgl_toolbar.h>

#include <esp_app_desc.h>
Expand All @@ -18,6 +18,8 @@

#include <tactility/log.h>

constexpr TickType_t LVGL_DEFAULT_LOCK_TIME = 500; // 500 ticks = 500 ms

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

Expand Down Expand Up @@ -283,12 +285,12 @@ struct UiDispatchPayload {
void EspNowBridge::dispatchToUi(void (*work)(EspNowBridge&, void*), void* context, void (*freeContext)(void*)) {
auto* payload = new UiDispatchPayload{this, work, context, freeContext};
// lv_async_call() itself is an LVGL operation and must be lock-guarded when called from a
// non-LVGL task (see tt_lvgl_lock()'s doc comment) - the OTA worker task calls dispatchToUi()
// non-LVGL task (see lvgl_lock()'s doc comment) - the OTA worker task calls dispatchToUi()
// repeatedly during the transfer, and without this lock most of those calls were silently
// racing LVGL's own task and getting lost (only the very last status update, right before
// esp_restart(), happened to land - everything else stayed stuck at "Waiting for
// co-processor link...").
bool locked = tt_lvgl_lock(TT_LVGL_DEFAULT_LOCK_TIME);
bool locked = lvgl_try_lock(LVGL_DEFAULT_LOCK_TIME);
if (!locked) {
// Without the lock, lv_async_call() itself would be touching LVGL's internal timer list
// unguarded - and if it happened to still enqueue successfully, the callback below would
Expand All @@ -310,7 +312,7 @@ void EspNowBridge::dispatchToUi(void (*work)(EspNowBridge&, void*), void* contex
}
delete payload;
}, payload);
tt_lvgl_unlock();
lvgl_unlock();

if (result != LV_RESULT_OK) {
if (freeContext != nullptr) {
Expand Down
4 changes: 2 additions & 2 deletions Apps/EspNowBridge/manifest.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ manifest.version=0.2
target.sdk=0.8.0-dev
target.platforms=esp32p4
app.id=one.tactility.espnowbridge
app.version.name=0.1.0
app.version.code=1
app.version.name=0.2.0
app.version.code=2
app.name=ESP-NOW Bridge
app.description=Companion app for updating P4 device C6 co-processor firmware to enable ESP-NOW bridge support.
7 changes: 3 additions & 4 deletions Apps/GPIO/main/Source/Gpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

#include <Tactility/kernel/Kernel.h>

#include <tt_lvgl.h>
#include <tt_lvgl_toolbar.h>

#include <tactility/lvgl_module.h>
#include <lvgl/lvgl.h>

#include <esp_log.h>
#include <driver/gpio.h>
Expand All @@ -20,7 +19,7 @@ void Gpio::updatePinStates() {
}

void Gpio::updatePinWidgets() {
tt_lvgl_lock(tt::kernel::MAX_TICKS);
lvgl_lock();
for (int j = 0; j < pinStates.size(); ++j) {
int level = pinStates[j];
lv_obj_t* label = pinWidgets[j];
Expand All @@ -35,7 +34,7 @@ void Gpio::updatePinWidgets() {
}
}
}
tt_lvgl_unlock();
lvgl_unlock();
}

lv_obj_t* Gpio::createGpioRowWrapper(lv_obj_t* parent) {
Expand Down
4 changes: 2 additions & 2 deletions Apps/GPIO/manifest.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ manifest.version=0.2
target.sdk=0.8.0-dev
target.platforms=esp32,esp32s3,esp32c6,esp32p4
app.id=one.tactility.gpio
app.version.name=0.7.0
app.version.code=7
app.version.name=0.8.0
app.version.code=8
app.name=GPIO
32 changes: 16 additions & 16 deletions Apps/GraphicsDemo/main/Include/PixelBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
#include "drivers/Colors.h"

#include <cstring>
#include <tt_hal_display.h>
#include <tactility/drivers/display.h>

class PixelBuffer {
uint16_t pixelWidth;
uint16_t pixelHeight;
ColorFormat colorFormat;
enum DisplayColorFormat colorFormat;
uint8_t* data;

public:

PixelBuffer(uint16_t pixelWidth, uint16_t pixelHeight, ColorFormat colorFormat) :
PixelBuffer(uint16_t pixelWidth, uint16_t pixelHeight, enum DisplayColorFormat colorFormat) :
pixelWidth(pixelWidth),
pixelHeight(pixelHeight),
colorFormat(colorFormat)
Expand All @@ -35,7 +35,7 @@ class PixelBuffer {
return pixelHeight;
}

ColorFormat getColorFormat() const {
enum DisplayColorFormat getColorFormat() const {
return colorFormat;
}

Expand All @@ -58,14 +58,14 @@ class PixelBuffer {

uint8_t getPixelSize() const {
switch (colorFormat) {
case COLOR_FORMAT_MONOCHROME:
case DISPLAY_COLOR_FORMAT_MONOCHROME:
return 1;
case COLOR_FORMAT_BGR565:
case COLOR_FORMAT_BGR565_SWAPPED:
case COLOR_FORMAT_RGB565:
case COLOR_FORMAT_RGB565_SWAPPED:
case DISPLAY_COLOR_FORMAT_BGR565:
case DISPLAY_COLOR_FORMAT_BGR565_SWAPPED:
case DISPLAY_COLOR_FORMAT_RGB565:
case DISPLAY_COLOR_FORMAT_RGB565_SWAPPED:
return 2;
case COLOR_FORMAT_RGB888:
case DISPLAY_COLOR_FORMAT_RGB888:
return 3;
default:
// TODO: Crash with error
Expand All @@ -82,33 +82,33 @@ class PixelBuffer {
void setPixel(uint16_t x, uint16_t y, uint8_t r, uint8_t g, uint8_t b) const {
auto address = getPixelAddress(x, y);
switch (colorFormat) {
case COLOR_FORMAT_MONOCHROME:
case DISPLAY_COLOR_FORMAT_MONOCHROME:
*address = (uint8_t)((uint16_t)r + (uint16_t)g + (uint16_t)b / 3);
break;
case COLOR_FORMAT_BGR565:
case DISPLAY_COLOR_FORMAT_BGR565:
Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address));
break;
case COLOR_FORMAT_BGR565_SWAPPED: {
case DISPLAY_COLOR_FORMAT_BGR565_SWAPPED: {
// TODO: Make proper conversion function
Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address));
uint8_t temp = *address;
*address = *(address + 1);
*(address + 1) = temp;
break;
}
case COLOR_FORMAT_RGB565: {
case DISPLAY_COLOR_FORMAT_RGB565: {
Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address));
break;
}
case COLOR_FORMAT_RGB565_SWAPPED: {
case DISPLAY_COLOR_FORMAT_RGB565_SWAPPED: {
// TODO: Make proper conversion function
Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address));
uint8_t temp = *address;
*address = *(address + 1);
*(address + 1) = temp;
break;
}
case COLOR_FORMAT_RGB888: {
case DISPLAY_COLOR_FORMAT_RGB888: {
uint8_t pixel[3] = { r, g, b };
memcpy(address, pixel, 3);
break;
Expand Down
30 changes: 14 additions & 16 deletions Apps/GraphicsDemo/main/Include/drivers/DisplayDriver.h
Original file line number Diff line number Diff line change
@@ -1,49 +1,47 @@
#pragma once

#include <cassert>
#include <tt_hal_display.h>
#include <tactility/device.h>
#include <tactility/drivers/display.h>
#include <Tactility/kernel/Kernel.h>

/**
* Wrapper for tt_hal_display_driver_*
* Wrapper for display_* device driver functions
*/
class DisplayDriver {

DisplayDriverHandle handle = nullptr;
struct Device* device;

public:

explicit DisplayDriver(DeviceId id) {
assert(tt_hal_display_driver_supported(id));
handle = tt_hal_display_driver_alloc(id);
assert(handle != nullptr);
explicit DisplayDriver(struct Device* device) : device(device) {
device_get(device);
}

~DisplayDriver() {
tt_hal_display_driver_free(handle);
device_put(device);
}

bool lock(TickType_t timeout = tt::kernel::MAX_TICKS) const {
return tt_hal_display_driver_lock(handle, timeout);
return device_try_lock(device, timeout);
}

void unlock() const {
tt_hal_display_driver_unlock(handle);
device_unlock(device);
}

uint16_t getWidth() const {
return tt_hal_display_driver_get_pixel_width(handle);
return display_get_resolution_x(device);
}

uint16_t getHeight() const {
return tt_hal_display_driver_get_pixel_height(handle);
return display_get_resolution_y(device);
}

ColorFormat getColorFormat() const {
return tt_hal_display_driver_get_colorformat(handle);
enum DisplayColorFormat getColorFormat() const {
return display_get_color_format(device);
}

void drawBitmap(int xStart, int yStart, int xEnd, int yEnd, const void* pixelData) const {
tt_hal_display_driver_draw_bitmap(handle, xStart, yStart, xEnd, yEnd, pixelData);
display_draw_bitmap(device, xStart, yStart, xEnd, yEnd, pixelData);
}
};
20 changes: 10 additions & 10 deletions Apps/GraphicsDemo/main/Include/drivers/TouchDriver.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
#pragma once

#include <cassert>
#include <tt_hal_touch.h>
#include <tactility/device.h>
#include <tactility/drivers/pointer.h>

/**
* Wrapper for tt_hal_touch_driver_*
* Wrapper for pointer_* device driver functions
*/
class TouchDriver {

TouchDriverHandle handle = nullptr;
struct Device* device;

public:

explicit TouchDriver(DeviceId id) {
assert(tt_hal_touch_driver_supported(id));
handle = tt_hal_touch_driver_alloc(id);
assert(handle != nullptr);
explicit TouchDriver(struct Device* device) : device(device) {
device_get(device);
}

~TouchDriver() {
tt_hal_touch_driver_free(handle);
device_put(device);
}

bool getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* count, uint8_t maxCount) const {
return tt_hal_touch_driver_get_touched_points(handle, x, y, strength, count, maxCount);
// Poll without blocking: perform one read attempt, then report whatever is cached.
pointer_read_data(device, 0);
return pointer_get_touched_points(device, x, y, strength, count, maxCount);
}
};
Loading
Loading