# generateur
res = sum((i**2 for i in range(10000)))
print(res)

t1 = pyb.micros()
res = sum((i**2 for i in range(10000)))
print(pyb.micros() - t1)


# timers
tim = pyb.Timer(4, freq=1)
tim.callback(lambda x: print("coucou"))
tim.deinit()

# interruption
cb = lambda x: print("toi")
extint = pyb.ExtInt("B3", pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_UP, cb)
extint.disable()

# python advanced
class C(object):
    def __init__(self):
        self._x = None
    def __call__(self):
        print("Called")
    @property
    def x(self):
        """I'm the 'x' property."""
        return self._x
    @x.setter
    def x(self, value):
        self._x = value
    @x.deleter
    def x(self):
        del self._x

# Analog:
xin = pyb.Pin("A7")
x = pyb.ADC(xin)
x.read()

# HID
hid = pyb.USB_HID()
buf = bytearray(4)