mcauser / micropython-max7219

MicroPython driver for MAX7219 8x8 LED matrix modules, cascadable and with framebuf
MIT License
182 stars 57 forks source link

"shutdown()" and "normal()" functions #6

Closed vdbpeter closed 5 years ago

vdbpeter commented 5 years ago

The Maxim Max7219 Datasheet has some good use cases in the "Shutdown Mode" paragraph.

mcauser commented 5 years ago

For ones like this, I usually use a single method with a boolean arg, eg.

def power_on(self, on=True):
    self._write(_SHUTDOWN, 0 if on else 1)

Later, when I'm reading a power_on(), I find it more clear what's going on than seeing a normal().

vdbpeter commented 5 years ago

Yes- your construct is more elegant! :-)