2026-10-13 01:34:04 +02:00
|
|
|
#include "display/status_screen.h"
|
|
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "display/text.h"
|
|
|
|
|
|
2026-10-13 01:52:34 +02:00
|
|
|
StatusScreen::StatusScreen(BROSE9323 &display, NanoLink &nano) : _display(display), _nano(nano), _flip_time(FLIP_TIME)
|
2026-10-13 01:34:04 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-15 01:29:01 +02:00
|
|
|
void StatusScreen::setDrive(uint16_t flip_time, const DriveSettings &drive)
|
2026-10-13 01:52:34 +02:00
|
|
|
{
|
|
|
|
|
_flip_time = flip_time;
|
2026-10-15 01:29:01 +02:00
|
|
|
_drive = drive;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StatusScreen::sendDrive()
|
|
|
|
|
{
|
|
|
|
|
// Not sent right away: the Nano could be in its bootloader (flashing)
|
|
|
|
|
_drive_pending = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StatusScreen::loop()
|
|
|
|
|
{
|
|
|
|
|
if (!_drive_pending || !_started || !_nano.isOn())
|
|
|
|
|
return;
|
|
|
|
|
_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);
|
2026-10-13 01:52:34 +02:00
|
|
|
}
|
|
|
|
|
|
2026-10-13 01:34:04 +02:00
|
|
|
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;
|
2026-10-15 01:29:01 +02:00
|
|
|
_drive_pending = true;
|
|
|
|
|
loop();
|
2026-10-13 01:34:04 +02:00
|
|
|
}
|
|
|
|
|
drawTextLines(_display, line1, line2);
|
|
|
|
|
_display.display();
|
|
|
|
|
|
|
|
|
|
if (!keep_on)
|
|
|
|
|
{
|
|
|
|
|
// The first frame after power on flips every dot, give the Nano time for that
|
2026-10-15 01:29:01 +02:00
|
|
|
// (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));
|
2026-10-13 01:34:04 +02:00
|
|
|
_nano.off();
|
|
|
|
|
}
|
|
|
|
|
}
|