-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0bb800f
commit ce5db31
Showing
10 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Ports | ||
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/NeoPixelDriverPorts/") | ||
|
||
# Components | ||
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/NeoPixelDriver/") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#### | ||
# F prime CMakeLists.txt: | ||
# | ||
# SOURCE_FILES: combined list of source and autocoding files | ||
# MOD_DEPS: (optional) module dependencies | ||
# UT_SOURCE_FILES: list of source files for unit tests | ||
# | ||
#### | ||
set(SOURCE_FILES | ||
"${CMAKE_CURRENT_LIST_DIR}/NeoPixelDriver.fpp" | ||
"${CMAKE_CURRENT_LIST_DIR}/NeoPixelDriver.cpp" | ||
) | ||
|
||
set(MOD_DEPS | ||
Adafruit_NeoPixel | ||
) | ||
|
||
register_fprime_module() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// ====================================================================== | ||
// \title NeoPixelDriver.cpp | ||
// \author nate | ||
// \brief cpp file for NeoPixelDriver component implementation class | ||
// ====================================================================== | ||
|
||
#include "Components/Drv/NeoPixelDriver/NeoPixelDriver.hpp" | ||
#include "FpConfig.hpp" | ||
|
||
namespace Drv { | ||
|
||
// ---------------------------------------------------------------------- | ||
// Component construction and destruction | ||
// ---------------------------------------------------------------------- | ||
|
||
#define PIN 24 | ||
#define NUMPIXELS 1 | ||
|
||
NeoPixelDriver ::NeoPixelDriver(const char* const compName) : NeoPixelDriverComponentBase(compName), | ||
on_off(Fw::On::OFF), | ||
red(0), | ||
green(0), | ||
blue(0), | ||
pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800) | ||
{ | ||
pixels.begin(); | ||
} | ||
|
||
NeoPixelDriver ::~NeoPixelDriver() {} | ||
|
||
// ---------------------------------------------------------------------- | ||
// Handler implementations for user-defined typed input ports | ||
// ---------------------------------------------------------------------- | ||
|
||
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; | ||
this->blue = blue; | ||
|
||
if (Fw::On::ON == this->on_off) { | ||
pixels.setPixelColor(0, pixels.Color(red, green, blue)); | ||
} else { | ||
pixels.setPixelColor(0, pixels.Color(0, 0, 0)); | ||
} | ||
|
||
pixels.show(); | ||
} | ||
|
||
} // namespace Drv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Drv { | ||
@ FPrime driver implmementation for Adafruit NeoPixel. | ||
passive component NeoPixelDriver { | ||
|
||
@ Port to turn modify the NeoPixel state. | ||
sync input port neoPixelWrite: Drv.NeoPixelWrite | ||
|
||
@ Event to report current NeoPixel state. | ||
event NeoPixelState(on_off: Fw.On, $red: U8, green: U8, blue: U8) \ | ||
severity activity low \ | ||
format "LED is {} with color ({}, {}, {})" | ||
|
||
############################################################################### | ||
# Standard AC Ports: Required for Channels, Events, Commands, and Parameters # | ||
############################################################################### | ||
@ Port for requesting the current time | ||
time get port timeCaller | ||
|
||
@ Port for sending textual representation of events | ||
text event port logTextOut | ||
|
||
@ Port for sending events to downlink | ||
event port logOut | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// ====================================================================== | ||
// \title NeoPixelDriver.hpp | ||
// \author nate | ||
// \brief hpp file for NeoPixelDriver component implementation class | ||
// ====================================================================== | ||
|
||
#ifndef Drv_NeoPixelDriver_HPP | ||
#define Drv_NeoPixelDriver_HPP | ||
|
||
#include "Components/Drv/NeoPixelDriver/NeoPixelDriverComponentAc.hpp" | ||
#include "lib/Adafruit_NeoPixel/Adafruit_NeoPixel.h" | ||
|
||
namespace Drv { | ||
|
||
class NeoPixelDriver : public NeoPixelDriverComponentBase { | ||
public: | ||
// ---------------------------------------------------------------------- | ||
// Component construction and destruction | ||
// ---------------------------------------------------------------------- | ||
|
||
//! Construct NeoPixelDriver object | ||
NeoPixelDriver(const char* const compName //!< The component name | ||
); | ||
|
||
//! Destroy NeoPixelDriver object | ||
~NeoPixelDriver(); | ||
|
||
PRIVATE: | ||
// ---------------------------------------------------------------------- | ||
// Handler implementations for user-defined typed input ports | ||
// ---------------------------------------------------------------------- | ||
|
||
//! Handler implementation for onOff | ||
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 on_off; | ||
U8 red; | ||
U8 green; | ||
U8 blue; | ||
Adafruit_NeoPixel pixels; | ||
}; | ||
|
||
} // namespace Drv | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Drv::NeoPixelDriver | ||
|
||
FPrime driver implmementation for Adafruit NeoPixel. | ||
|
||
## Usage Examples | ||
Add usage examples here | ||
|
||
### Diagrams | ||
Add diagrams here | ||
|
||
### Typical Usage | ||
And the typical usage of the component here | ||
|
||
## Class Diagram | ||
Add a class diagram here | ||
|
||
## Port Descriptions | ||
| Name | Description | | ||
|---|---| | ||
|---|---| | ||
|
||
## Component States | ||
Add component states in the chart below | ||
| Name | Description | | ||
|---|---| | ||
|---|---| | ||
|
||
## Sequence Diagrams | ||
Add sequence diagrams here | ||
|
||
## Parameters | ||
| Name | Description | | ||
|---|---| | ||
|---|---| | ||
|
||
## Commands | ||
| Name | Description | | ||
|---|---| | ||
|---|---| | ||
|
||
## Events | ||
| Name | Description | | ||
|---|---| | ||
|---|---| | ||
|
||
## Telemetry | ||
| Name | Description | | ||
|---|---| | ||
|---|---| | ||
|
||
## Unit Tests | ||
Add unit test descriptions in the chart below | ||
| Name | Description | Output | Coverage | | ||
|---|---|---|---| | ||
|---|---|---|---| | ||
|
||
## Requirements | ||
Add requirements in the chart below | ||
| Name | Description | Validation | | ||
|---|---|---| | ||
|---|---|---| | ||
|
||
## Change Log | ||
| Date | Description | | ||
|---|---| | ||
|---| Initial Draft | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#### | ||
# F prime CMakeLists.txt: | ||
# | ||
# SOURCE_FILES: combined list of source and autocoding files | ||
# MOD_DEPS: (optional) module dependencies | ||
# | ||
#### | ||
set(SOURCE_FILES | ||
"${CMAKE_CURRENT_LIST_DIR}/NeoPixelDriverPorts.fpp" | ||
) | ||
|
||
register_fprime_module() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Drv { | ||
port NeoPixelWrite( | ||
on_off: Fw.On | ||
$red: U8 | ||
green: U8 | ||
blue: U8 | ||
) | ||
} |