Files
wadamesh/src
Kaj SchittecatandClaude Opus 5 0ad28ce7db feat(lua): wada.sys.epoch, datetime and beep (#245)
pisti87 asked for time and buzzer access from Lua. wada.sys had millis, toast,
board and random -- an app could measure elapsed time but never say what time
it was, and could not make a sound at all.

  wada.sys.epoch()     -> Unix seconds, or nil
  wada.sys.datetime()  -> { year month day hour min sec wday }, or nil
  wada.sys.beep()      -> true if a sound was actually produced

Three decisions worth recording:

nil, not 0, when the clock has never been set. The device genuinely boots
without a clock until GPS, NTP or a mesh peer supplies one, and an app stamping
a log needs to tell "no clock yet" from "1970". Uses the same sane-clock floor
the mesh already applies.

datetime() is LOCAL time, in the timezone the user picked, because every use for
it is display. epoch() stays UTC seconds for arithmetic.

beep() is one chime, not the melody player the issue sketched. What exists is a
single per-board notification chime -- and some boards have no sounder. Routing
Lua through the same uiPlaySlot() the UI uses means an app cannot be louder or
different from the rest of the firmware, and it honours the user's sound setting
instead of overriding it. Returning whether sound actually happened lets an app
fall back to a visual cue rather than silently doing nothing, which a fake
melody API could not.

All 8 S3 envs build -- the beep path is per-board, so that matters here.

Requested by pisti87.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-13 12:26:40 +02:00
..