From 0b561d247334562d8f8dd3e734e84ee7bb8e2a1f Mon Sep 17 00:00:00 2001 From: Jelmer Date: Sun, 29 Jan 2023 01:20:06 +0100 Subject: [PATCH] Fixed stuff.Haven't checked power consumption! --- tag_fw/board/boardZBS29common.c | 2 -- tag_fw/epd.c | 23 +++++++----------- tag_fw/epd.h | 2 ++ tag_fw/lut.h | 28 +++++++++++++++++++++ tag_fw/userinterface.c | 43 ++++++++++++++++++++++++++++++--- 5 files changed, 78 insertions(+), 20 deletions(-) diff --git a/tag_fw/board/boardZBS29common.c b/tag_fw/board/boardZBS29common.c index 558d961e..7a662eed 100644 --- a/tag_fw/board/boardZBS29common.c +++ b/tag_fw/board/boardZBS29common.c @@ -151,8 +151,6 @@ void selfUpdate(void) uint8_t i, len = updaterInfo >> 16; uint8_t __xdata *dst = tempBuffer; - pr("updater len = %d\n", len); - for (i = len; i ; i--) *dst++ = *src++; diff --git a/tag_fw/epd.c b/tag_fw/epd.c index fa7cee44..06bb23ef 100644 --- a/tag_fw/epd.c +++ b/tag_fw/epd.c @@ -71,6 +71,7 @@ static bool __xdata directionY = true; // print direction, X or Y (true) static uint8_t __xdata rbuffer[32]; // used to rotate bits around static uint16_t __xdata fontCurXpos = 0; // current X value where working with static bool __xdata isInited = false; +struct waveform __xdata waveform; #pragma callee_saves epdBusySleep #pragma callee_saves epdBusyWait @@ -511,8 +512,6 @@ void epdPrintEnd() { epdPr = false; } -extern uint8_t* __xdata tempBuffer; -extern void dump(uint8_t* __xdata a, uint16_t __xdata l); void loadFixedTempLUT() { shortCommand1(0x18, 0x48); @@ -521,24 +520,20 @@ void loadFixedTempLUT() { shortCommand(CMD_ACTIVATION); epdBusyWait(1333000UL); } -static uint8_t readLut() { - uint8_t sta = 0; - +static void readLut() { commandReadBegin(0x33); - uint16_t checksum = 0; uint16_t ident = 0; uint16_t shortl = 0; for (uint16_t c = 0; c < 76; c++) { - sta = epdReadByte(); - checksum += sta; - if (c < 70) ident += sta; - if (c < 14) shortl += sta; - tempBuffer[c] = sta; + ((uint8_t*)&waveform)[c] = epdReadByte(); } - pr("ident=%04X checksum=%04X shortl=%04X\n", ident, checksum, shortl); commandReadEnd(); - dump(tempBuffer, 96); +} - return sta; +extern void dump(uint8_t* __xdata a, uint16_t __xdata l); // remove me when done + +void lutTest() { + readLut(); + dump((uint8_t*)&waveform, 96); } \ No newline at end of file diff --git a/tag_fw/epd.h b/tag_fw/epd.h index 82d4b1fc..e1251b74 100644 --- a/tag_fw/epd.h +++ b/tag_fw/epd.h @@ -54,4 +54,6 @@ void epdPrintEnd(); void beginFullscreenImage(); void beginWriteFramebuffer(bool color); +void lutTest(); + #endif \ No newline at end of file diff --git a/tag_fw/lut.h b/tag_fw/lut.h index 7cef0509..7e0f8a34 100644 --- a/tag_fw/lut.h +++ b/tag_fw/lut.h @@ -1,3 +1,30 @@ +#define __packed + +struct vgroup { + uint8_t A : 2; + uint8_t B : 2; + uint8_t C : 2; + uint8_t D : 2; +} __packed; + +struct lut { + struct vgroup group[7]; +} __packed; + +struct group { + uint8_t phaselength[4]; + uint8_t repeat; +} __packed; + +struct waveform { + struct lut elut[5]; + struct group egroup[7]; + uint8_t gatelevel; + uint8_t sourcelevel[3]; + uint8_t dummyline; + uint8_t gatewidth; +} __packed; + static const uint8_t __code lut154[] = { // lut0 (KEEP) voltages 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -108,6 +135,7 @@ static const uint8_t __code lutSHA[] = { 0x0F, 0x0F, 0x0, 0x0, 0x0, }; + static const uint8_t __code lutorig[] = { 0x00, 0x66, 0x21, 0x45, 0x40, 0x00, 0x00, 0x15, 0x66, 0x21, 0xA8, 0x20, 0xA0, 0x00, diff --git a/tag_fw/userinterface.c b/tag_fw/userinterface.c index 4d086a63..57f4b89a 100644 --- a/tag_fw/userinterface.c +++ b/tag_fw/userinterface.c @@ -15,12 +15,15 @@ #include "spi.h" #include "timer.h" +extern uint8_t mSelfMac[]; + void showSplashScreen() { epdSetup(); -#if (SCREEN_WIDTH == 152) + lutTest(); +#if (SCREEN_WIDTH == 152) // 1.54" selectLUT(1); clearScreen(); - setColorMode(EPD_MODE_IGNORE, EPD_MODE_INVERT); + setColorMode(EPD_MODE_NORMAL, EPD_MODE_INVERT); drawLineHorizontal(EPD_COLOR_BLACK, 33, 1); epdPrintBegin(0, 0, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK); pr("Booting!"); @@ -28,10 +31,42 @@ void showSplashScreen() { draw(); timerDelay(1333000); #endif +#if (SCREEN_WIDTH == 128) // 2.9" + selectLUT(1); + clearScreen(); + setColorMode(EPD_MODE_NORMAL, EPD_MODE_INVERT); + epdPrintBegin(128, 0, EPD_DIRECTION_Y, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK); + pr("Booting!"); + epdPrintEnd(); + epdPrintBegin(16, 10, EPD_DIRECTION_Y, EPD_SIZE_SINGLE, EPD_COLOR_RED); + pr("MAC: %02X:%02X", mSelfMac[7], mSelfMac[6]); + pr(":%02X:%02X", mSelfMac[5], mSelfMac[4]); + pr(":%02X:%02X", mSelfMac[3], mSelfMac[2]); + pr(":%02X:%02X", mSelfMac[1], mSelfMac[0]); + epdPrintEnd(); + draw(); + timerDelay(1333000); +#endif +#if (SCREEN_WIDTH == 400) // 2.9" + selectLUT(1); + clearScreen(); + setColorMode(EPD_MODE_NORMAL, EPD_MODE_INVERT); + epdPrintBegin(0, 0, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK); + pr("Booting!"); + epdPrintEnd(); + epdPrintBegin(16, 284, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_RED); + pr("MAC: %02X:%02X", mSelfMac[7], mSelfMac[6]); + pr(":%02X:%02X", mSelfMac[5], mSelfMac[4]); + pr(":%02X:%02X", mSelfMac[3], mSelfMac[2]); + pr(":%02X:%02X", mSelfMac[1], mSelfMac[0]); + epdPrintEnd(); + draw(); + timerDelay(1333000); +#endif + } - -void showApplyUpdate(){ +void showApplyUpdate() { epdSetup(); selectLUT(1); clearScreen();