-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathHB-UNI-RGB-LED-CTRL.ino
109 lines (90 loc) · 3.13 KB
/
HB-UNI-RGB-LED-CTRL.ino
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//- -----------------------------------------------------------------------------------------------------------------------
// AskSin++
// 2018-08-03 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
//- -----------------------------------------------------------------------------------------------------------------------
// ci-test=yes board=328p aes=no
// define this to read the device id, serial and device type from bootloader section
// #define USE_OTA_BOOTLOADER
#define EI_NOTEXTERNAL
#include <EnableInterrupt.h>
#include <SPI.h>
#include <AskSinPP.h>
#include <LowPower.h>
#include <Register.h>
#include "analog.h"
//#define ENABLE_RGBW // for SK6812 LEDs
#define WSNUM_LEDS 5 //Anzahl angeschlossener LEDs
#define WSLED_PIN 9 //GPIO Pin LED Anschluss
#define WSLED_TYPE WS2812B //LED Typ
#define WSCOLOR_ORDER GRB //Farbreihenfolge
/*
#define PWM_ENABLED
#define PWM_RED_PIN 3
#define PWM_GREEN_PIN 5
#define PWM_BLUE_PIN 6
#define PWM_WHITE_PIN 9 //Pin für weiße LED, auskommentieren, wenn keine weiße LED vorhanden ist
#define PWM_WHITE_ONLY true //Wenn weiße LED vorhanden ist, soll nur diese angesteuert werden wenn die Farbe weiß ist?
*/
#define SLOW_PROGRAM_TIMER 30 //ms Wartezeit für den Übergang
#define NORMAL_PROGRAM_TIMER 15 //ms Wartezeit für den Übergang
#define FAST_PROGRAM_TIMER 0 //ms Wartezeit für den Übergang
#define FIRE_PROGRAM_COOLING 55
#define FIRE_PROGRAM_SPARKLING 120
#if defined __AVR_ATmega2560__
#define CONFIG_BUTTON_PIN 13
#else
#define CONFIG_BUTTON_PIN 8
#endif
#define ONBOARD_LED_PIN 4
#ifdef ENABLE_RGBW
#include "FastLED_RGBW.h"
#endif
#include "RGBCtrl.h"
#define PEERS_PER_CHANNEL 4
using namespace as;
// define all device properties
const struct DeviceInfo PROGMEM devinfo = {
{0xF3, 0x41, 0x01}, // Device ID
"JPRGB00001", // Device Serial
{0xF3, 0x41}, // Device Model
0x25, // Firmware Version
as::DeviceType::Dimmer, // Device Type
{0x01, 0x00} // Info Bytes
};
/**
Configure the used hardware
*/
#if defined __AVR_ATmega2560__
typedef AskSin<StatusLed<ONBOARD_LED_PIN>, NoBattery, Radio<LibSPI<53>, 2>> HalType;
#else
typedef AskSin<StatusLed<ONBOARD_LED_PIN>, NoBattery, Radio<LibSPI<10>, 2>> HalType;
#endif
DEFREGISTER(Reg0, MASTERID_REGS, 0x20, 0x21)
class Ws28xxList0 : public RegList0<Reg0> {
public:
Ws28xxList0(uint16_t addr) : RegList0<Reg0>(addr) {}
void defaults () {
clear();
}
};
typedef RGBLEDChannel<HalType, PEERS_PER_CHANNEL, Ws28xxList0> ChannelType;
typedef RGBLEDDevice<HalType, ChannelType, 3, Ws28xxList0> RGBLEDType;
HalType hal;
RGBLEDType sdev(devinfo, 0x20);
ConfigButton<RGBLEDType> cfgBtn(sdev);
void setup () {
DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER);
sdev.init(hal);
buttonISR(cfgBtn, CONFIG_BUTTON_PIN);
sdev.initDone();
}
void loop() {
bool worked = hal.runready();
bool poll = sdev.pollRadio();
if ( worked == false && poll == false ) {
#ifndef PWM_ENABLED
hal.activity.savePower<Idle<true>>(hal);
#endif
}
sdev.handleLED();
}