Ok so I got talking to the max7219 down and I can send digits to it to display. So I thought ok I'll try reading in a value from an adc and use the DIG command to isolate and display the digits. HELP...is this another math problem? It won't work
Code:
#picaxe 28x2
setfreq m16
dirsb = %00010000 'b.5 will be a pwm output
dirsc = %10111111 'c.1 and c.2 will be pwm outputs
let adcsetup = %00000000 'let inputs be inputs
hspisetup spimode00,spifast ' set up hspi
' Register addresses for the MAX7219
symbol decode = 9 ' decode register; specify digits to decode
symbol brite = 10 ' intensity (brightness) register; 15 = 100%
symbol scan = 11 ' scan-limit register; specify how many digits
symbol on_off = 12 ' 1 = display on; 0 = display off
symbol blank = 15 ' used by MAX7219 to blank a digit
symbol load = C.0
' Initialize MAX7219
hspiout (scan,5) ' set scan limit for digits 0-5
pulsout load,2
hspiout (brite,5) ' set brightness to 5 (15 = 100%)
pulsout load,2
hspiout (decode,%00111111) ' set BCD decoding for digits 0-5
pulsout load,2
hspiout (on_off,1) ' turn display on
pulsout load,2
main:
'readadc value into byte
readadc b.1,b1
'isolate digits
let b2= b1 dig 2
let b3= b1 dig 1
let b4= b1 dig 0
'send digits to display
hspiout (1,b2)
pulsout load,2
hspiout (2,b3)
pulsout load,2
hspiout (3,b4)
pulsout load,2
readadc b.2, b5
let b6= b1 dig 2
let b7= b1 dig 1
let b8= b1 dig 0
hspiout (4,b6)
pulsout load,2
hspiout (5,b7)
pulsout load,2
hspiout (6,b8)
pulsout load,2
goto main