fl { PropForth 5.5 Gradation1 P0-P7 --- CharliePlexing 8x8DotMatrix P8 ------ buzzar P9 ------ SW 3.3V ---- 3.3V GND ----- GND 2015/01/23 13:25:39 } \ =========================================================================== \ Constants \ =========================================================================== variable pic2 -4 allot 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 2 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 2 c, 6 c, 2 c, 0 c, 0 c, 0 c, 0 c, 2 c, 6 c, 16 c, 6 c, 2 c, 0 c, 0 c, 0 c, 0 c, 2 c, 6 c, 2 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 2 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, variable pic3 -4 allot 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 2 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 2 c, 6 c, 2 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 2 c, 6 c, 16 c, 6 c, 2 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 2 c, 6 c, 2 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 2 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, 0 c, \ =========================================================================== \ Variables \ =========================================================================== \ container for 8x8-Matrix table address variable table \ =========================================================================== \ Main \ =========================================================================== lockdict create _gray_scale_asm forthentry $C_a_lxasm w, h13E h113 1- tuck - h9 lshift or here W@ alignl h10 lshift or l, z4i]eB l, z2Wy]jG l, z2Wy]r8 l, z2Wya01 l, z2Wyxj0 l, z2WyxW0 l, z2WiPvv l, z1Sy][l l, z2Wix[r l, z2Wyxmy l, z2WiPvu l, z20iPyk l, z3ryPr0 l, z2Wya88 l, z2WyaG0 l, ziP[o l, z25iP[p l, z1bmaK0 l, zbyaG1 l, z20y]b1 l, z3[yaCY l, z2[iPnt l, z24yPj1 l, z2WixZE l, z2WiPvw l, z1Sy][l l, zfya01 l, z3[y]vN l, z4i]eB l, z3[y]nL l, z1SV04K l, z20iPyk l, z3ryPr0 l, z1SV000 l, 0 l, 0 l, 0 l, 0 l, 0 l, 0 l, z1[ l, zxW l, z1w0 l, freedict \ This pattern don't move \ ( -- ) : demo1 pic2 table W! c" table _gray_scale_asm" 0 cogx begin fkey? swap drop until 0 cogreset ; lockdict create _gray_scale1_asm forthentry $C_a_lxasm w, h14E h113 1- tuck - h9 lshift or here W@ alignl h10 lshift or l, z4ibJB l, z1WybGF l, z4ibRB l, zbybO8 l, z2WiPZB l, z20yPW2 l, z4iPeC l, z2Wib\2 l, zhybW4 l, z24\b\2 l, z20ib\3 l, z20ibZD l, z2Wibg4 l, z2WybjG l, z2Wybr8 l, z2Wyc01 l, z2Wyxj0 l, z2WyxW0 l, z2WiPwC l, z1SybCy l, z2Wix\8 l, z2Wyxmy l, z2WiPwB l, z20iPyk l, z3ryPr0 l, z2Wyc88 l, z2WycG0 l, ziP\5 l, z25iP\6 l, z1bmcK0 l, zbycG1 l, z20ybb1 l, z3[ycCh l, z2[iPoA l, z24yPj1 l, z2WixZE l, z2WiPwD l, z1SybCy l, z20ybb7 l, zfyc01 l, z3[ybvZ l, z2Wibg4 l, z3[ybnX l, z1SV04J l, z20iPyk l, z3ryPr0 l, z1SV000 l, 0 l, 0 l, 0 l, 0 l, 0 l, 0 l, 0 l, 0 l, 0 l, z1[ l, zxW l, z1w0 l, freedict \ This pattern don't move \ ( -- ) : demo2 0 table W! pic3 table 2+ W! c" table _gray_scale1_asm" 0 cogx 8 0 do 8 0 do j 8 lshift i or table W! d100 delms loop loop begin fkey? swap drop until 0 cogreset ; { \ 16 Gray-scale-driver for 8x8-Matrix-LED by Charlieplexing \ Using P0 - P7 \ Top pin for drive is P0(=bit0) \ ( n1 -- ) n1:top address of 8x8-Matrix table(64bytes) fl build_BootOpt :rasm rdword __addr , $C_stTOS __entry \ Repeat level[16] mov __level , # d16 __1 \ Reapet row[8] (scr1 to scr8) mov __row , # 8 mov __scr , # 1 __2 \ 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 mov $C_treg4 , __50usec jmpret __delayret , # __delay \ each SCR on mov outa , __scr mov dira , # hFF mov $C_treg4 , __1.25usec add $C_treg4 , cnt waitcnt $C_treg4 , # 0 \ Making 8bit[8] mov __column , # 8 mov __matrix , # 0 __3 rdbyte $C_treg1 , __addr sub $C_treg1 , __level wc if_nc or __matrix , # h100 shr __matrix , # 1 \ Increment memory address add __addr , # 1 djnz __column , # __3 \ Output 8bit neg $C_treg3 , __matrix sub $C_treg3 , # 1 mov outa , $C_treg3 \ Delay 100usec mov $C_treg4 , __100usec jmpret __delayret , # __delay \ Shift scr 1bit shl __scr , # 1 djnz __row , # __2 rdword __addr , $C_stTOS djnz __level , # __1 jmp # __entry __delay add $C_treg4 , cnt waitcnt $C_treg4 , # 0 __delayret ret \ --- Variables --- \ Address of container __addr 0 \ Gradation data __level 0 \ row counter(scr) __row 0 \ scr data __scr 0 \ loop-counter for making 1byte __column 0 \ 1byte to matrix __matrix 0 \ --- Constants --- \ This value must be adjust when changing SCR __1.25usec d100 __50usec d4000 __100usec d8000 ;asm _gray_scale_asm } { \ 16 Gray-scale-driver for 8x8-Matrix-LED by Charlieplexing \ Using P0 - P7 \ Top pin for drive is P0(=bit0) \ ( n1 -- ) n1:structure of 15x15-Matrix table(225byte) \ n1:upper4bit[y] lower4bit[x] \ n1+1:top address of 15x15-Matrix table(225bytes) fl build_BootOpt :rasm __entry rdword __x , $C_stTOS and __x , # hF rdword __y , $C_stTOS shr __y , # 8 mov $C_treg1 , $C_stTOS add $C_treg1 , # 2 rdword $C_treg2 , $C_treg1 \ base = 15*x + y mov __base , __x shl __base , # 4 wz if_nz sub __base , __x add __base , __y \ base = base v + table_addresss add __base , $C_treg2 mov __addr , __base \ Repeat level[16] mov __level , # d16 __1 \ Reapet row[8] (scr1 to scr8) mov __row , # 8 mov __scr , # 1 __2 \ 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 mov $C_treg4 , __50usec jmpret __delayret , # __delay \ each SCR on mov outa , __scr mov dira , # hFF mov $C_treg4 , __1.25usec add $C_treg4 , cnt waitcnt $C_treg4 , # 0 \ Making 8bit[8] mov __column , # 8 mov __matrix , # 0 __3 rdbyte $C_treg1 , __addr sub $C_treg1 , __level wc if_nc or __matrix , # h100 shr __matrix , # 1 \ Increment memory address add __addr , # 1 djnz __column , # __3 \ Output 8bit neg $C_treg3 , __matrix sub $C_treg3 , # 1 mov outa , $C_treg3 \ Delay 100usec mov $C_treg4 , __100usec jmpret __delayret , # __delay \ Update address add __addr , # 7 \ Shift scr 1bit shl __scr , # 1 djnz __row , # __2 \ Back to __base mov __addr , __base djnz __level , # __1 jmp # __entry __delay add $C_treg4 , cnt waitcnt $C_treg4 , # 0 __delayret ret \ --- Variables --- __x 0 __y 0 __base 0 \ Address of container __addr 0 \ Gradation data __level 0 \ row counter(scr) __row 0 \ scr data __scr 0 \ loop-counter for making 1byte __column 0 \ 1byte to matrix __matrix 0 \ --- Constants --- \ This value must be adjust when changing SCR __1.25usec d100 __50usec d4000 __100usec d8000 ;asm _gray_scale1_asm }