| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- #pragma once
- // Board- and application-wide configuration.
- //
- // Wi-Fi credentials, the outdoor sensor URL, the timezone and the NTP server
- // are runtime settings held in NVS and entered through the setup portal — see
- // src/settings.h and src/portal.h. The values below are compile-time
- // constants and safe to commit.
- // ---------------------------------------------------------------- display ---
- // The panel is a 300 x 400 ST7305 reflective LCD. The application runs it
- // rotated (U8G2_R1), so the drawing surface is 400 wide by 300 high.
- #define LCD_NATIVE_WIDTH 300
- #define LCD_NATIVE_HEIGHT 400
- #define DISPLAY_WIDTH 400
- #define DISPLAY_HEIGHT 300
- #define RLCD_SCK_PIN 11
- #define RLCD_MOSI_PIN 12
- #define RLCD_DC_PIN 5
- #define RLCD_CS_PIN 40
- #define RLCD_RST_PIN 41
- #define RLCD_TE_PIN 6 // tearing effect output, unused
- // Layout: top 60% is time + date, bottom 40% is indoor | outdoor.
- #define LAYOUT_SPLIT_Y 180
- #define LAYOUT_MID_X 200
- // ------------------------------------------------------------------- i2c ---
- #define I2C_SDA_PIN 13
- #define I2C_SCL_PIN 14
- #define I2C_FREQ_HZ 400000
- #define PCF85063_ADDR 0x51
- #define SHTC3_ADDR 0x70
- // BH1750 ambient light sensor, wired to the same bus on the expansion header.
- // Optional: without it the display falls back to quiet hours from the clock.
- // The part answers on 0x23 with ADDR low and 0x5C with ADDR high; both are
- // probed at boot.
- #define BH1750_ADDR_LOW 0x23
- #define BH1750_ADDR_HIGH 0x5C
- // --------------------------------------------------------------- battery ---
- // 18650 voltage divider, per the vendor's 03_ADC_Test: ADC1 channel 3 with a
- // 1:3 divider, so the measured millivolts are multiplied by three.
- #define BATTERY_ADC_PIN 4
- #define BATTERY_DIVIDER 3.0f
- #define BATTERY_SAMPLES 16 // oversampling per reading
- #define BATTERY_READ_MS 60000UL
- // --------------------------------------------------------------- buttons ---
- // Both onboard buttons are active low. KEY is the application button; BOOT is
- // avoided because holding it at reset also enters the ROM download mode.
- #define KEY_BUTTON_PIN 18
- #define BOOT_BUTTON_PIN 0
- // Hold KEY for this long during power-up to force the setup portal.
- #define KEY_FORCE_SETUP_MS 1500
- // ------------------------------------------------------------------ time ---
- // Defaults for a freshly erased device; both are editable in the setup portal.
- #define NTP_SERVER_1 "pool.ntp.org"
- #define NTP_SERVER_2 "time.google.com"
- // POSIX TZ string for Australia/Hobart (AEST-10, AEDT from Oct to Apr).
- #define TIMEZONE_POSIX "AEST-10AEDT,M10.1.0,M4.1.0/3"
- // Clock and date presentation defaults; all three are editable in the setup
- // portal. DATE_FORMAT is a strftime(3) string — "%A %e %B" is "MONDAY 24
- // AUGUST".
- #define CLOCK_24H_DEFAULT true
- #define DATE_FORMAT "%A %e %B"
- #define DATE_UPPERCASE_DEFAULT true
- // ----------------------------------------------------------------- setup ---
- // Soft-AP the device raises when it has nothing to connect to. The password
- // must be at least 8 characters or the AP comes up open.
- #define SETUP_AP_SSID "TempDisplay-Setup"
- #define SETUP_AP_PASSWORD "temp1234"
- #define DEVICE_HOSTNAME "temp-display"
- // ------------------------------------------------------------ power save ---
- // 80 MHz is the lowest the ESP32-S3 can run with Wi-Fi active and leaves the
- // 80 MHz APB clock — and so the display SPI — untouched.
- #define CPU_FREQ_MHZ 80
- // Defaults for the power-saving settings, all editable in the setup portal.
- #define SHOW_BATTERY_DEFAULT true
- #define SLEEP_WHEN_DARK_DEFAULT true
- #define PANEL_LOW_POWER_DEFAULT true
- #define DARK_LUX_DEFAULT 5 // below this the room is unreadable
- #define QUIET_START_HOUR_DEFAULT 23 // used only when no sensor is fitted
- #define QUIET_END_HOUR_DEFAULT 6
- // Hysteresis, so a flickering or marginal reading cannot chatter the display
- // in and out of sleep. Waking needs a clearly brighter room than sleeping.
- #define DARK_LUX_HYSTERESIS 3.0f
- // While asleep in a dark room, wake this often to re-check the light level.
- // Short enough that the clock is at most one minute stale when the lights come
- // on, long enough that the duty cycle is well under 1%.
- #define DARK_RECHECK_MS 20000UL
- // -------------------------------------------------------------- intervals ---
- #define WIFI_CONNECT_TIMEOUT_MS 20000UL // give up on a connect attempt
- #define WIFI_RETRY_MS 60000UL // then retry this often
- #define NTP_RESYNC_MS (6UL * 60UL * 60UL * 1000UL)
- #define INDOOR_READ_MS 30000UL
- #define OUTDOOR_POLL_MS 30000UL
- #define OUTDOOR_STALE_MS (10UL * 60UL * 1000UL) // mark reading stale
- #define DISPLAY_TICK_MS 1000UL // check-for-change rate
- // ---------------------------------------------------------------- outdoor ---
- // HTTP timeout for one outdoor poll.
- #define OUTDOOR_HTTP_TIMEOUT_MS 5000
- // Plausible temperature range; readings outside it are rejected.
- #define TEMP_MIN_VALID -50.0f
- #define TEMP_MAX_VALID 80.0f
- // Optional development conveniences. include/secrets.h is gitignored; when it
- // exists its values seed a freshly erased device so a bench unit does not need
- // to be re-provisioned through the portal after every flash erase.
- #if __has_include("secrets.h")
- #include "secrets.h"
- #endif
|