contrast.4th 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. \ contract check
  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 dup 5 lcd-u.r
  15. s" C" lcd-type
  16. lcd-cr
  17. s" c.dmd = " lcd-type
  18. 21079 swap
  19. dup 25 > if
  20. 25 - 46 * -
  21. else
  22. drop
  23. then
  24. 5 lcd-u.r
  25. ;
  26. \ display the current timer value
  27. : timer-display ( -- )
  28. 0 6 lcd-at-xy
  29. s" timer = " lcd-type
  30. timer-read 12 lcd-u.r
  31. ;
  32. \ display lcd_contrast
  33. : contrast-display ( -- )
  34. 0 8 lcd-at-xy
  35. s" contrast = " lcd-type
  36. contrast-mv 5 lcd-u.r
  37. s" mV" lcd-type
  38. ;
  39. : pwm-display ( -- )
  40. 0 10 lcd-at-xy
  41. s" pwm = " lcd-type
  42. get-contrast-pwm 5 lcd-u.r
  43. ;
  44. \ main
  45. : test-contrast-main ( -- )
  46. key-flush
  47. ctp-flush
  48. button-flush
  49. lcd-cls
  50. s" Contrast Check" lcd-type
  51. 10 lcd-text-rows 1- lcd-at-xy
  52. s" Norm Exit" lcd-type
  53. begin
  54. analog-scan
  55. battery-display
  56. thermistor-display
  57. timer-display
  58. contrast-display
  59. pwm-display
  60. ctp-pos? if
  61. ctp-pos 2drop
  62. then
  63. button? if
  64. button
  65. case
  66. button-left of
  67. endof
  68. button-centre of
  69. nominal-contrast-pwm set-contrast-pwm
  70. endof
  71. button-right of
  72. exit
  73. endof
  74. endcase
  75. then
  76. key? if
  77. key-flush
  78. then
  79. wait-for-event
  80. again
  81. ;
  82. base !