Fix uninitialized variables. This is not critical
This commit is contained in:
parent
7904dae4bf
commit
6f9d1474c6
37
main.c
37
main.c
@ -81,10 +81,10 @@ static void process_mode(enum color_mode mode, const struct poti_values *poti_va
|
||||
case MODE_GREEN:
|
||||
case MODE_BLUE:
|
||||
for (i = 0; i < 32; i++) {
|
||||
dmx_universe[i*4] = mode == MODE_RED ? poti_vals->pot_vals_filtered[0] : 0;
|
||||
dmx_universe[i*4+1] = mode == MODE_GREEN ? poti_vals->pot_vals_filtered[0] : 0;
|
||||
dmx_universe[i*4+2] = mode == MODE_BLUE ? poti_vals->pot_vals_filtered[0] : 0;
|
||||
dmx_universe[i*4+3] = 0x0;
|
||||
dmx_universe[i * 4 + 0] = mode == MODE_RED ? poti_vals->pot_vals_filtered[0] : 0;
|
||||
dmx_universe[i * 4 + 1] = mode == MODE_GREEN ? poti_vals->pot_vals_filtered[0] : 0;
|
||||
dmx_universe[i * 4 + 2] = mode == MODE_BLUE ? poti_vals->pot_vals_filtered[0] : 0;
|
||||
dmx_universe[i * 4 + 3] = 0x0;
|
||||
}
|
||||
dmx_universe[128] = 0;
|
||||
odr |= (1<<5);
|
||||
@ -92,20 +92,20 @@ static void process_mode(enum color_mode mode, const struct poti_values *poti_va
|
||||
case MODE_RGB:
|
||||
odr |= (1<<5) | (1<<6) | (1<<7);
|
||||
for (i = 0; i < 32; i++) {
|
||||
dmx_universe[i*4] =poti_vals->pot_vals_filtered[0];
|
||||
dmx_universe[i*4+1] = poti_vals->pot_vals_filtered[1];
|
||||
dmx_universe[i*4+2] = poti_vals->pot_vals_filtered[2];
|
||||
dmx_universe[i*4+3] = 0x0;
|
||||
dmx_universe[i * 4 + 0] =poti_vals->pot_vals_filtered[0];
|
||||
dmx_universe[i * 4 + 1] = poti_vals->pot_vals_filtered[1];
|
||||
dmx_universe[i * 4 + 2] = poti_vals->pot_vals_filtered[2];
|
||||
dmx_universe[i * 4 + 3] = 0x0;
|
||||
}
|
||||
dmx_universe[128] = 0;
|
||||
break;
|
||||
case MODE_WHITE_DISCRETE:
|
||||
odr |= (1<<5);
|
||||
odr |= (1<<5) | (1<<6);
|
||||
for (i = 0; i < 32; i++) {
|
||||
dmx_universe[i*4] = 0;
|
||||
dmx_universe[i*4+1] = 0;
|
||||
dmx_universe[i*4+2] = 0;
|
||||
dmx_universe[i*4+3] = 0;
|
||||
dmx_universe[i * 4 + 0] = 0;
|
||||
dmx_universe[i * 4 + 1] = 0;
|
||||
dmx_universe[i * 4 + 2] = 0;
|
||||
dmx_universe[i * 4 + 3] = gamma_corr(poti_vals->pot_vals_filtered[1]);
|
||||
}
|
||||
dmx_universe[128] = gamma_corr(poti_vals->pot_vals_filtered[0]);
|
||||
break;
|
||||
@ -171,10 +171,10 @@ int main(void)
|
||||
int i;
|
||||
uint8_t port;
|
||||
uint8_t button_pressed;
|
||||
enum color_mode mode = MODE_WHITE_DISCRETE;
|
||||
enum color_mode mode = MODE_DMX_SHUTDOWN;
|
||||
enum color_mode old_mode = MODE_BLUE;
|
||||
struct poti_values poti_vals;
|
||||
struct poti_values old_poti_vals;
|
||||
struct poti_values poti_vals = {0};
|
||||
struct poti_values old_poti_vals = {0};
|
||||
bool buttons_released_since_dual_press = true;
|
||||
|
||||
setup_pins();
|
||||
@ -191,8 +191,6 @@ int main(void)
|
||||
dmx_universe[i] = 0x00;
|
||||
}
|
||||
|
||||
dmx_stream_start();
|
||||
|
||||
while (1) {
|
||||
systick_wait_ms(20);
|
||||
poti_get_values(&poti_vals);
|
||||
@ -212,6 +210,7 @@ int main(void)
|
||||
if (!buttons_released_since_dual_press)
|
||||
button_pressed = 0u;
|
||||
} else {
|
||||
/* Buttons are released. Remember this */
|
||||
buttons_released_since_dual_press = true;
|
||||
}
|
||||
|
||||
@ -264,6 +263,6 @@ int main(void)
|
||||
|
||||
/* Move to old values. Used to detect changes */
|
||||
old_mode = mode;
|
||||
memcpy(&old_poti_vals, &poti_vals, sizeof(struct poti_values));
|
||||
old_poti_vals = poti_vals;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user