Skip to content

Commit

Permalink
Added compression to M3, moved stuff around
Browse files Browse the repository at this point in the history
  • Loading branch information
jjwbruijn committed Feb 13, 2024
1 parent d7f6fee commit 57748d8
Show file tree
Hide file tree
Showing 19 changed files with 2,281 additions and 1,802 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "ARM_Tag_FW/common/uzlib"]
path = ARM_Tag_FW/common/uzlib
url = https://github.com/pfalcon/uzlib.git
[submodule "ARM_Tag_FW/common/QRCode"]
path = ARM_Tag_FW/common/QRCode
url = https://github.com/ricmoo/QRCode
7 changes: 7 additions & 0 deletions ARM_Tag_FW/Newton_M3_nRF52811/include/compression.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#ifdef ENABLE_OEPLFS
#include "oepl_fs.h"
#endif

#include "../../common/compression.h"
113 changes: 2 additions & 111 deletions ARM_Tag_FW/Newton_M3_nRF52811/include/drawing.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,115 +4,6 @@
#include <Arduino.h>
#include <stdint.h>

#define COLOR_RED 1
#define COLOR_BLACK 0
#include "../../common/drawing.h"

#define IMAGE_OR 1
#define IMAGE_REPLACE 0

#define DRAW_INVERTED 1
#define DRAW_NORMAL 0

typedef struct {
uint16_t bitmapOffset; ///< Pointer into GFXfont->bitmap
uint8_t width; ///< Bitmap dimensions in pixels
uint8_t height; ///< Bitmap dimensions in pixels
uint8_t xAdvance; ///< Distance to advance cursor (x axis)
int8_t xOffset; ///< X dist from cursor pos to UL corner
int8_t yOffset; ///< Y dist from cursor pos to UL corner
} GFXglyph;

/// Data stored for FONT AS A WHOLE
typedef struct {
uint8_t *bitmap; ///< Glyph bitmaps, concatenated
GFXglyph *glyph; ///< Glyph array
uint16_t first; ///< ASCII extents (first char)
uint16_t last; ///< ASCII extents (last char)
uint8_t yAdvance; ///< Newline distance (y axis)
} GFXfont;

enum rotation {
ROTATE_0,
ROTATE_90,
ROTATE_180,
ROTATE_270
};

void addBufferedImage(uint16_t x, uint16_t y, bool color, enum rotation ro, const uint8_t *image, bool mask);
void addFlashImage(uint16_t x, uint16_t y, bool color, enum rotation ro, const uint8_t *image);
void addQR(uint16_t x, uint16_t y, uint8_t version, uint8_t scale, const char *c, ...);
void drawImageAtAddress(uint32_t addr, uint8_t lut);
void drawRoundedRectangle(uint16_t xpos, uint16_t ypos, uint16_t width, uint16_t height, bool color);
void drawMask(uint16_t xpos, uint16_t ypos, uint16_t width, uint16_t height, bool color);

class drawItem {
public:
drawItem();
~drawItem();
void setRotation(enum rotation ro);
void addItem(uint8_t *data, uint16_t width, uint16_t height);
bool addToList();

static void shiftBytesRight(uint8_t *data, uint8_t shift, uint8_t len);
static void renderDrawLine(uint8_t *line, uint16_t number, uint8_t c);
static void flushDrawItems();

// these are also used for rotated screens
static void reverseBytes(uint8_t *src, uint8_t src_len);
static uint8_t bitReverse(uint8_t byte);


enum drawType {
DRAW_FONT,
DRAW_BUFFERED_1BPP,
DRAW_MASK,
DRAW_EEPROM_1BPP,
DRAW_EEPROM_2BPP,
} type;

int16_t xpos;
int16_t ypos;

enum rotation rotate = ROTATE_0;

uint8_t color = 0;

bool direction = false;

bool mirrorH = false;
bool mirrorV = false;
uint16_t width;
uint16_t height;

// if this is true, clean up the reference (free memory).
bool cleanUp = true;

protected:
void copyWithByteShift(uint8_t *dst, uint8_t *src, uint8_t src_len, uint8_t offset);


void getDrawLine(uint8_t *line, uint16_t number, uint8_t c);
void getXLine(uint8_t *line, uint16_t yPos, uint8_t color);
void getYLine(uint8_t *line, uint16_t xPos, uint8_t color);
uint8_t widthBytes = 0;
uint8_t *buffer;
};

