# DiSCO-Multispec-Firmware (forked from Dual-Mag-Control)
![version](https://img.shields.io/badge/version-1.0.0-blue.svg) ![license](https://img.shields.io/badge/license-MIT-blue.svg) 

DiSCO-Multispec-Firmware is an Arduino (C++) firmware for controlling the multispec LED array and trigger image capture. The system is designed around a [Adafruit](https://www.adafruit.com/) [QT Py ](https://www.adafruit.com/qtpy?gclid=CjwKCAiAu5agBhBzEiwAdiR5tOhwb6lSpmMUvRzA2kKYONYJesY7FEuFaPEgaqMGxviO9Sez0c7EUxoCgo4QAvD_BwE), which is a compact and pin-rich breakout board for the Atmel SAMD21.

## Requirements

- [LED Array revA](https://github.com/mbari-org/disco-multispec-kicad) hardware
- [Arduino](https://www.arduino.cc/en/software)

## Highly Recommended

- [VS Code](https://code.visualstudio.com/)
- [PlatformIO](https://platformio.org/) with [Atmel SAM Platform](https://docs.platformio.org/en/latest/platforms/atmelsam.html) and [Adafruit QT Py M0](https://docs.platformio.org/en/latest/boards/atmelsam/adafruit_qt_py_m0.htmlo)

## System Archetecture

Details of the archetecture will be described at some point in the future. For the time being, the system does the following:

### Setup 

1. Start the debug serial port (USB)
2. Setup pins modes
3. Initialize DS3231 real time clock
4. Start timers
5. Initialize flash
6. Start sensors
7. Add all of the config parameters to the SystemConfig object
8. Configure watchdog
9. Start all of the remaining serial ports
10. Load saved SystemConfig values from flash
11. Load saved Scheduler from flash
12. Setup timers and ISRs for camera and flash trigger signals 

### Loop

1. System Update (read sensors, process data)
2. Check for user input
3. Check input voltage
4. Check environment sensors (temp, humidity, pressure)
5. Check Scheduler events
6. Check status of camera power events
7. Sleep
8. Flash status LED
9. GoTo: 1


## Reporting Issues
Please contact proberts@mbari.org

## Licensing

- Copyright 2021 Guatek (http://www.guatek.com)
- Copyright 2023 MBARI (http://www.mbari.org)
- Licensed under MIT (https://github.com/mbari-org/disco-multispec-firmware/blob/master/LICENSE.md)

