gpiotest.4th 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. \ gpio tests
  2. base @ decimal
  3. \ display battery
  4. : battery-display ( -- )
  5. 0 2 lcd-at-xy
  6. s" battery = " lcd-type
  7. battery-mv 5 lcd-u.r
  8. s" mV" lcd-type
  9. ;
  10. \ display thermistor
  11. : thermistor-display ( -- )
  12. 0 4 lcd-at-xy
  13. s" thermistor = " lcd-type
  14. temperature-c 5 lcd-u.r
  15. s" C" lcd-type
  16. ;
  17. \ display the current timer value
  18. : timer-display ( -- )
  19. 0 6 lcd-at-xy
  20. s" timer = " lcd-type
  21. timer-read 12 lcd-u.r
  22. ;
  23. \ display lcd_contrast
  24. : contrast-display ( u -- )
  25. 0 8 lcd-at-xy
  26. s" contrast = " lcd-type
  27. contrast-mv 5 lcd-u.r
  28. s" mV" lcd-type
  29. ;
  30. : pwm-display ( -- )
  31. 0 10 lcd-at-xy
  32. s" pwm = " lcd-type
  33. get-contrast-pwm 5 lcd-u.r
  34. ;
  35. \ main
  36. variable measure-count
  37. variable last-x
  38. : test-gpio-main ( -- )
  39. key-flush
  40. ctp-flush
  41. button-flush
  42. lcd-cls
  43. s" GPIO TESTS" lcd-type
  44. 3 12 lcd-at-xy
  45. s" <-- change contrast -->" lcd-type
  46. 10 lcd-text-rows 1- lcd-at-xy
  47. s" Off Norm Exit" lcd-type
  48. 0 last-x !
  49. begin
  50. 1 measure-count +!
  51. measure-count @ $3ff = if
  52. 0 measure-count !
  53. analog-scan
  54. battery-display
  55. thermistor-display
  56. timer-display
  57. contrast-display
  58. pwm-display
  59. then
  60. ctp-pos? if
  61. ctp-pos 0< if
  62. drop 0 last-x !
  63. else
  64. last-x @ 0= if
  65. last-x !
  66. else
  67. dup
  68. last-x @
  69. - get-contrast-pwm + set-contrast-pwm
  70. last-x !
  71. then
  72. then
  73. then
  74. button? if
  75. button
  76. case
  77. button-left of
  78. power-off
  79. endof
  80. button-centre of
  81. nominal-contrast-pwm set-contrast-pwm
  82. endof
  83. button-right of
  84. exit
  85. endof
  86. endcase
  87. then
  88. key? if
  89. key-flush
  90. then
  91. again
  92. ;
  93. base !