Download the file
  1. #include "starter.h"
  2. #include "hsphoto.h"
  3. #include "shooter.h"
  4. #include "items.h"
  5. #include "digital_input.h"
  6. #include "digital_output.h"
  7. #include "shooter.h"
  8. #include "camera.h"
  9.  
  10. extern Count flash_delay;
  11. extern DigitalInput sensor;
  12. extern DigitalOutput laser;
  13. extern DigitalOutput backlight;
  14. extern Shooter shooter;
  15. extern Camera camera;
  16.  
  17. void Starter::refresh() {
  18. if (!initialized)
  19. show_static();
  20. lcd.setCursor(0,1);
  21. if (running)
  22. lcd.print(F("En cours..."));
  23. else
  24. lcd.print(F("En attente "));
  25.  
  26. }
  27.  
  28. void Starter::show_static() {
  29. lcd.noCursor();
  30. lcd.noBlink();
  31. lcd.clear();
  32. lcd.setCursor(0,0);
  33. lcd.print(F("Intervalle: "));
  34. lcd.print(flash_delay.get_value(), DEC);
  35. initialized = 1;
  36. }
  37.  
  38. void Starter::start() {
  39. backlight.low();
  40. camera.open_shutter(SHUTTER_BEFORE);
  41. laser.high();
  42. sensor.set_handler((DigitalInputObserver *) this);
  43. for (int i=0; i<nb_screens; i++)
  44. screens[i]->disable();
  45. running = 1;
  46. }
  47.  
  48. void Starter::stop() {
  49. shooter.deactivate();
  50. laser.low();
  51. done();
  52. }
  53.  
  54. void Starter::done() {
  55. sensor.set_handler(NULL);
  56. camera.close_shutter();
  57. backlight.high();
  58. for (int i=0; i<nb_screens; i++)
  59. screens[i]->enable();
  60. running = 0;
  61. refresh();
  62. }
  63.  
  64. uint8_t Starter::click() {
  65. if (running) {
  66. stop();
  67. }
  68. else {
  69. start();
  70. }
  71. refresh();
  72. return 1;
  73. }
  74.  
  75. void Starter::on_rise() {
  76. shooter.activate(millis() + flash_delay.get_value());
  77. }
  78. // vim:ft=arduino
  79.