Improved format specifiers, bracing, removed C-style casts, whitespace fixes and removed Tiles shadowing
This commit is contained in:
parent
645f6f43dc
commit
6a442b90a1
|
@ -36,7 +36,7 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController)
|
||||||
|
|
||||||
alarmHours = alarmController.Hours();
|
alarmHours = alarmController.Hours();
|
||||||
alarmMinutes = alarmController.Minutes();
|
alarmMinutes = alarmController.Minutes();
|
||||||
lv_label_set_text_fmt(time, "%02lu:%02lu", alarmHours, alarmMinutes);
|
lv_label_set_text_fmt(time, "%02hhu:%02hhu", alarmHours, alarmMinutes);
|
||||||
|
|
||||||
lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -25);
|
lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -25);
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ void Alarm::ShowInfo() {
|
||||||
auto secToAlarm = timeToAlarm % 60;
|
auto secToAlarm = timeToAlarm % 60;
|
||||||
|
|
||||||
lv_label_set_text_fmt(
|
lv_label_set_text_fmt(
|
||||||
txtMessage, "Time to\nalarm:\n%2d Days\n%2d Hours\n%2d Minutes\n%2d Seconds", daysToAlarm, hrsToAlarm, minToAlarm, secToAlarm);
|
txtMessage, "Time to\nalarm:\n%2lu Days\n%2lu Hours\n%2lu Minutes\n%2lu Seconds", daysToAlarm, hrsToAlarm, minToAlarm, secToAlarm);
|
||||||
} else {
|
} else {
|
||||||
lv_label_set_text(txtMessage, "Alarm\nis not\nset.");
|
lv_label_set_text(txtMessage, "Alarm\nis not\nset.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app,
|
||||||
: Screen {app}, validator {validator} {
|
: Screen {app}, validator {validator} {
|
||||||
labelVersion = lv_label_create(lv_scr_act(), nullptr);
|
labelVersion = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_label_set_text_fmt(labelVersion,
|
lv_label_set_text_fmt(labelVersion,
|
||||||
"Version : %d.%d.%d\n"
|
"Version : %lu.%lu.%lu\n"
|
||||||
"ShortRef : %s",
|
"ShortRef : %s",
|
||||||
Version::Major(),
|
Version::Major(),
|
||||||
Version::Minor(),
|
Version::Minor(),
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include <FreeRTOS.h>
|
||||||
|
#include <task.h>
|
||||||
#include "displayapp/screens/SystemInfo.h"
|
#include "displayapp/screens/SystemInfo.h"
|
||||||
#include <lvgl/lvgl.h>
|
#include <lvgl/lvgl.h>
|
||||||
#include "displayapp/DisplayApp.h"
|
#include "displayapp/DisplayApp.h"
|
||||||
|
@ -41,8 +43,8 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
|
||||||
brightnessController {brightnessController},
|
brightnessController {brightnessController},
|
||||||
bleController {bleController},
|
bleController {bleController},
|
||||||
watchdog {watchdog},
|
watchdog {watchdog},
|
||||||
motionController{motionController},
|
motionController {motionController},
|
||||||
touchPanel{touchPanel},
|
touchPanel {touchPanel},
|
||||||
screens {app,
|
screens {app,
|
||||||
0,
|
0,
|
||||||
{[this]() -> std::unique_ptr<Screen> {
|
{[this]() -> std::unique_ptr<Screen> {
|
||||||
|
@ -182,7 +184,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
|
||||||
" #444444 used# %d (%d%%)\n"
|
" #444444 used# %d (%d%%)\n"
|
||||||
" #444444 max used# %lu\n"
|
" #444444 max used# %lu\n"
|
||||||
" #444444 frag# %d%%\n"
|
" #444444 frag# %d%%\n"
|
||||||
" #444444 free# %d",
|
" #444444 free# %d",
|
||||||
bleAddr[5],
|
bleAddr[5],
|
||||||
bleAddr[4],
|
bleAddr[4],
|
||||||
bleAddr[3],
|
bleAddr[3],
|
||||||
|
|
|
@ -129,7 +129,7 @@ bool Twos::placeNewTile() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Twos::tryMerge(Tile grid[][4], int& newRow, int& newCol, int oldRow, int oldCol) {
|
bool Twos::tryMerge(TwosTile grid[][4], int& newRow, int& newCol, int oldRow, int oldCol) {
|
||||||
if ((grid[newRow][newCol].value == grid[oldRow][oldCol].value)) {
|
if ((grid[newRow][newCol].value == grid[oldRow][oldCol].value)) {
|
||||||
if ((newCol != oldCol) || (newRow != oldRow)) {
|
if ((newCol != oldCol) || (newRow != oldRow)) {
|
||||||
if (!grid[newRow][newCol].merged) {
|
if (!grid[newRow][newCol].merged) {
|
||||||
|
@ -146,7 +146,7 @@ bool Twos::tryMerge(Tile grid[][4], int& newRow, int& newCol, int oldRow, int ol
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Twos::tryMove(Tile grid[][4], int newRow, int newCol, int oldRow, int oldCol) {
|
bool Twos::tryMove(TwosTile grid[][4], int newRow, int newCol, int oldRow, int oldCol) {
|
||||||
if (((newCol >= 0) && (newCol != oldCol)) || ((newRow >= 0) && (newRow != oldRow))) {
|
if (((newCol >= 0) && (newCol != oldCol)) || ((newRow >= 0) && (newRow != oldRow))) {
|
||||||
grid[newRow][newCol].value = grid[oldRow][oldCol].value;
|
grid[newRow][newCol].value = grid[oldRow][oldCol].value;
|
||||||
grid[oldRow][oldCol].value = 0;
|
grid[oldRow][oldCol].value = 0;
|
||||||
|
@ -261,7 +261,7 @@ bool Twos::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Twos::updateGridDisplay(Tile grid[][4]) {
|
void Twos::updateGridDisplay(TwosTile grid[][4]) {
|
||||||
for (int row = 0; row < 4; row++) {
|
for (int row = 0; row < 4; row++) {
|
||||||
for (int col = 0; col < 4; col++) {
|
for (int col = 0; col < 4; col++) {
|
||||||
if (grid[row][col].value) {
|
if (grid[row][col].value) {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
namespace Applications {
|
namespace Applications {
|
||||||
struct Tile {
|
struct TwosTile {
|
||||||
bool merged = false;
|
bool merged = false;
|
||||||
unsigned int value = 0;
|
unsigned int value = 0;
|
||||||
};
|
};
|
||||||
|
@ -26,11 +26,11 @@ namespace Pinetime {
|
||||||
|
|
||||||
lv_obj_t* scoreText;
|
lv_obj_t* scoreText;
|
||||||
lv_obj_t* gridDisplay;
|
lv_obj_t* gridDisplay;
|
||||||
Tile grid[4][4];
|
TwosTile grid[4][4];
|
||||||
unsigned int score = 0;
|
unsigned int score = 0;
|
||||||
void updateGridDisplay(Tile grid[][4]);
|
void updateGridDisplay(TwosTile grid[][4]);
|
||||||
bool tryMerge(Tile grid[][4], int& newRow, int& newCol, int oldRow, int oldCol);
|
bool tryMerge(TwosTile grid[][4], int& newRow, int& newCol, int oldRow, int oldCol);
|
||||||
bool tryMove(Tile grid[][4], int newRow, int newCol, int oldRow, int oldCol);
|
bool tryMove(TwosTile grid[][4], int newRow, int newCol, int oldRow, int oldCol);
|
||||||
bool placeNewTile();
|
bool placeNewTile();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,8 +115,9 @@ SystemTask::SystemTask(Drivers::SpiMaster& spi,
|
||||||
|
|
||||||
void SystemTask::Start() {
|
void SystemTask::Start() {
|
||||||
systemTasksMsgQueue = xQueueCreate(10, 1);
|
systemTasksMsgQueue = xQueueCreate(10, 1);
|
||||||
if (pdPASS != xTaskCreate(SystemTask::Process, "MAIN", 350, this, 0, &taskHandle))
|
if (pdPASS != xTaskCreate(SystemTask::Process, "MAIN", 350, this, 0, &taskHandle)) {
|
||||||
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
|
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTask::Process(void* instance) {
|
void SystemTask::Process(void* instance) {
|
||||||
|
@ -187,20 +188,22 @@ void SystemTask::Work() {
|
||||||
pinConfig.skip_gpio_setup = false;
|
pinConfig.skip_gpio_setup = false;
|
||||||
pinConfig.hi_accuracy = false;
|
pinConfig.hi_accuracy = false;
|
||||||
pinConfig.is_watcher = false;
|
pinConfig.is_watcher = false;
|
||||||
pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_TOGGLE;
|
pinConfig.sense = static_cast<nrf_gpiote_polarity_t>(NRF_GPIOTE_POLARITY_TOGGLE);
|
||||||
pinConfig.pull = (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown;
|
pinConfig.pull = static_cast<nrf_gpio_pin_pull_t>(GPIO_PIN_CNF_PULL_Pulldown);
|
||||||
|
|
||||||
nrfx_gpiote_in_init(PinMap::Button, &pinConfig, nrfx_gpiote_evt_handler);
|
nrfx_gpiote_in_init(PinMap::Button, &pinConfig, nrfx_gpiote_evt_handler);
|
||||||
nrfx_gpiote_in_event_enable(PinMap::Button, true);
|
nrfx_gpiote_in_event_enable(PinMap::Button, true);
|
||||||
|
|
||||||
// Touchscreen
|
// Touchscreen
|
||||||
nrf_gpio_cfg_sense_input(PinMap::Cst816sIrq, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_Low);
|
nrf_gpio_cfg_sense_input(PinMap::Cst816sIrq,
|
||||||
|
static_cast<nrf_gpio_pin_pull_t>(GPIO_PIN_CNF_PULL_Pullup),
|
||||||
|
static_cast<nrf_gpio_pin_sense_t> GPIO_PIN_CNF_SENSE_Low);
|
||||||
|
|
||||||
pinConfig.skip_gpio_setup = true;
|
pinConfig.skip_gpio_setup = true;
|
||||||
pinConfig.hi_accuracy = false;
|
pinConfig.hi_accuracy = false;
|
||||||
pinConfig.is_watcher = false;
|
pinConfig.is_watcher = false;
|
||||||
pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_HITOLO;
|
pinConfig.sense = static_cast<nrf_gpiote_polarity_t>(NRF_GPIOTE_POLARITY_HITOLO);
|
||||||
pinConfig.pull = (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup;
|
pinConfig.pull = static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Pullup;
|
||||||
|
|
||||||
nrfx_gpiote_in_init(PinMap::Cst816sIrq, &pinConfig, nrfx_gpiote_evt_handler);
|
nrfx_gpiote_in_init(PinMap::Cst816sIrq, &pinConfig, nrfx_gpiote_evt_handler);
|
||||||
|
|
||||||
|
@ -328,8 +331,9 @@ void SystemTask::Work() {
|
||||||
break;
|
break;
|
||||||
case Messages::BleFirmwareUpdateStarted:
|
case Messages::BleFirmwareUpdateStarted:
|
||||||
doNotGoToSleep = true;
|
doNotGoToSleep = true;
|
||||||
if (isSleeping && !isWakingUp)
|
if (isSleeping && !isWakingUp) {
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
|
}
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::BleFirmwareUpdateStarted);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::BleFirmwareUpdateStarted);
|
||||||
break;
|
break;
|
||||||
case Messages::BleFirmwareUpdateFinished:
|
case Messages::BleFirmwareUpdateFinished:
|
||||||
|
@ -429,18 +433,20 @@ void SystemTask::Work() {
|
||||||
uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG);
|
uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG);
|
||||||
dateTimeController.UpdateTime(systick_counter);
|
dateTimeController.UpdateTime(systick_counter);
|
||||||
NoInit_BackUpTime = dateTimeController.CurrentDateTime();
|
NoInit_BackUpTime = dateTimeController.CurrentDateTime();
|
||||||
if (!nrf_gpio_pin_read(PinMap::Button))
|
if (!nrf_gpio_pin_read(PinMap::Button)) {
|
||||||
watchdog.Kick();
|
watchdog.Kick();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Clear diagnostic suppression
|
|
||||||
#pragma clang diagnostic pop
|
|
||||||
}
|
}
|
||||||
void SystemTask::UpdateMotion() {
|
|
||||||
if (isGoingToSleep or isWakingUp)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (isSleeping && !settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist))
|
void SystemTask::UpdateMotion() {
|
||||||
|
if (isGoingToSleep or isWakingUp) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSleeping && !settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (stepCounterMustBeReset) {
|
if (stepCounterMustBeReset) {
|
||||||
motionSensor.ResetStepCounter();
|
motionSensor.ResetStepCounter();
|
||||||
|
@ -489,15 +495,17 @@ void SystemTask::HandleButtonAction(Controllers::ButtonActions action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTask::GoToRunning() {
|
void SystemTask::GoToRunning() {
|
||||||
if (isGoingToSleep or (not isSleeping) or isWakingUp)
|
if (isGoingToSleep or (not isSleeping) or isWakingUp) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
isWakingUp = true;
|
isWakingUp = true;
|
||||||
PushMessage(Messages::GoToRunning);
|
PushMessage(Messages::GoToRunning);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTask::OnTouchEvent() {
|
void SystemTask::OnTouchEvent() {
|
||||||
if (isGoingToSleep)
|
if (isGoingToSleep) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (!isSleeping) {
|
if (!isSleeping) {
|
||||||
PushMessage(Messages::OnTouchEvent);
|
PushMessage(Messages::OnTouchEvent);
|
||||||
} else if (!isWakingUp) {
|
} else if (!isWakingUp) {
|
||||||
|
@ -527,8 +535,9 @@ void SystemTask::PushMessage(System::Messages msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTask::OnDim() {
|
void SystemTask::OnDim() {
|
||||||
if (doNotGoToSleep)
|
if (doNotGoToSleep) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
NRF_LOG_INFO("Dim timeout -> Dim screen")
|
NRF_LOG_INFO("Dim timeout -> Dim screen")
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::DimScreen);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::DimScreen);
|
||||||
xTimerStart(idleTimer, 0);
|
xTimerStart(idleTimer, 0);
|
||||||
|
@ -536,15 +545,17 @@ void SystemTask::OnDim() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTask::OnIdle() {
|
void SystemTask::OnIdle() {
|
||||||
if (doNotGoToSleep)
|
if (doNotGoToSleep) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
NRF_LOG_INFO("Idle timeout -> Going to sleep")
|
NRF_LOG_INFO("Idle timeout -> Going to sleep")
|
||||||
PushMessage(Messages::GoToSleep);
|
PushMessage(Messages::GoToSleep);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTask::ReloadIdleTimer() {
|
void SystemTask::ReloadIdleTimer() {
|
||||||
if (isSleeping || isGoingToSleep)
|
if (isSleeping || isGoingToSleep) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (isDimmed) {
|
if (isDimmed) {
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::RestoreBrightness);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::RestoreBrightness);
|
||||||
isDimmed = false;
|
isDimmed = false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user