-
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.
Create a spike lk_led tthat does not use FastLED but CoreLED instead.
- Loading branch information
Showing
3 changed files
with
95 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_led_) | ||
|
||
target_include_directories(spike_lk_led_ | ||
PRIVATE | ||
. | ||
) | ||
|
||
target_sources(spike_lk_led_ | ||
PRIVATE | ||
main.cpp | ||
) | ||
|
||
target_link_libraries(spike_lk_led_ | ||
CoreLED | ||
) | ||
|
||
target_link_custom_leka_targets(spike_lk_led_) |
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,73 @@ | ||
// Leka - LekaOS | ||
// Copyright 2022 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include <cstddef> | ||
|
||
#include "PinNames.h" | ||
|
||
// #include "drivers/BufferedSerial.h" | ||
// #include "drivers/HighResClock.h" | ||
// #include "rtos/Kernel.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 const NUM_BELT_LEDS = 20; | ||
auto const NUM_EAR_LEDS = 2; | ||
auto const BRIGHTNESS = 255; | ||
const std::array<RGB, 6> COLORS = { | ||
RGB::pure_green, RGB::pure_red, RGB::pure_blue, RGB::yellow, RGB::cyan, RGB::magenta, | ||
}; | ||
|
||
void ChangeColor(CoreLED coreled, uint8_t index) | ||
{ | ||
if (index < COLORS.size()) { | ||
coreled.setColor(COLORS[index]); | ||
coreled.showColor(); | ||
} | ||
coreled.hideColor(); | ||
} | ||
|
||
auto main() -> int | ||
{ | ||
mbed::SPI spi(LED_BELT_SPI_MOSI, NC, LED_BELT_SPI_SCK); | ||
CoreSPI corespi(spi); | ||
CoreLED belt(corespi, NUM_BELT_LEDS); | ||
CoreLED ear(corespi, NUM_EAR_LEDS); | ||
|
||
logger::init(); | ||
|
||
HelloWorld hello; | ||
hello.start(); | ||
log_info("Hello, World!\n\n"); | ||
|
||
int index = 0; | ||
|
||
belt.setColor(COLORS[index]); | ||
ear.setColor(RGB::pure_blue); | ||
|
||
belt.showColor(); | ||
ear.showColor(); | ||
|
||
rtos::ThisThread::sleep_for(2s); | ||
|
||
while (true) { | ||
index++; | ||
|
||
ChangeColor(belt, index); | ||
ChangeColor(ear, index); | ||
|
||
if (not belt.isOn() && not ear.isOn()) { | ||
index = 0; | ||
} | ||
|
||
rtos::ThisThread::sleep_for(10ms); | ||
} | ||
} |