Loading...
Searching...
No Matches
beats.c File Reference

Pure swatch .beats math, host-testable off-device. More...

#include "clock/beats.h"
#include "math/scale.h"
#include <string.h>

Functions

int beats_from_ms (int32_t ms_into_bmt_day)
 Calculates swatch internet time in .beats (0..999) for a given ms.
uint32_t ms_until_next_beat (int32_t ms_into_bmt_day)
 Calculates milliseconds until the next .beats boundary.
int32_t beats_ms_from_hms (int hour, int minute, int second, uint16_t ms)
 Milliseconds into the Biel Mean Time day, from a UTC wall clock.
static int token_at (const char *text)
bool beats_has_token (const char *format)
 Whether a date format asks for a .beats reading.
void beats_expand_token (char *text, int beats)
 Overwrite every BEATS_TOKEN in a string with a three digit .beats reading.

Detailed Description

Pure swatch .beats math, host-testable off-device.

Function Documentation

◆ token_at()

int token_at ( const char * text)
static

Where the first .beats token starts in a string, or -1 when there is none. The token is three fixed characters, so a plain walk finds it with strncmp, which the firmware already exports. strstr is not exported, so it would link about 1.4 KB of newlib into every face that references the date readout.

Parameters
textThe string to search.
Returns
The offset of the first token, or -1 when there is none.