cleanup, rewrote epd-print method

This commit is contained in:
Jelmer
2023-01-31 11:46:16 +01:00
parent 5089ecf308
commit 849fbc44fd
14 changed files with 816 additions and 948 deletions

View File

@@ -4,27 +4,11 @@
#include <stdint.h>
#include "spi.h"
#include "uart.h"
//colors for ui messages
#define UI_MSG_MAGNIFY1 1
#define UI_MSG_MAGNIFY2 1
#define UI_MSG_MAGNIFY3 1
#define UI_MSG_BACK_COLOR 4
#define UI_MSG_FORE_COLOR_1 0
#define UI_MSG_FORE_COLOR_2 5
#define UI_MSG_FORE_COLOR_3 5
#define UI_BARCODE_VERTICAL
#define eepromByte spiByte
#define eepromPrvSelect() do { __asm__("nop\nnop\nnop\n"); P1_1 = 0; __asm__("nop\nnop\nnop\n"); } while(0)
#define eepromPrvDeselect() do { __asm__("nop\nnop\nnop\n"); P1_1 = 1; __asm__("nop\nnop\nnop\n"); } while(0)
//debug uart (enable only when needed, on some boards it inhibits eeprom access)
#define dbgUartOn()
#define dbgUartOff()
#define dbgUartByte uartTx
//eeprom map
#define EEPROM_SETTINGS_AREA_START (0x01000UL)
#define EEPROM_SETTINGS_AREA_LEN (0x03000UL)
@@ -35,19 +19,10 @@
//till end of eeprom really. do not put anything after - it will be erased at pairing time!!!
#define EEPROM_PROGRESS_BYTES (128)
//radio cfg
#define RADIO_FIRST_CHANNEL (11) //2.4-GHz channels start at 11
#define RADIO_NUM_CHANNELS (1)
//hw types
#define HW_TYPE_NORMAL HW_TYPE_154_INCH_ZBS_033
#define HW_TYPE_CYCLING HW_TYPE_154_INCH_ZBS_033_FRAME_MODE
#include "../boardCommon.h"
#endif
#endif

View File

@@ -22,6 +22,4 @@
#define SCREEN_DATA_PASSES 2
#endif
#endif

View File

@@ -4,27 +4,11 @@
#include <stdint.h>
#include "spi.h"
#include "uart.h"
//colors for ui messages
#define UI_MSG_MAGNIFY1 1
#define UI_MSG_MAGNIFY2 1
#define UI_MSG_MAGNIFY3 1
#define UI_MSG_BACK_COLOR 4
#define UI_MSG_FORE_COLOR_1 0
#define UI_MSG_FORE_COLOR_2 5
#define UI_MSG_FORE_COLOR_3 5
#define UI_BARCODE_VERTICAL
#define eepromByte spiByte
#define eepromPrvSelect() do { __asm__("nop\nnop\nnop\n"); P1_1 = 0; __asm__("nop\nnop\nnop\n"); } while(0)
#define eepromPrvDeselect() do { __asm__("nop\nnop\nnop\n"); P1_1 = 1; __asm__("nop\nnop\nnop\n"); } while(0)
//debug uart (enable only when needed, on some boards it inhibits eeprom access)
#define dbgUartOn()
#define dbgUartOff()
#define dbgUartByte uartTx
//eeprom map
#define EEPROM_SETTINGS_AREA_START (0x01000UL)
#define EEPROM_SETTINGS_AREA_LEN (0x03000UL)
@@ -35,19 +19,10 @@
//till end of eeprom really. do not put anything after - it will be erased at pairing time!!!
#define EEPROM_PROGRESS_BYTES (128)
//radio cfg
#define RADIO_FIRST_CHANNEL (11) //2.4-GHz channels start at 11
#define RADIO_NUM_CHANNELS (1)
//hw types
#define HW_TYPE_NORMAL HW_TYPE_29_INCH_ZBS_026
#define HW_TYPE_CYCLING HW_TYPE_29_INCH_ZBS_026_FRAME_MODE
#include "../boardCommon.h"
#endif
#endif

