summaryrefslogtreecommitdiff
path: root/src/components/rle/RleDecoder.cpp
diff options
context:
space:
mode:
authorJean-François Milants <jf@codingfield.com>2021-01-26 19:31:45 (GMT)
committerJean-François Milants <jf@codingfield.com>2021-01-26 19:31:45 (GMT)
commit25f35c7d0e27af4308b8c263fde6661dbe29c2cc (patch)
tree145df6c4f8ab6be34771ee3d8caceb0dbb792d23 /src/components/rle/RleDecoder.cpp
parent80838d1e42e83b50188d6237d16c81cfa27781a6 (diff)
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
Diffstat (limited to 'src/components/rle/RleDecoder.cpp')
-rw-r--r--src/components/rle/RleDecoder.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/components/rle/RleDecoder.cpp b/src/components/rle/RleDecoder.cpp
new file mode 100644
index 0000000..19a90fd
--- /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<size; encodedBufferIndex++) {
+ uint8_t rl = buffer[encodedBufferIndex] - processedCount;
+ while (rl) {
+ output[bp] = color >> 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;
+ }
+}
+