Build system : add the possibility to build the app / factory firmware.
This commit is contained in:
parent
89783286da
commit
a7484e6daa
46
doc/bootloader/workflow.puml
Normal file
46
doc/bootloader/workflow.puml
Normal file
@ -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
|
@ -380,6 +380,45 @@ list(APPEND SOURCE_FILES
|
||||
displayapp/fonts/jetbrains_mono_extrabold_compressed.c
|
||||
displayapp/fonts/jetbrains_mono_bold_20.c
|
||||
|
||||
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
|
||||
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
|
||||
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${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
|
||||
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
|
||||
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
|
||||
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
|
||||
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
|
||||
$<$<COMPILE_LANGUAGE:ASM>: -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
|
||||
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
|
||||
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
|
||||
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
|
||||
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
|
||||
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -std=c99 -x assembler-with-cpp>
|
||||
)
|
||||
target_include_directories(${EXECUTABLE_FACTORYLOADER_NAME} PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/src>
|
||||
)
|
||||
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
|
||||
|
@ -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);
|
||||
|
@ -13,13 +13,14 @@
|
||||
#include "components/ble/NotificationManager.h"
|
||||
#include "components/firmwarevalidator/FirmwareValidator.h"
|
||||
#include "drivers/Cst816s.h"
|
||||
#include "DummyLittleVgl.h"
|
||||
#include <date/date.h>
|
||||
#include "displayapp/screens/Clock.h"
|
||||
#include "displayapp/screens/Modal.h"
|
||||
#include <drivers/Watchdog.h>
|
||||
#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);
|
||||
|
||||
|
72
src/displayapp/DisplayAppFactory.cpp
Normal file
72
src/displayapp/DisplayAppFactory.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
#include "DisplayAppFactory.h"
|
||||
#include "DisplayAppFactory.h"
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
#include <libraries/log/nrf_log.h>
|
||||
|
||||
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<DisplayApp *>(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?
|
||||
}
|
||||
}
|
55
src/displayapp/DisplayAppFactory.h
Normal file
55
src/displayapp/DisplayAppFactory.h
Normal file
@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
#include <drivers/St7789.h>
|
||||
#include <drivers/SpiMaster.h>
|
||||
#include <bits/unique_ptr.h>
|
||||
#include <queue.h>
|
||||
#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 <date/date.h>
|
||||
#include "displayapp/screens/Clock.h"
|
||||
#include "displayapp/screens/Modal.h"
|
||||
#include <drivers/Watchdog.h>
|
||||
#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;
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
11
src/displayapp/Messages.h
Normal file
11
src/displayapp/Messages.h
Normal file
@ -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
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
#include <libs/lvgl/src/lv_core/lv_style.h>
|
||||
#include <libs/lvgl/src/lv_core/lv_obj.h>
|
||||
#include <drivers/St7789.h>
|
||||
#include "displayapp/DummyLittleVgl.h"
|
||||
#include <displayapp/LittleVgl.h>
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Applications {
|
||||
|
@ -13,7 +13,8 @@
|
||||
#include <components/gfx/Gfx.h>
|
||||
#include <drivers/St7789.h>
|
||||
#include <components/brightness/BrightnessController.h>
|
||||
#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);
|
||||
}
|
||||
|
18
src/main.cpp
18
src/main.cpp
@ -7,7 +7,7 @@
|
||||
#include <os/os_cputime.h>
|
||||
#include <libraries/timer/app_timer.h>
|
||||
#include <libraries/gpiote/app_gpiote.h>
|
||||
#include "displayapp/DisplayApp.h"
|
||||
|
||||
#include <softdevice/common/nrf_sdh.h>
|
||||
#include "components/datetime/DateTimeController.h"
|
||||
#include "components/battery/BatteryController.h"
|
||||
@ -16,7 +16,7 @@
|
||||
#include <drivers/St7789.h>
|
||||
#include <drivers/SpiMaster.h>
|
||||
#include <drivers/Spi.h>
|
||||
#include "displayapp/DummyLittleVgl.h"
|
||||
|
||||
#include <systemtask/SystemTask.h>
|
||||
#include <nimble/nimble_port_freertos.h>
|
||||
#include <nimble/npl_freertos.h>
|
||||
@ -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<Pinetime::System::SystemTask> 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,6 +110,7 @@ void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action
|
||||
|
||||
extern "C" {
|
||||
void vApplicationIdleHook(void) {
|
||||
if(!isFactory)
|
||||
lv_tick_inc(1);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <libraries/log/nrf_log.h>
|
||||
#include <libraries/gpiote/app_gpiote.h>
|
||||
#include <drivers/Cst816s.h>
|
||||
#include "displayapp/DummyLittleVgl.h"
|
||||
#include <hal/nrf_rtc.h>
|
||||
#include "components/ble/NotificationManager.h"
|
||||
#include <host/ble_gatt.h>
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,21 @@
|
||||
#include <drivers/SpiMaster.h>
|
||||
#include <drivers/St7789.h>
|
||||
#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 <drivers/Watchdog.h>
|
||||
#include <drivers/SpiNorFlash.h>
|
||||
#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<Pinetime::Applications::DisplayApp> displayApp;
|
||||
Pinetime::Components::Gfx gfx;
|
||||
std::unique_ptr<Pinetime::Applications::DisplayApp> displayApp;
|
||||
Pinetime::Controllers::Ble& bleController;
|
||||
Pinetime::Controllers::DateTime& dateTimeController;
|
||||
QueueHandle_t systemTasksMsgQueue;
|
||||
|
Loading…
Reference in New Issue
Block a user