1# test machine.Signal class 2 3try: 4 try: 5 import umachine as machine 6 except ImportError: 7 import machine 8 machine.PinBase 9 machine.Signal 10except: 11 print("SKIP") 12 raise SystemExit 13 14 15class Pin(machine.PinBase): 16 def __init__(self): 17 self.v = 0 18 19 def value(self, v=None): 20 if v is None: 21 return self.v 22 else: 23 self.v = int(v) 24 25 26# test non-inverted 27p = Pin() 28s = machine.Signal(p) 29s.value(0) 30print(p.value(), s.value()) 31s.value(1) 32print(p.value(), s.value()) 33 34# test inverted, and using on/off methods 35p = Pin() 36s = machine.Signal(p, invert=True) 37s.off() 38print(p.value(), s.value()) 39s.on() 40print(p.value(), s.value()) 41