Everyone, do not let @neil sell you a watch!

He suggested to me that I get a PrimeTime once, and then I fell into a deep hole of programming it with WaspOS and MicroPython for a month or two. Nothing else could hold me interest all through January.

Now I have a one of a kind watch running software nobody else in the world runs and an understanding of tiny memory-footprint constraints in a Micropython environment.

Sure, it's great, but I'll never get that month back.

@falken @neil

Ah, but you don't run the Monolithic Watch Face I made for it or the time-tracking app "Mood" I wrote ;)

Least probably not. It is open on my github but I doubt anyone is using it.

@falken Sure, he's my fork.

github.com/revpriest/pre-wasp-

I do still intend to do a pull request eventually, but there's at least one bug still and seems like the maintainer prefers to have it all in one big chunk than deal with weekly pull requests as I find and fix the tiny things.

Follow

@pre wow that's a full mod! So many features.
Didn't realise Settings used so much RAM. Wonder why. It's only got a half dozen screens with one control on each!

@falken Indeed. Micropython is a memory hog. Just storing a single int variable takes like 16 bytes.

Gotta write it tight to keep memory under control. I ended up allocating a word-array and indexing into that for all my variables.

@pre hmm. I'm new to embed systems.
Is the compiler clever enough that this is a good pattern and saves RAM over using two ints then? Eg it optimises away the two const ints:

vars=[]
const variable_one = 0
const something_else = 1
...
vars[something_else] = do_some_maths(vars[variable_one]

@falken I wouldn't wanna give the impression that I know what I'm doing exactly.

There's a micropython library called "const"

> from micropython import const

It means you can define names that are compile-time reduced without putting the names in the image:

> _FONTNUM = const(0)

You can then define a memory-chunk you need:

> self._wordvars = array.array("H",range(_MAXVARS))

[_MAXVARS is a const defined at the top more than all the others]

Then access them as needed:

> self._wordvars[_FONTNUM] = 0

Then each word-var is 16 bits instead of like 16 bytes even for a bool.

Doing that over having python objects for every variable was the biggest memory-saver.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.