|
|
|
@ -19,16 +19,16 @@ |
|
|
|
|
#include "looper.h" |
|
|
|
|
#include <RGBConverter.h> |
|
|
|
|
|
|
|
|
|
#define DEBUG 1 |
|
|
|
|
//#define DEBUG 1
|
|
|
|
|
|
|
|
|
|
#define SENSOR_SCHED 10 |
|
|
|
|
#define DMX_COLOR_CHANGER_SCHED 100 |
|
|
|
|
#define DMX_COLOR_CHANGER_SCHED 50 |
|
|
|
|
#define LED_SCHED 50 |
|
|
|
|
#define LEVEL_CHECK_SCHED 100 |
|
|
|
|
#define LEVEL_CHECK_SCHED 50 |
|
|
|
|
#define DEBUG_SCHED 500 |
|
|
|
|
|
|
|
|
|
#define BUTTON_LONG_PRESS 1000 |
|
|
|
|
#define MIN_TIME_SWITCH_PRESSED 50 |
|
|
|
|
#define MIN_TIME_SWITCH_PRESSED 30 |
|
|
|
|
#define POTI_DEAD_ZONE 3 |
|
|
|
|
#define LED_NORMAL_BRIGHTNESS 180 |
|
|
|
|
#define LED_PLAY_BRIGHTNESS 20 |
|
|
|
@ -36,7 +36,7 @@ |
|
|
|
|
#define MAX_VOL_LEVEL 30 |
|
|
|
|
#define MAX_DMX_LEVEL 255 |
|
|
|
|
#define DMX_FOG_MACHINE_ADDRESS 100 |
|
|
|
|
#define MAX_RAND_WHITE_LEVEL 128 |
|
|
|
|
#define MAX_RAND_WHITE_LEVEL 150 |
|
|
|
|
|
|
|
|
|
#define DMX_BRIGHTNESS 0 |
|
|
|
|
#define DMX_FADE_TIME 1 |
|
|
|
@ -47,7 +47,7 @@ |
|
|
|
|
#define MAX_DMX_FADE_TIME 15 |
|
|
|
|
#define MIN_DMX_HOLD_TIME 3 |
|
|
|
|
#define MAX_DMX_HOLD_TIME 30 |
|
|
|
|
#define ON_OFF_FADE_TIME 1 |
|
|
|
|
#define ON_OFF_FADE_TIME 1.5 |
|
|
|
|
|
|
|
|
|
// Arduino pins
|
|
|
|
|
#define POTI1_PIN A1 |
|
|
|
@ -75,7 +75,7 @@ enum { |
|
|
|
|
OFF |
|
|
|
|
}; |
|
|
|
|
bool fog_state = false; |
|
|
|
|
uint8_t light_state = NORMAL; |
|
|
|
|
uint8_t light_state = OFF; |
|
|
|
|
|
|
|
|
|
typedef struct { |
|
|
|
|
uint8_t dmx_type = 4; |
|
|
|
@ -152,10 +152,6 @@ void show_led(void) { |
|
|
|
|
|
|
|
|
|
void dmx_auto_colorchanger(void) { |
|
|
|
|
// DMX auto Fade
|
|
|
|
|
|
|
|
|
|
//if (light_state != NORMAL)
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
|
|
for (uint8_t s = 0; s < MAX_DMX_SPOTS; s++) { |
|
|
|
|
uint8_t diff_counter = 0; |
|
|
|
|
|
|
|
|
@ -170,7 +166,7 @@ void dmx_auto_colorchanger(void) { |
|
|
|
|
// start hold timer
|
|
|
|
|
if (light_state != NORMAL) |
|
|
|
|
continue; |
|
|
|
|
int8_t start = MIN_DMX_HOLD_TIME + MIN_DMX_HOLD_TIME * poti_level[1] / 255.0 * 4; |
|
|
|
|
int8_t start = MIN_DMX_HOLD_TIME + MIN_DMX_HOLD_TIME * poti_level[DMX_HOLD_TIME] / 255.0 * MIN_DMX_HOLD_TIME; |
|
|
|
|
spot[s].steps = random(start, start + ((MAX_DMX_HOLD_TIME - start) * poti_level[DMX_HOLD_TIME] / 255.0)) * 1000 / DMX_COLOR_CHANGER_SCHED; |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Spot ")); |
|
|
|
@ -185,7 +181,7 @@ void dmx_auto_colorchanger(void) { |
|
|
|
|
continue; |
|
|
|
|
RGBConverter color_converter; |
|
|
|
|
uint8_t rgb[3]; |
|
|
|
|
uint8_t start = MIN_DMX_FADE_TIME + MIN_DMX_FADE_TIME * poti_level[2] / 255.0 * 4; |
|
|
|
|
uint8_t start = MIN_DMX_FADE_TIME + MIN_DMX_FADE_TIME * poti_level[DMX_FADE_TIME] / 255.0 * MIN_DMX_FADE_TIME; |
|
|
|
|
|
|
|
|
|
color_converter.hsvToRgb(random(0, 1024) / 1024.0, 1.0, 1.0, rgb); |
|
|
|
|
|
|
|
|
@ -212,7 +208,7 @@ void dmx_auto_colorchanger(void) { |
|
|
|
|
Serial.println(F(" seconds")); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
} /* else {
|
|
|
|
|
for (uint8_t i = 0; i < spot[s].dmx_type; i++) { |
|
|
|
|
if (spot[s].diff[i] != 0.0) { |
|
|
|
|
spot[s].values[i] += spot[s].diff[i]; |
|
|
|
@ -224,7 +220,6 @@ void dmx_auto_colorchanger(void) { |
|
|
|
|
DmxSimple.write(spot[s].address + i, uint8_t(spot[s].values[i] * poti_level[DMX_BRIGHTNESS] / 255.0 + 0.5)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Spot ")); |
|
|
|
|
Serial.print(s, DEC); |
|
|
|
@ -237,12 +232,13 @@ void dmx_auto_colorchanger(void) { |
|
|
|
|
Serial.print(F(" value ")); |
|
|
|
|
Serial.println(spot[s].values[i], 4); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
spot[s].steps--; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dmx_commit(); |
|
|
|
|
|
|
|
|
|
// Fog machine
|
|
|
|
|
if (fog_state == true) { |
|
|
|
|
DmxSimple.write(DMX_FOG_MACHINE_ADDRESS, poti_level[DMX_FOG_LEVEL]); |
|
|
|
@ -269,6 +265,24 @@ void test_worker(void) { |
|
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
|
// HELPER FUNCTIONS
|
|
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
|
void dmx_commit(void) { |
|
|
|
|
float l = pow(poti_level[DMX_BRIGHTNESS] / 255.0, 3); |
|
|
|
|
|
|
|
|
|
for (uint8_t s = 0; s < MAX_DMX_SPOTS; s++) { |
|
|
|
|
for (uint8_t i = 0; i < spot[s].dmx_type; i++) { |
|
|
|
|
//if (spot[s].diff[i] != 0.0) {
|
|
|
|
|
spot[s].values[i] += spot[s].diff[i]; |
|
|
|
|
if (spot[s].values[i] > 255.0) |
|
|
|
|
spot[s].values[i] = 255.0; |
|
|
|
|
else if (spot[s].values[i] < 0) |
|
|
|
|
spot[s].values[i] = 0.0; |
|
|
|
|
|
|
|
|
|
DmxSimple.write(spot[s].address + i, uint8_t(spot[s].values[i] * l + 0.5)); |
|
|
|
|
} |
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void do_level(uint8_t p) { |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("POTI ")); |
|
|
|
@ -442,13 +456,13 @@ uint8_t poti_pin_by_number(byte n) { |
|
|
|
|
return (0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void set_rgbw(dmx_spot* spot, uint8_t fade, uint8_t* rgb, uint8_t w) { |
|
|
|
|
void set_rgbw(dmx_spot* spot, float fade, uint8_t* rgb, uint8_t w) { |
|
|
|
|
spot->steps = fade * 1000 / DMX_COLOR_CHANGER_SCHED; |
|
|
|
|
spot->diff[3] = (w - spot->values[3]) / spot->steps; |
|
|
|
|
set_rgb(spot, fade, rgb); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void set_rgb(dmx_spot* spot, uint8_t fade, uint8_t* rgb) { |
|
|
|
|
void set_rgb(dmx_spot* spot, float fade, uint8_t* rgb) { |
|
|
|
|
spot->steps = fade * 1000 / DMX_COLOR_CHANGER_SCHED; |
|
|
|
|
for (uint8_t i = 0; i < 3; i++) |
|
|
|
|
spot->diff[i] = (rgb[i] - spot->values[i]) / spot->steps; |
|
|
|
|