Files
Flipdot-display/src/esp32/display/status_screen.cpp
T
mangavalkandClaude Opus 5.5 a904615c51 Refresh effect per page
Pages choose their own refresh effect (or the Hardware setting), used when
the page appears and for its own changes. Schedule blocks that switch
instantly and rules still switch instantly. The ESP32 sends page effects
to the Nano with a new no-save flag (E ...,2), so page switches don't wear
the Nano's EEPROM. Page format 7 (version 6 pages are converted).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 16:57:31 +02:00

60 lines
1.5 KiB
C++

#include "display/status_screen.h"
#include <Arduino.h>
#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();
}
}