-#if CONFIG_MASTER_MODE
-/* parameters for master mode script commands */
-#define MASTER_PROGRAMS 2
-static PROGMEM uint8_t master_parameters[] = {
- /* first: colorwheel forward */
- 0, /* program index */
- 1, /* fade step */
- 2, /* fade delay */
- 0, /* fade sleep */
- 0, 0, /* hue start (little endian) */
- 20, 0, /* hue step (little endian) */
- -1, /* addr add */
- 255, /* saturation */
- 255, /* value */
-
- /* first: colorwheel backward */
- 0, /* program index */
- 1, /* fade step */
- 2, /* fade delay */
- 0, /* fade sleep */
- 0, 0, /* hue start (little endian) */
- 20, 0, /* hue step (little endian) */
- 1, /* addr add */
- 255, /* saturation */
- 255, /* value */
-};
-
-static PT_THREAD(remote_master_thread(struct pt *thread))
-{
- static struct remote_msg_start_program_t msg;
- static timer_t timer;
- static uint16_t sleep;
- static uint8_t *ptr;
- static uint8_t idx;
-
- PT_BEGIN(thread);
-
- /* wait */
- timer_set(&timer, MASTER_WAIT_BEFORE_SYNC);
- while(!timer_expired(&timer))
- PT_YIELD(thread);
-
- /* start program on all devices */
- msg.address = 0xff;
- msg.cmd = REMOTE_CMD_START_PROGRAM;
-
- while (1) {
- ptr = &master_parameters[0];
-
- for (idx = 0; idx < MASTER_PROGRAMS; idx++) {
- /* stop current program and fading */
- script_stop();
- pwm_stop_fading();
-
- /* start program colorwheel on all nodes */
- msg.script = pgm_read_byte(ptr++);
- /* load parameters */
- for (uint8_t i = 0; i < sizeof(msg.params); i++)
- msg.params.raw[i] = pgm_read_byte(ptr++);
-
- /* send */
- send_resync(MASTER_MODE_FIRST_ADDRESS);
- PT_YIELD(thread);
- send_msg((struct remote_msg_t *)&msg);
-
- /* start program locally */
- script_start(0, msg.script, &msg.params);
-
- /* sleep */
- sleep = MASTER_MODE_SLEEP;
- while (sleep--) {
- /* sleep 1s */
- timer_set(&timer, 100);
-
- while (!timer_expired(&timer))
- PT_YIELD(thread);
- }
- }
- }
-
- PT_END(thread);
-}
-#endif
-