123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- \ ctp testing
- base @ decimal
- 80 constant touch-box-width
- 40 constant touch-box-height
- : draw-patterns ( -- )
- lcd-black
- 60 0 do
- i i lcd-move-to
- lcd-width-pixels i 2* - lcd-height-pixels i 2* - lcd-box
- 5 +loop
- lcd-width-pixels 2/ touch-box-width 2/ -
- lcd-height-pixels 2/ touch-box-height 2/ -
- lcd-move-to
- touch-box-width touch-box-height lcd-box
- lcd-text-columns 2/ 3 - lcd-text-rows 2/ 1- lcd-at-xy
- s" TOUCH" lcd-type
- ;
- variable touch-down
- variable touch-timeout
- 20000 constant touch-timeout-millisec
- : test-touch-sequence ( -- flag )
- lcd-cls
- draw-patterns
- button-flush
- key-flush
- ctp-flush
- false touch-down !
- 0 touch-timeout !
- begin
- ctp-pos? if
- ctp-pos dup 0<
- if
- 2drop
- touch-down @
- exit
- else
- 2drop
- true touch-down !
- lcd-text-columns 2/ 4 - lcd-text-rows 2/ 1- lcd-at-xy
- s" RELEASE" lcd-type
- then
- then
- button? if
- button
- case
- button-left of
- endof
- button-centre of
- endof
- button-right of
- endof
- endcase
- then
- key? if
- key-flush
- then
- \ wait-for-event
- 1 touch-timeout +!
- touch-timeout @ touch-timeout-millisec > if
- false exit
- then
- 1000 delay-us
- again
- ;
- : test-touch-main ( -- )
- test-touch-sequence if
- s" PASS"
- else
- s" FAIL"
- then
- lcd-cls
- s" Touch Test" lcd-type
- lcd-text-columns 2/ lcd-text-rows 2/ lcd-at-xy
- 2dup lcd-type
- 500000 delay-us
- type ." : touch test" cr
- ;
- base !
|