kopia lustrzana https://github.com/micropython/micropython-lib
pyb: First cut at implementing "pyb" micropython module emulation for Linux.
rodzic
9f4f3ca261
commit
523282758a
|
@ -0,0 +1,21 @@
|
|||
class LED:
|
||||
|
||||
def __init__(self, id):
|
||||
self.f = open("/sys/class/leds/%s/brightness" % id, "r+b")
|
||||
|
||||
def on(self):
|
||||
self.f.write(b"255")
|
||||
|
||||
def off(self):
|
||||
self.f.write(b"0")
|
||||
|
||||
def get(self):
|
||||
self.f.seek(0)
|
||||
return int(self.f.read())
|
||||
|
||||
def toggle(self):
|
||||
v = self.get()
|
||||
if v:
|
||||
self.off()
|
||||
else:
|
||||
self.on()
|
Ładowanie…
Reference in New Issue