Merge branch 'master' into development

This commit is contained in:
Nic Limper
2023-02-07 12:56:45 +01:00
3 changed files with 128 additions and 37 deletions

View File

@@ -239,18 +239,15 @@ static uint8_t epdGetStatus() {
return sta;
}
uint16_t epdGetBattery(void) {
// epdEnterSleep(); // r
// return 2600; // r
uint16_t voltage = 2600;
uint8_t val;
//epdReset();
timerDelay(50);
timerDelay(50);
P2_0 = 0;
timerDelay(50);
timerDelay(50);
P2_0 = 1;
timerDelay(50);
timerDelay(50);
shortCommand(CMD_SOFT_RESET); // software reset
epdBusyWait(TIMER_TICKS_PER_MS * 30);
@@ -346,23 +343,26 @@ void selectLUT(uint8_t lut) {
lutGroupRepeatReduce(LUTGROUP_IMPROVE_SHARPNESS, 2);
lutGroupSpeedup(LUTGROUP_IMPROVE_REDS, 2);
lutGroupRepeatReduce(LUTGROUP_IMPROVE_REDS, 2);
lutGroupDisable(LUTGROUP_UNUSED);
break;
case EPD_LUT_FAST_NO_REDS:
lutGroupDisable(LUTGROUP_NEGATIVE);
lutGroupDisable(LUTGROUP_FASTBLINK);
lutGroupDisable(LUTGROUP_SLOWBLINK);
// lutGroupSpeedup(LUTGROUP_SET, 2);
lutGroupSpeedup(LUTGROUP_SET, 2);
lutGroupDisable(LUTGROUP_IMPROVE_REDS);
lutGroupDisable(LUTGROUP_IMPROVE_SHARPNESS);
lutGroupDisable(LUTGROUP_UNUSED);
break;
case EPD_LUT_FAST:
lutGroupDisable(LUTGROUP_NEGATIVE);
lutGroupDisable(LUTGROUP_FASTBLINK);
lutGroupDisable(LUTGROUP_SLOWBLINK);
lutGroupRepeat(LUTGROUP_SET, 0);
// lutGroupSpeedup(LUTGROUP_SET, 2);
lutGroupDisable(LUTGROUP_IMPROVE_REDS);
lutGroupSpeedup(LUTGROUP_SET, 2);
lutGroupDisable(LUTGROUP_IMPROVE_SHARPNESS);
lutGroupDisable(LUTGROUP_IMPROVE_REDS);
lutGroupDisable(LUTGROUP_UNUSED);
break;
}

View File

@@ -22,6 +22,70 @@
// #define DEBUG_MODE
static bool __xdata attemptFirstContact = true;
void displayLoop() {
powerUp(INIT_BASE | INIT_UART | INIT_GPIO);
pr("Splash screen\n");
powerUp(INIT_EPD);
showSplashScreen();
timerDelay(TIMER_TICKS_PER_SECOND * 4);
pr("Update screen\n");
powerUp(INIT_EPD);
showApplyUpdate();
timerDelay(TIMER_TICKS_PER_SECOND * 4);
wdtOn();
wdt60s();
pr("Scanning screen - ");
powerUp(INIT_EPD);
showScanningWindow();
timerDelay(TIMER_TICKS_PER_SECOND * 8);
for (uint8_t i = 0; i < 5; i++) {
for (uint8_t c = 0; c < 16; c++) {
addScanResult(11 + c, 2 * i + 60 + c);
}
pr("redraw... ");
draw();
}
pr("\n");
timerDelay(TIMER_TICKS_PER_SECOND * 4);
wdtOn();
wdt30s();
pr("AP Found\n");
powerUp(INIT_EPD);
showAPFound();
timerDelay(TIMER_TICKS_PER_SECOND * 4);
wdtOn();
wdt30s();
pr("AP NOT Found\n");
powerUp(INIT_EPD);
showNoAP();
timerDelay(TIMER_TICKS_PER_SECOND * 4);
wdtOn();
wdt30s();
pr("NO EEPROM\n");
powerUp(INIT_EPD);
showNoEEPROM();
timerDelay(TIMER_TICKS_PER_SECOND * 4);
wdtOn();
wdt30s();
pr("NO EEPROM\n");
powerUp(INIT_EPD);
showNoMAC();
timerDelay(TIMER_TICKS_PER_SECOND * 4);
wdtDeviceReset();
}
uint8_t showChannelSelect() { // returns 0 if no accesspoints were found
uint8_t __xdata result[16];
memset(result, 0, sizeof(result));
@@ -77,6 +141,7 @@ uint8_t channelSelect() { // returns 0 if no accesspoints were found
}
void mainProtocolLoop(void) {
//displayLoop(); // remove me
powerUp(INIT_BASE | INIT_UART | INIT_GPIO);
wdt10s();
boardGetOwnMac(mSelfMac);
@@ -142,8 +207,7 @@ void mainProtocolLoop(void) {
if ((longDataReqCounter > LONG_DATAREQ_INTERVAL) || attemptFirstContact || wakeUpReason != WAKEUP_REASON_TIMED) {
if (attemptFirstContact)
wakeUpReason = WAKEUP_REASON_BOOTUP;
if (voltageCheckCounter == VOLTAGE_CHECK_INTERVAL) {
powerUp(INIT_BASE | INIT_TEMPREADING | INIT_EPD_VOLTREADING | INIT_RADIO);
voltageCheckCounter = 0;

View File

@@ -29,10 +29,11 @@ const uint8_t __code fwVersion = FW_VERSION;
const char __code fwVersionSuffix[] = FW_VERSION_SUFFIX;
void showSplashScreen() {
#if (SCREEN_WIDTH == 152) // 1.54"
selectLUT(EPD_LUT_NO_REPEATS);
clearScreen();
setColorMode(EPD_MODE_NORMAL, EPD_MODE_INVERT);
selectLUT(1);
#if (SCREEN_WIDTH == 152) // 1.54"
epdPrintBegin(12, 2, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
epdpr("Starting!");
epdPrintEnd();
@@ -54,9 +55,6 @@ void showSplashScreen() {
#endif
#if (SCREEN_WIDTH == 128) // 2.9"
selectLUT(EPD_LUT_NO_REPEATS);
clearScreen();
setColorMode(EPD_MODE_NORMAL, EPD_MODE_INVERT);
epdPrintBegin(0, 295, EPD_DIRECTION_Y, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
epdpr("Starting!");
@@ -88,23 +86,15 @@ void showSplashScreen() {
// timerDelay(TIMER_TICKS_PER_SECOND * 4);
#endif
#if (SCREEN_WIDTH == 400) // 2.9"
selectLUT(1);
clearScreen();
setColorMode(EPD_MODE_NORMAL, EPD_MODE_INVERT);
epdPrintBegin(300, 296, EPD_DIRECTION_Y, EPD_SIZE_DOUBLE, EPD_COLOR_RED);
epdpr("Booting!Y");
epdpr("");
epdPrintBegin(0, 0, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
#if (SCREEN_WIDTH == 400) // 4.2"
epdPrintBegin(3, 3, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
epdpr("Starting!");
epdPrintEnd();
epdPrintBegin(16, 252, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK);
epdPrintBegin(3, 268, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK);
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);
epdPrintBegin(3, 284, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_RED);
epdpr("MAC: %02X:%02X", mSelfMac[7], mSelfMac[6]);
epdpr(":%02X:%02X", mSelfMac[5], mSelfMac[4]);
epdpr(":%02X:%02X", mSelfMac[3], mSelfMac[2]);
@@ -114,8 +104,12 @@ void showSplashScreen() {
loadRawBitmap(solum, 256, 10, EPD_COLOR_BLACK);
loadRawBitmap(hacked, 264, 22, EPD_COLOR_RED);
loadRawBitmap(solum, 253, 72, EPD_COLOR_BLACK);
loadRawBitmap(hacked, 261, 82, EPD_COLOR_RED);
uint8_t __xdata buffer[17];
spr(buffer, "%02X%02X", mSelfMac[7], mSelfMac[6]);
spr(buffer + 4, "%02X%02X", mSelfMac[5], mSelfMac[4]);
spr(buffer + 8, "%02X%02X", mSelfMac[3], mSelfMac[2]);
spr(buffer + 12, "%02X%02X", mSelfMac[1], mSelfMac[0]);
printBarcode(buffer, 392, 286);
#endif
drawWithSleep();
@@ -126,7 +120,18 @@ void showApplyUpdate() {
selectLUT(1);
clearScreen();
setColorMode(EPD_MODE_IGNORE, EPD_MODE_NORMAL);
epdPrintBegin(8, 60, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
#if (SCREEN_WIDTH == 152)
epdPrintBegin(12, 60, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
#endif
#if (SCREEN_WIDTH == 128)
epdPrintBegin(48, 86, EPD_DIRECTION_Y, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
#endif
#if (SCREEN_WIDTH == 400)
epdPrintBegin(136, 134, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
#endif
epdpr("Updating!");
epdPrintEnd();
drawNoWait();
@@ -153,6 +158,18 @@ void showScanningWindow() {
epdpr("Scanning...");
epdPrintEnd();
#endif
#if (SCREEN_WIDTH == 400) // 4.2"
epdPrintBegin(2, 2, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
epdpr("Scanning for APs");
epdPrintEnd();
epdPrintBegin(2, 40, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_RED);
epdpr("Channel - Quality");
epdPrintEnd();
loadRawBitmap(receive, 320, 125, EPD_COLOR_BLACK);
#endif
draw();
selectLUT(EPD_LUT_FAST);
resultcounter = 0;
@@ -160,16 +177,17 @@ void showScanningWindow() {
void addScanResult(uint8_t channel, uint8_t lqi) {
if (channel == 11) resultcounter = 0;
#if (SCREEN_WIDTH == 128)
#if (SCREEN_WIDTH == 128) // 2.9"
epdPrintBegin(56 + ((resultcounter % 4) * 16), 282 - (47 * (resultcounter / 4)), EPD_DIRECTION_Y, EPD_SIZE_SINGLE, EPD_COLOR_BLACK);
epdpr("%d-%d", channel, lqi);
epdPrintEnd();
#endif
#if (SCREEN_WIDTH == 152) // 1.54"
#if (SCREEN_WIDTH ==150) // 1.54"
epdPrintBegin(4 + (47 * (resultcounter / 8)), 31 + (15 * (resultcounter % 8)), EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK);
#endif
#if (SCREEN_WIDTH == 400) // 4.2"
epdPrintBegin(4 + (47 * (resultcounter / 8)), 50 + (15 * (resultcounter % 8)), EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK);
#endif
epdpr("%d-%d", channel, lqi);
epdPrintEnd();
#endif
resultcounter++;
}
@@ -332,6 +350,15 @@ void showNoMAC() {
epdPrintBegin(3, 136, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK);
epdpr("Sleeping forever :'(");
epdPrintEnd();
#endif
#if (SCREEN_WIDTH == 400) // 1.54"
epdPrintBegin(100, 3, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
epdpr("NO MAC SET :(");
epdPrintEnd();
loadRawBitmap(failed, 176, 126, EPD_COLOR_RED);
epdPrintBegin(100, 284, EPD_DIRECTION_X, EPD_SIZE_SINGLE, EPD_COLOR_BLACK);
epdpr("Sleeping forever :'(");
epdPrintEnd();
#endif
drawWithSleep();
}