class fontrender {
public:
void epdPrintf(uint16_t x, uint16_t y, bool color, enum rotation ro, const char *c, ...);
fontrender(const GFXfont *font);
void setFont(const GFXfont *font);

protected:
GFXfont *gfxFont; // = &FreeSansBold18pt7b;
uint16_t bufferByteWidth = 0;
uint8_t *fb = nullptr;
uint16_t Xpixels;
uint8_t drawChar(int32_t x, int32_t y, uint16_t c, uint8_t size);
uint8_t getCharWidth(uint16_t c);
void drawFastHLine(uint16_t x, uint16_t y, uint16_t w);
void fillRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
};

#endif
#endif
6 changes: 3 additions & 3 deletions ARM_Tag_FW/Newton_M3_nRF52811/include/font.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include <Arduino.h>
#include "FreeSans9pt7b.h"
#include "FreeSansBold18pt7b.h"
#include "FreeSansBold24pt7b.h"
#include "../../common/fonts/FreeSans9pt7b.h"
#include "../../common/fonts/FreeSansBold18pt7b.h"
#include "../../common/fonts/FreeSansBold24pt7b.h"
11 changes: 8 additions & 3 deletions ARM_Tag_FW/Newton_M3_nRF52811/include/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@

#include <stdint.h>

#define FW_VERSION 0x0026 // version number (max 2.5.5 :) )
#define FW_VERSION_SUFFIX "LED2" // suffix, like RC1 or whatever.
//#define DEBUGBLOCKS // uncomment to enable extra debug information on the block transfers
#define FW_VERSION 0x0027 // version number (max 2.5.5 :) )
#define FW_VERSION_SUFFIX "ZLIB" // suffix, like RC1 or whatever.
#define DEBUGBLOCKS // uncomment to enable extra debug information on the block transfers
#endif


#define DEBUG_BUILD
#define DEBUG_DRAWING


#define SETTINGS_STRUCT_VERSION 0x01

#define DEFAULT_SETTING_FASTBOOT 0
Expand Down
22 changes: 2 additions & 20 deletions ARM_Tag_FW/Newton_M3_nRF52811/include/syncedproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,6 @@
#include <stdint.h>
#include "settings.h"

extern uint8_t mSelfMac[];
extern uint8_t currentChannel;
extern uint8_t APmac[];
#define PERSISTENTVAR

extern uint8_t curImgSlot;

extern void setupRadio(void);
extern void killRadio(void);

extern uint8_t findSlotDataTypeArg(uint8_t arg);
extern uint8_t findNextSlideshowImage(uint8_t start);
extern uint8_t getEepromImageDataArgument(const uint8_t slot);

extern struct AvailDataInfo *getAvailDataInfo();
extern struct AvailDataInfo *getShortAvailDataInfo();

extern void drawImageFromEeprom(const uint8_t imgSlot, uint8_t lut);
extern void eraseImageBlocks();
extern bool processAvailDataInfo(struct AvailDataInfo *avail);
extern void initializeProto();
extern uint8_t detectAP(const uint8_t channel);
#include "../../common/oepl-protocol.h"
1 change: 1 addition & 0 deletions ARM_Tag_FW/Newton_M3_nRF52811/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ lib_deps =
stevemarple/AsyncDelay @ ^1.1.2
https://github.com/calebstewart/md5
https://github.com/ricmoo/QRCode
https://github.com/pfalcon/uzlib
extra_scripts = post:preparefiles.py

[env:Newton_M3_Universal]
Expand Down
25 changes: 25 additions & 0 deletions ARM_Tag_FW/Newton_M3_nRF52811/src/compression.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <vector>
#include <Arduino.h>
#include "eeprom.h"
#include "comms.h"
#include "powermgt.h"

#include "syncedproto.h"
#include "hal.h"

#include "compression.h"

#include "../../../oepl-definitions.h"
#include "../../../oepl-proto.h"

#include "settings.h"

#define MAX_WINDOW_SIZE 8192
#define ZLIB_CACHE_SIZE 256

uint32_t __attribute__((always_inline)) inline HAL_flashRead(uint32_t address, uint8_t *buffer, uint16_t numbytes) {
eepromRead(address, (void *)buffer, numbytes);
return numbytes;;
}

#include "../../common/compression.cpp"
Loading

0 comments on commit 57748d8

Please sign in to comment.