From 25f35c7d0e27af4308b8c263fde6661dbe29c2cc Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Tue, 26 Jan 2021 20:31:45 +0100 Subject: Generate pinetime-recovery : a light version of InfiniTime design to be used as a recovery firmware : it only provides basic UI and BLE connectivity for OTA. This new FW is build on the same codebasse than the actual InfiniTime. Only the display task is different (this allows to remove lvgl from the recovery fw, which is very heavy). CMake builds and docker have been modified accordingly. Note than the fw is converted into an image and then into a DFU in the cmake build (previously, it was only done in the --- src/components/rle/RleDecoder.cpp | 39 +++++++++++++++++++++++++++++++++++++++ src/components/rle/RleDecoder.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/components/rle/RleDecoder.cpp create mode 100644 src/components/rle/RleDecoder.h (limited to 'src/components/rle') diff --git a/src/components/rle/RleDecoder.cpp b/src/components/rle/RleDecoder.cpp new file mode 100644 index 00000000..19a90fda --- /dev/null +++ b/src/components/rle/RleDecoder.cpp @@ -0,0 +1,39 @@ +#include "RleDecoder.h" + +using namespace Pinetime::Tools; + +RleDecoder::RleDecoder(const uint8_t *buffer, size_t size) : buffer{buffer}, size{size} { + +} + +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) { + for (;encodedBufferIndex> 8; + output[bp + 1] = color & 0xff; + bp += 2; + rl -= 1; + processedCount++; + + if (bp >= maxBytes) { + bp = 0; + y += 1; + return; + } + } + processedCount = 0; + + if (color == backgroundColor) + color = foregroundColor; + else + color = backgroundColor; + } +} + diff --git a/src/components/rle/RleDecoder.h b/src/components/rle/RleDecoder.h new file mode 100644 index 00000000..0f607fb8 --- /dev/null +++ b/src/components/rle/RleDecoder.h @@ -0,0 +1,33 @@ +#pragma once + +#include +#include + +namespace Pinetime { + namespace Tools { + /* 1-bit RLE decoder. Provide the encoded buffer to the constructor and then call DecodeNext() by + * specifying the output (decoded) buffer and the maximum number of bytes this buffer can handle. + * + * Code from https://github.com/daniel-thompson/wasp-bootloader by Daniel Thompson released under the MIT license. + */ + class RleDecoder { + public: + 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); + + private: + const uint8_t* buffer; + size_t size; + + int encodedBufferIndex = 0; + int y = 0; + uint16_t bp = 0; + uint16_t foregroundColor = 0xffff; + uint16_t backgroundColor = 0; + uint16_t color = backgroundColor; + int processedCount = 0; + }; + } +} -- cgit v1.2.3