eink display improvements

1.2-legacy
Kevin Hester 2020-10-16 10:53:55 +08:00
rodzic 9134faaed1
commit b0837c10c6
5 zmienionych plików z 51 dodań i 18 usunięć

Wyświetl plik

@ -0,0 +1,22 @@
# You probably don't want to use this script, it programs a custom bootloader build onto a nrf52 board
set -e
BOOTDIR=/home/kevinh/development/meshtastic/Adafruit_nRF52_Bootloader
nrfjprog --eraseall -f nrf52
# this generates an intel hex file that can be programmed into a NRF52 to tell the adafruit bootloader that the current app image is valid
# Bootloader settings are at BOOTLOADER_SETTINGS (rw) : ORIGIN = 0xFF000, LENGTH = 0x1000
# first 4 bytes should be 0x01 to indicate valid app image
# second 4 bytes should be 0x00 to indicate no CRC required for image
echo "01 00 00 00 00 00 00 00" | xxd -r -p - >/tmp/bootconf.bin
srec_cat /tmp/bootconf.bin -binary -offset 0xff000 -output /tmp/bootconf.hex -intel
echo Generating merged hex file
mergehex -m $BOOTDIR/_build/build-ttgo_eink/ttgo_eink_bootloader-0.3.2-125-gf38f8f4-dirty_s140_6.1.1.hex .pio/build/eink/firmware.hex /tmp/bootconf.hex -o ttgo_eink_full.hex
echo Telling bootloader app region is valid and telling CPU to run
nrfjprog --program ttgo_eink_full.hex -f nrf52 --reset
# nrfjprog --readuicr /tmp/uicr.hex; objdump -s /tmp/uicr.hex | less

Wyświetl plik

@ -102,8 +102,7 @@ void EInkDisplay::display(void)
// at least one forceDisplay() keyframe. This prevents flashing when we should the critical // at least one forceDisplay() keyframe. This prevents flashing when we should the critical
// bootscreen (that we want to look nice) // bootscreen (that we want to look nice)
if (lastDrawMsec) if (lastDrawMsec)
if (forceDisplay(slowUpdateMsec)) // Show the first screen a few seconds after boot, then slower forceDisplay(slowUpdateMsec); // Show the first screen a few seconds after boot, then slower
slowUpdateMsec = 5 * 60 * 1000;
} }
// Send a command to the display (low level function) // Send a command to the display (low level function)

Wyświetl plik

