fl fl { Display font(JIS0208) ROM(JIS0208)-chip(GT21L16J1Y) PropForth 5.5 2014/06/08 16:08:44 propeller ROM-chip(GT21L16J1Y) P10 ----> sclk P11 ----> cs P12 ----> si P13 <---- so 240X68dots Graphic LCD driver WD-G2406B-1YLYa Using graphic-LCD(WD-G2406B-1YLYa) Propeller WD-G2406B-1YLYa 1 FG P0 ---------- 2 DIO1(FLM) P1 ---------- 3 LP P2 ---------- 4 SCP P3 ---------- 5 FR(M) P4 ---------- 6 DI 7 Vdd 8 -Vee 9 Vss 10 Vadj P5 ---------- -9V_on P6 ---------- Dummy(DISP_OFF) Not using on WD-G2406B } \ =========================================================================== \ Constants \ =========================================================================== d10 wconstant SCK d11 wconstant CS d12 wconstant DO d13 wconstant DI \ string wvariable str1 -2 allot d05 c, d13 c, d05 c, d74 c, d05 c, d19 c, d04 c, d12 c, d16 c, d91 c, d04 c, d64 c, d05 c, d06 c, d05 c, d41 c, d04 c, d46 c, d05 c, d19 c, d01 c, d29 c, d05 c, d50 c, d01 c, d29 c, d04 c, d47 c, wvariable str2 -2 allot d22 c, d76 c, d04 c, d04 c, d01 c, d01 c, d05 c, d02 c, d05 c, d35 c, d05 c, d27 c, d05 c, d83 c, d05 c, d54 c, d05 c, d75 c, d03 c, d37 c, d03 c, d56 c, d01 c, d28 c, d03 c, d17 c, d03 c, d16 c, wvariable str3 -2 allot d03 c, d16 c, d03 c, d17 c, d03 c, d16 c, d03 c, d18 c, d03 c, d19 c, d03 c, d20 c, d03 c, d21 c, d03 c, d22 c, d03 c, d23 c, d03 c, d24 c, wvariable str4 -2 allot d04 c, d04 c, d04 c, d46 c, d04 c, d06 c, d04 c, d27 c, d04 c, d04 c, d04 c, d30 c, d04 c, d83 c, d04 c, d31 c, d04 c, d04 c, \ =========================================================================== \ Variables \ =========================================================================== variable font d28 allot \ JIS0208(16x16) charcter position \ X_0208=0 - 14 \ Y_0208=0 - 3 wvariable X_0208 wvariable Y_0208 \ =========================================================================== \ Main \ =========================================================================== \ Initialize ports \ ( -- ) : initROM SCK pinout CS pinhi CS pinout DO pinout ; : do_h DO pinhi ; : do_l DO pinlo ; : sck_h SCK pinhi ; : sck_l SCK pinlo ; : di_m DI >m ; \ READ instruction and Save JIS0208's font-data to font buffer \ ( n1 n2 -- ) n1:byte number n2:address[24bit] : read_ROM CS pinlo \ ( n1 n2 ) \ Send instruction 3 h80 8 0 do 2dup and 0<> if do_h else do_l then sck_h sck_l 1 rshift loop 2drop \ Send address h800000 \ ( n1 n2 h800 ) d24 0 do sck_l 2dup and 0<> if do_h else do_l then sck_h 1 rshift loop 2drop \ ( n1 ) do_l sck_l \ Read data 0 do 0 8 0 do 1 lshift sck_h ina COG@ di_m and 0<> if 1 else 0 then or sck_l loop font i + C! loop CS pinhi ; \ Get font address \ ( n1 n2 -- n3 ) n1:ku[8bit] n2:ten[8bit] n3:address[24bit] : get_addr1 2dup \ 1 d94 between swap 1 d15 between and if 1- d32 u* swap 1- d3008 u* + else 2dup 1 d94 between swap d16 d47 between and if 1- d32 u* d43584 + swap d16 - d3008 u* + else 2dup 1 d94 between swap d48 d84 between and if 1- d32 u* d138463 + swap d48 - d3008 u* + else 2dup 1 d94 between swap d85 = and if 1- d32 u* d246944 + swap d85 - d3008 u* + else 1- d32 u* d249952 + swap d88 - d3008 u* + thens ; \ Get font address \ ( n1 -- n2 ) n1:ASCII code[h20 - h7F] n2:address[24bit] : get_addr2 h20 - d16 u* d255968 + ; \ Get font address \ ( n1 -- n2 ) n1:ASCII code[h00 - hFF] n2:address[24bit] : get_addr3 d16 u* d257504 + ; \ Get font address \ ( n1 -- n2 ) n1:ASCII code[h00 - hFF] n2:address[24bit] : get_addr4 d16 u* d261600 + ; \ Print character type1(JIS0208:16X16) to TearTerm \ ( n1 -- ) n1:font address : print_char1 1 swap 8 0 do 2dup \ ( 1 font 1 font ) d16 0 do 2dup \ ( 1 font 1 font 1 font ) C@ j rshift and 0<> if h2A else bl then emit bl emit 1+ loop 2drop cr loop 2drop ; \ Print character type2,3(8X16) to TearTerm \ ( n -- ) n1:font address : print_char2 1 swap 8 0 do 2dup \ ( 1 font 1 font ) 8 0 do 2dup \ ( 1 font 1 font 1 font ) C@ j rshift and 0<> if h2A else bl then emit bl emit 1+ loop 2drop cr loop 2drop ; \ ( n1 n2 -- ) n1:ku[8bit] n2:ten[8bit] \ 16X16 : char_type1 get_addr1 d32 swap read_ROM font d32 dump font print_char1 font d16 + print_char1 ; \ ( n1 -- ) n1:ASCII code[h20 - h7F] \ 8X16 : char_type2 h20 - d16 u* d255968 + d16 swap read_ROM font d16 dump font print_char2 font 8 + print_char2 ; \ ( n1 -- ) n1:ASCII code[h00 - hFF] \ 8X16 : char_type3 h20 - d16 u* d257504 + d16 swap read_ROM font d16 dump font print_char2 font 8 + print_char2 ; \ ( n1 -- ) n1:ASCII code[h00 - hFF] \ 8X16 : char_type4 h20 - d16 u* d261600 + d16 swap read_ROM font d16 dump font print_char2 font 8 + print_char2 ; \ Clear vidMem \ ( n1 n2 -- ) n1:start address n2:number of word (2byte) : clr_vram 0 do dup 0 swap W! 2+ loop drop ; \ Get 1-line for character(JIS0208:16X16) \ ( n1 n2 -- n3 ) n1:bit number n2:font buffer's address n3:1-line[16bits] of font : getLine 0 1 rot \ ( bit 0 1 address ) d16 0 do 2dup \ ( bit 0 1 address 1 address ) 4 ST@ 1 lshift 4 ST! C@ 5 ST@ rshift and 0<> if 1 else 0 then 3 ST@ or 2 ST! 1+ loop 2drop nip dup hFF and 8 lshift swap 8 rshift or ; \ Copy font to vidMem buffer \ ( n1 n2 -- ) n1:X_0208 n2:Y_0208 : disp_GLCD \ Copy upper 8line of JIS0208-font to vidMem d480 u* swap 2 u* + \ Get offset in vidMem buffer vidMem + \ Get RAM address dup 8 0 do i font getLine \ Get 1-line swap \ ( 1Line_data vidMem_address ) 2dup W! \ ( 1Line_data vidMem_address ) nip d30 + \ Get next line [1-Line=30bytes(240dots)] loop drop \ Copy lower 8line of JIS0208-font to vidMem d240 + \ Get RAM address 8 0 do i font d16 + getLine \ Get 1-line swap \ ( 1Line_data vidMem_address ) 2dup W! \ ( 1Line_data vidMem_address ) nip d30 + \ Get next line [1-Line=30bytes(240dots)] loop drop ; \ Display string(JIS0208) \ ( n1 n2 0 -- ) n1:string address n2:number of character(JIS0208) : disp_str do dup \ ( str1 str1 ) i 2 u* 2dup \ ( str1 str1 index str1 index ) + C@ rot2 + 1+ C@ \ ( str1 ku ten ) \ Read font of JIS0208(16X16) from ROM-chip and copy font-data to font buffer get_addr1 d32 swap read_ROM \ Load XY-position X_0208 W@ Y_0208 W@ \ Copy font-data to vidMem disp_GLCD X_0208 W@ 1+ X_0208 W! loop drop ; \ ***** Display JIS0208-Font ***** \ ( -- ) : demo1 BASE DISP_OFF + pinout \ Disable graphicLCD BASE Vee + pinout \ Disable Vee c" vidMem BASE GraphicLCD" 0 cogx \ Drive graphicLCD vidMem pixel_X pixel_Y u* d16 u/ clr_vram BASE Vee + pinhi \ Enable Vee 1 delms BASE DISP_OFF + pinhi \ Enable graphicLCD initROM \ Display str1 0 X_0208 W! 0 Y_0208 W! str1 d14 0 disp_str \ Display str2 0 X_0208 W! 1 Y_0208 W! str2 d14 0 disp_str \ Display str3 0 X_0208 W! 2 Y_0208 W! str3 d10 0 disp_str \ Display str4 0 X_0208 W! 3 Y_0208 W! str4 9 0 disp_str begin fkey? swap drop until \ LCD-off BASE DISP_OFF + pinlo \ Disable -9V BASE Vee + pinlo 0 cogreset ;