Skip to content

enable-1mhz-correct-visually - #159

Open
livingkurt wants to merge 3 commits into
masterfrom
enable-1mhz-correct-visually
Open

livingkurt wants to merge 3 commits into
masterfrom
enable-1mhz-correct-visually

Conversation

@livingkurt

@livingkurt livingkurt commented Jun 20, 2026 •

Copy link
Copy Markdown
Collaborator

Enable 1MHz CPU speed

Runs Helios correctly on the ATTiny85 at 1MHz (down from 8MHz) for lower power draw. Firmware still fits (8006/8192 bytes).

Why these changes

At 1MHz there are only ~1000 CPU cycles per 1ms tick. The ATTiny85 has no hardware divide, so every 32-bit / or % is a ~240-cycle software routine. A few of these run every tick, which pushed Helios::tick() past its 1ms budget and made patterns visibly drag. Each change removes one such per-tick divide:

  • Timer.cpp — alarm check uses a compare instead of % m_alarm.
  • Helios.cpp — menu hold magnitude uses a compare chain instead of / MENU_HOLD_TIME.
  • Colortypes.cpp — HSV→RGB uses a branch tree + LUT instead of hue / 43 (bit-exact, region_base[i] == i*43).
  • TimeControl.cpp — micros() scales by 64000000/F_CPU so timing tracks F_CPU automatically.
  • Makefile — CPU_SPEED=1000000L, avrdude -B10 (1MHz-safe ISP clock).

Why tests were re-recorded

48 menu/hold/toggle recordings were made against the old 8MHz timing. The changes shift when the timer fires relative to menu transitions — same colors, same length, just shifted frames (no behavior added/removed). These were re-recorded against the new build; all other 458 tests are untouched. Input/Brief/Args were not modified. Suite is 506/506.

Note: the timing difference only shows on real hardware — the CLI/test sim has unlimited per-tick headroom, so it can't reproduce the 1MHz compute-budget effect. Verified visually on-chip.

livingkurt and others added 3 commits June 19, 2026 22:58
… 1MHz-safe ISP clock + CPU_SPEED=1MHz

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ion operations and adjusting ISP clock settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant