Skip to content

Commit 1443a29

Browse files
Updates for new SDK (#26)
1 parent d799c88 commit 1443a29

3 files changed

Lines changed: 20 additions & 19 deletions

File tree

Apps/GPIO/main/Source/Gpio.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
#include <Tactility/kernel/Kernel.h>
44

5-
#include <tt_hal.h>
65
#include <tt_lvgl.h>
76
#include <tt_lvgl_toolbar.h>
87

8+
#include <tactility/lvgl_module.h>
9+
910
#include <esp_log.h>
1011
#include <driver/gpio.h>
1112

@@ -66,17 +67,15 @@ void Gpio::stopTask() {
6667

6768
// endregion Task
6869

69-
static int getSquareSpacing(UiScale scale) {
70-
if (scale == UiScaleSmallest) {
70+
static int getSquareSpacing(UiDensity density) {
71+
if (density == LVGL_UI_DENSITY_COMPACT) {
7172
return 0;
7273
} else {
7374
return 4;
7475
}
7576
}
7677

7778
void Gpio::onShow(AppHandle app, lv_obj_t* parent) {
78-
// auto ui_scale = hal::getConfiguration()->uiScale;
79-
8079
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
8180
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
8281

@@ -102,8 +101,8 @@ void Gpio::onShow(AppHandle app, lv_obj_t* parent) {
102101
bool is_landscape_display = horizontal_px > vertical_px;
103102

104103
constexpr auto block_width = 16;
105-
auto ui_scale = tt_hal_configuration_get_ui_scale();
106-
const auto square_spacing = getSquareSpacing(ui_scale);
104+
auto ui_density = lvgl_get_ui_density();
105+
const auto square_spacing = getSquareSpacing(ui_density);
107106
int32_t x_spacing = block_width + square_spacing;
108107
uint8_t column = 0;
109108
const uint8_t column_limit = is_landscape_display ? 10 : 5;

Apps/Snake/main/Source/Snake.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
#include "Snake.h"
66

77
#include <inttypes.h>
8-
#include <tt_hal.h>
98
#include <tt_lvgl_toolbar.h>
109
#include <tt_app_alertdialog.h>
1110
#include <tt_app_selectiondialog.h>
1211
#include <tt_preferences.h>
12+
1313
#include <TactilityCpp/LvglLock.h>
1414

15+
#include <tactility/lvgl_module.h>
16+
1517
constexpr auto* TAG = "Snake";
1618

1719
// Preferences keys for high scores (one per difficulty)
@@ -40,8 +42,8 @@ static constexpr int32_t SELECTION_HELL = 4;
4042
// Hell uses same size as Hard but with wall collision enabled
4143
static const uint16_t difficultySizes[DIFFICULTY_COUNT] = { SNAKE_CELL_LARGE, SNAKE_CELL_MEDIUM, SNAKE_CELL_SMALL, SNAKE_CELL_SMALL };
4244

43-
static int getToolbarHeight(UiScale uiScale) {
44-
if (uiScale == UiScale::UiScaleSmallest) {
45+
static int getToolbarHeight(UiDensity density) {
46+
if (density == LVGL_UI_DENSITY_COMPACT) {
4547
return 22;
4648
} else {
4749
return 40;
@@ -201,10 +203,10 @@ void Snake::createGame(lv_obj_t* parent, uint16_t cell_size, bool wallCollision,
201203
lv_obj_set_style_bg_opa(newGameWrapper, 0, LV_STATE_DEFAULT);
202204

203205
// Create new game button
204-
auto ui_scale = tt_hal_configuration_get_ui_scale();
205-
auto toolbar_height = getToolbarHeight(ui_scale);
206+
auto ui_density = lvgl_get_ui_density();
207+
auto toolbar_height = getToolbarHeight(ui_density);
206208
lv_obj_t* newGameBtn = lv_btn_create(newGameWrapper);
207-
if (ui_scale == UiScale::UiScaleSmallest) {
209+
if (ui_density == LVGL_UI_DENSITY_COMPACT) {
208210
lv_obj_set_size(newGameBtn, toolbar_height - 8, toolbar_height - 8);
209211
} else {
210212
lv_obj_set_size(newGameBtn, toolbar_height - 6, toolbar_height - 6);

Apps/TwoEleven/main/Source/TwoEleven.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
#include "TwoEleven.h"
66

77
#include <inttypes.h>
8-
#include <tt_hal.h>
98
#include <tt_lvgl_toolbar.h>
109
#include <tt_app_alertdialog.h>
1110
#include <tt_app_selectiondialog.h>
1211
#include <tt_preferences.h>
12+
#include <tactility/lvgl_module.h>
1313
#include <TactilityCpp/LvglLock.h>
1414

1515
constexpr auto* TAG = "TwoEleven";
@@ -39,8 +39,8 @@ static constexpr int32_t SELECTION_6X6 = 4;
3939
// Grid size options (index matches selection - 1)
4040
static const uint16_t gridSizes[SIZE_COUNT] = { 3, 4, 5, 6 };
4141

42-
static int getToolbarHeight(UiScale uiScale) {
43-
if (uiScale == UiScale::UiScaleSmallest) {
42+
static int getToolbarHeight(UiDensity density) {
43+
if (density == LVGL_UI_DENSITY_COMPACT) {
4444
return 22;
4545
} else {
4646
return 40;
@@ -215,10 +215,10 @@ void TwoEleven::createGame(lv_obj_t* parent, uint16_t size, lv_obj_t* tb) {
215215
lv_obj_set_style_bg_opa(newGameWrapper, 0, LV_STATE_DEFAULT);
216216

217217
// Create new game button
218-
auto ui_scale = tt_hal_configuration_get_ui_scale();
219-
auto toolbar_height = getToolbarHeight(ui_scale);
218+
auto ui_density = lvgl_get_ui_density();
219+
auto toolbar_height = getToolbarHeight(ui_density);
220220
lv_obj_t* newGameBtn = lv_btn_create(newGameWrapper);
221-
if (ui_scale == UiScale::UiScaleSmallest) {
221+
if (ui_density == LVGL_UI_DENSITY_COMPACT) {
222222
lv_obj_set_size(newGameBtn, toolbar_height - 8, toolbar_height - 8);
223223
} else {
224224
lv_obj_set_size(newGameBtn, toolbar_height - 6, toolbar_height - 6);

0 commit comments

Comments
 (0)