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
13 changes: 6 additions & 7 deletions Apps/GPIO/main/Source/Gpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

#include <Tactility/kernel/Kernel.h>

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

#include <tactility/lvgl_module.h>

#include <esp_log.h>
#include <driver/gpio.h>

Expand Down Expand Up @@ -66,17 +67,15 @@ void Gpio::stopTask() {

// endregion Task

static int getSquareSpacing(UiScale scale) {
if (scale == UiScaleSmallest) {
static int getSquareSpacing(UiDensity density) {
if (density == LVGL_UI_DENSITY_COMPACT) {
return 0;
} else {
return 4;
}
}

void Gpio::onShow(AppHandle app, lv_obj_t* parent) {
// auto ui_scale = hal::getConfiguration()->uiScale;

lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);

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

constexpr auto block_width = 16;
auto ui_scale = tt_hal_configuration_get_ui_scale();
const auto square_spacing = getSquareSpacing(ui_scale);
auto ui_density = lvgl_get_ui_density();
const auto square_spacing = getSquareSpacing(ui_density);
int32_t x_spacing = block_width + square_spacing;
uint8_t column = 0;
const uint8_t column_limit = is_landscape_display ? 10 : 5;
Expand Down
14 changes: 8 additions & 6 deletions Apps/Snake/main/Source/Snake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
#include "Snake.h"

#include <inttypes.h>
#include <tt_hal.h>
#include <tt_lvgl_toolbar.h>
#include <tt_app_alertdialog.h>
#include <tt_app_selectiondialog.h>
#include <tt_preferences.h>

#include <TactilityCpp/LvglLock.h>

#include <tactility/lvgl_module.h>

constexpr auto* TAG = "Snake";

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

static int getToolbarHeight(UiScale uiScale) {
if (uiScale == UiScale::UiScaleSmallest) {
static int getToolbarHeight(UiDensity density) {
if (density == LVGL_UI_DENSITY_COMPACT) {
return 22;
} else {
return 40;
Expand Down Expand Up @@ -201,10 +203,10 @@ void Snake::createGame(lv_obj_t* parent, uint16_t cell_size, bool wallCollision,
lv_obj_set_style_bg_opa(newGameWrapper, 0, LV_STATE_DEFAULT);

// Create new game button
auto ui_scale = tt_hal_configuration_get_ui_scale();
auto toolbar_height = getToolbarHeight(ui_scale);
auto ui_density = lvgl_get_ui_density();
auto toolbar_height = getToolbarHeight(ui_density);
lv_obj_t* newGameBtn = lv_btn_create(newGameWrapper);
if (ui_scale == UiScale::UiScaleSmallest) {
if (ui_density == LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_size(newGameBtn, toolbar_height - 8, toolbar_height - 8);
} else {
lv_obj_set_size(newGameBtn, toolbar_height - 6, toolbar_height - 6);
Expand Down
12 changes: 6 additions & 6 deletions Apps/TwoEleven/main/Source/TwoEleven.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#include "TwoEleven.h"

#include <inttypes.h>
#include <tt_hal.h>
#include <tt_lvgl_toolbar.h>
#include <tt_app_alertdialog.h>
#include <tt_app_selectiondialog.h>
#include <tt_preferences.h>
#include <tactility/lvgl_module.h>
#include <TactilityCpp/LvglLock.h>

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

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

// Create new game button
auto ui_scale = tt_hal_configuration_get_ui_scale();
auto toolbar_height = getToolbarHeight(ui_scale);
auto ui_density = lvgl_get_ui_density();
auto toolbar_height = getToolbarHeight(ui_density);
lv_obj_t* newGameBtn = lv_btn_create(newGameWrapper);
if (ui_scale == UiScale::UiScaleSmallest) {
if (ui_density == LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_size(newGameBtn, toolbar_height - 8, toolbar_height - 8);
} else {
lv_obj_set_size(newGameBtn, toolbar_height - 6, toolbar_height - 6);
Expand Down