From 12e3713e7705e4353d306ae2ec03abfe8fcd5f55 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 21 Mar 2022 09:43:10 +0100 Subject: feat: add status LED --- src/gyronardo.cpp | 5 +++++ src/status.cpp | 13 +++++++++++++ src/status.hpp | 9 +++++++++ 3 files changed, 27 insertions(+) create mode 100644 src/status.cpp create mode 100644 src/status.hpp (limited to 'src') diff --git a/src/gyronardo.cpp b/src/gyronardo.cpp index bee13b6..9b1aa24 100644 --- a/src/gyronardo.cpp +++ b/src/gyronardo.cpp @@ -2,6 +2,7 @@ #include "sensor/calibration.hpp" #include "sensor/sensor.hpp" #include "serial.hpp" +#include "status.hpp" #include "utils.hpp" #include @@ -15,6 +16,8 @@ constexpr unsigned int BAUD_RATE = 9600U; void setup() { + initialize_status_leds(); + auto sout = common::make_shared(Serial, BAUD_RATE); auto sensor = common::make_shared(SENSOR_ADDRESS, Wire, SENSOR_THROTTLE_TIME); @@ -58,6 +61,8 @@ void setup() stop(); } + set_led_positive(HIGH); + *sout << "Finished calibrating sensor\n"; *sout << "Calibration values:\n" diff --git a/src/status.cpp b/src/status.cpp new file mode 100644 index 0000000..2712895 --- /dev/null +++ b/src/status.cpp @@ -0,0 +1,13 @@ +#include "status.hpp" + +#include + +void initialize_status_leds() noexcept +{ + pinMode(STATUS_LED_POSITIVE, OUTPUT); +} + +void set_led_positive(uint8_t value) noexcept +{ + digitalWrite(STATUS_LED_POSITIVE, value); +} diff --git a/src/status.hpp b/src/status.hpp new file mode 100644 index 0000000..ff8980e --- /dev/null +++ b/src/status.hpp @@ -0,0 +1,9 @@ +#pragma once + +#include + +constexpr uint8_t STATUS_LED_POSITIVE = 5U; + +void initialize_status_leds() noexcept; + +void set_led_positive(uint8_t value) noexcept; -- cgit v1.2.3-18-g5258