@ -14,9 +14,9 @@
*/ */
class EInkDisplay : public OLEDDisplay class EInkDisplay : public OLEDDisplay
{ {
/// How often should we update the display, at first we do an update 5 secs after boot, /// How often should we update the display
/// thereafter we do once per 5 minutes /// thereafter we do once per 5 minutes
uint32_t slowUpdateMsec = 5 * 1000; uint32_t slowUpdateMsec = 5 * 60 * 1000;
public: public:
/* constructor /* constructor
@ -32,7 +32,7 @@ class EInkDisplay : public OLEDDisplay
* *
* @return true if we did draw the screen * @return true if we did draw the screen
*/ */
bool forceDisplay(uint32_t msecLimit = 2000); bool forceDisplay(uint32_t msecLimit = 1000);
protected: protected:
// the header size of the buffer used, e.g. for the SPI command header // the header size of the buffer used, e.g. for the SPI command header

Wyświetl plik

@ -681,7 +681,8 @@ int32_t Screen::runOnce()
// Show boot screen for first 3 seconds, then switch to normal operation. // Show boot screen for first 3 seconds, then switch to normal operation.
static bool showingBootScreen = true; static bool showingBootScreen = true;
if (showingBootScreen && (millis() > 3000)) { if (showingBootScreen && (millis() > 5000)) {
DEBUG_MSG("Done with boot screen...\n");
stopBootScreen(); stopBootScreen();
showingBootScreen = false; showingBootScreen = false;
} }
@ -727,6 +728,10 @@ int32_t Screen::runOnce()
return 0; return 0;
} }
// this must be before the frameState == FIXED check, because we always
// want to draw at least one FIXED frame before doing forceDisplay
ui.update();
// Switch to a low framerate (to save CPU) when we are not in transition // Switch to a low framerate (to save CPU) when we are not in transition
// but we should only call setTargetFPS when framestate changes, because // but we should only call setTargetFPS when framestate changes, because
// otherwise that breaks animations. // otherwise that breaks animations.
@ -744,8 +749,6 @@ int32_t Screen::runOnce()
// standard screen loop handling here // standard screen loop handling here
} }
ui.update();
// DEBUG_MSG("want fps %d, fixed=%d\n", targetFramerate, // DEBUG_MSG("want fps %d, fixed=%d\n", targetFramerate,
// ui.getUiState()->frameState); If we are scrolling we need to be called // ui.getUiState()->frameState); If we are scrolling we need to be called
// soon, otherwise just 1 fps (to save CPU) We also ask to be called twice // soon, otherwise just 1 fps (to save CPU) We also ask to be called twice
@ -812,6 +815,8 @@ void Screen::setFrames()
prevFrame = -1; // Force drawNodeInfo to pick a new node (because our list prevFrame = -1; // Force drawNodeInfo to pick a new node (because our list
// just changed) // just changed)
setFastFramerate(); // Draw ASAP
} }
void Screen::handleStartBluetoothPinScreen(uint32_t pin) void Screen::handleStartBluetoothPinScreen(uint32_t pin)
@ -825,12 +830,13 @@ void Screen::handleStartBluetoothPinScreen(uint32_t pin)
ui.disableAllIndicators(); ui.disableAllIndicators();
ui.setFrames(btFrames, 1); ui.setFrames(btFrames, 1);
setFastFramerate();
} }
void Screen::handlePrint(const char *text) void Screen::handlePrint(const char *text)
{ {
DEBUG_MSG("Screen: %s", text); DEBUG_MSG("Screen: %s", text);
if (!useDisplay) if (!useDisplay || !showingNormalScreen)
return; return;
dispdev.print(text); dispdev.print(text);
@ -841,17 +847,22 @@ void Screen::handleOnPress()
// If screen was off, just wake it, otherwise advance to next frame // If screen was off, just wake it, otherwise advance to next frame
// If we are in a transition, the press must have bounced, drop it. // If we are in a transition, the press must have bounced, drop it.
if (ui.getUiState()->frameState == FIXED) { if (ui.getUiState()->frameState == FIXED) {
setInterval(0); // redraw ASAP
ui.nextFrame(); ui.nextFrame();
DEBUG_MSG("Setting fast framerate\n"); setFastFramerate();
// We are about to start a transition so speed up fps
targetFramerate = TRANSITION_FRAMERATE;
ui.setTargetFPS(targetFramerate);
} }
} }
void Screen::setFastFramerate()
{
DEBUG_MSG("Setting fast framerate\n");
// We are about to start a transition so speed up fps
targetFramerate = TRANSITION_FRAMERATE;
ui.setTargetFPS(targetFramerate);
setInterval(0); // redraw ASAP
}
void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{ {
displayedNodeNum = 0; // Not currently showing a node pane displayedNodeNum = 0; // Not currently showing a node pane
@ -1100,9 +1111,7 @@ int Screen::handleStatusUpdate(const meshtastic::Status *arg)
switch (arg->getStatusType()) { switch (arg->getStatusType()) {
case STATUS_TYPE_NODE: case STATUS_TYPE_NODE:
if (nodeDB.updateTextMessage || nodeStatus->getLastNumTotal() != nodeStatus->getNumTotal()) { if (nodeDB.updateTextMessage || nodeStatus->getLastNumTotal() != nodeStatus->getNumTotal()) {
setFrames(); // Regen the list of screens setFrames(); // Regen the list of screens
prevFrame = -1; // Force a GUI update
setInterval(0); // Update the screen right away
} }
nodeDB.updateGUI = false; nodeDB.updateGUI = false;
nodeDB.updateTextMessage = false; nodeDB.updateTextMessage = false;

Wyświetl plik

@ -219,6 +219,9 @@ class Screen : public concurrency::OSThread
/// Rebuilds our list of frames (screens) to default ones. /// Rebuilds our list of frames (screens) to default ones.
void setFrames(); void setFrames();
/// Try to start drawing ASAP
void setFastFramerate();
/// Called when debug screen is to be drawn, calls through to debugInfo.drawFrame. /// Called when debug screen is to be drawn, calls through to debugInfo.drawFrame.
static void drawDebugInfoTrampoline(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y); static void drawDebugInfoTrampoline(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);