Download the file
  1. #include "items.h"
  2. #include "menu.h"
  3. #include "screen.h"
  4. #include "tasks.h"
  5. #include "scheduler.h"
  6. #include "shooter.h"
  7. #include "rotary.h"
  8. #include "formatter.h"
  9. #include "starter.h"
  10. #include "digital_input.h"
  11. #include "digital_output.h"
  12. #include "test_screen.h"
  13. #include "camera.h"
  14. //#include <EEPROM.h> // let the dumb Arduino IDE know we need EEPROM.h :(
  15. #include <LiquidCrystal.h>
  16.  
  17. LiquidCrystal lcd(LCD_RS, LCD_ENABLE, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
  18.  
  19. DigitalOutput backlight(BACKLIGHT_PIN);
  20.  
  21. DigitalInput sensor(BEAM_SENSOR_PIN, true);
  22.  
  23. DigitalOutput laser(BEAM_LASER_PIN);
  24.  
  25. Camera camera(FOCUS_PIN, SHUTTER_PIN, FLASH_PIN);
  26.  
  27. Formatter formatter;
  28.  
  29. TestScreen test_screen;
  30.  
  31. Count flash_delay(15, // minimum delay -> 11 mm drop
  32. 320, // maximum delay -> 502 mm drop
  33. 1, // step value
  34. 200, // default delay
  35. "Intervalle", // screen title
  36. "ms", // value unit
  37. 3, // width of formatted value
  38. &formatter);
  39.  
  40. Count flash_duration(1, // minimum delay
  41. 100, // maximum delay
  42. 1, // step value
  43. 50, // default delay
  44. "Impulsion flash", // screen title
  45. "ms", // value unit
  46. 3, // width of formatted value
  47. &formatter);
  48.  
  49.  
  50. const char * no_yes_labels[] = { "Non", "Oui" };
  51. Option focus_option(no_yes_labels, NB_ELEMENTS(no_yes_labels),
  52. 1, // default index in focus_options[]
  53. "Mise au point",
  54. 3);
  55.  
  56. const char * shutter_option_labels[] = { "Jamais", "Avant", "A temps" };
  57. Option shutter_option(shutter_option_labels, NB_ELEMENTS(shutter_option_labels),
  58. 1, // default index in focus_options[]
  59. "Obturat. ouvert",
  60. 7 );
  61.  
  62. // Screens that are disabled while shooting
  63. Screen * disable_screens[] = { &test_screen, &flash_delay, &flash_duration, &focus_option, &shutter_option };
  64. Starter starter(disable_screens, NB_ELEMENTS(disable_screens));
  65.  
  66. Screen * menu_items[] = {&starter, &test_screen, &flash_delay, &flash_duration, &focus_option, &shutter_option};
  67. Menu menu(menu_items, NB_ELEMENTS(menu_items));
  68.  
  69. Shooter shooter(&starter);
  70.  
  71. RotaryEncoder knob(&menu, ENCODER_PINA, ENCODER_PINB, BUTTON_PIN);
  72.  
  73. Task * tasks[] = {&shooter, &knob, &sensor};
  74. TaskScheduler scheduler(tasks, NB_ELEMENTS(tasks));
  75.  
  76. void setup() {
  77. Serial.begin(57600);
  78. lcd.begin(20, 4);
  79. backlight.high();
  80. //interval.read_eeprom(); // Needed here if we want to Serial.print()
  81. //count.read_eeprom(); // in those functions
  82. menu.refresh();
  83. }
  84.  
  85. void loop() {
  86. scheduler.run(); // infinite loop
  87. }
  88.