Files
Flipdot-display/src/esp32/config.h
T

69 lines
3.0 KiB
C
Raw Normal View History

#pragma once
// All ESP32 settings. Credentials are in secrets.h (see secrets.example.h).
// Kept free of Arduino types so the logic modules can be tested on the PC.
#include <stdint.h>
// ---------------------------------------------------------------------------
// Pins
// ---------------------------------------------------------------------------
const int LED_PIN = 2; // built-in LED of the ESP32 DevKit v1
const int RELAY_PIN = 13; // powers the panels and the Nano (LOW = on)
// Link to the Nano on UART2. Serial (UART0) stays free for USB / debug output.
const int NANO_RX_PIN = 16; // wired to the Nano TX (through a 5V -> 3.3V divider)
const int NANO_TX_PIN = 17; // wired to the Nano RX
// Optional: GPIO that resets the Nano through an NPN transistor (HIGH = reset), -1 = not wired.
// Needed to flash a Nano with the Optiboot bootloader, which doesn't start after a power cycle.
const int NANO_RESET_PIN = -1;
// ---------------------------------------------------------------------------
// Display and Nano
// ---------------------------------------------------------------------------
const uint8_t DISPLAY_WIDTH = 84;
const uint8_t DISPLAY_HEIGHT = 19;
const uint8_t PANEL_WIDTH = 28;
const uint16_t FLIP_TIME = 225; // flip pulse length in us, sent to the Nano at boot
const uint32_t NANO_BAUD = 115200;
// Max wait for the Nano's READY after power on (also the wait when Nano TX is not wired to our RX)
const uint32_t NANO_BOOT_TIMEOUT = 3000;
// After a frame is cleared, wait this long before cutting the power, so the dots can flip
const uint32_t CLEAR_BEFORE_OFF_TIME = 1000;
// Power off this long after the display is no longer needed (night, standby, logo)
const uint32_t POWER_OFF_DELAY = 30000;
// ---------------------------------------------------------------------------
// Flashing the Nano over WiFi (see README.md, pio run -e nano_ota -t upload)
// ---------------------------------------------------------------------------
const uint16_t NANO_FLASH_PORT = 2323;
// The bootloader baud rate is chosen by the uploader (57600 old bootloader, 115200 Optiboot)
const uint32_t NANO_POWER_OFF_TIME = 1000; // relay off time to make sure the Nano resets
const uint32_t NANO_RESET_DELAY = 200; // after power on, before the reset pulse
const uint32_t NANO_RESET_PULSE = 50;
// ---------------------------------------------------------------------------
// Network, time and Home Assistant
// ---------------------------------------------------------------------------
#define HOSTNAME "FlipDotDisplay"
// Europe/Amsterdam
#define TIMEZONE "CET-1CEST,M3.5.0,M10.5.0/3"
#define NTP_SERVER "pool.ntp.org"
// After a crash or unexpected reset, only run OTA for this long before starting the
// main code, so a firmware that crashes at boot can still be replaced
const uint32_t OTA_PANIC_WINDOW = 15000;
// Home Assistant device id (do not change: Home Assistant's entities are linked to it)
const uint8_t HA_DEVICE_ID[] = {0x34, 0x86, 0x5d, 0x3a, 0x08, 0x28};
#define HA_DEVICE_NAME "FlipDotDisplay"
#define HA_SOFTWARE_VERSION "2.0.0"