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
23 changes: 14 additions & 9 deletions Apps/Doom/main/Source/Application.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "Application.h"
#include "DoomEsp.h"

#include <tactility/drivers/pointer.h>
#include <tactility/drivers/mouse.h>
#include <tactility/drivers/touch.h>

#include <esp_log.h>
#include <freertos/FreeRTOS.h>
Expand Down Expand Up @@ -30,16 +31,20 @@ static void doomTask(void* arg) {
vTaskDelete(nullptr);
}

static bool isTouched(Device* touch) {
if (pointer_read_data(touch, 0) != ERROR_NONE) {
return false;
static bool isTouched(Device* touch, Device* mouse) {
if (touch != nullptr) {
uint16_t x, y, strength;
uint8_t pointCount = 0;
touch_read_data(touch, 0);
if (touch_get_touched_points(touch, &x, &y, &strength, &pointCount, 1)) {
return true;
}
}
uint16_t x, y, strength;
uint8_t pointCount = 0;
return pointer_get_touched_points(touch, &x, &y, &strength, &pointCount, 1);
bool pressed = false;
return mouse != nullptr && mouse_get_button_pressed(mouse, 0, &pressed) == ERROR_NONE && pressed;
}

void runApplication(Device* display, Device* touch) {
void runApplication(Device* display, Device* touch, Device* mouse) {
SemaphoreHandle_t doneSem = xSemaphoreCreateBinary();
if (doneSem == nullptr) {
ESP_LOGE(TAG, "Failed to create shutdown semaphore");
Expand All @@ -62,7 +67,7 @@ void runApplication(Device* display, Device* touch) {

// Wait until either the doom task exits on its own, or the user touches the screen
while (xSemaphoreTake(doneSem, pdMS_TO_TICKS(EXIT_POLL_DELAY_MS)) == pdFALSE) {
if (isTouched(touch)) {
if (isTouched(touch, mouse)) {
doomEsp_RequestStop();
xSemaphoreTake(doneSem, portMAX_DELAY);
break;
Expand Down
2 changes: 1 addition & 1 deletion Apps/Doom/main/Source/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

#include <tactility/device.h>

void runApplication(struct Device* display, struct Device* touch);
void runApplication(struct Device* display, struct Device* touch, struct Device* mouse);
20 changes: 16 additions & 4 deletions Apps/Doom/main/Source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#include <tactility/check.h>
#include <tactility/device.h>
#include <tactility/drivers/display.h>
#include <tactility/drivers/pointer.h>
#include <tactility/drivers/mouse.h>
#include <tactility/drivers/touch.h>
#include <lvgl/lvgl.h>
#include <lvgl/module.h>
#include <tactility/module.h>
Expand Down Expand Up @@ -65,10 +66,14 @@ int main(int argc, char* argv[]) {
return 0;
}

struct Device* touch_device;
if (device_get_first_active_by_type(&POINTER_TYPE, &touch_device) != ERROR_NONE) {
struct Device* touch_device = nullptr;
struct Device* mouse_device = nullptr;
device_get_first_active_by_type(&TOUCH_TYPE, &touch_device);
device_get_first_active_by_type(&MOUSE_TYPE, &mouse_device);
Comment thread
KenVanHoeylandt marked this conversation as resolved.
if (touch_device == nullptr && mouse_device == nullptr) {
ESP_LOGE(TAG, "No touch device found");
showErrorAndWait(app_instance_id, "No touch device was found.");
device_put(display_device);
return 0;
}

Expand All @@ -77,7 +82,14 @@ int main(int argc, char* argv[]) {

// Run the main logic
ESP_LOGI(TAG, "Running application");
runApplication(display_device, touch_device);
runApplication(display_device, touch_device, mouse_device);
device_put(display_device);
if (touch_device != nullptr) {
device_put(touch_device);
}
if (mouse_device != nullptr) {
device_put(mouse_device);
}

// Restart LVGL to resume rendering of regular apps
if (!module_is_started(&lvgl_module)) {
Expand Down
4 changes: 2 additions & 2 deletions Apps/Doom/manifest.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ manifest.version=0.3
target.sdk=0.8.0-dev
target.platforms=esp32p4
id=tactility.doom
version.name=0.11.0
version.code=11
version.name=0.12.0
version.code=12
name=Doom
description=Classic DOOM. Tab5 only, keyboard required to play.
app.0.id=tactility.doom
Expand Down
41 changes: 31 additions & 10 deletions Apps/GraphicsDemo/main/Include/drivers/TouchDriver.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,49 @@
#pragma once

#include <tactility/device.h>
#include <tactility/drivers/pointer.h>
#include <tactility/drivers/mouse.h>
#include <tactility/drivers/touch.h>

/**
* Wrapper for pointer_* device driver functions
* Wrapper for touch_* and mouse_* device driver functions.
* Either device can be absent. A press of the primary mouse button counts as a touch.
*/
class TouchDriver {

struct Device* device;
struct Device* touchDevice;
struct Device* mouseDevice;

public:

explicit TouchDriver(struct Device* device) : device(device) {
device_get(device);
TouchDriver(struct Device* touchDevice, struct Device* mouseDevice) : touchDevice(touchDevice), mouseDevice(mouseDevice) {
if (touchDevice != nullptr) {
device_get(touchDevice);
}
if (mouseDevice != nullptr) {
device_get(mouseDevice);
}
}

~TouchDriver() {
device_put(device);
if (touchDevice != nullptr) {
device_put(touchDevice);
}
if (mouseDevice != nullptr) {
device_put(mouseDevice);
}
}

bool getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* count, uint8_t maxCount) const {
// 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);
bool isTouched() const {
if (touchDevice != nullptr) {
uint16_t x, y, strength;
uint8_t count = 0;
// Poll without blocking: perform one read attempt, then report whatever is cached.
touch_read_data(touchDevice, 0);
if (touch_get_touched_points(touchDevice, &x, &y, &strength, &count, 1)) {
return true;
}
}
bool pressed = false;
return mouseDevice != nullptr && mouse_get_button_pressed(mouseDevice, 0, &pressed) == ERROR_NONE && pressed;
}
};
4 changes: 1 addition & 3 deletions Apps/GraphicsDemo/main/Source/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
constexpr auto TAG = "Application";

static bool isTouched(TouchDriver* touch) {
uint16_t x, y, strength;
uint8_t pointCount = 0;
return touch->getTouchedPoints(&x, &y, &strength, &pointCount, 1);
return touch->isTouched();
}

void createRgbRow(PixelBuffer& buffer) {
Expand Down
19 changes: 14 additions & 5 deletions Apps/GraphicsDemo/main/Source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#include <tactility/check.h>
#include <tactility/device.h>
#include <tactility/drivers/display.h>
#include <tactility/drivers/pointer.h>
#include <tactility/drivers/mouse.h>
#include <tactility/drivers/touch.h>
#include <lvgl/lvgl.h>
#include <lvgl/module.h>
#include <tactility/module.h>
Expand Down Expand Up @@ -70,8 +71,11 @@ int main(int argc, char* argv[]) {
return 0;
}

struct Device* touch_device;
if (device_get_first_active_by_type(&POINTER_TYPE, &touch_device) != ERROR_NONE) {
struct Device* touch_device = nullptr;
struct Device* mouse_device = nullptr;
device_get_first_active_by_type(&TOUCH_TYPE, &touch_device);
device_get_first_active_by_type(&MOUSE_TYPE, &mouse_device);
if (touch_device == nullptr && mouse_device == nullptr) {
ESP_LOGE(TAG, "No touch device found");
device_put(display_device);
showErrorAndWait(app_instance_id, "No touch device was found.");
Expand All @@ -86,8 +90,13 @@ int main(int argc, char* argv[]) {
device_put(display_device);

ESP_LOGI(TAG, "Creating touch driver");
auto touch = new TouchDriver(touch_device);
device_put(touch_device);
auto touch = new TouchDriver(touch_device, mouse_device);
if (touch_device != nullptr) {
device_put(touch_device);
}
if (mouse_device != nullptr) {
device_put(mouse_device);
}

// Run the main logic
ESP_LOGI(TAG, "Running application");
Expand Down
4 changes: 2 additions & 2 deletions Apps/GraphicsDemo/manifest.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ manifest.version=0.3
target.sdk=0.8.0-dev
target.platforms=esp32,esp32s3,esp32c6,esp32p4
id=tactility.graphicsdemo
version.name=0.18.0
version.code=18
version.name=0.19.0
version.code=19
name=Graphics Demo
app.0.id=tactility.graphicsdemo
app.0.name=Graphics Demo
Expand Down
41 changes: 31 additions & 10 deletions Apps/MystifyDemo/main/Include/drivers/TouchDriver.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,49 @@
#pragma once

#include <tactility/device.h>
#include <tactility/drivers/pointer.h>
#include <tactility/drivers/mouse.h>
#include <tactility/drivers/touch.h>

/**
* Wrapper for pointer_* device driver functions
* Wrapper for touch_* and mouse_* device driver functions.
* Either device can be absent. A press of the primary mouse button counts as a touch.
*/
class TouchDriver {

struct Device* device;
struct Device* touchDevice;
struct Device* mouseDevice;

public:

explicit TouchDriver(struct Device* device) : device(device) {
device_get(device);
TouchDriver(struct Device* touchDevice, struct Device* mouseDevice) : touchDevice(touchDevice), mouseDevice(mouseDevice) {
if (touchDevice != nullptr) {
device_get(touchDevice);
}
if (mouseDevice != nullptr) {
device_get(mouseDevice);
}
}

~TouchDriver() {
device_put(device);
if (touchDevice != nullptr) {
device_put(touchDevice);
}
if (mouseDevice != nullptr) {
device_put(mouseDevice);
}
}

bool getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* count, uint8_t maxCount) const {
// 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);
bool isTouched() const {
if (touchDevice != nullptr) {
uint16_t x, y, strength;
uint8_t count = 0;
// Poll without blocking: perform one read attempt, then report whatever is cached.
touch_read_data(touchDevice, 0);
if (touch_get_touched_points(touchDevice, &x, &y, &strength, &count, 1)) {
return true;
}
}
bool pressed = false;
return mouseDevice != nullptr && mouse_get_button_pressed(mouseDevice, 0, &pressed) == ERROR_NONE && pressed;
}
};
4 changes: 1 addition & 3 deletions Apps/MystifyDemo/main/Source/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ constexpr auto TAG = "Application";
constexpr int MYSTIFY_FRAME_DELAY_MS = 50; // ~20 FPS for smooth animation

static bool isTouched(TouchDriver* touch) {
uint16_t x, y, strength;
uint8_t pointCount = 0;
return touch->getTouchedPoints(&x, &y, &strength, &pointCount, 1);
return touch->isTouched();
}

void runApplication(DisplayDriver* display, TouchDriver* touch) {
Expand Down
19 changes: 14 additions & 5 deletions Apps/MystifyDemo/main/Source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#include <tactility/check.h>
#include <tactility/device.h>
#include <tactility/drivers/display.h>
#include <tactility/drivers/pointer.h>
#include <tactility/drivers/mouse.h>
#include <tactility/drivers/touch.h>
#include <lvgl/lvgl.h>
#include <lvgl/module.h>
#include <tactility/module.h>
Expand Down Expand Up @@ -70,8 +71,11 @@ int main(int argc, char* argv[]) {
return 0;
}

struct Device* touch_device;
if (device_get_first_active_by_type(&POINTER_TYPE, &touch_device) != ERROR_NONE) {
struct Device* touch_device = nullptr;
struct Device* mouse_device = nullptr;
device_get_first_active_by_type(&TOUCH_TYPE, &touch_device);
device_get_first_active_by_type(&MOUSE_TYPE, &mouse_device);
if (touch_device == nullptr && mouse_device == nullptr) {
ESP_LOGE(TAG, "No touch device found");
device_put(display_device);
showErrorAndWait(app_instance_id, "No touch device was found.");
Expand All @@ -86,8 +90,13 @@ int main(int argc, char* argv[]) {
device_put(display_device);

ESP_LOGI(TAG, "Creating touch driver");
auto touch = new TouchDriver(touch_device);
device_put(touch_device);
auto touch = new TouchDriver(touch_device, mouse_device);
if (touch_device != nullptr) {
device_put(touch_device);
}
if (mouse_device != nullptr) {
device_put(mouse_device);
}

// Run the main logic
ESP_LOGI(TAG, "Running application");
Expand Down
4 changes: 2 additions & 2 deletions Apps/MystifyDemo/manifest.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ manifest.version=0.3
target.sdk=0.8.0-dev
target.platforms=esp32,esp32s3,esp32c6,esp32p4
id=tactility.mystifydemo
version.name=0.19.0
version.code=19
version.name=0.20.0
version.code=20
name=Mystify Demo
description=A graphics demo that is inspired by a Windows 95 screensaver.
app.0.id=tactility.mystifydemo
Expand Down
15 changes: 12 additions & 3 deletions tt.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import urllib.request
import zipfile

TT_VERSION = "1.3.0"
TT_VERSION = "1.3.1"
CDN_URL = os.environ.get("TT_CDN", "https://cdn.tactilityproject.org")
HOME_DIRECTORY = os.path.join(os.path.expanduser("~"), ".tactility")
INDEX_VALIDITY_SECONDS = 3600
Expand Down Expand Up @@ -297,13 +297,19 @@ def read_text(path):


def is_installed_build(version_directory, index):
"""True when the installed tools and platforms are of the build that the index describes"""
"""True when the installed tools and platforms are of the build that the index describes.
Installed platforms that the index no longer has (e.g. after a rename) don't count: they can't be
updated, and "tt update-sdk" removes them."""
installed_tools_hash = read_text(os.path.join(version_directory, "tools.sha256"))
if installed_tools_hash is not None and installed_tools_hash != index.get("tools", {}).get("sha256"):
return False
available = index.get("platforms", {})
prefix = "platform-"
for name in os.listdir(version_directory):
if not name.startswith(prefix) or name[len(prefix):] not in available:
continue
commit = read_text(os.path.join(version_directory, name, "commit"))
if name.startswith("platform-") and commit is not None and commit != index.get("gitCommit", ""):
if commit is not None and commit != index.get("gitCommit", ""):
return False
return True

Expand All @@ -324,6 +330,9 @@ def prepare_sdk(version, platforms):
os.makedirs(version_directory, exist_ok=True)
if index is None:
index = load_index(version, version_directory)
for platform in platforms:
if platform not in index.get("platforms", {}):
fail(f"platform {platform} is not available in SDK {version}")
Comment thread
KenVanHoeylandt marked this conversation as resolved.
# The CDN only has the latest build of a version, so a newer build can't be mixed with the installed one
if not is_installed_build(version_directory, index):
if has_tools:
Expand Down
Loading