Reformatted all the files according to clang-format style
This commit is contained in:
@@ -4,37 +4,35 @@
|
||||
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
|
||||
namespace {
|
||||
static void lv_update_task(struct _lv_task_t *task) {
|
||||
auto user_data = static_cast<Tile *>(task->user_data);
|
||||
static void lv_update_task(struct _lv_task_t* task) {
|
||||
auto user_data = static_cast<Tile*>(task->user_data);
|
||||
user_data->UpdateScreen();
|
||||
}
|
||||
|
||||
static void event_handler(lv_obj_t * obj, lv_event_t event) {
|
||||
Tile* screen = static_cast<Tile *>(obj->user_data);
|
||||
static void event_handler(lv_obj_t* obj, lv_event_t event) {
|
||||
Tile* screen = static_cast<Tile*>(obj->user_data);
|
||||
uint32_t* eventDataPtr = (uint32_t*) lv_event_get_data();
|
||||
uint32_t eventData = *eventDataPtr;
|
||||
screen->OnObjectEvent(obj, event, eventData);
|
||||
}
|
||||
}
|
||||
|
||||
Tile::Tile(uint8_t screenID, uint8_t numScreens,
|
||||
DisplayApp* app,
|
||||
Controllers::Settings& settingsController,
|
||||
Pinetime::Controllers::Battery& batteryController,
|
||||
Controllers::DateTime& dateTimeController,
|
||||
std::array<Applications, 6>& applications) :
|
||||
Screen(app),
|
||||
batteryController{batteryController},
|
||||
dateTimeController{dateTimeController} {
|
||||
|
||||
Tile::Tile(uint8_t screenID,
|
||||
uint8_t numScreens,
|
||||
DisplayApp* app,
|
||||
Controllers::Settings& settingsController,
|
||||
Pinetime::Controllers::Battery& batteryController,
|
||||
Controllers::DateTime& dateTimeController,
|
||||
std::array<Applications, 6>& applications)
|
||||
: Screen(app), batteryController {batteryController}, dateTimeController {dateTimeController} {
|
||||
|
||||
settingsController.SetAppMenu(screenID);
|
||||
|
||||
// Time
|
||||
label_time = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_text_fmt(label_time, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes());
|
||||
lv_label_set_align( label_time, LV_LABEL_ALIGN_CENTER );
|
||||
label_time = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_text_fmt(label_time, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes());
|
||||
lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER);
|
||||
lv_obj_align(label_time, nullptr, LV_ALIGN_IN_TOP_LEFT, 15, 6);
|
||||
|
||||
// Battery
|
||||
@@ -42,19 +40,18 @@ Tile::Tile(uint8_t screenID, uint8_t numScreens,
|
||||
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
|
||||
lv_obj_align(batteryIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, -15, 6);
|
||||
|
||||
if ( numScreens > 1 ) {
|
||||
if (numScreens > 1) {
|
||||
pageIndicatorBasePoints[0].x = 240 - 1;
|
||||
pageIndicatorBasePoints[0].y = 6;
|
||||
pageIndicatorBasePoints[1].x = 240 - 1;
|
||||
pageIndicatorBasePoints[1].y = 240 - 6;
|
||||
|
||||
|
||||
pageIndicatorBase = lv_line_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_line_width(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
||||
lv_obj_set_style_local_line_color(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111));
|
||||
lv_obj_set_style_local_line_rounded(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true);
|
||||
lv_line_set_points(pageIndicatorBase, pageIndicatorBasePoints, 2);
|
||||
|
||||
|
||||
uint16_t indicatorSize = 228 / numScreens;
|
||||
uint16_t indicatorPos = indicatorSize * screenID;
|
||||
|
||||
@@ -69,11 +66,12 @@ Tile::Tile(uint8_t screenID, uint8_t numScreens,
|
||||
lv_obj_set_style_local_line_rounded(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true);
|
||||
lv_line_set_points(pageIndicator, pageIndicatorPoints, 2);
|
||||
}
|
||||
|
||||
|
||||
uint8_t btIndex = 0;
|
||||
for(uint8_t i = 0; i < 6; i++) {
|
||||
if(i == 3) btnmMap[btIndex++] = "\n";
|
||||
if ( applications[i].application == Apps::None ) {
|
||||
for (uint8_t i = 0; i < 6; i++) {
|
||||
if (i == 3)
|
||||
btnmMap[btIndex++] = "\n";
|
||||
if (applications[i].application == Apps::None) {
|
||||
btnmMap[btIndex] = " ";
|
||||
} else {
|
||||
btnmMap[btIndex] = applications[i].icon;
|
||||
@@ -94,16 +92,16 @@ Tile::Tile(uint8_t screenID, uint8_t numScreens,
|
||||
lv_obj_set_style_local_bg_opa(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DISABLED, LV_OPA_20);
|
||||
lv_obj_set_style_local_bg_color(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DISABLED, lv_color_hex(0x111111));
|
||||
|
||||
for(uint8_t i = 0; i < 6; i++) {
|
||||
if ( applications[i].application == Apps::None ) {
|
||||
lv_btnmatrix_set_btn_ctrl(btnm1, i, LV_BTNMATRIX_CTRL_DISABLED );
|
||||
for (uint8_t i = 0; i < 6; i++) {
|
||||
if (applications[i].application == Apps::None) {
|
||||
lv_btnmatrix_set_btn_ctrl(btnm1, i, LV_BTNMATRIX_CTRL_DISABLED);
|
||||
}
|
||||
}
|
||||
|
||||
btnm1->user_data = this;
|
||||
lv_obj_set_event_cb(btnm1, event_handler);
|
||||
|
||||
lv_obj_t * backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
|
||||
lv_obj_set_size(backgroundLabel, 240, 240);
|
||||
lv_obj_set_pos(backgroundLabel, 0, 0);
|
||||
@@ -118,7 +116,7 @@ Tile::~Tile() {
|
||||
}
|
||||
|
||||
void Tile::UpdateScreen() {
|
||||
lv_label_set_text_fmt(label_time, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes());
|
||||
lv_label_set_text_fmt(label_time, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes());
|
||||
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
|
||||
}
|
||||
|
||||
@@ -126,11 +124,9 @@ bool Tile::Refresh() {
|
||||
return running;
|
||||
}
|
||||
|
||||
void Tile::OnObjectEvent(lv_obj_t *obj, lv_event_t event, uint32_t buttonId) {
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
void Tile::OnObjectEvent(lv_obj_t* obj, lv_event_t event, uint32_t buttonId) {
|
||||
if (event == LV_EVENT_VALUE_CHANGED) {
|
||||
app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up);
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user