-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test the CoreLED library as a replacement of FastLED.
- Loading branch information
Showing
3 changed files
with
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Leka - LekaOS | ||
# Copyright 2022 APF France handicap | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
add_mbed_executable(spike_lk_coreled) | ||
|
||
target_include_directories(spike_lk_coreled | ||
PRIVATE | ||
. | ||
) | ||
|
||
target_sources(spike_lk_coreled | ||
PRIVATE | ||
main.cpp | ||
) | ||
|
||
target_link_libraries(spike_lk_coreled | ||
CoreLED | ||
) | ||
|
||
target_link_custom_leka_targets(spike_lk_coreled) |
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,70 @@ | ||
// Leka - LekaOS | ||
// Copyright 2022 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// #include <cstddef> | ||
|
||
#include "PinNames.h" | ||
|
||
#include "rtos/ThisThread.h" | ||
|
||
#include "CoreLED.h" | ||
#include "CoreSPI.h" | ||
#include "HelloWorld.h" | ||
#include "LogKit.h" | ||
|
||
using namespace leka; | ||
using namespace std::chrono; | ||
|
||
auto constexpr NUM_BELT_LEDS = 20; | ||
auto constexpr NUM_EAR_LEDS = 2; | ||
|
||
constexpr std::array<RGB, 6> colors_available = { | ||
RGB::pure_green, RGB::pure_red, RGB::pure_blue, RGB::yellow, RGB::cyan, RGB::magenta, | ||
}; | ||
|
||
mbed::SPI spi_belt(LED_BELT_SPI_MOSI, NC, LED_BELT_SPI_SCK); | ||
mbed::SPI spi_ear(LED_EARS_SPI_MOSI, NC, LED_EARS_SPI_SCK); | ||
|
||
CoreSPI corespi_belt(spi_belt); | ||
CoreSPI corespi_ear(spi_ear); | ||
|
||
CoreLED belt(corespi_belt, NUM_BELT_LEDS); | ||
CoreLED ears(corespi_ear, NUM_EAR_LEDS); | ||
|
||
void changeColor(interface::LED &ears, interface::LED &belt) | ||
{ | ||
static auto index = uint8_t {0}; | ||
|
||
if (index < colors_available.size()) { | ||
ears.setColor(colors_available.at(index)); | ||
ears.showColor(); | ||
|
||
belt.setColor(colors_available.at(index)); | ||
belt.showColor(); | ||
|
||
index++; | ||
} else { | ||
ears.hideColor(); | ||
belt.hideColor(); | ||
|
||
index = 0; | ||
} | ||
} | ||
|
||
auto main() -> int | ||
{ | ||
logger::init(); | ||
|
||
HelloWorld hello; | ||
hello.start(); | ||
|
||
log_info("Hello, World!\n\n"); | ||
|
||
rtos::ThisThread::sleep_for(2s); | ||
|
||
while (true) { | ||
changeColor(belt, ears); | ||
rtos::ThisThread::sleep_for(1s); | ||
} | ||
} |