Various fixes and improvements (#269)

- Bump version for next release
- Fix default gamma for CYD 2432S032C
- Remember gamma curve setting from Display settings app
- Add UART to Core2 (still has no voltage on Grove port, though)
- LVGL performance improvements: pin to second core and set task priority to "critical"
- Fix build warnings, including deprecations
- Removed deprecated `Thread` constructor
- Fix WaveShare S3 display: Some displays would show a white screen at 12MHz, so I'm putting it back to the
official config values.
This commit is contained in:
Ken Van Hoeylandt
2025-04-01 23:42:56 +02:00
committed by GitHub
parent eb4e9f9649
commit 08029a84dd
30 changed files with 203 additions and 145 deletions
+13 -5
View File
@@ -32,9 +32,9 @@ class BootApp : public App {
private:
Thread thread = Thread("boot", 4096, bootThreadCallback, this);
Thread thread = Thread("boot", 4096, [this]() { return bootThreadCallback(); });
static int32_t bootThreadCallback(TT_UNUSED void* context) {
int32_t bootThreadCallback() {
TickType_t start_time = kernel::getTicks();
kernel::publishSystemEvent(kernel::SystemEvent::BootSplash);
@@ -42,14 +42,22 @@ private:
auto hal_display = getHalDisplay();
assert(hal_display != nullptr);
if (hal_display->supportsBacklightDuty()) {
int32_t backlight_duty = app::display::getBacklightDuty();
TT_LOG_I(TAG, "backlight %ld", backlight_duty);
uint8_t backlight_duty = 200;
app::display::getBacklightDuty(backlight_duty);
TT_LOG_I(TAG, "backlight %du", backlight_duty);
hal_display->setBacklightDuty(backlight_duty);
} else {
TT_LOG_I(TAG, "no backlight");
}
if (hal_display->getGammaCurveCount() > 0) {
uint8_t gamma_curve;
if (app::display::getGammaCurve(gamma_curve)) {
hal_display->setGammaCurve(gamma_curve);
TT_LOG_I(TAG, "gamma %du", gamma_curve);
}
}
if (hal::usb::isUsbBootMode()) {
TT_LOG_I(TAG, "Rebooting into mass storage device mode");
hal::usb::resetUsbBootMode();
+18 -3
View File
@@ -55,6 +55,7 @@ static void onGammaSliderEvent(lv_event_t* event) {
gamma = (uint8_t)slider_value;
hal_display->setGammaCurve(gamma);
tt::app::display::setGammaCurve(gamma);
}
}
@@ -136,11 +137,25 @@ class DisplayApp : public App {
lv_slider_set_value(brightness_slider, 255, LV_ANIM_OFF);
lv_obj_add_state(brightness_slider, LV_STATE_DISABLED);
} else {
uint8_t value = getBacklightDuty();
lv_slider_set_value(brightness_slider, value, LV_ANIM_OFF);
uint8_t value;
if (getBacklightDuty(value)) {
lv_slider_set_value(brightness_slider, value, LV_ANIM_OFF);
} else {
lv_slider_set_value(brightness_slider, 0, LV_ANIM_OFF);
}
}
lv_slider_set_value(gamma_slider, 128, LV_ANIM_OFF);
if (hal_display->getGammaCurveCount() == 0) {
lv_slider_set_value(gamma_slider, 0, LV_ANIM_OFF);
lv_obj_add_state(gamma_slider, LV_STATE_DISABLED);
} else {
uint8_t curve_index;
if (getGammaCurve(curve_index)) {
lv_slider_set_value(gamma_slider, curve_index, LV_ANIM_OFF);
} else {
lv_slider_set_value(gamma_slider, 0, LV_ANIM_OFF);
}
}
auto* orientation_label = lv_label_create(wrapper);
lv_label_set_text(orientation_label, "Orientation");
@@ -6,19 +6,21 @@ namespace tt::app::display {
tt::Preferences preferences("display");
#define BACKLIGHT_DUTY_KEY "backlight_duty"
#define ROTATION_KEY "rotation"
constexpr const char* BACKLIGHT_DUTY_KEY = "backlight_duty";
constexpr const char* GAMMA_CURVE_KEY = "gamma";
constexpr const char* ROTATION_KEY = "rotation";
void setBacklightDuty(uint8_t value) {
preferences.putInt32(BACKLIGHT_DUTY_KEY, (int32_t)value);
}
uint8_t getBacklightDuty() {
bool getBacklightDuty(uint8_t& duty) {
int32_t result;
if (preferences.optInt32(BACKLIGHT_DUTY_KEY, result)) {
return (uint8_t)(result % 256);
duty = (uint8_t)(result % 256);
return true;
} else {
return 200;
return false;
}
}
@@ -35,4 +37,18 @@ lv_display_rotation_t getRotation() {
}
}
void setGammaCurve(uint8_t curveIndex) {
preferences.putInt32(GAMMA_CURVE_KEY, (int32_t)curveIndex);
}
bool getGammaCurve(uint8_t& curveIndex) {
int32_t result;
if (preferences.optInt32(GAMMA_CURVE_KEY, result)) {
curveIndex = (uint8_t)(result % 256);
return true;
} else {
return false;
}
}
} // namespace
+6 -6
View File
@@ -228,8 +228,8 @@ void View::showActionsForFile() {
}
void View::update() {
auto scoped_lockable = lvgl::getSyncLock()->scoped();
if (scoped_lockable->lock(100 / portTICK_PERIOD_MS)) {
auto scoped_lockable = lvgl::getSyncLock()->asScopedLock();
if (scoped_lockable.lock(lvgl::defaultLockTime)) {
lv_obj_clean(dir_entry_list);
state->withEntries([this](const std::vector<dirent>& entries) {
@@ -277,15 +277,15 @@ void View::init(lv_obj_t* parent) {
}
void View::onDirEntryListScrollBegin() {
auto scoped_lockable = lvgl::getSyncLock()->scoped();
if (scoped_lockable->lock(100 / portTICK_PERIOD_MS)) {
auto scoped_lockable = lvgl::getSyncLock()->asScopedLock();
if (scoped_lockable.lock(lvgl::defaultLockTime)) {
lv_obj_add_flag(action_list, LV_OBJ_FLAG_HIDDEN);
}
}
void View::onNavigate() {
auto scoped_lockable = lvgl::getSyncLock()->scoped();
if (scoped_lockable->lock(100 / portTICK_PERIOD_MS)) {
auto scoped_lockable = lvgl::getSyncLock()->asScopedLock();
if (scoped_lockable.lock(lvgl::defaultLockTime)) {
lv_obj_add_flag(action_list, LV_OBJ_FLAG_HIDDEN);
}
}
+2 -2
View File
@@ -57,8 +57,8 @@ void GpioApp::updatePinWidgets() {
lv_obj_t* label = lvPins[j];
void* label_user_data = lv_obj_get_user_data(label);
// The user data stores the state, so we can avoid unnecessary updates
if ((void*)level != label_user_data) {
lv_obj_set_user_data(label, (void*)level);
if (reinterpret_cast<void*>(level) != label_user_data) {
lv_obj_set_user_data(label, reinterpret_cast<void*>(level));
if (level == 0) {
lv_obj_set_style_text_color(label, lv_color_black(), 0);
} else {
@@ -20,7 +20,8 @@ class ImageViewerApp : public App {
auto wrapper = lv_obj_create(parent);
lv_obj_set_size(wrapper, LV_PCT(100), LV_PCT(100));
lv_obj_set_style_border_width(wrapper, 0, 0);
lvgl::obj_set_style_no_padding(wrapper);
lv_obj_set_style_pad_all(wrapper, 0, 0);
lv_obj_set_style_pad_gap(wrapper, 0, 0);
auto toolbar = lvgl::toolbar_create(wrapper, app);
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
@@ -32,7 +33,8 @@ class ImageViewerApp : public App {
lv_obj_set_height(image_wrapper, parent_height - TOOLBAR_HEIGHT);
lv_obj_set_flex_flow(image_wrapper, LV_FLEX_FLOW_COLUMN);
lv_obj_set_flex_align(image_wrapper, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
lvgl::obj_set_style_no_padding(image_wrapper);
lv_obj_set_style_pad_all(image_wrapper, 0, 0);
lv_obj_set_style_pad_gap(image_wrapper, 0, 0);
lvgl::obj_set_style_bg_invisible(image_wrapper);
auto* image = lv_image_create(image_wrapper);
+2 -1
View File
@@ -81,7 +81,8 @@ public:
lv_obj_set_width(wrapper, LV_PCT(100));
lv_obj_set_flex_grow(wrapper, 1);
lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_COLUMN);
lvgl::obj_set_style_no_padding(wrapper);
lv_obj_set_style_pad_all(wrapper, 0, 0);
lv_obj_set_style_pad_gap(wrapper, 0, 0);
lvgl::obj_set_style_bg_invisible(wrapper);
labelWidget = lv_label_create(wrapper);
+2 -1
View File
@@ -161,7 +161,8 @@ public:
lv_obj_t* switch_container = lv_obj_create(wrapper);
lv_obj_set_width(switch_container, LV_PCT(100));
lv_obj_set_height(switch_container, LV_SIZE_CONTENT);
lvgl::obj_set_style_no_padding(switch_container);
lv_obj_set_style_pad_all(switch_container, 0, 0);
lv_obj_set_style_pad_gap(switch_container, 0, 0);
lvgl::obj_set_style_bg_invisible(switch_container);
enableLabel = lv_label_create(switch_container);
@@ -78,7 +78,8 @@ class WifiApSettings : public App {
auto* auto_connect_wrapper = lv_obj_create(wrapper);
lv_obj_set_size(auto_connect_wrapper, LV_PCT(100), LV_SIZE_CONTENT);
lvgl::obj_set_style_no_padding(auto_connect_wrapper);
lv_obj_set_style_pad_all(auto_connect_wrapper, 0, 0);
lv_obj_set_style_pad_gap(auto_connect_wrapper, 0, 0);
lv_obj_set_style_border_width(auto_connect_wrapper, 0, 0);
auto* auto_connect_label = lv_label_create(auto_connect_wrapper);
+6 -5
View File
@@ -16,8 +16,6 @@ namespace tt::app::wificonnect {
#define TAG "wifi_connect"
std::shared_ptr<WifiConnect> _Nullable optWifiConnect();
void View::resetErrors() {
lv_obj_add_flag(password_error, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(ssid_error, LV_OBJ_FLAG_HIDDEN);
@@ -87,7 +85,8 @@ void View::createBottomButtons(lv_obj_t* parent) {
auto* button_container = lv_obj_create(parent);
lv_obj_set_width(button_container, LV_PCT(100));
lv_obj_set_height(button_container, LV_SIZE_CONTENT);
lvgl::obj_set_style_no_padding(button_container);
lv_obj_set_style_pad_all(button_container, 0, 0);
lv_obj_set_style_pad_gap(button_container, 0, 0);
lv_obj_set_style_border_width(button_container, 0, 0);
remember_switch = lv_switch_create(button_container);
@@ -126,7 +125,8 @@ void View::init(AppContext& app, lv_obj_t* parent) {
auto* ssid_wrapper = lv_obj_create(wrapper);
lv_obj_set_width(ssid_wrapper, LV_PCT(100));
lv_obj_set_height(ssid_wrapper, LV_SIZE_CONTENT);
lvgl::obj_set_style_no_padding(ssid_wrapper);
lv_obj_set_style_pad_all(ssid_wrapper, 0, 0);
lv_obj_set_style_pad_gap(ssid_wrapper, 0, 0);
lv_obj_set_style_border_width(ssid_wrapper, 0, 0);
auto* ssid_label_wrapper = lv_obj_create(ssid_wrapper);
@@ -154,7 +154,8 @@ void View::init(AppContext& app, lv_obj_t* parent) {
auto* password_wrapper = lv_obj_create(wrapper);
lv_obj_set_width(password_wrapper, LV_PCT(100));
lv_obj_set_height(password_wrapper, LV_SIZE_CONTENT);
lvgl::obj_set_style_no_padding(password_wrapper);
lv_obj_set_style_pad_all(password_wrapper, 0, 0);
lv_obj_set_style_pad_gap(password_wrapper, 0, 0);
lv_obj_set_style_border_width(password_wrapper, 0, 0);
auto* password_label_wrapper = lv_obj_create(password_wrapper);
+4 -2
View File
@@ -93,7 +93,8 @@ void View::createSsidListItem(const service::wifi::ApRecord& record, bool isConn
lv_obj_add_event_cb(wrapper, &connect, LV_EVENT_SHORT_CLICKED, bindings);
lv_obj_set_user_data(wrapper, bindings);
lv_obj_set_size(wrapper, LV_PCT(100), LV_SIZE_CONTENT);
lvgl::obj_set_style_no_padding(wrapper);
lv_obj_set_style_pad_all(wrapper, 0, 0);
lv_obj_set_style_pad_gap(wrapper, 0, 0);
lv_obj_set_style_margin_all(wrapper, 0, 0);
lv_obj_set_style_border_width(wrapper, 0, 0);
@@ -285,7 +286,8 @@ void View::init(const AppContext& app, lv_obj_t* parent) {
lv_obj_set_flex_grow(secondary_flex, 1);
lv_obj_set_flex_flow(secondary_flex, LV_FLEX_FLOW_COLUMN);
lv_obj_set_style_border_width(secondary_flex, 0, 0);
lvgl::obj_set_style_no_padding(secondary_flex);
lv_obj_set_style_pad_all(secondary_flex, 0, 0);
lv_obj_set_style_pad_gap(secondary_flex, 0, 0);
lvgl::obj_set_style_bg_invisible(secondary_flex);
// align() methods don't work on flex, so we need this extra wrapper