The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
#!/usr/bin/env python3
"""Writes main/ui/habitat/arc_geometry.inc: the curved labels' fixed-point sin/cos (Q14, no runtime trig).
python3 devices/harness-device/firmware/scripts/gen_arc_geometry.py [--check]
--check regenerates in memory and exits non-zero when the committed file differs.
arc_trig steps by half a mono cell (7.5 px of arc) and serves the GeistMono labels; arc_prop_trig steps by
1 px of arc and serves the proportional ones, which interpolate between entries. Both are on the 205 px
radius. Pure standard library; the first table reproduces the file as it was before this script.
"""
import math
import sys
from pathlib import Path
RADIUS = 205
COLS, CELL = 26, 15
# Half of the 390 px a proportional label may span (COLS * CELL), plus the glyph half-width and the
# interpolation neighbour: 213 entries, 0..212 px.
PROP_STEPS = 213
def table(name, count, step, cols):
rows = ''.join(f' {{{round(math.sin(i * step / RADIUS) * 16384)}, '
f'{round(math.cos(i * step / RADIUS) * 16384)}}},\n' for i in range(count))
return f'static const int16_t {name}[{cols}][2] = {{\n{rows}}};\n'
def render():
return ('// Generated by scripts/gen_arc_geometry.py. Do not edit.\n'
'// Generated fixed-point sin/cos for half-cell steps on the 205 px title radius.\n'
'// angle = index * (15 / 2 / 205) radians; Q14. No runtime trigonometry.\n'
+ table('arc_trig', COLS, CELL / 2, 'HT_ARC_COLS') +
'// The proportional labels: angle = index / 205 radians (1 px of arc length per entry), Q14.\n'
f'enum {{ ARC_PROP_TRIG = {PROP_STEPS} }};\n'
+ table('arc_prop_trig', PROP_STEPS, 1, 'ARC_PROP_TRIG'))
def main():
path = Path(__file__).resolve().parents[1] / 'main/ui/habitat/arc_geometry.inc'
if '--check' in sys.argv[1:]:
if not path.exists() or path.read_text() != render():
sys.exit(f'{path.name} is stale: run scripts/gen_arc_geometry.py')
print('arc_geometry.inc up to date')
return
path.write_text(render())
if __name__ == '__main__':
main()