#pragma once #include #include "logic/display_controller.h" // The relay that powers the panels and the Nano, and the serial link to the Nano. class NanoLink : public DisplayPower { public: NanoLink(HardwareSerial &serial, int rx_pin, int tx_pin, int relay_pin, int reset_pin); // Set up the pins; the display starts switched off void begin(); // The serial port to the Nano (for the BROSE9323 driver) Stream &stream(); bool isOn() override; // Switch on, then wait for the Nano's READY (or NANO_BOOT_TIMEOUT) void on() override; // Switch off and release the TX pin void off() override; // For flashing: restart the Nano so its bootloader runs, and talk to it at `baud` void startBootloader(uint32_t baud); private: HardwareSerial &_serial; const int _rx_pin, _tx_pin, _relay_pin, _reset_pin; bool _on = false; void _beginSerial(uint32_t baud); void _drain(); void _waitForReady(); };