diff --git a/main.c b/main.c index 3d3d9fc..d4963bd 100644 --- a/main.c +++ b/main.c @@ -348,6 +348,7 @@ const uint8_t switch_timer_index[STATE_START_COUNT]= { 13, 0 }; /** contains the port assignments for each interval */ uint8_t switch_state[STATE_COUNT][PORT_COUNT]; +uint8_t switch_state_new[STATE_COUNT][PORT_COUNT]; /** * Three bytes have to be received for a full command. This enum is used to * indicate what part of the command we are waiting for. @@ -401,10 +402,10 @@ void set_brightness(uint8_t channel, uint16_t brightness){ // walk through all states... if (brightness & 1) { // set the bit if it needs to be set in this state - switch_state[i][port] |= mask; + switch_state_new[i][port] |= mask; } else { // clear it otherwise - switch_state[i][port] &= ~mask; + switch_state_new[i][port] &= ~mask; } // shift the value to look at the next bit brightness >>= 1; @@ -536,6 +537,12 @@ int main(void) { } } } + for(state_number= 0; state_number < STATE_COUNT; state_number++) { + for(port= 0; port < PORT_COUNT; port++) { + switch_state[state_number][port]= + switch_state_new[state_number][port]; + } + } } return 0; }