diff options
Diffstat (limited to 'test_fw/src/main.cpp')
| -rw-r--r-- | test_fw/src/main.cpp | 75 |
1 files changed, 28 insertions, 47 deletions
diff --git a/test_fw/src/main.cpp b/test_fw/src/main.cpp index c6d3834..5f8e1d4 100644 --- a/test_fw/src/main.cpp +++ b/test_fw/src/main.cpp @@ -1,5 +1,7 @@ #include <Arduino.h> #include <Wire.h> +#include <SPI.h> +#include <SD.h> #include <Adafruit_BME680.h> @@ -7,25 +9,21 @@ #include "i2c_scan.h" #include "veml.h" +#include "board.h" +#include "bringup.h" -constexpr auto SDA = 6; -constexpr auto SCL = 23; +using namespace ocularium; -constexpr auto BME_ADDR = 0x76; -static TwoWire wire(SDA, SCL); +static Adafruit_BME680 bme(&Wire1); +static VEML lux(Wire1); -static Adafruit_BME680 bme(&wire); -static ocularium::VEML veml(wire); +#define SCAN_I2C 0 -struct init_check -{ - const String name; - bool (*f)(); - bool succeeded; -}; +#define SDCARD_SPI SD_SPI +static SDClass sd; -static init_check STARTUP_CHECKS[] = { +static bringup::init_check STARTUP_CHECKS[] = { { .name = String("bme680"), .f = [] { return bme.begin(BME_ADDR); }, @@ -33,50 +31,33 @@ static init_check STARTUP_CHECKS[] = { }, { .name = String("veml7700"), - .f = []{ return veml.init(ocularium::veml::Config { - .gain = ocularium::veml::AmbientLightGain::Quarter, + .f = []{ return lux.init(veml::Config { + .gain = veml::AmbientLightGain::Quarter, }); }, .succeeded = false, } }; -void startup_checks() -{ - auto success = true; - - do - { - success = true; - - for (auto & check : STARTUP_CHECKS) - { - if (check.succeeded) - continue; - - Serial.print("checking " + check.name + "... "); - - check.succeeded = check.f(); - success = success && check.succeeded; - - if (check.succeeded) Serial.println("ok"); - else Serial.println("bad"); - } - - if (!success) delay(10); - } while (!success); -} - void setup() { Serial.begin(115200); - delay(2000); - Serial.println("boot"); - wire.begin(); - ocularium::scan(wire); - startup_checks(); + bringup::init_buses(); + bringup::init_pins(); + +#if SCAN_I2C + Serial.println("scanning..."); + scan(Wire1); +#endif + + bringup::startup_checks(STARTUP_CHECKS); Serial.println("sensors initialized"); + + bringup::boot_animation(); + delay(100); + + digitalWrite(LED_CAPTURING, HIGH); } void loop() { @@ -92,7 +73,7 @@ void loop() { bme_target_millis = bme.beginReading(); } - Serial.print("lux: " + String(veml.lux())); + Serial.print("lux: " + String(lux.lux())); Serial.print(", temp: " + String(bme.temperature)); Serial.print(", hum: " + String(bme.humidity)); Serial.print(", pres: " + String(bme.pressure)); |