View File

@@ -4,12 +4,6 @@
#include <stdbool.h>
#include <stdint.h>
//i hate globals, but for 8051 this makes life a lot easier, sorry :(
extern uint8_t __xdata mScreenVcom;
extern int8_t __xdata mCurTemperature;
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 296
@@ -27,22 +21,5 @@ extern int8_t __xdata mCurTemperature;
#define SCREEN_DATA_PASSES 2
void screenShutdown(void);
void screenTest(void);
__bit screenTxStart(__bit forPartial);
void screenEndPass(void); //at end of each pass
#pragma callee_saves screenByteTx
void screenByteTx(uint8_t byte);
void screenTxEnd(void);
void screenSleep(void);
extern uint8_t __xdata mScreenRow[]; //320 bytes used as temp by many on cc where memory is tight
#endif
#endif

View File

@@ -4,27 +4,11 @@
#include <stdint.h>
#include "spi.h"
#include "uart.h"
//colors for ui messages
#define UI_MSG_MAGNIFY1 1
#define UI_MSG_MAGNIFY2 1
#define UI_MSG_MAGNIFY3 1
#define UI_MSG_BACK_COLOR 4
#define UI_MSG_FORE_COLOR_1 0
#define UI_MSG_FORE_COLOR_2 5
#define UI_MSG_FORE_COLOR_3 5
#define UI_BARCODE_VERTICAL
#define eepromByte spiByte
#define eepromPrvSelect() do { __asm__("nop\nnop\nnop\n"); P1_1 = 0; __asm__("nop\nnop\nnop\n"); } while(0)
#define eepromPrvDeselect() do { __asm__("nop\nnop\nnop\n"); P1_1 = 1; __asm__("nop\nnop\nnop\n"); } while(0)
//debug uart (enable only when needed, on some boards it inhibits eeprom access)
#define dbgUartOn()
#define dbgUartOff()
#define dbgUartByte uartTx
//eeprom map
#define EEPROM_SETTINGS_AREA_START (0x01000UL)
#define EEPROM_SETTINGS_AREA_LEN (0x03000UL)
@@ -35,19 +19,10 @@
//till end of eeprom really. do not put anything after - it will be erased at pairing time!!!
#define EEPROM_PROGRESS_BYTES (128)
//radio cfg
#define RADIO_FIRST_CHANNEL (11) //2.4-GHz channels start at 11
#define RADIO_NUM_CHANNELS (1)
//hw types
#define HW_TYPE_NORMAL HW_TYPE_42_INCH_ZBS_026
#define HW_TYPE_CYCLING HW_TYPE_42_INCH_ZBS_026_FRAME_MODE
#include "../boardCommon.h"
#endif
#endif

View File

@@ -4,12 +4,6 @@
#include <stdbool.h>
#include <stdint.h>
//i hate globals, but for 8051 this makes life a lot easier, sorry :(
extern uint8_t __xdata mScreenVcom;
extern int8_t __xdata mCurTemperature;
#define SCREEN_WIDTH 400
#define SCREEN_HEIGHT 300
@@ -27,24 +21,5 @@ extern int8_t __xdata mCurTemperature;
#define SCREEN_DATA_PASSES 2
void screenShutdown(void);
void screenTest(void);
__bit screenTxStart(__bit forPartial);
void screenEndPass(void); //at end of each pass
#pragma callee_saves screenByteTx
void screenByteTx(uint8_t byte);
void screenTxEnd(void);
void screenSleep(void);
extern uint8_t __xdata mScreenRow[]; //320 bytes used as temp by many on cc where memory is tight
#endif
#endif

View File

@@ -3,13 +3,11 @@
#include <stdint.h>
#define COMMS_MAX_RADIO_WAIT_MSEC 200
#define COMMS_IV_SIZE (4) //zeroes except these 4 counter bytes
#define COMMS_MAX_RADIO_WAIT_MSEC 200
#define COMMS_RX_ERR_NO_PACKETS (-1)
#define COMMS_RX_ERR_INVALID_PACKET (-2)
#define COMMS_RX_ERR_MIC_FAIL (-3)
#define COMMS_MAX_PACKET_SZ (127)

