#include "display/status_screen.h" #include #include "config.h" #include "display/text.h" StatusScreen::StatusScreen(BROSE9323 &display, NanoLink &nano) : _display(display), _nano(nano), _flip_time(FLIP_TIME) { } void StatusScreen::setDrive(uint16_t flip_time, const DriveSettings &drive, uint16_t dot_refresh) { _flip_time = flip_time; _drive = drive; _dot_refresh = dot_refresh; } void StatusScreen::sendDrive() { // Not sent right away: the Nano could be in its bootloader (flashing) _drive_pending = true; } bool StatusScreen::loop() { if (!_drive_pending || !_started || !_nano.isOn()) return false; _drive_pending = false; _display.setTiming(_flip_time); _display.setGap(_drive.flip_gap); _display.setPulses(_drive.pulses); _display.setEffect(_drive.effect, _drive.effect_time, _drive.effect_small_only ? EFFECT_FLAG_SMALL_ONLY : 0); _display.setRefreshInterval(_dot_refresh); return true; } void StatusScreen::show(const char *line1, const char *line2, bool keep_on) { Serial.printf("Display: %s / %s\n", line1, line2 ? line2 : ""); _nano.on(); if (!_started) { _display.begin(&_nano.stream()); _started = true; _drive_pending = true; loop(); } drawTextLines(_display, line1, line2); _display.display(); if (!keep_on) { // The first frame after power on flips every dot, give the Nano time for that // (a push can take longer, but these messages are short: at worst it is cut off) delay(STATUS_FLIP_TIME + (_drive.effect == DRIVE_EFFECT_INSTANT ? 0 : _drive.effect_time)); _nano.off(); } }