/* KE0WPC 2 m CW beacon - compile-time configuration
 *
 * Everything the beacon does is fixed here at build time. There is no menu,
 * no VFO, no keypad entry. Change a value, rebuild, reflash.
 *
 * Licensed under the Apache License, Version 2.0, carrying forward the
 * copyright of DualTachyon / egzumer / F4HWN whose drivers this uses.
 */

#ifndef BEACON_CONFIG_H
#define BEACON_CONFIG_H

/* ------------------------------------------------------------------ */
/* IDENTITY - locked                                                   */
/* ------------------------------------------------------------------ */

/* Your callsign. Sent in CW at the start of every cycle. */
#define BEACON_CALLSIGN         "KE0WPC"

/* Full CW identification string sent each cycle.
 * "/B" is the conventional suffix for a beacon station.
 * Grid square: EN14 covers the Brookings / Toronto SD area. Verify yours
 * before you deploy - a wrong grid in a propagation beacon is worse than
 * no grid at all. */
#define BEACON_ID_TEXT          BEACON_CALLSIGN "/B EN14"

/* ------------------------------------------------------------------ */
/* FREQUENCY - locked                                                  */
/* ------------------------------------------------------------------ */

/* Units are 10 Hz, matching the BK4819 driver.
 * 14427700 = 144.2770 MHz */
#define BEACON_FREQ_10HZ        14427700u

/* Optional fine trim in 10 Hz units, applied on top of BEACON_FREQ_10HZ.
 * The UV-K5 reference oscillator is a plain crystal, not a TCXO, so expect
 * to be a couple of ppm off and to drift with temperature. Measure against
 * a known-good reference and correct here. +1 = +10 Hz. */
#define BEACON_FREQ_TRIM_10HZ   0

/* Hard guard rails. The build fails outright if the frequency above is not
 * inside the US 2 m propagation-beacon segment (144.275 - 144.300 MHz),
 * which is where 97.203 permits automatically controlled beacon operation. */
#define BEACON_GUARD_LOWER      14427500u
#define BEACON_GUARD_UPPER      14430000u

/* ------------------------------------------------------------------ */
/* TIMING                                                              */
/* ------------------------------------------------------------------ */

/* CW speed, words per minute. Dot length = 1200 / WPM milliseconds.
 * 12-15 WPM is typical for a beacon; slower copies better under
 * marginal conditions. */
#define BEACON_WPM              12

/* Steady unmodulated carrier after the ID, in seconds. This is what
 * distant stations actually measure. 0 disables it. */
#define BEACON_CARRIER_SEC      10

/* Silent gap between cycles, in seconds.
 * This is your duty cycle control. The UV-K5 was never designed for
 * continuous transmit - see the duty cycle note in beacon.c. */
#define BEACON_GAP_SEC          30

/* Seconds to wait at power-on before the first transmission. Gives you
 * time to confirm the antenna is connected, and time to abort. */
#define BEACON_ARM_DELAY_SEC    10

/* ------------------------------------------------------------------ */
/* RF                                                                  */
/* ------------------------------------------------------------------ */

/* 0 = low, 1 = mid, 2 = high.
 * Low is strongly recommended for unattended duty. High on a UV-K5 is
 * roughly 5 W and the PA has no heatsink worth the name. */
#define BEACON_POWER_LEVEL      0

/* Extra safety clamp on the PA bias register, 0-255. The calibrated bias
 * read from EEPROM is capped at this value. 255 disables the clamp. */
#define BEACON_BIAS_CLAMP       255

/* Keying envelope shaping. The BK4819 has no CW keying circuit, so we ramp
 * the PA bias in steps to soften the edges and cut key clicks.
 * Total rise/fall time = STEPS * STEP_US microseconds. */
#define BEACON_RAMP_STEPS       16
#define BEACON_RAMP_STEP_US     250   /* 16 * 250 us = 4 ms rise and fall */

/* 1 = also drop the PA enable line between elements for a deeper key-up
 * notch. 0 = bias ramp only (slightly faster, tiny bit of carrier leak). */
#define BEACON_HARD_KEY         1

/* ------------------------------------------------------------------ */
/* SAFETY                                                              */
/* ------------------------------------------------------------------ */

/* Refuse to transmit below this battery voltage, in units of 10 mV.
 * 660 = 6.60 V. Set to 0 to disable the check. */
#define BEACON_LOW_BATT_10MV    660

/* 1 = pressing any key halts the beacon permanently until power cycle. */
#define BEACON_KEY_ABORT        1

/* ------------------------------------------------------------------ */
/* Build-time enforcement                                              */
/* ------------------------------------------------------------------ */

_Static_assert(BEACON_FREQ_10HZ >= BEACON_GUARD_LOWER &&
               BEACON_FREQ_10HZ <  BEACON_GUARD_UPPER,
               "BEACON_FREQ_10HZ is outside the 2 m beacon segment "
               "(144.275-144.300 MHz). Refusing to build.");

_Static_assert(sizeof(BEACON_CALLSIGN) > 3,
               "BEACON_CALLSIGN must be set to a real callsign.");

_Static_assert(BEACON_WPM >= 5 && BEACON_WPM <= 40,
               "BEACON_WPM out of sane range.");

_Static_assert(BEACON_POWER_LEVEL <= 2,
               "BEACON_POWER_LEVEL must be 0, 1 or 2.");

#endif /* BEACON_CONFIG_H */
