fl { 2010.10.14 TouchScreen demo Start:TS_demo Restart:demo Up-arrow: going up bar-graph Down-arrow going down bar-graph Quit to touch inside bar-graph's square } wvariable x_diff wvariable y_diff wvariable x_cal_max wvariable x_cal_min wvariable y_cal_max wvariable y_cal_min wvariable level : LCD_pos \ A/D value of TS to LCD's position : AD_x AD_y --- LCD_pos_y LCD_pos_x y_cal_min W@ - cf * y_diff W@ u/ 10 + swap x_cal_min W@ - 11f * x_diff W@ u/ 10 + ; : level_up dup 64 < if 2 * db swap - 1+ 33 21 lcd_out 2 0 do 1- dup 20 lcd_out \ y 32 0 do 0 3f 0 color_data loop loop drop level dup W@ 1+ swap W! else drop then ; : level_down dup 0 > if 2 * db swap - 1+ 33 21 lcd_out 2 0 do dup 20 lcd_out \ y 32 0 do 3f 3f 3f color_data loop 1+ loop drop level dup W@ 1- swap W! else drop then ; : Bar_display begin sense LCD_pos 2dup 33 64 between if 14 db between if 2drop exit then else drop then \ 78 97 between if dup 50 6f between if drop level W@ level_up 78 97 between if dup 50 6f between if drop 1 state W! arrow level W@ level_up else 82 a1 between if 1 state W! arrow1 level W@ level_down then then else drop then 0 20 delms until ; : TS_demo YHY024006A_init clear init_TS \ calibration \ croshair of top left 10 20 lcd_out \ y 0 21 lcd_out 20 0 do 0 0 3f color_data loop 10 21 lcd_out \ x 20 0 do i 20 lcd_out 0 0 3f color_data loop cal y_cal_min W! x_cal_min W! 10 20 lcd_out \ y 0 21 lcd_out 20 0 do 3f 3f 3f color_data loop 10 21 lcd_out \ x 20 0 do i 20 lcd_out 3f 3f 3f color_data loop \ croshair of bottom right df 20 lcd_out \ y 120 21 lcd_out 20 0 do 0 0 3f color_data loop 12f 21 lcd_out \ x 20 0 do i d0 + 20 lcd_out 0 0 3f color_data loop cal y_cal_max W! x_cal_max W! df 20 lcd_out \ y 120 21 lcd_out 20 0 do 3f 3f 3f color_data loop 12f 21 lcd_out \ x 20 0 do i d0 + 20 lcd_out 3f 3f 3f color_data loop x_cal_max W@ x_cal_min W@ - x_diff W! y_cal_max W@ y_cal_min W@ - y_diff W! \ Drawing rectangle and up/down button 13 20 lcd_out \ y 32 21 lcd_out 34 0 do 0 0 0 color_data loop dc 20 lcd_out \ y 32 21 lcd_out 34 0 do 0 0 0 color_data loop 32 21 lcd_out c8 0 do i 14 + 20 lcd_out 0 0 0 color_data loop 65 21 lcd_out c8 0 do i 14 + 20 lcd_out 0 0 0 color_data loop harf_draw 50 6f 50 button \ up button arrow 82 a1 82 button \ down button arrow1 32 level W! Bar_display ; : demo Bar_display ;