mirror of
https://github.com/skogaby/OpeNITHM.git
synced 2026-09-28 01:48:01 +03:00
(*) Improve the auto calibration for the slider (32k has been tested, 16k has not) (*) Move the calibration routines into the main loop, seems to improve consistency greatly (*) Simplify the reactive lighting code (*) Make the code style more consistent
57 lines
1.2 KiB
C++
57 lines
1.2 KiB
C++
#include "SerialLeds.h"
|
|
|
|
SerialLeds::SerialLeds()
|
|
{ }
|
|
|
|
void SerialLeds::saveLights() {
|
|
EEPROM.put(67, (byte) LIGHTS_FLAG);
|
|
EEPROM.put(68, led_on.r);
|
|
EEPROM.put(69, led_on.g);
|
|
EEPROM.put(70, led_on.b);
|
|
EEPROM.put(71, led_off.r);
|
|
EEPROM.put(72, led_off.g);
|
|
EEPROM.put(73, led_off.b);
|
|
EEPROM.put(40, divider_color.r);
|
|
EEPROM.put(41, divider_color.g);
|
|
EEPROM.put(42, divider_color.b);
|
|
}
|
|
|
|
void SerialLeds::loadLights() {
|
|
EEPROM.get(68, led_on.r);
|
|
EEPROM.get(69, led_on.g);
|
|
EEPROM.get(70, led_on.b);
|
|
EEPROM.get(71, led_off.r);
|
|
EEPROM.get(72, led_off.g);
|
|
EEPROM.get(73, led_off.b);
|
|
EEPROM.get(40, divider_color.r);
|
|
EEPROM.get(41, divider_color.g);
|
|
EEPROM.get(42, divider_color.b);
|
|
}
|
|
|
|
void SerialLeds::processBulk(uint8_t *buf)
|
|
{
|
|
if (memcmp(buf + 2, lastBuffer + 2, 98) != 0)
|
|
{
|
|
memcpy(ledData.raw, buf + 2, 96);
|
|
updateLeds = true;
|
|
}
|
|
|
|
memcpy(lastBuffer, buf, 100);
|
|
}
|
|
|
|
// Left to Right, zero index
|
|
RGBLed SerialLeds::getKey(uint8_t key)
|
|
{
|
|
if (key > 15)
|
|
key = 15;
|
|
return ledData.rgb[30 - (key * 2)];
|
|
}
|
|
|
|
// Left to Right, zero index
|
|
RGBLed SerialLeds::getDivider(uint8_t divider)
|
|
{
|
|
if (divider > 14)
|
|
divider = 14;
|
|
return ledData.rgb[29 - (divider * 2)];
|
|
}
|