2424#define SIGNAL_ERROR_TOLERANCE 2 // Allow N bit errors in pattern matching
2525
2626uint8_t gpio_btn_taptempo_val = 0 ;
27+ #ifdef ECTOCORE_VERSION_4
28+ static const uint8_t gpio_mode_leds [4 ] = {
29+ GPIO_MODE_1 ,
30+ GPIO_MODE_2 ,
31+ GPIO_MODE_3 ,
32+ GPIO_MODE_4 ,
33+ };
34+ #endif
2735
2836// toggle the fx
2937void toggle_fx (uint8_t fx_num ) {
@@ -47,6 +55,63 @@ void ws2812_mode_color(WS2812 *ws2812) {
4755 }
4856}
4957
58+ void update_gpios_for_mode () {
59+ switch (ectocore_trigger_mode ) {
60+ case TRIGGER_MODE_KICK :
61+ // printf("[ectocore] trigger mode: kick\n");
62+ #ifdef ECTOCORE_VERSION_3
63+ gpio_put (GPIO_MODE_LEDA , 0 );
64+ gpio_put (GPIO_MODE_LEDB , 0 );
65+ #endif
66+ #ifdef ECTOCORE_VERSION_4
67+ for (uint8_t i = 0 ; i < 4 ; i ++ ) {
68+ gpio_put (gpio_mode_leds [i ], 1 );
69+ }
70+ gpio_put (gpio_mode_leds [0 ], 0 );
71+ #endif
72+ break ;
73+ case TRIGGER_MODE_SNARE :
74+ // printf("[ectocore] trigger mode: snare\n");
75+ #ifdef ECTOCORE_VERSION_3
76+ gpio_put (GPIO_MODE_LEDA , 1 );
77+ gpio_put (GPIO_MODE_LEDB , 0 );
78+ #endif
79+ #ifdef ECTOCORE_VERSION_4
80+ for (uint8_t i = 0 ; i < 4 ; i ++ ) {
81+ gpio_put (gpio_mode_leds [i ], 1 );
82+ }
83+ gpio_put (gpio_mode_leds [1 ], 0 );
84+ #endif
85+ break ;
86+ case TRIGGER_MODE_HH :
87+ printf ("[ectocore] trigger mode: hh\n" );
88+ #ifdef ECTOCORE_VERSION_3
89+ gpio_put (GPIO_MODE_LEDA , 0 );
90+ gpio_put (GPIO_MODE_LEDB , 1 );
91+ #endif
92+ #ifdef ECTOCORE_VERSION_4
93+ for (uint8_t i = 0 ; i < 4 ; i ++ ) {
94+ gpio_put (gpio_mode_leds [i ], 1 );
95+ }
96+ gpio_put (gpio_mode_leds [2 ], 0 );
97+ #endif
98+ break ;
99+ case TRIGGER_MODE_RANDOM :
100+ printf ("[ectocore] trigger mode: random\n" );
101+ #ifdef ECTOCORE_VERSION_3
102+ gpio_put (GPIO_MODE_LEDA , 1 );
103+ gpio_put (GPIO_MODE_LEDB , 1 );
104+ #endif
105+ #ifdef ECTOCORE_VERSION_4
106+ for (uint8_t i = 0 ; i < 4 ; i ++ ) {
107+ gpio_put (gpio_mode_leds [i ], 1 );
108+ }
109+ gpio_put (gpio_mode_leds [3 ], 0 );
110+ #endif
111+ break ;
112+ }
113+ }
114+
50115void ws2812_wheel_clear (WS2812 * ws2812 ) {
51116 debounce_ws2812_set_wheel = debounce_ws2812_set_wheel_time ;
52117 for (uint8_t i = 0 ; i < 16 ; i ++ ) {
@@ -529,12 +594,6 @@ void __not_in_flash_func(input_handling)() {
529594 gpio_put (GPIO_MODE_LEDB , 0 );
530595#endif
531596#ifdef ECTOCORE_VERSION_4
532- const uint8_t gpio_mode_leds [4 ] = {
533- GPIO_MODE_1 ,
534- GPIO_MODE_2 ,
535- GPIO_MODE_3 ,
536- GPIO_MODE_4 ,
537- };
538597 for (uint8_t i = 0 ; i < 4 ; i ++ ) {
539598 gpio_init (gpio_mode_leds [i ]);
540599 gpio_set_dir (gpio_mode_leds [i ], GPIO_OUT );
@@ -1332,6 +1391,12 @@ void __not_in_flash_func(input_handling)() {
13321391 if (mode_held_new_duration >= MODE_HOLD_DURATION_THRESHOLD &&
13331392 mode_held_duration < MODE_HOLD_DURATION_THRESHOLD ) {
13341393 printf ("[ectocore] MODE held for 2 seconds\n" );
1394+ if (ectocore_trigger_mode > 0 ) {
1395+ ectocore_trigger_mode -- ;
1396+ } else {
1397+ ectocore_trigger_mode = 4 - 1 ;
1398+ }
1399+ update_gpios_for_mode ();
13351400 }
13361401 mode_held_duration = mode_held_new_duration ;
13371402 }
@@ -1415,60 +1480,7 @@ void __not_in_flash_func(input_handling)() {
14151480 } else {
14161481 ectocore_trigger_mode = 0 ;
14171482 }
1418- switch (ectocore_trigger_mode ) {
1419- case TRIGGER_MODE_KICK :
1420- // printf("[ectocore] trigger mode: kick\n");
1421- #ifdef ECTOCORE_VERSION_3
1422- gpio_put (GPIO_MODE_LEDA , 0 );
1423- gpio_put (GPIO_MODE_LEDB , 0 );
1424- #endif
1425- #ifdef ECTOCORE_VERSION_4
1426- for (uint8_t i = 0 ; i < 4 ; i ++ ) {
1427- gpio_put (gpio_mode_leds [i ], 1 );
1428- }
1429- gpio_put (gpio_mode_leds [0 ], 0 );
1430- #endif
1431- break ;
1432- case TRIGGER_MODE_SNARE :
1433- // printf("[ectocore] trigger mode: snare\n");
1434- #ifdef ECTOCORE_VERSION_3
1435- gpio_put (GPIO_MODE_LEDA , 1 );
1436- gpio_put (GPIO_MODE_LEDB , 0 );
1437- #endif
1438- #ifdef ECTOCORE_VERSION_4
1439- for (uint8_t i = 0 ; i < 4 ; i ++ ) {
1440- gpio_put (gpio_mode_leds [i ], 1 );
1441- }
1442- gpio_put (gpio_mode_leds [1 ], 0 );
1443- #endif
1444- break ;
1445- case TRIGGER_MODE_HH :
1446- printf ("[ectocore] trigger mode: hh\n" );
1447- #ifdef ECTOCORE_VERSION_3
1448- gpio_put (GPIO_MODE_LEDA , 0 );
1449- gpio_put (GPIO_MODE_LEDB , 1 );
1450- #endif
1451- #ifdef ECTOCORE_VERSION_4
1452- for (uint8_t i = 0 ; i < 4 ; i ++ ) {
1453- gpio_put (gpio_mode_leds [i ], 1 );
1454- }
1455- gpio_put (gpio_mode_leds [2 ], 0 );
1456- #endif
1457- break ;
1458- case TRIGGER_MODE_RANDOM :
1459- printf ("[ectocore] trigger mode: random\n" );
1460- #ifdef ECTOCORE_VERSION_3
1461- gpio_put (GPIO_MODE_LEDA , 1 );
1462- gpio_put (GPIO_MODE_LEDB , 1 );
1463- #endif
1464- #ifdef ECTOCORE_VERSION_4
1465- for (uint8_t i = 0 ; i < 4 ; i ++ ) {
1466- gpio_put (gpio_mode_leds [i ], 1 );
1467- }
1468- gpio_put (gpio_mode_leds [3 ], 0 );
1469- #endif
1470- break ;
1471- }
1483+ update_gpios_for_mode ();
14721484 }
14731485 }
14741486 } else if (gpio_btns [i ] == GPIO_BTN_BANK ) {
0 commit comments