Scratch registers for Thumby settings

acedent

  • Full Member
  • ***
    • Posts: 14
    • View Profile
Currently the core files make use of the Watchdog timer's scratch register, to store and transfer data between soft-resets.
This allows `menu.py` to launch a game by soft-reseting back to `main.py` with a True `1` flag  set in the first scratch register (0), address `0x40058000+0x0C`.
(More info: https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf  - Section 4.7.6)

My proposal:
I'd like to store 3 other settings in this semi-persistent storage:
`0x40058010` (scratch1) - Hardware ID / HWID (0–15)
`0x40058014` (scratch2) - Brightness level (1–127)
`0x40058018` (scratch3) - Intro /skip scrolling indicator (0,1)

Although these values require less than a byte each, I don't feel it's worth the code overhead to pack them into one 4 byte long register, since we have 8 registers available in total. Update: Cannot use `mem8()` to address each of the four bytes separately, as byte access is aligned to the start address block AFAIK (tested 28-Dec).

Motivation:
- We only need to evaluate the HWID once per session (on hard reset), not on every soft-reset (faster load times).
- We only need to read Contrast once and on change (faster load times).
- Additionally, I'd like to add a 'fast boot' option that skips scrolling and uses the 'scroll indicator', after the first boot.

Would welcome any feedback from TC staff (@Jason) and the community...?


Note: I'm posting here (vs Discord) for visibility and future search/ knowledge repository.
« Last Edit: January 10, 2023, 12:02:48 PM by acedent »



Ben Rose

  • Administrator
  • Hero Member
  • *****
    • Posts: 390
    • View Profile
Hi- thanks for posting over here, unfortunately I haven't been able to directly engage on the Discord channel due to time constraints. I agree this is a pretty good/public/searchable spot for this.

Glad the WDT register usage could be understood! I haven't reviewed everything but the changes all look like they're going in the right direction, we're long past due for a cleanup.. We're a little slow/conservative on changes to avoid breaking things obviously, but I don't see anything I'm too concerned about. I'll check with Jason when he's back in the office next week.

Thanks,
Ben


acedent

  • Full Member
  • ***
    • Posts: 14
    • View Profile
Thanks @Ben.  8)
I will continue to experiment this week on the branch.
You're probably aware it builds on the PR to tweak the core files:
https://github.com/TinyCircuits/TinyCircuits-Thumby-Code-Editor/pull/42


 

SMF spam blocked by CleanTalk