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:
committed by
GitHub
parent
eb4e9f9649
commit
08029a84dd
@@ -5,8 +5,15 @@
|
||||
namespace tt::app::display {
|
||||
|
||||
void setBacklightDuty(uint8_t value);
|
||||
uint8_t getBacklightDuty();
|
||||
|
||||
bool getBacklightDuty(uint8_t& duty);
|
||||
|
||||
void setGammaCurve(uint8_t curveIndex);
|
||||
|
||||
bool getGammaCurve(uint8_t& curveIndex);
|
||||
|
||||
void setRotation(lv_display_rotation_t rotation);
|
||||
|
||||
lv_display_rotation_t getRotation();
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -16,9 +16,9 @@ bool initEspLvglPort() {
|
||||
TT_LOG_D(TAG, "Port init");
|
||||
static lv_disp_t* display = nullptr;
|
||||
const lvgl_port_cfg_t lvgl_cfg = {
|
||||
.task_priority = static_cast<UBaseType_t>(tt::THREAD_PRIORITY_RENDER),
|
||||
.task_priority = static_cast<UBaseType_t>(Thread::Priority::Critical),
|
||||
.task_stack = TDECK_LVGL_TASK_STACK_DEPTH,
|
||||
.task_affinity = -1, // core pinning
|
||||
.task_affinity = 1, // -1 = disabled, 0 = core 1, 1 = core 2
|
||||
.task_max_sleep_ms = 500,
|
||||
.timer_period_ms = 5
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ void syncSet(LvglLock lock, LvglUnlock unlock) {
|
||||
auto old_unlock = unlock_singleton;
|
||||
|
||||
// Ensure the old lock is not engaged when changing locks
|
||||
old_lock(portMAX_DELAY);
|
||||
old_lock((uint32_t)portMAX_DELAY);
|
||||
lock_singleton = lock;
|
||||
unlock_singleton = unlock;
|
||||
old_unlock();
|
||||
|
||||
@@ -112,7 +112,8 @@ lv_obj_t* toolbar_add_button_action(lv_obj_t* obj, const char* icon, lv_event_cb
|
||||
|
||||
lv_obj_t* action_button = lv_button_create(toolbar->action_container);
|
||||
lv_obj_set_size(action_button, TOOLBAR_HEIGHT - 4, TOOLBAR_HEIGHT - 4);
|
||||
obj_set_style_no_padding(action_button);
|
||||
lv_obj_set_style_pad_all(action_button, 0, 0);
|
||||
lv_obj_set_style_pad_gap(action_button, 0, 0);
|
||||
lv_obj_add_event_cb(action_button, callback, LV_EVENT_SHORT_CLICKED, user_data);
|
||||
lv_obj_t* action_button_image = lv_image_create(action_button);
|
||||
lv_image_set_src(action_button_image, icon);
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace tt::service::gui {
|
||||
|
||||
// Forward declarations
|
||||
void redraw(Gui*);
|
||||
static int32_t guiMain(TT_UNUSED void* p);
|
||||
static int32_t guiMain();
|
||||
|
||||
Gui* gui = nullptr;
|
||||
|
||||
@@ -33,8 +33,7 @@ Gui* gui_alloc() {
|
||||
instance->thread = new Thread(
|
||||
"gui",
|
||||
4096, // Last known minimum was 2800 for launching desktop
|
||||
&guiMain,
|
||||
nullptr
|
||||
[]() { return guiMain(); }
|
||||
);
|
||||
instance->loader_pubsub_subscription = loader::getPubsub()->subscribe(&onLoaderMessage, instance);
|
||||
tt_check(lvgl::lock(1000 / portTICK_PERIOD_MS));
|
||||
@@ -118,7 +117,7 @@ void hideApp() {
|
||||
unlock();
|
||||
}
|
||||
|
||||
static int32_t guiMain(TT_UNUSED void* p) {
|
||||
static int32_t guiMain() {
|
||||
tt_check(gui);
|
||||
Gui* local_gui = gui;
|
||||
|
||||
|
||||
@@ -59,13 +59,6 @@ static void makeScreenshot(const std::string& filename) {
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t screenshotTaskCallback(void* context) {
|
||||
auto* data = static_cast<ScreenshotTask*>(context);
|
||||
assert(data != nullptr);
|
||||
data->taskMain();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ScreenshotTask::taskMain() {
|
||||
uint8_t screenshots_taken = 0;
|
||||
std::string last_app_id;
|
||||
@@ -116,8 +109,10 @@ void ScreenshotTask::taskStart() {
|
||||
thread = new Thread(
|
||||
"screenshot",
|
||||
8192,
|
||||
&screenshotTaskCallback,
|
||||
this
|
||||
[this]() {
|
||||
this->taskMain();
|
||||
return 0;
|
||||
}
|
||||
);
|
||||
thread->start();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user