Skip to content

Instantly share code, notes, and snippets.

@Beormund
Beormund / persist.py
Last active August 1, 2022 11:06
Simple micropython module to persist dictionary data to flash and automatically load from flash on restart/import. Tested for RP2 Pico W
import json
persist = None
class Persist(object):
__persist = None
__filename = '__persist__.json'
__p = {}
def __new__(self, d = None):
@Beormund
Beormund / daylightsaving.py
Last active November 12, 2023 09:16
Micropython module for converting UTC to local time using daylight saving policies.
import utime
# hemisphere [0 = Northern, 1 = Southern]
# week [0 = last week of month, 1..4 = first..fourth]
# month [1 = January; 12 = December]
# weekday [0 = Monday; 6 = Sunday] (day of week)
# hour (hour at which dst/std changes)
# timezone [-780..780] (offset from UTC in MINUTES - 780min / 60min=13hrs)
class Policy:
def __init__(self, hemisphere, week, month, weekday, hour, timezone):