digitalsputnik / ApolloFirmware

Micropython software for the Apollo lamps
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Generic Empire_HW_Object #17

Open KKallas opened 2 years ago

KKallas commented 2 years ago

To have standard object and functionalities in a defines structure for various IOs like

Some ideas that should be defined:

interruptCounter = 0 totalInterruptsCounter = 0 connectedPin = 5

def callback(pin): global interruptCounter interruptCounter = interruptCounter + 1

digital = machine.Pin(connectedPin, machine.Pin.IN) digital.irq(trigger=machine.Pin.IRQ_FALLING, handler=callback)

while True: if interruptCounter > 0: state = machine.disable_irq() interruptCounter = interruptCounter - 1 utime.sleep(0.5) #note this is optimised for my specific use case machine.enable_irq(state)

    totalInterruptsCounter = totalInterruptsCounter + 1
    print (str(totalInterruptsCounter), " cyclists have passed.")

- [ ] Toolset for test timing to understand how fast can the rendering loop run