File diff suppressed because it is too large Load Diff

View File

@@ -66,7 +66,6 @@
extern void dump(uint8_t* __xdata a, uint16_t __xdata l); // remove me when done
static bool __idata epdPr = false; // wheter or not we copy the pr("") output to the EPD
static uint8_t __xdata epdCharSize = 1; // character size, 1 or 2 (doubled)
static bool __xdata directionY = true; // print direction, X or Y (true)
static uint8_t __xdata rbuffer[32]; // used to rotate bits around
@@ -303,9 +302,8 @@ void selectLUT(uint8_t lut) {
if (SCREEN_WIDTH == 152) {
sendCustomLut(lut154, 100);
} else {
sendCustomLut(lut154, 70);
sendCustomLut(lutorig, 70);
}
return;
readLut();
// dump((uint8_t*)&waveform, 96);
dump(blockXferBuffer, 512);
@@ -524,9 +522,6 @@ static void pushYFontBytesToEPD(uint8_t byte1, uint8_t byte2) {
}
}
void writeCharEPD(uint8_t c) {
if (!epdPr) {
return;
}
// Writes a single character to the framebuffer
bool empty = true;
for (uint8_t i = 0; i < 20; i++) {
@@ -611,7 +606,6 @@ void epdPrintBegin(uint16_t x, uint16_t y, bool direction, bool fontsize, bool c
memset(rbuffer, 0, 32);
}
epdPr = true;
if (color) {
commandBegin(CMD_WRITE_FB_RED);
} else {
@@ -625,7 +619,6 @@ void epdPrintEnd() {
}
}
commandEnd();
epdPr = false;
}
extern uint8_t __xdata blockXferBuffer[];

View File

@@ -54,10 +54,12 @@ void ByteDecode(uint8_t byte);
void epdPrintBegin(uint16_t x, uint16_t y, bool direction, bool fontsize, bool red);
void epdPrintEnd();
void beginFullscreenImage();
void beginWriteFramebuffer(bool color);
void lutTest();
// for printf.c
void writeCharEPD(uint8_t c);
#endif

View File

@@ -19,6 +19,9 @@
#pragma callee_saves pr
void pr(const char __code *fmt, ...) __reentrant;
#pragma callee_saves epdpr
void epdpr(const char __code *fmt, ...) __reentrant;
#pragma callee_saves spr
void spr(char __xdata* out, const char __code *fmt, ...) __reentrant;

View File

@@ -5,6 +5,10 @@
#include <stdint.h>
//radio cfg
#define RADIO_FIRST_CHANNEL (11) //2.4-GHz channels start at 11
#define RADIO_NUM_CHANNELS (1)
#define RADIO_MAX_PACKET_LEN (125) //useful payload, not including the crc
@@ -20,10 +24,6 @@
#define SHORT_MAC_UNUSED (0x10000000UL) //for radioRxFilterCfg's myShortMac
void radioInit(void);
bool radioTx(const void __xdata* packet); //waits for tx end

View File

@@ -12,10 +12,7 @@ void uartInit(void) {
UARTSTA = 0x12; // also set the "empty" bit else we wait forever for it to go up
}
extern void writeCharEPD(uint8_t c);
void uartTx(uint8_t val) {
writeCharEPD(val);
while (!(UARTSTA & (1 << 1)))
;
UARTSTA &= ~(1 << 1);

View File

@@ -31,21 +31,21 @@ void showSplashScreen() {
setColorMode(EPD_MODE_NORMAL, EPD_MODE_INVERT);
selectLUT(1);
epdPrintBegin(12, 2, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
pr("Starting!");
epdpr("Starting!");
epdPrintEnd();
loadRawBitmap(solum, 8, 34, EPD_COLOR_BLACK);
loadRawBitmap(hacked, 32, 46, EPD_COLOR_RED);
epdPrintBegin(5, 136, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_RED);
pr("%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]);
epdpr("%02X%02X", mSelfMac[7], mSelfMac[6]);
epdpr("%02X%02X", mSelfMac[5], mSelfMac[4]);
epdpr("%02X%02X", mSelfMac[3], mSelfMac[2]);
epdpr("%02X%02X", mSelfMac[1], mSelfMac[0]);
epdPrintEnd();
epdPrintBegin(2, 120, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK);
pr("zbs154v033 %d.%d.%d%s", fwVersion/100, (fwVersion%100)/10, (fwVersion%10),fwVersionSuffix);
epdpr("zbs154v033 %d.%d.%d%s", fwVersion/100, (fwVersion%100)/10, (fwVersion%10),fwVersionSuffix);
epdPrintEnd();
draw();
#endif
@@ -57,18 +57,18 @@ void showSplashScreen() {
setColorMode(EPD_MODE_NORMAL, EPD_MODE_INVERT);
epdPrintBegin(0, 295, EPD_DIRECTION_Y, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
pr("Starting!");
epdpr("Starting!");
epdPrintEnd();
epdPrintBegin(115, 295, 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]);
epdpr("MAC: %02X:%02X", mSelfMac[7], mSelfMac[6]);
epdpr(":%02X:%02X", mSelfMac[5], mSelfMac[4]);
epdpr(":%02X:%02X", mSelfMac[3], mSelfMac[2]);
epdpr(":%02X:%02X", mSelfMac[1], mSelfMac[0]);
epdPrintEnd();
epdPrintBegin(96, 295, EPD_DIRECTION_Y, EPD_SIZE_SINGLE, EPD_COLOR_BLACK);
pr("zbs29v033 %d.%d.%d%s", fwVersion/100, (fwVersion%100)/10, (fwVersion%10),fwVersionSuffix);
epdpr("zbs29v033 %d.%d.%d%s", fwVersion/100, (fwVersion%100)/10, (fwVersion%10),fwVersionSuffix);
epdPrintEnd();
loadRawBitmap(solum, 0, 0, EPD_COLOR_BLACK);
@@ -84,27 +84,23 @@ void showSplashScreen() {
clearScreen();
setColorMode(EPD_MODE_NORMAL, EPD_MODE_INVERT);
epdPrintBegin(64, 150, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
pr("TEST");
epdPrintEnd();
epdPrintBegin(300, 296, EPD_DIRECTION_Y, EPD_SIZE_DOUBLE, EPD_COLOR_RED);
pr("Booting!Y");
epdPrintEnd();
epdpr("Booting!Y");
epdpr();
epdPrintBegin(0, 0, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
pr("BootingX!");
epdpr("Starting!");
epdPrintEnd();
epdPrintBegin(16, 252, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK);
pr("zbs42v033 %d.%d.%d%s", fwVersion/100, (fwVersion%100)/10, (fwVersion%10),fwVersionSuffix);
epdpr("zbs42v033 %d.%d.%d%s", fwVersion/100, (fwVersion%100)/10, (fwVersion%10),fwVersionSuffix);
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]);
epdpr("MAC: %02X:%02X", mSelfMac[7], mSelfMac[6]);
epdpr(":%02X:%02X", mSelfMac[5], mSelfMac[4]);
epdpr(":%02X:%02X", mSelfMac[3], mSelfMac[2]);
epdpr(":%02X:%02X", mSelfMac[1], mSelfMac[0]);
epdPrintEnd();
loadRawBitmap(solum, 256, 10, EPD_COLOR_BLACK);
@@ -123,7 +119,7 @@ void showApplyUpdate() {
clearScreen();
setColorMode(EPD_MODE_IGNORE, EPD_MODE_NORMAL);
epdPrintBegin(8, 60, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
pr("Updating!");
epdpr("Updating!");
epdPrintEnd();
drawNoWait();
}