diff --git a/doc/bootloader/workflow.puml b/doc/bootloader/workflow.puml new file mode 100644 index 00000000..7a6c4bd3 --- /dev/null +++ b/doc/bootloader/workflow.puml @@ -0,0 +1,46 @@ +@startuml +start +partition Custom { +:Check button for 5s; +note right + Display is updated to show when + //revert firmware// and //factory reset// + are taken into account +end note +if (Pushed >50% of the time) then (yes) + :Mark previous firmware \n(in secondary slot) __pending__.\nIt'll be swapped in primary\nafter reset; + #pink:Reset; + detach +elseif (Pushed > 25% of the time) then (yes) + :Copy factory firmware in\nsecondary slot and\nmark it __pending__.\nIt'll be swapped in primary\nafter reset; + #pink:Reset; + detach +else (not pushed) + partition MCUBoot { + :Inspect swap status region; + if (is an interrupted swap being resumed?) then (yes) + :Complete the partial swap operation; + :Boot into image in primary slot; + stop + else(no) + endif + + :Inspect image trailers; + if(s a swap requested?) then(yes) + if(Is the requested image valid (integrity and security check)?) then (yes) + :Perform swap operation; + :Persist completion of swap procedure to image trailers; + else (no) + :Erase invalid image; + :Persist failure of swap procedure to image trailers; + endif + else(no) + endif + + :Boot into image in primary slot; + } +endif +} + +stop +@enduml \ No newline at end of file diff --git a/factory/image.h b/factory/image2.h similarity index 100% rename from factory/image.h rename to factory/image2.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b95cafc2..6f461f02 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -382,6 +382,45 @@ list(APPEND SOURCE_FILES systemtask/SystemTask.cpp drivers/TwiMaster.cpp + ) + +list(APPEND FACTORY_SOURCE_FILES + BootloaderVersion.cpp + logging/NrfLogger.cpp + displayapp/DisplayAppFactory.cpp + + main.cpp + drivers/St7789.cpp + drivers/SpiNorFlash.cpp + drivers/SpiMaster.cpp + drivers/Spi.cpp + drivers/Watchdog.cpp + drivers/DebugPins.cpp + drivers/InternalFlash.cpp + components/battery/BatteryController.cpp + components/ble/BleController.cpp + components/ble/NotificationManager.cpp + components/datetime/DateTimeController.cpp + components/brightness/BrightnessController.cpp + components/ble/NimbleController.cpp + components/ble/DeviceInformationService.cpp + components/ble/CurrentTimeClient.cpp + components/ble/AlertNotificationClient.cpp + components/ble/DfuService.cpp + components/ble/CurrentTimeService.cpp + components/ble/AlertNotificationService.cpp + components/ble/MusicService.cpp + components/ble/BatteryInformationService.cpp + components/ble/ImmediateAlertService.cpp + components/ble/ServiceDiscovery.cpp + components/firmwarevalidator/FirmwareValidator.cpp + drivers/Cst816s.cpp + FreeRTOS/port.c + FreeRTOS/port_cmsis_systick.c + FreeRTOS/port_cmsis.c + + systemtask/SystemTask.cpp + drivers/TwiMaster.cpp components/gfx/Gfx.cpp ) @@ -404,7 +443,7 @@ list(APPEND GRAPHICS_SOURCE_FILES graphics.cpp ) -list(APPEND FACTORY_SOURCE_FILES +list(APPEND FACTORYLOADER_SOURCE_FILES # FreeRTOS FreeRTOS/port.c FreeRTOS/port_cmsis_systick.c @@ -427,6 +466,7 @@ set(INCLUDE_FILES logging/Logger.h logging/NrfLogger.h displayapp/DisplayApp.h + displayapp/Messages.h displayapp/TouchEvents.h displayapp/screens/Screen.h displayapp/screens/Clock.h @@ -481,7 +521,7 @@ set(INCLUDE_FILES libs/date/includes/date/julian.h libs/date/includes/date/ptz.h libs/date/includes/date/tz_private.h - displayapp/LittleVgl.h + #displayapp/LittleVgl.h systemtask/SystemTask.h systemtask/SystemMonitor.h displayapp/screens/Symbols.h @@ -725,12 +765,13 @@ add_custom_command(TARGET ${EXECUTABLE_GRAPHICS_NAME} COMMENT "post build steps for ${EXECUTABLE_GRAPHICS_FILE_NAME}" ) -# Build binary that writes the factory image +# infinitime-light set(EXECUTABLE_FACTORY_NAME "pinetime-factory") set(EXECUTABLE_FACTORY_FILE_NAME ${EXECUTABLE_FACTORY_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}) add_executable(${EXECUTABLE_FACTORY_NAME} ${FACTORY_SOURCE_FILES}) -target_link_libraries(${EXECUTABLE_FACTORY_NAME} nrf-sdk) +target_link_libraries(${EXECUTABLE_FACTORY_NAME} nimble nrf-sdk) set_target_properties(${EXECUTABLE_FACTORY_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_FACTORY_FILE_NAME}) +target_compile_definitions(${EXECUTABLE_FACTORY_NAME} PUBLIC "PINETIME_IS_FACTORY") target_compile_options(${EXECUTABLE_FACTORY_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> @@ -754,6 +795,71 @@ add_custom_command(TARGET ${EXECUTABLE_FACTORY_NAME} COMMENT "post build steps for ${EXECUTABLE_FACTORY_FILE_NAME}" ) +# infinitime-light MCUBOOT +set(EXECUTABLE_FACTORY_MCUBOOT_NAME "pinetime-mcuboot-factory") +set(EXECUTABLE_FACTORY_MCUBOOT_FILE_NAME ${EXECUTABLE_FACTORY_MCUBOOT_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}) +add_executable(${EXECUTABLE_FACTORY_MCUBOOT_NAME} ${FACTORY_SOURCE_FILES}) +target_link_libraries(${EXECUTABLE_FACTORY_MCUBOOT_NAME} nimble nrf-sdk) +set_target_properties(${EXECUTABLE_FACTORY_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_FACTORY_MCUBOOT_FILE_NAME}) +target_compile_definitions(${EXECUTABLE_FACTORY_MCUBOOT_NAME} PUBLIC "PINETIME_IS_FACTORY") +target_compile_options(${EXECUTABLE_FACTORY_MCUBOOT_NAME} PUBLIC + $<$,$>: ${COMMON_FLAGS} -O0 -g3> + $<$,$>: ${COMMON_FLAGS} -O3> + $<$,$>: ${COMMON_FLAGS} -O0 -g3> + $<$,$>: ${COMMON_FLAGS} -O3> + $<$: -MP -MD -std=c99 -x assembler-with-cpp> + ) + +set_target_properties(${EXECUTABLE_FACTORY_MCUBOOT_NAME} PROPERTIES + SUFFIX ".out" + LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_FACTORY_MCUBOOT_FILE_NAME}.map" + CXX_STANDARD 11 + C_STANDARD 99 + ) + +add_custom_command(TARGET ${EXECUTABLE_FACTORY_MCUBOOT_NAME} + POST_BUILD + COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_FACTORY_MCUBOOT_FILE_NAME}.out + COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_FACTORY_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_FACTORY_MCUBOOT_FILE_NAME}.bin" + COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_FACTORY_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_FACTORY_MCUBOOT_FILE_NAME}.hex" + COMMAND /home/jf/nrf52/mcuboot/scripts/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header ${EXECUTABLE_FACTORY_MCUBOOT_FILE_NAME}.bin factoryImage.bin + COMMAND python ${CMAKE_SOURCE_DIR}/tools/bin2c.py factoryImage.bin factoryImage > factoryImage.h + COMMENT "post build steps for ${EXECUTABLE_FACTORY_MCUBOOT_FILE_NAME}" + ) + +# Build binary that writes the factory image +set(EXECUTABLE_FACTORYLOADER_NAME "pinetime-factory-loader") +set(EXECUTABLE_FACTORYLOADER_FILE_NAME ${EXECUTABLE_FACTORYLOADER_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}) +add_executable(${EXECUTABLE_FACTORYLOADER_NAME} ${FACTORYLOADER_SOURCE_FILES}) +target_link_libraries(${EXECUTABLE_FACTORYLOADER_NAME} nrf-sdk) +set_target_properties(${EXECUTABLE_FACTORYLOADER_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_FACTORYLOADER_FILE_NAME}) +target_compile_options(${EXECUTABLE_FACTORYLOADER_NAME} PUBLIC + $<$,$>: ${COMMON_FLAGS} -O0 -g3> + $<$,$>: ${COMMON_FLAGS} -O3> + $<$,$>: ${COMMON_FLAGS} -O0 -g3> + $<$,$>: ${COMMON_FLAGS} -O3> + $<$: -MP -MD -std=c99 -x assembler-with-cpp> + ) +target_include_directories(${EXECUTABLE_FACTORYLOADER_NAME} PUBLIC + $ +) +add_dependencies(${EXECUTABLE_FACTORYLOADER_NAME} ${EXECUTABLE_FACTORY_MCUBOOT_NAME}) + +set_target_properties(${EXECUTABLE_FACTORYLOADER_NAME} PROPERTIES + SUFFIX ".out" + LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_FACTORYLOADER_FILE_NAME}.map" + CXX_STANDARD 11 + C_STANDARD 99 + ) + +add_custom_command(TARGET ${EXECUTABLE_FACTORYLOADER_NAME} + POST_BUILD + COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_FACTORYLOADER_FILE_NAME}.out + COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_FACTORYLOADER_FILE_NAME}.out "${EXECUTABLE_FACTORYLOADER_FILE_NAME}.bin" + COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_FACTORYLOADER_FILE_NAME}.out "${EXECUTABLE_FACTORYLOADER_FILE_NAME}.hex" + COMMENT "post build steps for ${EXECUTABLE_FACTORYLOADER_FILE_NAME}" + ) + # FLASH if (USE_JLINK) add_custom_target(FLASH_ERASE diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index d4d41333..2af5e9db 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -23,6 +23,7 @@ #include "systemtask/SystemTask.h" using namespace Pinetime::Applications; +using namespace Pinetime::Applications::Display; DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Drivers::Cst816S &touchPanel, Controllers::Battery &batteryController, Controllers::Ble &bleController, @@ -218,7 +219,7 @@ void DisplayApp::IdleState() { } -void DisplayApp::PushMessage(DisplayApp::Messages msg) { +void DisplayApp::PushMessage(Messages msg) { BaseType_t xHigherPriorityTaskWoken; xHigherPriorityTaskWoken = pdFALSE; xQueueSendFromISR(msgQueue, &msg, &xHigherPriorityTaskWoken); diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index ca862cb8..db6fe138 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -13,13 +13,14 @@ #include "components/ble/NotificationManager.h" #include "components/firmwarevalidator/FirmwareValidator.h" #include "drivers/Cst816s.h" -#include "DummyLittleVgl.h" #include #include "displayapp/screens/Clock.h" #include "displayapp/screens/Modal.h" #include #include "TouchEvents.h" #include "Apps.h" +#include "Messages.h" +#include "LittleVgl.h" namespace Pinetime { @@ -30,9 +31,6 @@ namespace Pinetime { class DisplayApp { public: enum class States {Idle, Running}; - enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent, ButtonPushed, - NewNotification, BleFirmwareUpdateStarted }; - enum class FullRefreshDirections { None, Up, Down }; enum class TouchModes { Gestures, Polling }; @@ -42,7 +40,7 @@ namespace Pinetime { System::SystemTask &systemTask, Pinetime::Controllers::NotificationManager& notificationManager); void Start(); - void PushMessage(Messages msg); + void PushMessage(Display::Messages msg); void StartApp(Apps app); diff --git a/src/displayapp/DisplayAppFactory.cpp b/src/displayapp/DisplayAppFactory.cpp new file mode 100644 index 00000000..c75011e8 --- /dev/null +++ b/src/displayapp/DisplayAppFactory.cpp @@ -0,0 +1,72 @@ +#include "DisplayAppFactory.h" +#include "DisplayAppFactory.h" +#include +#include +#include + +using namespace Pinetime::Applications; + +DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Drivers::Cst816S &, + Controllers::Battery &batteryController, Controllers::Ble &bleController, + Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog, + System::SystemTask &systemTask, + Pinetime::Controllers::NotificationManager& notificationManager) : + lcd{lcd} { + msgQueue = xQueueCreate(queueSize, itemSize); + +} + +void DisplayApp::Start() { + if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 512, this, 0, &taskHandle)) + APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); +} + +void DisplayApp::Process(void *instance) { + auto *app = static_cast(instance); + NRF_LOG_INFO("displayapp task started!"); + app->InitHw(); + + // Send a dummy notification to unlock the lvgl display driver for the first iteration + xTaskNotifyGive(xTaskGetCurrentTaskHandle()); + + while (1) { + app->Refresh(); + } +} + +void DisplayApp::InitHw() { + +} + +void DisplayApp::Refresh() { + static bool hello = false; + + + if(hello) { + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + lcd.DrawPixel(j, i, 0xF000); + } + } + } + else { + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + lcd.DrawPixel(j, i, 0x0); + } + } + } + + hello = !hello; + vTaskDelay(200); +} + +void DisplayApp::PushMessage(Display::Messages msg) { + BaseType_t xHigherPriorityTaskWoken; + xHigherPriorityTaskWoken = pdFALSE; + xQueueSendFromISR(msgQueue, &msg, &xHigherPriorityTaskWoken); + if (xHigherPriorityTaskWoken) { + /* Actual macro used here is port specific. */ + // TODO : should I do something here? + } +} \ No newline at end of file diff --git a/src/displayapp/DisplayAppFactory.h b/src/displayapp/DisplayAppFactory.h new file mode 100644 index 00000000..a923ae2d --- /dev/null +++ b/src/displayapp/DisplayAppFactory.h @@ -0,0 +1,55 @@ +#pragma once +#include +#include +#include +#include +#include +#include +#include "components/gfx/Gfx.h" +#include "components/battery/BatteryController.h" +#include "components/brightness/BrightnessController.h" +#include "components/ble/BleController.h" +#include "components/datetime/DateTimeController.h" +#include "components/ble/NotificationManager.h" +#include "components/firmwarevalidator/FirmwareValidator.h" +#include "drivers/Cst816s.h" +#include +#include "displayapp/screens/Clock.h" +#include "displayapp/screens/Modal.h" +#include +#include "TouchEvents.h" +#include "Apps.h" +#include "Messages.h" +#include "DummyLittleVgl.h" + +namespace Pinetime { + namespace System { + class SystemTask; + }; + namespace Applications { + class DisplayApp { + public: + DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Drivers::Cst816S &, + Controllers::Battery &batteryController, Controllers::Ble &bleController, + Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog, + System::SystemTask &systemTask, + Pinetime::Controllers::NotificationManager& notificationManager); + void Start(); + void PushMessage(Pinetime::Applications::Display::Messages msg); + + private: + TaskHandle_t taskHandle; + static void Process(void* instance); + void InitHw(); + void Refresh(); + Pinetime::Drivers::St7789& lcd; + static constexpr uint8_t queueSize = 10; + static constexpr uint8_t itemSize = 1; + QueueHandle_t msgQueue; + + + }; + } +} + + diff --git a/src/displayapp/Messages.h b/src/displayapp/Messages.h new file mode 100644 index 00000000..a4621cfc --- /dev/null +++ b/src/displayapp/Messages.h @@ -0,0 +1,11 @@ +#pragma once +namespace Pinetime { + namespace Applications { + namespace Display { + enum class Messages : uint8_t { + GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent, ButtonPushed, + NewNotification, BleFirmwareUpdateStarted + }; + } + } +} \ No newline at end of file diff --git a/src/displayapp/screens/InfiniPaint.h b/src/displayapp/screens/InfiniPaint.h index 74d06d9c..65265108 100644 --- a/src/displayapp/screens/InfiniPaint.h +++ b/src/displayapp/screens/InfiniPaint.h @@ -6,7 +6,7 @@ #include #include #include -#include "displayapp/DummyLittleVgl.h" +#include namespace Pinetime { namespace Applications { diff --git a/src/factory.cpp b/src/factory.cpp index 959585ae..0fe56dd0 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -13,7 +13,8 @@ #include #include #include -#include "../factory/image.h" +#include "factoryImage.h" + #if NRF_LOG_ENABLED #include "logging/NrfLogger.h" @@ -106,7 +107,7 @@ void Process(void* instance) { static constexpr uint32_t memoryChunkSize = 200; uint8_t writeBuffer[memoryChunkSize]; - for(int offset = 0; offset < sizeof(factoryImage); offset+=memoryChunkSize) { + for(size_t offset = 0; offset < sizeof(factoryImage); offset+=memoryChunkSize) { std::memcpy(writeBuffer, &factoryImage[offset], memoryChunkSize); spiNorFlash.Write(offset, writeBuffer, memoryChunkSize); } diff --git a/src/main.cpp b/src/main.cpp index 37135bb9..6652c9b2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,7 +7,7 @@ #include #include #include -#include "displayapp/DisplayApp.h" + #include #include "components/datetime/DateTimeController.h" #include "components/battery/BatteryController.h" @@ -16,7 +16,7 @@ #include #include #include -#include "displayapp/DummyLittleVgl.h" + #include #include #include @@ -70,7 +70,18 @@ Pinetime::Drivers::TwiMaster twiMaster{Pinetime::Drivers::TwiMaster::Modules::TW Pinetime::Drivers::TwiMaster::Parameters { MaxTwiFrequencyWithoutHardwareBug, pinTwiSda, pinTwiScl}}; Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress}; + +#ifdef PINETIME_IS_FACTORY +static constexpr bool isFactory = true; +#include "displayapp/DummyLittleVgl.h" +#include "displayapp/DisplayAppFactory.h" Pinetime::Components::LittleVgl lvgl {lcd, touchPanel}; +#else +static constexpr bool isFactory = false; +#include "displayapp/LittleVgl.h" +#include "displayapp/DisplayApp.h" +Pinetime::Components::LittleVgl lvgl {lcd, touchPanel}; +#endif TimerHandle_t debounceTimer; @@ -84,6 +95,8 @@ std::unique_ptr systemTask; Pinetime::Controllers::NotificationManager notificationManager; + + void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { if(pin == pinTouchIrq) { systemTask->OnTouchEvent(); @@ -97,7 +110,8 @@ void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action extern "C" { void vApplicationIdleHook(void) { - lv_tick_inc(1); + if(!isFactory) + lv_tick_inc(1); } } diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index f2ff9f4b..efa22a6f 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -1,7 +1,6 @@ #include #include #include -#include "displayapp/DummyLittleVgl.h" #include #include "components/ble/NotificationManager.h" #include @@ -33,7 +32,7 @@ SystemTask::SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd, Controllers::DateTime &dateTimeController, Pinetime::Controllers::NotificationManager& notificationManager) : spi{spi}, lcd{lcd}, spiNorFlash{spiNorFlash}, - twiMaster{twiMaster}, touchPanel{touchPanel}, lvgl{lvgl}, batteryController{batteryController}, gfx{lcd}, + twiMaster{twiMaster}, touchPanel{touchPanel}, lvgl{lvgl}, batteryController{batteryController}, bleController{bleController}, dateTimeController{dateTimeController}, watchdog{}, watchdogView{watchdog}, notificationManager{notificationManager}, nimbleController(*this, bleController,dateTimeController, notificationManager, batteryController, spiNorFlash) { @@ -65,20 +64,16 @@ void SystemTask::Work() { brightnessController.Init(); lcd.Init(); - lcd.VerticalScrollDefinition(0, 240, 0); - - lcd.VerticalScrollStartAddress(0); - gfx.Init(); twiMaster.Init(); touchPanel.Init(); batteryController.Init(); -// displayApp.reset(new Pinetime::Applications::DisplayApp(lcd, lvgl, touchPanel, batteryController, bleController, -// dateTimeController, watchdogView, *this, notificationManager)); -// displayApp->Start(); + displayApp.reset(new Pinetime::Applications::DisplayApp(lcd, lvgl, touchPanel, batteryController, bleController, + dateTimeController, watchdogView, *this, notificationManager)); + displayApp->Start(); batteryController.Update(); -// displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateBatteryLevel); + displayApp->PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel); nrf_gpio_cfg_sense_input(pinButton, (nrf_gpio_pin_pull_t)GPIO_PIN_CNF_PULL_Pulldown, (nrf_gpio_pin_sense_t)GPIO_PIN_CNF_SENSE_High); nrf_gpio_cfg_output(15); @@ -122,8 +117,8 @@ void SystemTask::Work() { lcd.Wakeup(); touchPanel.Wakeup(); -// displayApp->PushMessage(Applications::DisplayApp::Messages::GoToRunning); -// displayApp->PushMessage(Applications::DisplayApp::Messages::UpdateBatteryLevel); + displayApp->PushMessage(Pinetime::Applications::Display::Messages::GoToRunning); + displayApp->PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel); xTimerStart(idleTimer, 0); nimbleController.StartAdvertising(); @@ -134,15 +129,15 @@ void SystemTask::Work() { isGoingToSleep = true; NRF_LOG_INFO("[systemtask] Going to sleep"); xTimerStop(idleTimer, 0); -// displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::GoToSleep); + displayApp->PushMessage(Pinetime::Applications::Display::Messages::GoToSleep); break; case Messages::OnNewTime: ReloadIdleTimer(); -// displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateDateTime); + displayApp->PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime); break; case Messages::OnNewNotification: if(isSleeping && !isWakingUp) GoToRunning(); -// displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::NewNotification); + displayApp->PushMessage(Pinetime::Applications::Display::Messages::NewNotification); break; case Messages::BleConnected: ReloadIdleTimer(); @@ -152,7 +147,7 @@ void SystemTask::Work() { case Messages::BleFirmwareUpdateStarted: doNotGoToSleep = true; if(isSleeping && !isWakingUp) GoToRunning(); -// displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::BleFirmwareUpdateStarted); + displayApp->PushMessage(Pinetime::Applications::Display::Messages::BleFirmwareUpdateStarted); break; case Messages::BleFirmwareUpdateFinished: doNotGoToSleep = false; @@ -200,25 +195,6 @@ void SystemTask::Work() { batteryController.Update(); monitor.Process(); - static bool hello = false; - - - if(hello) { - for (int i = 0; i < 10; i++) { - for (int j = 0; j < 10; j++) { - lcd.DrawPixel(j, i, 0xffff); - } - } - } - else { - for (int i = 0; i < 10; i++) { - for (int j = 0; j < 10; j++) { - lcd.DrawPixel(j, i, 0x0); - } - } - } - - hello = !hello; if(!nrf_gpio_pin_read(pinButton)) watchdog.Kick(); @@ -232,7 +208,7 @@ void SystemTask::OnButtonPushed() { if(!isSleeping) { NRF_LOG_INFO("[systemtask] Button pushed"); PushMessage(Messages::OnButtonEvent); -// displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::ButtonPushed); + displayApp->PushMessage(Pinetime::Applications::Display::Messages::ButtonPushed); } else { if(!isWakingUp) { @@ -252,7 +228,7 @@ void SystemTask::OnTouchEvent() { NRF_LOG_INFO("[systemtask] Touch event"); if(!isSleeping) { PushMessage(Messages::OnTouchEvent); -// displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::TouchEvent); + displayApp->PushMessage(Pinetime::Applications::Display::Messages::TouchEvent); } } diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index a7e98017..c297b3da 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -7,13 +7,21 @@ #include #include #include "components/battery/BatteryController.h" +#ifdef PINETIME_IS_FACTORY +#include "displayapp/DisplayAppFactory.h" +#include "displayapp/DummyLittleVgl.h" +#else #include "displayapp/DisplayApp.h" +#include "displayapp/LittleVgl.h" +#endif #include #include #include "SystemMonitor.h" #include "components/ble/NimbleController.h" #include "timers.h" + + namespace Pinetime { namespace System { class SystemTask { @@ -51,8 +59,7 @@ namespace Pinetime { Pinetime::Drivers::Cst816S& touchPanel; Pinetime::Components::LittleVgl& lvgl; Pinetime::Controllers::Battery& batteryController; - //std::unique_ptr displayApp; - Pinetime::Components::Gfx gfx; + std::unique_ptr displayApp; Pinetime::Controllers::Ble& bleController; Pinetime::Controllers::DateTime& dateTimeController; QueueHandle_t systemTasksMsgQueue;