-
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 1c2bed1
Showing
11 changed files
with
241 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 @@ | ||
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,41 @@ | ||
// ====================================================================== | ||
// \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), | ||
pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800) | ||
{ | ||
pixels.begin(); | ||
} | ||
|
||
NeoPixelDriver ::~NeoPixelDriver() {} | ||
|
||
// ---------------------------------------------------------------------- | ||
// Handler implementations for user-defined typed input ports | ||
// ---------------------------------------------------------------------- | ||
|
||
Drv::NeoPixelColor NeoPixelDriver ::neoPixelRead_handler(NATIVE_INT_TYPE portNum) { | ||
uint16_t color = pixels.getPixelColor(0); | ||
return Drv::NeoPixelColor((color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF); | ||
} | ||
|
||
void NeoPixelDriver ::neoPixelSet_handler(NATIVE_INT_TYPE portNum, const Drv::NeoPixelColor& color) { | ||
pixels.setPixelColor(0, pixels.Color(color.getred(), color.getgreen(), color.getblue())); | ||
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,43 @@ | ||
# Type definition | ||
module Drv { | ||
struct NeoPixelColor { | ||
$red: U8 @< Red color value. | ||
green: U8 @< Green color value. | ||
blue: U8 @< Blue color value. | ||
} | ||
} | ||
|
||
# Port definition | ||
module Drv { | ||
port NeoPixelSet(color: NeoPixelColor) | ||
port NeoPixelRead -> NeoPixelColor | ||
} | ||
|
||
# Component definition | ||
module Drv { | ||
@ FPrime driver implmementation for Adafruit NeoPixel. | ||
passive component NeoPixelDriver { | ||
@ Port to turn modify the NeoPixel state. | ||
sync input port neoPixelSet: NeoPixelSet | ||
|
||
@ Port to read the current NeoPixel state. | ||
sync input port neoPixelRead: NeoPixelRead | ||
|
||
@ Event to report current NeoPixel state. | ||
event NeoPixelState($red: U8, green: U8, blue: U8) \ | ||
severity activity low \ | ||
format "LED is set to ({}, {}, {})" | ||
|
||
############################################################################### | ||
# 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,51 @@ | ||
// ====================================================================== | ||
// \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 neoPixelRead | ||
//! | ||
//! Port to read the current NeoPixel state. | ||
Drv::NeoPixelColor neoPixelRead_handler(NATIVE_INT_TYPE portNum //!< The port number | ||
) override; | ||
|
||
//! Handler implementation for neoPixelSet | ||
//! | ||
//! Port to turn modify the NeoPixel state. | ||
void neoPixelSet_handler(NATIVE_INT_TYPE portNum, //!< The port number | ||
const Drv::NeoPixelColor& color) override; | ||
|
||
PRIVATE: | ||
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 | |
Submodule Adafruit_NeoPixel
added at
aa798f
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,14 @@ | ||
#### | ||
# F prime CMakeLists.txt: | ||
# | ||
# SOURCE_FILES: combined list of source and autocoding files | ||
# MOD_DEPS: (optional) module dependencies | ||
# | ||
# Note: using PROJECT_NAME as EXECUTABLE_NAME | ||
#### | ||
set(SOURCE_FILES | ||
"${CMAKE_CURRENT_LIST_DIR}/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp" | ||
) | ||
|
||
add_library(Adafruit_NeoPixel ${SOURCE_FILES}) | ||
target_include_directories(Adafruit_NeoPixel PUBLIC "${CMAKE_CURRENT_LIST_DIR}/Adafruit_NeoPixel") |
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