Skip to content

Commit 9ba1d46

Browse files
Update GPIO driver usage (#23)
Recently the SDK removed GPIO functionality because pins are now exclusively claimed by a driver. That means the GPIO app can't claim pins that are already in use... except when it calls the ESP-IDF driver code directly, which is what the app now does.
1 parent 1955cda commit 9ba1d46

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

Apps/GPIO/main/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ idf_component_register(
77
# Library headers must be included directly,
88
# because all regular dependencies get stripped by elf_loader's cmake script
99
INCLUDE_DIRS ../../../Libraries/TactilityCpp/Include
10-
REQUIRES TactilitySDK
10+
REQUIRES TactilitySDK driver
1111
)
1212

Apps/GPIO/main/Source/Gpio.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
#include <Tactility/kernel/Kernel.h>
44

55
#include <tt_hal.h>
6-
#include <tt_hal_gpio.h>
76
#include <tt_lvgl.h>
87
#include <tt_lvgl_toolbar.h>
98

109
#include <esp_log.h>
10+
#include <driver/gpio.h>
1111

1212
constexpr char* TAG = "GPIO";
1313

1414
void Gpio::updatePinStates() {
1515
// Update pin states
1616
for (int i = 0; i < pinStates.size(); ++i) {
17-
pinStates[i] = tt_hal_gpio_get_level(i);
17+
pinStates[i] = gpio_get_level((gpio_num_t)i);
1818
}
1919
}
2020

@@ -113,11 +113,10 @@ void Gpio::onShow(AppHandle app, lv_obj_t* parent) {
113113

114114
mutex.lock();
115115

116-
auto pin_count = tt_hal_gpio_get_pin_count();
117-
pinStates.resize(pin_count);
118-
pinWidgets.resize(pin_count);
116+
pinStates.resize(GPIO_PIN_COUNT);
117+
pinWidgets.resize(GPIO_PIN_COUNT);
119118

120-
for (int i = 0; i < pin_count; ++i) {
119+
for (int i = 0; i < GPIO_PIN_COUNT; ++i) {
121120
constexpr uint8_t offset_from_left_label = 4;
122121

123122
// Add the GPIO number before the first item on a row

Apps/GPIO/manifest.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ sdk=0.7.0-dev
55
platforms=esp32,esp32s3,esp32c6,esp32p4
66
[app]
77
id=one.tactility.gpio
8-
versionName=0.3.0
9-
versionCode=3
8+
versionName=0.4.0
9+
versionCode=4
1010
name=GPIO

0 commit comments

Comments
 (0)