1.2-legacy
geeksville 2020-07-01 10:09:06 -07:00
rodzic a4f53270e8
commit c327fee986
1 zmienionych plików z 20 dodań i 15 usunięć

Wyświetl plik

@ -55,8 +55,11 @@ static FrameCallback normalFrames[MAX_NUM_NODES + NUM_EXTRA_FRAMES];
static uint32_t targetFramerate = IDLE_FRAMERATE; static uint32_t targetFramerate = IDLE_FRAMERATE;
static char btPIN[16] = "888888"; static char btPIN[16] = "888888";
uint8_t imgBattery[16] = { 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xE7, 0x3C }; uint8_t imgBattery[16] = {0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xE7, 0x3C};
#ifdef SHOW_REDRAWS
static bool heartbeat = false; static bool heartbeat = false;
#endif
static void drawBootScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) static void drawBootScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{ {
@ -177,10 +180,10 @@ static void drawColumns(OLEDDisplay *display, int16_t x, int16_t y, const char *
#endif #endif
// Draw power bars or a charging indicator on an image of a battery, determined by battery charge voltage or percentage. // Draw power bars or a charging indicator on an image of a battery, determined by battery charge voltage or percentage.
static void drawBattery(OLEDDisplay *display, int16_t x, int16_t y, uint8_t *imgBuffer, const PowerStatus *powerStatus) static void drawBattery(OLEDDisplay *display, int16_t x, int16_t y, uint8_t *imgBuffer, const PowerStatus *powerStatus)
{ {
static const uint8_t powerBar[3] = { 0x81, 0xBD, 0xBD }; static const uint8_t powerBar[3] = {0x81, 0xBD, 0xBD};
static const uint8_t lightning[8] = { 0xA1, 0xA1, 0xA5, 0xAD, 0xB5, 0xA5, 0x85, 0x85 }; static const uint8_t lightning[8] = {0xA1, 0xA1, 0xA5, 0xAD, 0xB5, 0xA5, 0x85, 0x85};
// Clear the bar area on the battery image // Clear the bar area on the battery image
for (int i = 1; i < 14; i++) { for (int i = 1; i < 14; i++) {
imgBuffer[i] = 0x81; imgBuffer[i] = 0x81;
@ -191,7 +194,7 @@ static void drawBattery(OLEDDisplay *display, int16_t x, int16_t y, uint8_t *img
// If not charging, Draw power bars // If not charging, Draw power bars
} else { } else {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if(powerStatus->getBatteryChargePercent() >= 25 * i) if (powerStatus->getBatteryChargePercent() >= 25 * i)
memcpy(imgBuffer + 1 + (i * 3), powerBar, 3); memcpy(imgBuffer + 1 + (i * 3), powerBar, 3);
} }
} }
@ -199,7 +202,7 @@ static void drawBattery(OLEDDisplay *display, int16_t x, int16_t y, uint8_t *img
} }
// Draw nodes status // Draw nodes status
static void drawNodes(OLEDDisplay *display, int16_t x, int16_t y, NodeStatus *nodeStatus) static void drawNodes(OLEDDisplay *display, int16_t x, int16_t y, NodeStatus *nodeStatus)
{ {
char usersString[20]; char usersString[20];
sprintf(usersString, "%d/%d", nodeStatus->getNumOnline(), nodeStatus->getNumTotal()); sprintf(usersString, "%d/%d", nodeStatus->getNumOnline(), nodeStatus->getNumTotal());
@ -765,10 +768,12 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
display->drawLogBuffer(x, y + (FONT_HEIGHT * 2)); display->drawLogBuffer(x, y + (FONT_HEIGHT * 2));
/* Display a heartbeat pixel that blinks every time the frame is redrawn /* Display a heartbeat pixel that blinks every time the frame is redrawn */
if(heartbeat) display->setPixel(0, 0); #ifdef SHOW_REDRAWS
if (heartbeat)
display->setPixel(0, 0);
heartbeat = !heartbeat; heartbeat = !heartbeat;
*/ #endif
} }
// adjust Brightness cycle trough 1 to 254 as long as attachDuringLongPress is true // adjust Brightness cycle trough 1 to 254 as long as attachDuringLongPress is true
@ -786,13 +791,13 @@ void Screen::adjustBrightness()
dispdev.setBrightness(brightness); dispdev.setBrightness(brightness);
} }
int Screen::handleStatusUpdate(const Status *arg) { int Screen::handleStatusUpdate(const Status *arg)
{
DEBUG_MSG("Screen got status update %d\n", arg->getStatusType()); DEBUG_MSG("Screen got status update %d\n", arg->getStatusType());
switch(arg->getStatusType()) switch (arg->getStatusType()) {
{ case STATUS_TYPE_NODE:
case STATUS_TYPE_NODE: setFrames();
setFrames(); break;
break;
} }
setPeriod(1); // Update the screen right away setPeriod(1); // Update the screen right away
return 0; return 0;