diff --git a/BroncoDeployment/Top/BroncoDeploymentPackets.xml b/BroncoDeployment/Top/BroncoDeploymentPackets.xml
index 90d5f44..13f8261 100644
--- a/BroncoDeployment/Top/BroncoDeploymentPackets.xml
+++ b/BroncoDeployment/Top/BroncoDeploymentPackets.xml
@@ -53,9 +53,9 @@
-
-
-
+
+
+
diff --git a/BroncoDeployment/Top/BroncoDeploymentTopology.cpp b/BroncoDeployment/Top/BroncoDeploymentTopology.cpp
index 965073c..69cfff7 100644
--- a/BroncoDeployment/Top/BroncoDeploymentTopology.cpp
+++ b/BroncoDeployment/Top/BroncoDeploymentTopology.cpp
@@ -77,12 +77,6 @@ void configureTopology() {
// Framer and Deframer components need to be passed a protocol handler
framer.setup(framing);
deframer.setup(deframing);
-
- // gpioDriver.open(Arduino::DEF_LED_BUILTIN, Arduino::GpioDriver::GpioDirection::OUT);
- // bool gpio_success = gpioDriver.open(27, Arduino::GpioDriver::GpioDirection::OUT);
- // if (!gpio_success) {
- // Fw::Logger::logMsg("[ERROR] Failed to open GPIO pin\n"); // requires os
- // }
}
// Public functions for use in main program are namespaced with deployment name BroncoDeployment
diff --git a/BroncoDeployment/Top/instances.fpp b/BroncoDeployment/Top/instances.fpp
index bf8ff44..1f36080 100644
--- a/BroncoDeployment/Top/instances.fpp
+++ b/BroncoDeployment/Top/instances.fpp
@@ -28,7 +28,7 @@ module BroncoDeployment {
stack size Default.STACK_SIZE \
priority 97
- instance led: Components.Led base id 0x0E00 \
+ instance ledBlinker: Components.LedBlinker base id 0x0E00 \
queue size Default.QUEUE_SIZE \
stack size Default.STACK_SIZE \
priority 95
@@ -65,6 +65,8 @@ module BroncoDeployment {
instance rateDriver: Arduino.HardwareRateDriver base id 0x4A00
+ instance neoPixelDriver: Drv.NeoPixelDriver base id 0x4C00
+
# Hub Connections
instance hub: Svc.GenericHub base id 0x5000
@@ -75,10 +77,7 @@ module BroncoDeployment {
instance hubComDriver: Radio.RFM69 base id 0x5300
-
-
# Custom Connections
instance broncoOreMessageHandler: Components.BroncoOreMessageHandler base id 0x6000
- instance gpioDriver: Arduino.GpioDriver base id 0x4C00
}
diff --git a/BroncoDeployment/Top/topology.fpp b/BroncoDeployment/Top/topology.fpp
index f28694b..9867f4d 100644
--- a/BroncoDeployment/Top/topology.fpp
+++ b/BroncoDeployment/Top/topology.fpp
@@ -44,8 +44,8 @@ module BroncoDeployment {
#custom instances
instance broncoOreMessageHandler
- instance led
- instance gpioDriver
+ instance ledBlinker
+ instance neoPixelDriver
# ----------------------------------------------------------------------
# Pattern graph specifiers
@@ -132,9 +132,9 @@ module BroncoDeployment {
# Named connection group
connections LedConnections {
# Rate Group 1 (1Hz cycle) ouput is connected to led's run input
- rateGroup1.RateGroupMemberOut[3] -> led.run
- # led's gpioSet output is connected to gpioDriver's gpioWrite input
- led.gpioSet -> gpioDriver.gpioWrite
+ rateGroup1.RateGroupMemberOut[3] -> ledBlinker.run
+ # led's neopixel output is connected to neoPixelDriver's neoPixelOnOff input
+ ledBlinker.neoPixelSet -> neoPixelDriver.neoPixelWrite
}
}
diff --git a/Components/CMakeLists.txt b/Components/CMakeLists.txt
index 415b811..bedc4d2 100644
--- a/Components/CMakeLists.txt
+++ b/Components/CMakeLists.txt
@@ -4,5 +4,5 @@
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BroncoOreMessageHandler/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Radio/")
-add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Led/")
+add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/LedBlinker/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Drv/")
diff --git a/Components/Drv/NeoPixelDriver/NeoPixelDriver.cpp b/Components/Drv/NeoPixelDriver/NeoPixelDriver.cpp
index e7df875..175200e 100644
--- a/Components/Drv/NeoPixelDriver/NeoPixelDriver.cpp
+++ b/Components/Drv/NeoPixelDriver/NeoPixelDriver.cpp
@@ -32,7 +32,7 @@ NeoPixelDriver ::~NeoPixelDriver() {}
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------
-void NeoPixelDriver ::neoPixelOnOff_handler(NATIVE_INT_TYPE portNum, const Fw::On& on_off, U8 red, U8 green, U8 blue) {
+void NeoPixelDriver ::neoPixelWrite_handler(NATIVE_INT_TYPE portNum, const Fw::On& on_off, U8 red, U8 green, U8 blue) {
this->on_off = on_off;
this->red = red;
this->green = green;
@@ -40,8 +40,7 @@ void NeoPixelDriver ::neoPixelOnOff_handler(NATIVE_INT_TYPE portNum, const Fw::O
if (Fw::On::ON == this->on_off) {
pixels.setPixelColor(0, pixels.Color(red, green, blue));
- }
- else {
+ } else {
pixels.setPixelColor(0, pixels.Color(0, 0, 0));
}
diff --git a/Components/Drv/NeoPixelDriver/NeoPixelDriver.fpp b/Components/Drv/NeoPixelDriver/NeoPixelDriver.fpp
index 126221b..012f7a8 100644
--- a/Components/Drv/NeoPixelDriver/NeoPixelDriver.fpp
+++ b/Components/Drv/NeoPixelDriver/NeoPixelDriver.fpp
@@ -2,7 +2,8 @@ module Drv {
@ FPrime driver implmementation for Adafruit NeoPixel.
passive component NeoPixelDriver {
- sync input port neoPixelOnOff: Drv.NeoPixelOnOff
+ @ Port to turn modify the NeoPixel state.
+ sync input port neoPixelWrite: Drv.NeoPixelWrite
###############################################################################
# Standard AC Ports: Required for Channels, Events, Commands, and Parameters #
diff --git a/Components/Drv/NeoPixelDriver/NeoPixelDriver.hpp b/Components/Drv/NeoPixelDriver/NeoPixelDriver.hpp
index c00af0f..b59799b 100644
--- a/Components/Drv/NeoPixelDriver/NeoPixelDriver.hpp
+++ b/Components/Drv/NeoPixelDriver/NeoPixelDriver.hpp
@@ -31,17 +31,18 @@ class NeoPixelDriver : public NeoPixelDriverComponentBase {
// ----------------------------------------------------------------------
//! Handler implementation for onOff
- void neoPixelOnOff_handler(NATIVE_INT_TYPE portNum, //!< The port number
- const Fw::On& on_off,
- U8 red,
- U8 green,
- U8 blue) override;
+ void neoPixelWrite_handler(NATIVE_INT_TYPE portNum, //!< The port number
+ const Fw::On& on_off,
+ U8 red,
+ U8 green,
+ U8 blue) override;
PRIVATE:
- Fw::On state;
+ Fw::On on_off;
U8 red;
U8 green;
U8 blue;
+ Adafruit_NeoPixel pixels;
};
} // namespace Drv
diff --git a/Components/Drv/NeoPixelDriverPorts/NeoPixelDriverPorts.fpp b/Components/Drv/NeoPixelDriverPorts/NeoPixelDriverPorts.fpp
index 0b5bd36..24a4c10 100644
--- a/Components/Drv/NeoPixelDriverPorts/NeoPixelDriverPorts.fpp
+++ b/Components/Drv/NeoPixelDriverPorts/NeoPixelDriverPorts.fpp
@@ -1,5 +1,5 @@
module Drv {
- port NeoPixelOnOff(
+ port NeoPixelWrite(
on_off: Fw.On
$red: U8
green: U8
diff --git a/Components/Led/CMakeLists.txt b/Components/LedBlinker/CMakeLists.txt
similarity index 82%
rename from Components/Led/CMakeLists.txt
rename to Components/LedBlinker/CMakeLists.txt
index 7c57b75..37fb734 100644
--- a/Components/Led/CMakeLists.txt
+++ b/Components/LedBlinker/CMakeLists.txt
@@ -7,8 +7,8 @@
#
####
set(SOURCE_FILES
- "${CMAKE_CURRENT_LIST_DIR}/Led.fpp"
- "${CMAKE_CURRENT_LIST_DIR}/Led.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/LedBlinker.fpp"
+ "${CMAKE_CURRENT_LIST_DIR}/LedBlinker.cpp"
)
# Uncomment and add any modules that this component depends on, else
diff --git a/Components/Led/Led.cpp b/Components/LedBlinker/LedBlinker.cpp
similarity index 58%
rename from Components/Led/Led.cpp
rename to Components/LedBlinker/LedBlinker.cpp
index 780266f..b061c9d 100644
--- a/Components/Led/Led.cpp
+++ b/Components/LedBlinker/LedBlinker.cpp
@@ -1,37 +1,32 @@
// ======================================================================
-// \title Led.cpp
+// \title LedBlinker.cpp
// \author nateinaction
-// \brief cpp file for Led component implementation class
+// \brief cpp file for LedBlinker component implementation class
// ======================================================================
-#include "Components/Led/Led.hpp"
+#include "Components/LedBlinker/LedBlinker.hpp"
#include "FpConfig.hpp"
namespace Components {
-#define PIN 24
-#define NUMPIXELS 1
-
// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------
-Led ::Led(const char* const compName) : LedComponentBase(compName),
- state(Fw::On::OFF),
- transitions(0),
- count(0),
- blinking(false),
- pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800)
+LedBlinker ::LedBlinker(const char* const compName) : LedBlinkerComponentBase(compName),
+ blinking(Fw::On::OFF),
+ blinkCount(0),
+ cycleCount(0)
{
- pixels.begin();
+
}
-Led ::~Led() {}
+LedBlinker ::~LedBlinker() {}
// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------
- void Led ::
+ void LedBlinker ::
run_handler(
const NATIVE_INT_TYPE portNum,
NATIVE_UINT_TYPE context)
@@ -44,54 +39,21 @@ Led ::~Led() {}
interval = ((Fw::ParamValid::INVALID == isValid) || (Fw::ParamValid::UNINIT == isValid)) ? 0 : interval;
// Only perform actions when set to blinking
- bool is_blinking = this->blinking;
- if (is_blinking)
- {
- Fw::On new_state = this->state;
- // Check for transitions
- if ((0 == this->count) && (this->state == Fw::On::OFF))
- {
- new_state = Fw::On::ON;
- }
- else if (((interval / 2) == this->count) && (this->state == Fw::On::ON))
- {
- new_state = Fw::On::OFF;
- }
+ if (this->blinking == Fw::On::ON) {
+ bool transition_occurred = false;
- // A transition has occurred
- if (this->state != new_state)
- {
- this->transitions = this->transitions + 1;
+ if (0 == this->cycleCount) {
+ this->neoPixelSet_out(0, Fw::On::ON, 255, 0, 0);
- // Report the number of LED transitions (this->transitions)
- this->tlmWrite_LedTransitions(this->transitions);
-
- if (Fw::On::ON == new_state) {
- pixels.setPixelColor(0, pixels.Color(150, 0, 0));
- }
- else {
- pixels.setPixelColor(0, pixels.Color(0, 0, 0));
- }
-
- pixels.show();
-
- this->state = new_state;
- this->tlmWrite_BlinkingState(this->state);
+ this->blinkCount = this->blinkCount + 1;
+ this->tlmWrite_LedBlinks(this->blinkCount);
+ } else if ((interval / 2) == this->cycleCount) {
+ this->neoPixelSet_out(0, Fw::On::OFF, 0, 0, 0);
}
- this->count = ((this->count + 1) >= interval) ? 0 : (this->count + 1);
- }
- else
- {
- if(this->state == Fw::On::ON)
- {
- pixels.setPixelColor(0, pixels.Color(0, 0, 0));
- pixels.show();
-
- this->state = Fw::On::OFF;
-
- this->tlmWrite_BlinkingState(this->state);
- }
+ this->cycleCount = ((this->cycleCount + 1) >= interval) ? 0 : (this->cycleCount + 1);
+ } else {
+ this->neoPixelSet_out(0, Fw::On::OFF, 0, 0, 0);
}
}
@@ -99,7 +61,7 @@ Led ::~Led() {}
// Handler implementations for commands
// ----------------------------------------------------------------------
-void Led ::
+void LedBlinker ::
BLINKING_ON_OFF_cmdHandler(
const FwOpcodeType opCode,
const U32 cmdSeq,
@@ -122,7 +84,7 @@ void Led ::
else
{
this->count = 0; // Reset count on any successful command
- this->blinking = Fw::On::ON == on_off; // Update blinking state
+ this->blinking = on_off; // Update blinking state
// Reports the state we set to blinking.
this->log_ACTIVITY_HI_SetBlinkingState(on_off);
@@ -135,7 +97,7 @@ void Led ::
this->cmdResponse_out(opCode,cmdSeq,cmdResp);
}
- void Led ::parameterUpdated(FwPrmIdType id) {
+ void LedBlinker ::parameterUpdated(FwPrmIdType id) {
// Read back the parameter value
Fw::ParamValid isValid;
U32 interval = this->paramGet_BLINK_INTERVAL(isValid);
diff --git a/Components/Led/Led.fpp b/Components/LedBlinker/LedBlinker.fpp
similarity index 71%
rename from Components/Led/Led.fpp
rename to Components/LedBlinker/LedBlinker.fpp
index 9885c26..c148bb2 100644
--- a/Components/Led/Led.fpp
+++ b/Components/LedBlinker/LedBlinker.fpp
@@ -1,6 +1,6 @@
module Components {
@ Component to blink an LED driven by a rate group
- active component Led {
+ active component LedBlinker {
@ Command to turn on or off the blinking LED
async command BLINKING_ON_OFF(
@@ -21,7 +21,7 @@ module Components {
severity activity high \
format "LED blink interval set to {}"
- event LedState(on_off: Fw.On) \
+ event LedBlinkerState(on_off: Fw.On) \
severity activity low \
format "LED is {}"
@@ -29,7 +29,7 @@ module Components {
telemetry BlinkingState: Fw.On
@ Telemetry channel to report the LED state.
- telemetry LedTransitions: U64
+ telemetry LedBlinks: U64
@ Blinking interval in rate group ticks
param BLINK_INTERVAL: U32
@@ -38,26 +38,7 @@ module Components {
sync input port run: Svc.Sched
@ Port sending calls to the GPIO driver
- output port neoPixelSet: Drv.NeoPixelDriver
-
- ##############################################################################
- #### Uncomment the following examples to start customizing your component ####
- ##############################################################################
-
- # @ Example async command
- # async command COMMAND_NAME(param_name: U32)
-
- # @ Example telemetry counter
- # telemetry ExampleCounter: U64
-
- # @ Example event
- # event ExampleStateEvent(example_state: Fw.On) severity activity high id 0 format "State set to {}"
-
- # @ Example port: receiving calls from the rate group
- # sync input port run: Svc.Sched
-
- # @ Example parameter
- # param PARAMETER_NAME: U32
+ output port neoPixelSet: Drv.NeoPixelWrite
###############################################################################
# Standard AC Ports: Required for Channels, Events, Commands, and Parameters #
diff --git a/Components/Led/Led.hpp b/Components/LedBlinker/LedBlinker.hpp
similarity index 68%
rename from Components/Led/Led.hpp
rename to Components/LedBlinker/LedBlinker.hpp
index c628656..3d7a685 100644
--- a/Components/Led/Led.hpp
+++ b/Components/LedBlinker/LedBlinker.hpp
@@ -1,29 +1,28 @@
// ======================================================================
-// \title Led.hpp
+// \title LedBlinker.hpp
// \author nateinaction
-// \brief hpp file for Led component implementation class
+// \brief hpp file for LedBlinker component implementation class
// ======================================================================
-#ifndef Components_Led_HPP
-#define Components_Led_HPP
+#ifndef Components_LedBlinker_HPP
+#define Components_LedBlinker_HPP
-#include "Components/Led/LedComponentAc.hpp"
-#include "lib/Adafruit_NeoPixel/Adafruit_NeoPixel.h"
+#include "Components/LedBlinker/LedBlinkerComponentAc.hpp"
namespace Components {
-class Led : public LedComponentBase {
+class LedBlinker : public LedBlinkerComponentBase {
public:
// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------
- //! Construct Led object
- Led(const char* const compName //!< The component name
+ //! Construct LedBlinker object
+ LedBlinker(const char* const compName //!< The component name
);
- //! Destroy Led object
- ~Led();
+ //! Destroy LedBlinker object
+ ~LedBlinker();
PRIVATE:
// ----------------------------------------------------------------------
@@ -58,11 +57,9 @@ class Led : public LedComponentBase {
);
PRIVATE:
- Fw::On state; //! Keeps track if LED is on or off
- U64 transitions; //! The number of on/off transitions that have occurred from FSW boot up
- U32 count; //! Keeps track of how many ticks the LED has been on for
- bool blinking; //! Flag: if true then LED blinking will occur else no blinking will happen
- Adafruit_NeoPixel pixels;
+ Fw::On blinking; //! If LED blinking is on
+ U64 blinkCount; //! The number of on/off transitions that have occurred from FSW boot up
+ U32 cycleCount; //! Keeps track of how many ticks the LED has been on for
};
} // namespace Components
diff --git a/Components/Led/docs/sdd.md b/Components/LedBlinker/docs/sdd.md
similarity index 95%
rename from Components/Led/docs/sdd.md
rename to Components/LedBlinker/docs/sdd.md
index 02c0bd6..fc8f77f 100644
--- a/Components/Led/docs/sdd.md
+++ b/Components/LedBlinker/docs/sdd.md
@@ -1,4 +1,4 @@
-# Components::Led
+# Components::LedBlinker
Component to blink an LED driven by a rate group
@@ -63,4 +63,4 @@ Add requirements in the chart below
## Change Log
| Date | Description |
|---|---|
-|---| Initial Draft |
\ No newline at end of file
+|---| Initial Draft |