Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
b73934d
Add $PMTXTS per-PPS host timestamping (opt-in)
peterlewis Jul 4, 2026
5ba7320
SOF-correlation timestamping: latch (USB frame, DWT) for sub-ms PPS o…
peterlewis Jul 7, 2026
1fdbf33
SOF timestamping: audit fixes — valid-gated tail, latch only when pps=on
peterlewis Jul 7, 2026
4d62738
Add astro pack: sun / moon / Maidenhead / lat-lon display modes
peterlewis Jun 30, 2026
e1eeeb8
astro: give LAT/LON a sign slot so negatives keep the label gap
peterlewis Jul 5, 2026
02c9823
astro: configurable per-screen page dwell (page_ms, default 5500 ms)
peterlewis Jul 5, 2026
54d560e
Harden firmware: bounds + ISR-safety fixes from broad audit
peterlewis Jun 30, 2026
aff121d
Fix charger-only-power CDC hard-fault and date-board CMD_LOAD_TEXT OOB
peterlewis Jul 4, 2026
bd112bc
tz: distance-gate the ZoneDetect lookup — kill the 300 ms/second main…
peterlewis Jul 12, 2026
01663f9
Add sidereal (LST) and apparent-solar time-row modes
peterlewis Jul 5, 2026
67f2dfb
sidereal: rename config key alt_colon_mode -> colon_alt_mode
peterlewis Jul 12, 2026
f998de6
astro: subsolar-point helper (sun_subsolar) + shared-series comments
peterlewis Jul 7, 2026
5c8160e
Add self-learning holdover temperature compensation
peterlewis Jul 5, 2026
311e031
Holdover significance-fade + persistent, evolving warm-start temp model
peterlewis Jul 6, 2026
78e0534
Fix significance_fade boot flash: digit_bright defaults to 0 (dashed)…
peterlewis Jul 7, 2026
bfb784a
significance_fade: compute per-digit dash thresholds (duty-mirror wir…
peterlewis Jul 10, 2026
171fef0
tempcomp: MODE_TEMPCOMP pages on page_ms + final enum position
peterlewis Jul 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion mk4-date/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,13 @@ static inline void latchDisplay(void){
buffer_a[3] = pre_buffer_a[3];
buffer_a[4] = pre_buffer_a[4];

// dp_pos is the 1-based digit the decimal point attaches to (0 = none). It comes from
// text_idx, which the sender can advance past the 10-digit display, and it indexes the
// 5-entry buffer_a/buffer_b below. Clamp to each orientation's valid range so a stray or
// garbled '.' in the UART stream can't drive a negative / out-of-range index into RAM.
if (!dp_pos) return;
if (inverted) { if (dp_pos > 9) return; } // inverted: 9-dp_pos goes negative at 10
else { if (dp_pos > 10) return; } // non-inverted: dp_pos-6 tops out at [4]

if (inverted){
if (dp_pos>=5) {
Expand Down Expand Up @@ -601,7 +607,7 @@ static inline void parseByte(uint8_t x){
dp_pos = text_idx;
return;
}
if(text_idx > MAX_TEXT_LEN) return;
if(text_idx >= MAX_TEXT_LEN) return; // was '>': at text_idx==MAX_TEXT_LEN this wrote text[32], 1 byte past the buffer

if (text_idx < 10) setDigitPre(text_idx, x);
text[text_idx++] = x;
Expand Down
55 changes: 55 additions & 0 deletions mk4-time/Core/Inc/astro.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* astro.h — minimal solar/lunar/grid astronomy for the Precision Clock Mk IV.
*
* Self-contained C99 + <math.h>; NO firmware dependencies, so it compiles and
* unit-tests natively (see test_astro.c). All angles in degrees at the API
* boundary; UTC instants are passed as a double of Unix seconds.
*
* Algorithms are low-precision (NOAA/Meeus-class) approximations — accurate to a
* fraction of a degree / a minute or two, which is all a 7-segment readout shows,
* and cheap enough to evaluate once per mode entry on the STM32's soft-double.
*/
#ifndef ASTRO_H
#define ASTRO_H

/* (a) Sun apparent alt/az for an observer at (lat, lon) decimal degrees, N+/E+,
* at the given UTC instant. Writes azimuth in [0,360) measured from North
* clockwise, and elevation in [-90,90] (negative = below the horizon).
* No refraction or parallax correction. */
void sun_az_el(double lat, double lon, double unix_s, double *az, double *el);

/* (b) Sun event times for the UTC calendar day containing unix_s.
* Every output is a decimal UTC hour and MAY be < 0 or > 24 (the event falls
* on the previous/next day) — callers add the local offset and wrap, they do
* NOT clamp. solar_noon is always written. Returns 0 normally; returns
* nonzero on polar day/night (sun never crosses -0.833 deg), in which case
* sunrise/sunset are left untouched and only solar_noon is meaningful.
* Any of the optional twilight pointers may be NULL. */
int sun_times(double lat, double lon, double unix_s,
double *sunrise, double *sunset, double *solar_noon,
double *civil_dusk, double *nautical_dusk, double *golden_dusk);

/* (c) Moon. phase is the synodic fraction [0,1): 0=new, .25=first quarter,
* .5=full, .75=last quarter. */
double moon_phase(double unix_s);
double moon_illuminated_fraction(double phase); /* (1 - cos(2*pi*phase)) / 2 */
int moon_phase_index(double phase); /* 0..7, see ASTRO_MOON_NAMES */

/* (d) Equation of time in minutes (+ = apparent sun ahead of mean/clock sun). */
double equation_of_time(double unix_s);

double local_sidereal_time(double unix_s, double lon); /* LMST, hours [0,24), lon E+ */
double local_solar_time(double unix_s, double lon); /* apparent solar, hours [0,24) */

/* (d2) Subsolar point at the given UTC instant: latitude = solar declination,
* longitude in [-180,180] (E+). Time-only — needs no observer position. */
void sun_subsolar(double unix_s, double *lat, double *lon);

/* (e) 6-character Maidenhead locator for (lat, lon). out must hold >= 7 bytes.
* Writes "----\0" if either coordinate is non-finite. */
void maidenhead(double lat, double lon, char out[7]);

/* Phase-index -> short name. Index from moon_phase_index(). */
extern const char *const ASTRO_MOON_NAMES[8];

#endif /* ASTRO_H */
Loading