2016-06-19 17:45:29 +01:00
|
|
|
try:
|
2016-07-17 14:30:24 +01:00
|
|
|
import umachine as machine
|
2016-06-19 17:45:29 +01:00
|
|
|
except ImportError:
|
2016-07-17 14:30:24 +01:00
|
|
|
import machine
|
|
|
|
try:
|
|
|
|
machine.PinBase
|
|
|
|
except AttributeError:
|
|
|
|
print("SKIP")
|
|
|
|
import sys
|
|
|
|
sys.exit()
|
2016-06-19 17:45:29 +01:00
|
|
|
|
|
|
|
|
2016-07-17 14:30:24 +01:00
|
|
|
class MyPin(machine.PinBase):
|
2016-06-19 17:45:29 +01:00
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
print("__init__")
|
|
|
|
self.v = False
|
|
|
|
|
|
|
|
def value(self, v=None):
|
|
|
|
print("value:", v)
|
|
|
|
if v is None:
|
|
|
|
self.v = not self.v
|
|
|
|
return int(self.v)
|
|
|
|
|
|
|
|
p = MyPin()
|
|
|
|
|
|
|
|
print(p.value())
|
|
|
|
print(p.value())
|
|
|
|
print(p.value())
|
|
|
|
p.value(1)
|
|
|
|
p.value(0)
|