-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·67 lines (58 loc) · 1.9 KB
/
main.cpp
File metadata and controls
executable file
·67 lines (58 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright Jasper van Poelgeest 2018.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt)
#include "hwlib.hpp"
#include "dmx_ws2812b.hpp"
int main( void ){
// kill the watchdog
WDT->WDT_MR = WDT_MR_WDDIS;
// choose a program:
// 0 = dmx mode
// 1 = show mode
// 2 = test mode
uint8_t programma = 0;
if(programma == 0){
uint16_t channelModes[] = {1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60, 120};
dwarfNebula::DMX_WS2812B lamp(1, 120, channelModes, 16);
lamp.start();
}
else if(programma == 1){
int numLeds = 120;
dwarfNebula::WS2812B strip(numLeds);
int wait = 50;
int cycles = 5;
while(1){
strip.theaterChase(dwarfNebula::Color(255, 0, 0), wait, cycles);
strip.theaterChase(dwarfNebula::Color(255, 255, 0), wait, cycles);
strip.theaterChase(dwarfNebula::Color(0, 255, 0), wait, cycles);
strip.theaterChase(dwarfNebula::Color(0, 255, 255), wait, cycles);
strip.theaterChase(dwarfNebula::Color(0, 0, 255), wait, cycles);
strip.theaterChase(dwarfNebula::Color(255, 0, 255), wait, cycles);
strip.colorWipe(dwarfNebula::Color(255, 255, 255), wait/10);
strip.setColor(dwarfNebula::Color(0, 0, 0));
}
}
else if(programma == 2){
hwlib::cout << "\n\n";
hwlib::wait_ms(500);
hwlib::cout << "Start test\n";
hwlib::wait_ms(50);
unsigned int numLeds = 10;
dwarfNebula::WS2812B strip(numLeds);
for (unsigned int i = 0; i < numLeds; i++){
strip.setPixelColor(i, dwarfNebula::Color(0));
}
hwlib::wait_ms(50);
for (unsigned int i = 0; i < numLeds; i++){
if(strip.test(i, dwarfNebula::Color(0))){
hwlib::cout << "pixel " << i+1 << " passed the test!\n";
hwlib::wait_ms(50);
}
else{
hwlib::cout << "pixel " << i+1 << " failed the test!\n";
hwlib::wait_ms(50);
}
}
hwlib::cout << "End of test\n";
}
}