fl hex { 160X64dots Graphic LCD DMF-51026NY-LY 2013/02/21 22:59:31 PropForth5.2/5.0 Using graphic-LCD(DFM-51026NY-LY) Propeller DFM-51026NY-LY P0 ---------- FLM P1 ---------- LP P2 ---------- CP P3 ---------- M P4 ---------- D0 P5 ---------- D1 P6 ---------- D2 P7 ---------- D4 P8 ---------- DISPOFF P9 ---------- -9V_on } lockdict create DFM-51026 forthentry $C_a_lxasm w, h150 h113 1- tuck - h9 lshift or here W@ alignl h10 lshift or l, z2WyPW1 l, zfiPZB l, z2WicBC l, zfyPW1 l, z2WicJC l, zfyPW1 l, z2WicRC l, zfyPW1 l, z2WicZC l, z2WiceB l, z20ycb4 l, z2WyPZy l, zfiPZB l, z1bixmC l, z1SyLI[ l, z2WyPW2 l, z2WicmB l, z2WyPc0 l, z26VPc0 l, z1bdx\9 l, z1[\x\9 l, z2WyPjK l, ziQ5E l, z2WicuG l, z2WyPr2 l, z1bix\B l, z26VPr2 l, zbtQ04 l, z1WyQ0F l, zfiQ5D l, z1bixZG l, z1Syc55 l, z1[ix\B l, z2WyQ0F l, zfiQ5D l, z1[ixZG l, z2WiQ5F l, z1Syc55 l, z3[yPvf l, z20ycj1 l, z3[yPnc l, z1bix\A l, z1Syc55 l, z1[ix\A l, z3[yPf\ l, z26VPW2 l, z1bdx\C l, z1[\x\C l, z3[yP[Z l, z1SV04Y l, z2WiQFk l, z20yQAK l, z3ryQ80 l, z1SV000 l, 0 l, 0 l, 0 l, 0 l, 0 l, 0 l, 0 l, freedict \ Character Font 8X8dots wvariable Font -2 allot h00 c, h00 c, h00 c, h00 c, h00 c, h00 c, h00 c, h00 c, \ (space) h30 c, h78 c, h78 c, h30 c, h30 c, h00 c, h30 c, h00 c, \ ! h6C c, h6C c, h28 c, h00 c, h00 c, h00 c, h00 c, h00 c, \ " " h6C c, h6C c, hFE c, h6C c, hFE c, h6C c, h6C c, h00 c, \ # h18 c, h7E c, hC0 c, h7C c, h06 c, hFC c, h18 c, h00 c, \ $ h00 c, hC6 c, hCC c, h18 c, h30 c, h66 c, hC6 c, h00 c, \ % h38 c, h6C c, h38 c, h76 c, hDC c, hCC c, h76 c, h00 c, \ & h30 c, h30 c, h60 c, h00 c, h00 c, h00 c, h00 c, h00 c, \ \ h18 c, h30 c, h60 c, h60 c, h60 c, h30 c, h18 c, h00 c, \ ( h60 c, h30 c, h18 c, h18 c, h18 c, h30 c, h60 c, h00 c, \ ) h00 c, h66 c, h3C c, hFF c, h3C c, h66 c, h00 c, h00 c, \ * h00 c, h30 c, h30 c, hFC c, h30 c, h30 c, h00 c, h00 c, \ + h00 c, h00 c, h00 c, h00 c, h00 c, h30 c, h30 c, h60 c, \ , h00 c, h00 c, h00 c, hFC c, h00 c, h00 c, h00 c, h00 c, \ - h00 c, h00 c, h00 c, h00 c, h00 c, h30 c, h30 c, h00 c, \ . h06 c, h0C c, h18 c, h30 c, h60 c, hC0 c, h80 c, h00 c, \ / h7C c, hC6 c, hC6 c, hD6 c, hC6 c, hC6 c, h7C c, h00 c, \ 0 h30 c, h70 c, h30 c, h30 c, h30 c, h30 c, hFC c, h00 c, \ 1 h78 c, hCC c, h0C c, h38 c, h60 c, hCC c, hFC c, h00 c, \ 2 h78 c, hCC c, h0C c, h38 c, h0C c, hCC c, h78 c, h00 c, \ 3 h1C c, h3C c, h6C c, hCC c, hFE c, h0C c, h1E c, h00 c, \ 4 hFC c, hC0 c, hF8 c, h0C c, h0C c, hCC c, h78 c, h00 c, \ 5 h38 c, h60 c, hC0 c, hF8 c, hCC c, hCC c, h78 c, h00 c, \ 6 hFC c, hCC c, h0C c, h18 c, h30 c, h30 c, h30 c, h00 c, \ 7 h78 c, hCC c, hCC c, h78 c, hCC c, hCC c, h78 c, h00 c, \ 8 h78 c, hCC c, hCC c, h7C c, h0C c, h18 c, h70 c, h00 c, \ 9 h00 c, h30 c, h30 c, h00 c, h00 c, h30 c, h30 c, h00 c, \ : h00 c, h30 c, h30 c, h00 c, h00 c, h30 c, h30 c, h60 c, \ ; h18 c, h30 c, h60 c, hC0 c, h60 c, h30 c, h18 c, h00 c, \ < h00 c, h00 c, hFC c, h00 c, h00 c, hFC c, h00 c, h00 c, \ = h60 c, h30 c, h18 c, h0C c, h18 c, h30 c, h60 c, h00 c, \ > h78 c, hCC c, h0C c, h18 c, h30 c, h00 c, h30 c, h00 c, \ ? h7C c, hC6 c, hDE c, hDE c, hDC c, hC0 c, h78 c, h00 c, \ @ h30 c, h78 c, hCC c, hCC c, hFC c, hCC c, hCC c, h00 c, \ A hFC c, h66 c, h66 c, h7C c, h66 c, h66 c, hFC c, h00 c, \ B h3C c, h66 c, hC0 c, hC0 c, hC0 c, h66 c, h3C c, h00 c, \ C hF8 c, h6C c, h66 c, h66 c, h66 c, h6C c, hF8 c, h00 c, \ D hFE c, h62 c, h68 c, h78 c, h68 c, h62 c, hFE c, h00 c, \ E hFE c, h62 c, h68 c, h78 c, h68 c, h60 c, hF0 c, h00 c, \ F h3C c, h66 c, hC0 c, hC0 c, hCE c, h66 c, h3E c, h00 c, \ G hCC c, hCC c, hCC c, hFC c, hCC c, hCC c, hCC c, h00 c, \ H h78 c, h30 c, h30 c, h30 c, h30 c, h30 c, h78 c, h00 c, \ I h1E c, h0C c, h0C c, h0C c, hCC c, hCC c, h78 c, h00 c, \ J hE6 c, h66 c, h6C c, h78 c, h6C c, h66 c, hE6 c, h00 c, \ K hF0 c, h60 c, h60 c, h60 c, h62 c, h66 c, hFE c, h00 c, \ L hC6 c, hEE c, hFE c, hFE c, hD6 c, hC6 c, hC6 c, h00 c, \ M hC6 c, hE6 c, hF6 c, hDE c, hCE c, hC6 c, hC6 c, h00 c, \ N h38 c, h6C c, hC6 c, hC6 c, hC6 c, h6C c, h38 c, h00 c, \ O hFC c, h66 c, h66 c, h7C c, h60 c, h60 c, hF0 c, h00 c, \ P h78 c, hCC c, hCC c, hCC c, hDC c, h78 c, h1C c, h00 c, \ Q hFC c, h66 c, h66 c, h7C c, h6C c, h66 c, hE6 c, h00 c, \ R h78 c, hCC c, hC0 c, h78 c, h0C c, hCC c, h78 c, h00 c, \ S hFC c, hB4 c, h30 c, h30 c, h30 c, h30 c, h78 c, h00 c, \ T hCC c, hCC c, hCC c, hCC c, hCC c, hCC c, hFC c, h00 c, \ U hCC c, hCC c, hCC c, hCC c, hCC c, h78 c, h30 c, h00 c, \ V hC6 c, hC6 c, hC6 c, hD6 c, hFE c, hEE c, hC6 c, h00 c, \ W hC6 c, h6C c, h38 c, h38 c, h6C c, hC6 c, hC6 c, h00 c, \ X hCC c, hCC c, hCC c, h78 c, h30 c, h30 c, h78 c, h00 c, \ Y hFE c, hC6 c, h8C c, h18 c, h32 c, h66 c, hFE c, h00 c, \ Z h78 c, h60 c, h60 c, h60 c, h60 c, h60 c, h78 c, h00 c, \ [ hC0 c, h60 c, h30 c, h18 c, h0C c, h06 c, h02 c, h00 c, \ \ h78 c, h18 c, h18 c, h18 c, h18 c, h18 c, h78 c, h00 c, \ ] h10 c, h38 c, h6C c, hC6 c, h00 c, h00 c, h00 c, h00 c, \ ^ h00 c, h00 c, h00 c, h00 c, h00 c, h00 c, h00 c, hFF c, \ _ h30 c, h18 c, h0C c, h00 c, h00 c, h00 c, h00 c, h00 c, \ ` h00 c, h00 c, h78 c, h0C c, h7C c, hCC c, h76 c, h00 c, \ a hE0 c, h60 c, h60 c, h7C c, h66 c, h66 c, hDC c, h00 c, \ b h00 c, h00 c, h78 c, hCC c, hC0 c, hCC c, h78 c, h00 c, \ c h1C c, h0C c, h0C c, h7C c, hCC c, hCC c, h76 c, h00 c, \ d h00 c, h00 c, h78 c, hCC c, hFC c, hC0 c, h78 c, h00 c, \ e h38 c, h6C c, h60 c, hF0 c, h60 c, h60 c, hF0 c, h00 c, \ f h00 c, h00 c, h76 c, hCC c, hCC c, h7C c, h0C c, hF8 c, \ g hE0 c, h60 c, h6C c, h76 c, h66 c, h66 c, hE6 c, h00 c, \ h h30 c, h00 c, h70 c, h30 c, h30 c, h30 c, h78 c, h00 c, \ i h0C c, h00 c, h0C c, h0C c, h0C c, hCC c, hCC c, h78 c, \ j hE0 c, h60 c, h66 c, h6C c, h78 c, h6C c, hE6 c, h00 c, \ k h70 c, h30 c, h30 c, h30 c, h30 c, h30 c, h78 c, h00 c, \ l h00 c, h00 c, hCC c, hFE c, hD6 c, hD6 c, hC6 c, h00 c, \ m h00 c, h00 c, hF8 c, hCC c, hCC c, hCC c, hCC c, h00 c, \ n h00 c, h00 c, h78 c, hCC c, hCC c, hCC c, h78 c, h00 c, \ o h00 c, h00 c, hDC c, h66 c, h66 c, h7C c, h60 c, hF0 c, \ p h00 c, h00 c, h76 c, hCC c, hCC c, h7C c, h0C c, h1E c, \ q h00 c, h00 c, hDC c, h76 c, h66 c, h60 c, hF0 c, h00 c, \ r h00 c, h00 c, h7C c, hC0 c, h78 c, h0C c, hF8 c, h00 c, \ s h10 c, h30 c, h7C c, h30 c, h30 c, h34 c, h18 c, h00 c, \ t h00 c, h00 c, hCC c, hCC c, hCC c, hCC c, h76 c, h00 c, \ u h00 c, h00 c, hCC c, hCC c, hCC c, h78 c, h30 c, h00 c, \ v h00 c, h00 c, hC6 c, hD6 c, hD6 c, hFE c, h6C c, h00 c, \ w h00 c, h00 c, hC6 c, h6C c, h38 c, h6C c, hC6 c, h00 c, \ x h00 c, h00 c, hCC c, hCC c, hCC c, h7C c, h0C c, hF8 c, \ y h00 c, h00 c, hFC c, h98 c, h30 c, h64 c, hFC c, h00 c, \ z h1C c, h30 c, h30 c, hE0 c, h30 c, h30 c, h1C c, h00 c, \ { h30 c, h30 c, h30 c, h30 c, h30 c, h30 c, h30 c, h00 c, \ | hE0 c, h30 c, h30 c, h1C c, h30 c, h30 c, hE0 c, h00 c, \ } h76 c, hDC c, h00 c, h00 c, h00 c, h00 c, h00 c, h00 c, \ ~ h38 c, h6C c, hC6 c, hC6 c, h6C c, h28 c, hEE c, h00 c, \ ohm wvariable vidMem d1278 allot \ 20bytes X 64bytes \ charcter position vidX=0-d19 vidY=0-7 wvariable vidX wvariable vidY \ basepin for DMF-51026NY-LY's control 0 wconstant BASE \ display character to graphicLCD ( n1 n2 n3 -- ) \ n1:character n2:x-pos n3:y-pos : grlcd_char d160 u* + vidMem + \ Get vidMem's address for (x,y) swap h20 - 8 u* Font + \ Get Font-address \ Copy character to vidMem 8 0 do 2dup C@ swap i d20 u* + C! 1+ \ Font-address + 1 loop 2drop ; \ display string to graphicLCD ( cstr -- ) \ Set charcter position(vidX=0-d19 vidY=0-7) before call : grlcd_str C@++ dup if bounds do i C@ vidX W@ vidY W@ grlcd_char \ Calculate vidX and vidY vidX W@ 1+ dup d20 = if drop 0 vidX W! vidY W@ 1+ dup 8 = if drop 0 vidY W! else vidY W! then else vidX W! then loop else 2drop then ; \ Clear vidMem \ ( n1 n2 -- ) n1:start address n2:number of word (2byte) : clear_vram 0 do dup 0 swap W! 2+ loop drop ; \ Save-area for data from P-10 tester wvariable grdata d158 allot \ Start address of Graphic area vidMem d320 + wconstant grMem \ test-data : wr-data d160 0 do i d100 < if i 1+ i grdata + C! else i d100 - i grdata + C! then loop ; \ vidMem ------------------------------- \ | 16Lines X 20bytes | \ | = 320bytes | \ grMem |-------------------------------| \ 0 100 |(0,47) (159,47)| \ | | | | 48Lines X 20bytes \ | | | (x,y) | = 960bytes \ | | | | \ | | |(0,0) (159,0)| \ 47 1 ------------------------------- \ gr_y y 0 ---------------------------- 159 \ x \ 0 ---------------------------- 19 \ gr_x \ Calculate GraphicMemory(grMem) address \ ( n1 -- n2 ) n1:index of grdata[x-direction (from 0 to d159)] \ n2:address : GetAddr grMem over grdata + C@ \ Get y d47 u* d100 u/ \ Get gr_y d47 swap - d20 u* \ bytes for y + \ Get address of gr_y swap 8 u/ \ Get gr_x + \ Get address ; \ Place 1 on bit-position \ ( n1 n2 -- n3 ) n1:index of grdata[x-direction (from 0 to d159)] \ n2:GrMem address \ n3:bitdata : SetBit1 C@ swap 8 u/mod drop h80 swap rshift \ Get bit data or \ or bit data to original ; \ Place 0 on bit-position \ ( n1 n2 -- n3 ) n1:index of grdata[x-direction (from 0 to d159)] \ n2:GrMem address \ n3:bitdata : SetBit0 C@ swap 8 u/mod drop h80 swap rshift \ Get bit data andn \ andn bit data to original ; \ Plot dot into Graphic-area by grdata-array \ ( n -- ) n:index for x-direction (from 0 to d159) : plot dup GetAddr 2dup SetBit1 swap C! \ Save bit-data to grMem drop ; \ Erace dot into Graphic-area by grdata-array \ ( n -- ) n:index for x-direction (from 0 to d159) : erace dup GetAddr 2dup SetBit0 swap C! \ Save bit-data to grMem drop ; \ Shift graphic to left \ ( -- ) : gr_shift 0 erace \ Erace dot on grdata(0) \ shift dots from grdata(1) to grdata(d160) to left d161 1 do i grdata + C@ i erace i 1- grdata + C! i 1- plot loop ; { : demo BASE 8 + pinout \ Disable graphicLCD BASE 9 + pinout \ Disable -9V c" vidMem BASE DFM-51026" 0 cogx \ Drive graphicLCD 1 delms BASE 9 + pinhi \ Enable -9V 1 delms BASE 8 + pinhi \ Enable graphicLCD 0 vidX W! 0 vidY W! Font \ top address for character begin d96 0 do ." number= " i . cr dup i 3 lshift + \ Get Font-address vidMem vidX W@ + vidY W@ d160 u* + \ Calculate address of vidMem swap st? \ Copy character to vidMem 8 0 do 2dup C@ dup . swap i d20 u* + dup . C! 1+ \ Font-address + 1 cr loop 2drop vidX W@ 1+ dup d20 = \ Check if vixX = 20 if drop 0 vidX W! vidY W@ 1+ dup 8 = \ Check if vixY = 8 if drop 0 vidY W! else vidY W! then else vidX W! then loop ." AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" st? fkey? swap drop until drop \ LCD-off BASE 8 + pinlo \ Disable graphicLCD BASE 9 + pinlo \ Disable -9V 0 cogreset ; } decimal { Driver for DMF-51026NY-LY ( n1 n2 -- ) n1:Address of vidMem n2:basepin fl build_BootOpt :rasm mov $C_treg1 , # 1 shl $C_treg1 , $C_stTOS \ Get FLM mov __flm , $C_treg1 shl $C_treg1 , # 1 \ Get LP mov __lp , $C_treg1 shl $C_treg1 , # 1 \ Get CP mov __cp , $C_treg1 shl $C_treg1 , # 1 \ Get M mov __m , $C_treg1 \ Get top of data mov __data , $C_stTOS add __data , # 4 mov $C_treg1 , # hFF shl $C_treg1 , $C_stTOS \ Set pins to output or dira , $C_treg1 spop __1 mov $C_treg1 , # 2 __2 \ Get vidMem mov __vid , $C_stTOS mov $C_treg2 , # d64 __3 \ Set FLM cmp $C_treg2 , # d64 wz if_z or outa , __flm if_nz andn outa , __flm mov $C_treg3 , # d20 __4 \ Read vidmem rdbyte $C_treg5 , __vid mov __tmp , $C_treg5 mov $C_treg4 , # 2 __5 \ Set CP to High or outa , __cp cmp $C_treg4 , # 2 wz \ Set 4bit-data \ Upper 4bit if_z shr $C_treg5 , # 4 and $C_treg5 , # hF shl $C_treg5 , __data or outa , $C_treg5 jmpret __delay_ret , # __delay \ Set CP to Low andn outa , __cp \ Clear 4bit-data mov $C_treg5 , # hF shl $C_treg5 , __data andn outa , $C_treg5 mov $C_treg5 , __tmp jmpret __delay_ret , # __delay djnz $C_treg4 , # __5 add __vid , # 1 djnz $C_treg3 , # __4 \ Set LP or outa , __lp \ wait jmpret __delay_ret , # __delay andn outa , __lp djnz $C_treg2 , # __3 cmp $C_treg1 , # 2 wz \ Set M if_z or outa , __m if_nz andn outa , __m djnz $C_treg1 , # __2 jmp # __1 __delay mov $C_treg6 , cnt add $C_treg6 , # d148 waitcnt $C_treg6 , # 0 __delay_ret ret __flm 0 __lp 0 __cp 0 __m 0 __data 0 __vid 0 __tmp 0 ;asm DFM-51026 }