|
|
|
@ -17,6 +17,7 @@ |
|
|
|
|
#include "DmxSimple.h" |
|
|
|
|
#include <EEPROM.h> |
|
|
|
|
#include "looper.h" |
|
|
|
|
#include <RGBConverter.h> |
|
|
|
|
|
|
|
|
|
#define DEBUG 1 |
|
|
|
|
|
|
|
|
@ -36,8 +37,8 @@ |
|
|
|
|
#define MAX_DMX_SPOTS 2 |
|
|
|
|
|
|
|
|
|
#define MIN_DMX_FADE_TIME 1 |
|
|
|
|
#define MAX_DMX_FADE_TIME 5 |
|
|
|
|
#define MIN_DMX_HOLD_TIME 3 |
|
|
|
|
#define MAX_DMX_FADE_TIME 3 |
|
|
|
|
#define MIN_DMX_HOLD_TIME 5 |
|
|
|
|
#define MAX_DMX_HOLD_TIME 15 |
|
|
|
|
|
|
|
|
|
// Arduino pins
|
|
|
|
@ -144,7 +145,7 @@ void worker(void) { |
|
|
|
|
} |
|
|
|
|
if (diff_counter != 0) { |
|
|
|
|
// start hold timer
|
|
|
|
|
spot[s].steps = random(MIN_DMX_HOLD_TIME, MAX_DMX_HOLD_TIME) * 1000 / WORKER_SCHED; |
|
|
|
|
spot[s].steps = random(MIN_DMX_HOLD_TIME, MIN_DMX_HOLD_TIME + ((MAX_DMX_HOLD_TIME - MIN_DMX_HOLD_TIME) * poti_level[2] / 255.0)) * 1000 / WORKER_SCHED; |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Spot ")); |
|
|
|
|
Serial.print(s, DEC); |
|
|
|
@ -154,9 +155,14 @@ void worker(void) { |
|
|
|
|
#endif |
|
|
|
|
} else { |
|
|
|
|
// new random values
|
|
|
|
|
spot[s].steps = random(MIN_DMX_FADE_TIME, MAX_DMX_FADE_TIME) * 1000 / WORKER_SCHED; |
|
|
|
|
for (uint8_t i = 0; i < spot[s].dmx_type; i++) |
|
|
|
|
spot[s].diff[i] = (random(0, 255) - spot[s].values[i]) / spot[s].steps; |
|
|
|
|
RGBConverter color_converter; |
|
|
|
|
uint8_t rgb[3]; |
|
|
|
|
|
|
|
|
|
spot[s].steps = random(MIN_DMX_FADE_TIME, MIN_DMX_FADE_TIME + ((MAX_DMX_FADE_TIME - MIN_DMX_FADE_TIME) * poti_level[1] / 255.0)) * 1000 / WORKER_SCHED; |
|
|
|
|
color_converter.hsvToRgb(random(0, 1024) / 1024.0, random(0, 1024) / 1024.0, random(128, 255) / 255.0, rgb); |
|
|
|
|
for (uint8_t i = 0; i < 3; i++) |
|
|
|
|
spot[s].diff[i] = (rgb[i] - spot[s].values[i]) / spot[s].steps; |
|
|
|
|
spot[s].diff[3] = (random(0, 128) - spot[3].values[3]) / 255.0; |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Spot ")); |
|
|
|
|
Serial.print(s, DEC); |
|
|
|
@ -168,9 +174,9 @@ void worker(void) { |
|
|
|
|
} else { |
|
|
|
|
for (uint8_t i = 0; i < spot[s].dmx_type; i++) { |
|
|
|
|
spot[s].values[i] += spot[s].diff[i]; |
|
|
|
|
DmxSimple.write(spot[s].address + i, uint8_t(spot[s].values[i] + 0.5)); |
|
|
|
|
DmxSimple.write(spot[s].address + i, uint8_t(spot[s].values[i] * poti_level[0] / 255.0 + 0.5)); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Spot ")); |
|
|
|
|
/* Serial.print(F("Spot "));
|
|
|
|
|
Serial.print(s, DEC); |
|
|
|
|
Serial.print(F(" color ")); |
|
|
|
|
Serial.print(i, DEC); |
|
|
|
@ -179,7 +185,7 @@ void worker(void) { |
|
|
|
|
Serial.print(F(" diff ")); |
|
|
|
|
Serial.print(spot[s].diff[i], 4); |
|
|
|
|
Serial.print(F(" value ")); |
|
|
|
|
Serial.println(spot[s].values[i], 4); |
|
|
|
|
Serial.println(spot[s].values[i], 4);*/ |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -293,6 +299,8 @@ void setup() { |
|
|
|
|
|
|
|
|
|
mySoftwareSerial.begin(9600); |
|
|
|
|
|
|
|
|
|
randomSeed(analogRead(A6)); |
|
|
|
|
|
|
|
|
|
// setup poti pins
|
|
|
|
|
pinMode(POTI1_PIN, INPUT_PULLUP); |
|
|
|
|
pinMode(POTI2_PIN, INPUT_PULLUP); |
|
|
|
|