lcd-test.4th 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. \ lcd test patterns
  2. decimal
  3. : eye ( -- )
  4. \ lcd-cls
  5. 76 0 ?do 75 i -
  6. 120 over - 100 lcd-move-to
  7. 120 over 25 + lcd-line-to
  8. 120 over + 100 lcd-line-to
  9. 120 i 100 + lcd-line-to
  10. 120 over - 100 lcd-line-to
  11. drop
  12. 5 +loop
  13. ;
  14. 250000 constant stripe-delay
  15. : stripe ( -- )
  16. lcd-vram lcd-vram-size $80 fill
  17. stripe-delay delay-us
  18. lcd-vram lcd-vram-size $40 fill
  19. stripe-delay delay-us
  20. lcd-vram lcd-vram-size $20 fill
  21. stripe-delay delay-us
  22. lcd-vram lcd-vram-size $10 fill
  23. stripe-delay delay-us
  24. lcd-vram lcd-vram-size $08 fill
  25. stripe-delay delay-us
  26. lcd-vram lcd-vram-size $04 fill
  27. stripe-delay delay-us
  28. lcd-vram lcd-vram-size $02 fill
  29. stripe-delay delay-us
  30. lcd-vram lcd-vram-size $01 fill
  31. ;
  32. : charset-test ( -- )
  33. lcd-cls
  34. 256 0 ?do
  35. i lcd-emit
  36. loop
  37. ;
  38. : character-X-test ( -- )
  39. lcd-cls
  40. lcd-text-rows lcd-text-columns * 0 ?do
  41. [char] X lcd-emit
  42. loop
  43. ;
  44. : test-lcd-menu ( -- flag )
  45. button-flush
  46. ctp-flush
  47. key-flush
  48. 200000 delay-us
  49. 10 lcd-text-rows 1- lcd-at-xy
  50. s" PASS FAIL" lcd-type
  51. button-flush
  52. begin
  53. button? if
  54. button
  55. case
  56. button-left of
  57. true exit
  58. endof
  59. button-centre of
  60. endof
  61. button-right of
  62. false exit
  63. endof
  64. endcase
  65. then
  66. ctp-pos? if
  67. ctp-flush
  68. then
  69. key? if
  70. key-flush
  71. then
  72. wait-for-event
  73. again
  74. ;
  75. : test-lcd-pass-fail ( c-addr u -- flag )
  76. test-lcd-menu
  77. if
  78. s" PASS: "
  79. true >r
  80. else
  81. s" FAIL: "
  82. false >r
  83. then
  84. type type cr
  85. r>
  86. ;
  87. : test-lcd-sequence ( -- flag )
  88. eye
  89. s" LCD eye test"
  90. test-lcd-pass-fail
  91. lcd-set-all
  92. s" LCD all black pixels"
  93. test-lcd-pass-fail
  94. and
  95. character-X-test
  96. s" LCD text"
  97. test-lcd-pass-fail
  98. and
  99. ;
  100. : test-lcd-main
  101. lcd-cls
  102. test-lcd-sequence if
  103. s" PASS"
  104. else
  105. s" FAIL"
  106. then
  107. lcd-cls
  108. s" LCD Test" lcd-type
  109. lcd-text-columns 2/ lcd-text-rows 2/ lcd-at-xy
  110. 2dup lcd-type
  111. 500000 delay-us
  112. type ." : LCD test" cr
  113. ;