fl { PropForth 5.5 P0-P7 --- CharliePlexing 8x8DotMatrix P8 ------ buzzar P9 ------ SW P10 ------ PhotoTransistor(NJL7502L) 3.3V ----- 3.3V GND ------ GND Curcuit between PhotoTransistor(NJL7502L) and P10 collector -------sw(Normal open) ---3.3V emitter ---------NonInvert Amp(LM358)[Av=2.2]--- Propeller P10 | 200kohm | GND 2015/01/26 21:03:17 } \ Drive 8x8-LED-Matrix curcuit for Charlieplexing by assembler-word \ It takes about 16msec displaying 8-lines. \ ( n1 -- ) n1:address of 8x8-Matrix buffer lockdict create _matrix_Charlie_asm forthentry $C_a_lxasm w, h12E h113 1- tuck - h9 lshift or here W@ alignl h10 lshift or l, z2WyPW8 l, z2WiPfg l, z2WiPmB l, z2Wyxj0 l, z2WyxW0 l, z1Sy\Ka l, z2WixZD l, z2Wyxmy l, z2WiPve l, z20iPyk l, z3ryPr0 l, ziPuE l, z2[iQ3F l, z24yQ01 l, z2WixZG l, z1Sy\Ka l, zfyPb1 l, z20yPj1 l, z3[yP[M l, z1SV04J l, z2WiPvf l, z20iPyk l, z3ryPr0 l, z1SV000 l, z38 l, zJY0 l, z1 l, freedict \ ( n1 -- n2 ) n1:dummy n2:upper 4bit is [P0-P7] lower 4bit is scr# lockdict create _photoTr1_asm forthentry $C_a_lxasm w, h138 h113 1- tuck - h9 lshift or here W@ alignl h10 lshift or l, z2WyPW8 l, z2WiPfp l, z2Wyxj0 l, z2WyxW0 l, z1Sy]Ki l, z2WixZD l, z2Wyxmy l, z2WiPvm l, z20iPyk l, z3ryPr0 l, z2WyPj1 l, z2[iPuE l, z24yPr1 l, z2WixZF l, z1Sy]Ki l, z2WiQ4q l, z1YiQ7l l, z1SQ04c l, z2WiPRE l, zfyPO8 l, z1biPRD l, z1SV04h l, zfyPj1 l, z1YVPmy l, z1SL04U l, zfyPb1 l, z3[yP[L l, z1SV01X l, z2WiPvo l, z20iPyk l, z3ryPr0 l, z1SV000 l, z1[ l, z33K0 l, z1w0 l, z1 l, zG0 l, freedict \ =========================================================================== \ Constants \ =========================================================================== h1F8 wconstant ctra h1FA wconstant frqa 8 wconstant buzzar d10 wconstant photoTr photoTr >m constant photoTrm \ =========================================================================== \ Variables \ =========================================================================== \ Buffer for 8x8 LED-Matrix variable matrix 4 allot \ =========================================================================== \ Main \ =========================================================================== \ Clear matrix buffer \ ( -- ) : clr_matrix 0 matrix L! 0 matrix 4+ L! ; \ Buzzar \ ( n1 n2 -- ) n1:time n2:FRQA value : tone \ Set NCO/PWM single-ended mode h10000000 buzzar or ctra COG! frqa COG! delms 0 frqa COG! ; : lightpen clr_matrix begin \ Sense position of lightpen 0 _photoTr1_asm 0 dira COG! 0 outa COG! dup 0 <> if \ Buzzer buzzar pinout d50 d107374 tone \ Calculate dot-position dup 8 rshift swap hFF and 8 0 do dup 1 i lshift and if drop i 8 seti then loop matrix + C! \ Display matrix c" matrix _matrix_Charlie_asm" 0 cogx 1000 delms 0 cogreset clr_matrix else drop then fkey? swap drop until ; { \ Driver for 8x8-Matrix-LED by Charlieplexing \ Using P0 - P7 \ Top pin for drive is P0 \ Phototransistor pin is P10 \ $C_treg1:loop counter \ $C_treg2:SCR drive data \ $C_treg3:bit data \ ( n1 -- n2 ) n1:dummy n2:upper 4bit is [P0-P7] lower 4bit is scr# fl build_BootOpt :rasm mov $C_treg1 , # 8 mov $C_treg2 , __scr __1 \ Set from P0 to P7 to Hi-Z (All LEDs off) mov dira , # 0 \ Set data to 0 mov outa , # 0 \ Wait to drive next SCR jmpret __delayret , # __delay \ each SCR on mov outa , $C_treg2 mov dira , # hFF mov $C_treg4 , __1.25usec add $C_treg4 , cnt waitcnt $C_treg4 , # 0 \ Set data mov $C_treg3 , # 1 __2 neg $C_treg4 , $C_treg3 sub $C_treg4 , # 1 mov outa , $C_treg4 \ Delay 1msec jmpret __delayret , # __delay mov $C_treg5 , __photomask and $C_treg5 , ina wz if_z jmp # __3 mov $C_stTOS , $C_treg3 shl $C_stTOS , # 8 or $C_stTOS , $C_treg2 jmp # __exit __3 shl $C_treg3 , # 1 test $C_treg3 , # hFF wz if_nz jmp # __2 shl $C_treg2 , # 1 djnz $C_treg1 , # __1 __exit jexit __delay mov $C_treg4 , __100usec add $C_treg4 , cnt waitcnt $C_treg4 , # 0 __delayret ret \ This value must be adjust when changing SCR __1.25usec d100 __100usec d8000 __scr 1 __photomask h400 ;asm _photoTr1_asm }