Factory (infinitime-light) : display logo + color code + progress bar during ota.
This commit is contained in:
parent
9ae0550a84
commit
cdc6c5e082
@ -422,6 +422,8 @@ list(APPEND FACTORY_SOURCE_FILES
|
|||||||
systemtask/SystemTask.cpp
|
systemtask/SystemTask.cpp
|
||||||
drivers/TwiMaster.cpp
|
drivers/TwiMaster.cpp
|
||||||
components/gfx/Gfx.cpp
|
components/gfx/Gfx.cpp
|
||||||
|
displayapp/icons/infinitime/infinitime-nb.c
|
||||||
|
components/rle/RleDecoder.cpp
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -6,6 +6,12 @@ RleDecoder::RleDecoder(const uint8_t *buffer, size_t size) : buffer{buffer}, siz
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RleDecoder::RleDecoder(const uint8_t *buffer, size_t size, uint16_t foregroundColor, uint16_t backgroundColor) : RleDecoder{buffer, size} {
|
||||||
|
this->foregroundColor = foregroundColor;
|
||||||
|
this->backgroundColor = backgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void RleDecoder::DecodeNext(uint8_t *output, size_t maxBytes) {
|
void RleDecoder::DecodeNext(uint8_t *output, size_t maxBytes) {
|
||||||
for (;encodedBufferIndex<size; encodedBufferIndex++) {
|
for (;encodedBufferIndex<size; encodedBufferIndex++) {
|
||||||
uint8_t rl = buffer[encodedBufferIndex] - processedCount;
|
uint8_t rl = buffer[encodedBufferIndex] - processedCount;
|
||||||
@ -30,3 +36,4 @@ void RleDecoder::DecodeNext(uint8_t *output, size_t maxBytes) {
|
|||||||
color = backgroundColor;
|
color = backgroundColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ namespace Pinetime {
|
|||||||
class RleDecoder {
|
class RleDecoder {
|
||||||
public:
|
public:
|
||||||
RleDecoder(const uint8_t* buffer, size_t size);
|
RleDecoder(const uint8_t* buffer, size_t size);
|
||||||
|
RleDecoder(const uint8_t* buffer, size_t size, uint16_t foregroundColor, uint16_t backgroundColor);
|
||||||
|
|
||||||
void DecodeNext(uint8_t* output, size_t maxBytes);
|
void DecodeNext(uint8_t* output, size_t maxBytes);
|
||||||
|
|
||||||
@ -23,8 +24,8 @@ namespace Pinetime {
|
|||||||
int encodedBufferIndex = 0;
|
int encodedBufferIndex = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
uint16_t bp = 0;
|
uint16_t bp = 0;
|
||||||
static constexpr uint16_t foregroundColor = 0xffff;
|
uint16_t foregroundColor = 0xffff;
|
||||||
static constexpr uint16_t backgroundColor = 0;
|
uint16_t backgroundColor = 0;
|
||||||
uint16_t color = backgroundColor;
|
uint16_t color = backgroundColor;
|
||||||
int processedCount = 0;
|
int processedCount = 0;
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#include <FreeRTOS.h>
|
#include <FreeRTOS.h>
|
||||||
#include <task.h>
|
#include <task.h>
|
||||||
#include <libraries/log/nrf_log.h>
|
#include <libraries/log/nrf_log.h>
|
||||||
|
#include <components/rle/RleDecoder.h>
|
||||||
|
#include "displayapp/icons/infinitime/infinitime-nb.c"
|
||||||
|
|
||||||
using namespace Pinetime::Applications;
|
using namespace Pinetime::Applications;
|
||||||
|
|
||||||
@ -11,7 +13,7 @@ DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Driver
|
|||||||
Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog,
|
Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog,
|
||||||
System::SystemTask &systemTask,
|
System::SystemTask &systemTask,
|
||||||
Pinetime::Controllers::NotificationManager& notificationManager) :
|
Pinetime::Controllers::NotificationManager& notificationManager) :
|
||||||
lcd{lcd} {
|
lcd{lcd}, bleController{bleController} {
|
||||||
msgQueue = xQueueCreate(queueSize, itemSize);
|
msgQueue = xQueueCreate(queueSize, itemSize);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -24,41 +26,76 @@ void DisplayApp::Start() {
|
|||||||
void DisplayApp::Process(void *instance) {
|
void DisplayApp::Process(void *instance) {
|
||||||
auto *app = static_cast<DisplayApp *>(instance);
|
auto *app = static_cast<DisplayApp *>(instance);
|
||||||
NRF_LOG_INFO("displayapp task started!");
|
NRF_LOG_INFO("displayapp task started!");
|
||||||
app->InitHw();
|
|
||||||
|
|
||||||
// Send a dummy notification to unlock the lvgl display driver for the first iteration
|
// Send a dummy notification to unlock the lvgl display driver for the first iteration
|
||||||
xTaskNotifyGive(xTaskGetCurrentTaskHandle());
|
xTaskNotifyGive(xTaskGetCurrentTaskHandle());
|
||||||
|
|
||||||
|
app->InitHw();
|
||||||
while (1) {
|
while (1) {
|
||||||
app->Refresh();
|
app->Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::InitHw() {
|
void DisplayApp::InitHw() {
|
||||||
|
DisplayLogo(colorWhite);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::Refresh() {
|
void DisplayApp::Refresh() {
|
||||||
static bool hello = false;
|
Display::Messages msg;
|
||||||
|
if (xQueueReceive(msgQueue, &msg, 200)) {
|
||||||
|
switch (msg) {
|
||||||
if(hello) {
|
case Display::Messages::UpdateBleConnection:
|
||||||
for (int i = 0; i < 10; i++) {
|
if (bleController.IsConnected())
|
||||||
for (int j = 0; j < 10; j++) {
|
DisplayLogo(colorBlue);
|
||||||
lcd.DrawPixel(j, i, 0xF000);
|
else
|
||||||
}
|
DisplayLogo(colorWhite);
|
||||||
}
|
break;
|
||||||
}
|
case Display::Messages::BleFirmwareUpdateStarted:
|
||||||
else {
|
DisplayLogo(colorGreen);
|
||||||
for (int i = 0; i < 10; i++) {
|
break;
|
||||||
for (int j = 0; j < 10; j++) {
|
default:
|
||||||
lcd.DrawPixel(j, i, 0x0);
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hello = !hello;
|
if (bleController.IsFirmwareUpdating()) {
|
||||||
vTaskDelay(200);
|
uint8_t percent = (static_cast<float>(bleController.FirmwareUpdateCurrentBytes()) /
|
||||||
|
static_cast<float>(bleController.FirmwareUpdateTotalBytes())) * 100.0f;
|
||||||
|
switch (bleController.State()) {
|
||||||
|
case Controllers::Ble::FirmwareUpdateStates::Running:
|
||||||
|
DisplayOtaProgress(percent, colorWhite);
|
||||||
|
break;
|
||||||
|
case Controllers::Ble::FirmwareUpdateStates::Validated:
|
||||||
|
DisplayOtaProgress(100, colorGreenSwapped);
|
||||||
|
break;
|
||||||
|
case Controllers::Ble::FirmwareUpdateStates::Error:
|
||||||
|
DisplayOtaProgress(100, colorRedSwapped);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayApp::DisplayLogo(uint16_t color) {
|
||||||
|
Pinetime::Tools::RleDecoder rleDecoder(infinitime_nb, sizeof(infinitime_nb), color, colorBlack);
|
||||||
|
for(int i = 0; i < displayWidth; i++) {
|
||||||
|
rleDecoder.DecodeNext(displayBuffer, displayWidth * bytesPerPixel);
|
||||||
|
ulTaskNotifyTake(pdTRUE, 500);
|
||||||
|
lcd.BeginDrawBuffer(0, i, displayWidth, 1);
|
||||||
|
lcd.NextDrawBuffer(reinterpret_cast<const uint8_t *>(displayBuffer), displayWidth * bytesPerPixel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayApp::DisplayOtaProgress(uint8_t percent, uint16_t color) {
|
||||||
|
const uint8_t barHeight = 20;
|
||||||
|
std::fill(displayBuffer, displayBuffer+(displayWidth * bytesPerPixel), color);
|
||||||
|
for(int i = 0; i < barHeight; i++) {
|
||||||
|
ulTaskNotifyTake(pdTRUE, 500);
|
||||||
|
uint16_t barWidth = std::min(static_cast<float>(percent) * 2.4f, static_cast<float>(displayWidth));
|
||||||
|
lcd.BeginDrawBuffer(0, displayWidth - barHeight + i, barWidth, 1);
|
||||||
|
lcd.NextDrawBuffer(reinterpret_cast<const uint8_t *>(displayBuffer), barWidth * bytesPerPixel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::PushMessage(Display::Messages msg) {
|
void DisplayApp::PushMessage(Display::Messages msg) {
|
||||||
|
@ -40,12 +40,28 @@ namespace Pinetime {
|
|||||||
private:
|
private:
|
||||||
TaskHandle_t taskHandle;
|
TaskHandle_t taskHandle;
|
||||||
static void Process(void* instance);
|
static void Process(void* instance);
|
||||||
|
void DisplayLogo(uint16_t color);
|
||||||
|
void DisplayOtaProgress(uint8_t percent, uint16_t color);
|
||||||
void InitHw();
|
void InitHw();
|
||||||
void Refresh();
|
void Refresh();
|
||||||
Pinetime::Drivers::St7789& lcd;
|
Pinetime::Drivers::St7789& lcd;
|
||||||
|
Controllers::Ble &bleController;
|
||||||
|
|
||||||
static constexpr uint8_t queueSize = 10;
|
static constexpr uint8_t queueSize = 10;
|
||||||
static constexpr uint8_t itemSize = 1;
|
static constexpr uint8_t itemSize = 1;
|
||||||
QueueHandle_t msgQueue;
|
QueueHandle_t msgQueue;
|
||||||
|
static constexpr uint8_t displayWidth = 240;
|
||||||
|
static constexpr uint8_t displayHeight = 240;
|
||||||
|
static constexpr uint8_t bytesPerPixel = 2;
|
||||||
|
|
||||||
|
static constexpr uint16_t colorWhite = 0xFFFF;
|
||||||
|
static constexpr uint16_t colorGreen = 0x07E0;
|
||||||
|
static constexpr uint16_t colorGreenSwapped = 0xE007;
|
||||||
|
static constexpr uint16_t colorBlue = 0x0000ff;
|
||||||
|
static constexpr uint16_t colorRed = 0xff00;
|
||||||
|
static constexpr uint16_t colorRedSwapped = 0x00ff;
|
||||||
|
static constexpr uint16_t colorBlack = 0x0000;
|
||||||
|
uint8_t displayBuffer[displayWidth * bytesPerPixel];
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -143,6 +143,7 @@ void SystemTask::Work() {
|
|||||||
ReloadIdleTimer();
|
ReloadIdleTimer();
|
||||||
isBleDiscoveryTimerRunning = true;
|
isBleDiscoveryTimerRunning = true;
|
||||||
bleDiscoveryTimer = 5;
|
bleDiscoveryTimer = 5;
|
||||||
|
displayApp->PushMessage(Pinetime::Applications::Display::Messages::UpdateBleConnection);
|
||||||
break;
|
break;
|
||||||
case Messages::BleFirmwareUpdateStarted:
|
case Messages::BleFirmwareUpdateStarted:
|
||||||
doNotGoToSleep = true;
|
doNotGoToSleep = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user