pimoroni / phat-beat

Python library for PHAT BEAT - A stereo DAC, AMP and VU for the Raspberry Pi
https://shop.pimoroni.com/products/phat-beat
MIT License
99 stars 28 forks source link

Defer setup to avoid module import-time side-effects #14

Closed Gadgetoid closed 6 years ago

Gadgetoid commented 7 years ago

This PR makes several "friendly neighbour" changes to the pHAT BEAT library:

See here for details of the problems import-time side-effects can have: https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=193502&p=1212488#p1212488

Gadgetoid commented 6 years ago

Needs to drop ensure_setup() and just have setup() set an _is_setup flag and not run any of the actual setup routines twice. The current method is unnecessarily convoluted.