Close

shiftOut ported to MicroPython Viper

A project log for IMTAIDKW - ESP12 4-digit display

I made this and I don't know why

ArAr 07/09/2017 at 16:200 Comments
@micropython.viper
def shiftOut(data: int):
    GPIO_OUT = ptr32(0x60000300) # GPIO base register
    GPIO_OUT[2] = 0x10 # clear pin 4
    for i in range(8):
        value = data & 1<<i #Is bit set or cleared?
        reg = 2-(value >>i) #Selecting set or clear register - clear reg is 2, set reg is 1
        GPIO_OUT[reg] = 0x8000 #set or clear data bit
        GPIO_OUT[1] = 0x20 # set bit 5
        GPIO_OUT[2] = 0x20 # clear bit 5
instead of
def shiftOut(byte):
    latch.off()
    for i in range(8):
        value = byte & 1<<i #Is bit set or cleared?
        data.value(value)
        clock.on()
        clock.off()
Is it going to be faster? IDK, I asked about it on MicroPython forums to figure out - and also to make sure there are more Google-able examples of toggling GPIOs from Viper code. New example is here: https://github.com/CRImier/IMTAIDKW/blob/master/software/test_viper.py

Discussions