Download the file
  1. #include "test_screen.h"
  2. #include "digital_output.h"
  3.  
  4. extern DigitalInput sensor;
  5. extern DigitalOutput laser;
  6.  
  7. void TestScreen::refresh() {
  8. //Serial.println("refresh");
  9. if (! initialized)
  10. show_static();
  11. }
  12.  
  13. uint8_t TestScreen::click() {
  14. if (selected) {
  15. sensor.set_handler(NULL);
  16. laser.low();
  17. lcd.noCursor();
  18. lcd.noBlink();
  19. show_static();
  20. selected = 0;
  21. }
  22. else {
  23. //lcd.cursor();
  24. lcd.blink();
  25. laser.high();
  26. sensor.set_handler((DigitalInputObserver *) this);
  27. if (sensor.get_state() == HIGH)
  28. print_interrupted();
  29. else
  30. print_continuous();
  31. selected = 1;
  32. }
  33. return 1;
  34. }
  35.  
  36. void TestScreen::on_fall() {
  37. if (selected)
  38. print_continuous();
  39. }
  40.  
  41. void TestScreen::on_rise() {
  42. if (selected)
  43. print_interrupted();
  44. }
  45.  
  46. void TestScreen::print_continuous() {
  47. lcd.setCursor(0,1);
  48. lcd.print(F("continu "));
  49. }
  50.  
  51. void TestScreen::print_interrupted() {
  52. lcd.setCursor(0,1);
  53. lcd.print(F("interrompu"));
  54. }
  55.  
  56. void TestScreen::show_static() {
  57. lcd.noCursor();
  58. lcd.noBlink();
  59. lcd.clear();
  60. lcd.setCursor(0,0);
  61. lcd.print(F("Test faisceau:"));
  62. lcd.setCursor(0,1);
  63. lcd.print(F("inactif"));
  64. initialized = 1;
  65. }
  66.  
  67. // vim:ft=arduino
  68.