Skip to content

Latest commit

 

History

History
32 lines (20 loc) · 1.21 KB

Best-Practises.md

File metadata and controls

32 lines (20 loc) · 1.21 KB

Best practises for developing on RuuviTracker with MicroPython

Coroutines & generators FTW

Read the following

Many list-comprehensions can be written as generator expressions, this saves memory (and increases performance).

Some OOP patterns can be reworked to be coroutines, this may increase performance (and save memory).

Preallocate memory for exceptions in interrupt handlers

This will make debugging easier, add to boot.py

import micropython
micropython.alloc_emergency_exception_buf(100)

See MicroPython documentation for more info.

Reloading modules

Re-importing will not (usually) work, best way is to use ctrl-D in the REPL to do a soft reboot, this keeps all connections (terminal and flash-drive) intact but clears Python memory. NOTE: this does not reset GPIOs either so if your module initializations make assumptions about GPIO status' after reset you will be in a world of pain.