Accessing the row pins for LED display
Accessing the row pins for LED display
Is it possible to access the pins for the rows of the LED display to allow direct, low-level control of the LED screen after a display_off(), of course? The columns appear to be available as microbit.pinX but I've not worked out how to access the rows.
Re: Accessing the row pins for LED display
My understanding is that the column pins are available because they are also shared with the edge connector.
If you want to access the row pins you can do so via machine.mem32 to read and write the pin registers directly... (not fun, but also once you've got it working it's very simple).
e.g. this does pin 13, but you can look up the nrf51822 reference manual for the other addresses and bits to set for the row pins (although you might also have to set the pin mode).
Code: Select all
# pin13 = 1
machine.mem8[0x5000050a] |= 0b10000000
# pin13 = 0
machine.mem8[0x5000050e] |= 0b10000000
Re: Accessing the row pins for LED display
Thanks for the info. It reminds me of the days of peek and poke!
Re: Accessing the row pins for LED display
On a V1 micro:bit I had some success with this for driving directly one physical row (2nd one from top).
I realise this all changes on V2 with the 5x5 electrical layout rather than the 3x9.
Code: Select all
MicroPython v1.9.2-34-gd64154c73 on 2017-09-01; micro:bit v1.0.1 with nRF51822
Type "help()" for more information.
>>>
>>> import machine
>>> import microbit
>>> display.off()
>>> OUTSET = 0x50000508
>>> OUTCLR = 0x5000050c
>>> OUT = 0x50000504
>>> machine.mem32[OUTSET] = 0b1000000000000000 # turn on ROW3
>>> machine.mem32[OUTCLR] = 0b0110000000000000 # turn off ROW1 ROW2
>>> machine.mem32[OUTCLR] = 0b0001111111110000 # all LED on
>>> machine.mem32[OUTSET] = 0b0001000001110000 # clear LEDs not in physical row
>>> machine.mem32[OUT] = machine.mem32[OUT] & 0xfffff07f | (0b11111 << 7) # off
>>> machine.mem32[OUT] = machine.mem32[OUT] & 0xfffff07f | (0b00000 << 7) # on