FastLED 3.9.15
Loading...
Searching...
No Matches
ui_state.cpp
Go to the documentation of this file.
1
2
3#include "./ui_state.h"
4#include "shared/Painter.h"
5#include "fl/log/log.h"
7
8#include <Arduino.h>
9
10//#define UI_V1 // Based off the old midi shield with hand assmebled buttons.
11#define UI_V2 // Based on a new midi shield with buttons. https://learn.sparkfun.com/tutorials/midi-shield-hookup-guide
12#define UI_DBG
13
14
15// Silent fallback: many Arduino-core variants (ESP32, RP2040, nRF52, …) do
16// not expose `A3` / `A4` aliases. Previously this emitted a `#warning` that
17// fired on every board build (-Wcpp / hundreds of lines per CI run). The
18// fallback is harmless — we only use these macros as opaque pin numbers. #2728
19#ifndef A3
20#define A3 3
21#endif
22#ifndef A4
23#define A4 4
24#endif
25
26#ifdef __STM32F1__
27// Missing A-type pins, just use digital pins mapped to analog.
28#define PIN_POT_COLOR_SENSOR D3
29#define PIN_POT_VEL_SENSOR D4
30#else
31#define PIN_POT_COLOR_SENSOR A3
32#define PIN_POT_VEL_SENSOR A4
33#endif
34
35#define PIN_VIS_SELECT 2
36#define PIN_COLOR_SELECT 4
37
40
42 return color_pot.Read();
43}
44
46 return velocity_pot.Read();
47}
48
49
50//DigitalButton custom_notecolor_select(4);
53
54void ui_init() {
55}
56
57
58ui_state ui_update(uint32_t now_ms, uint32_t delta_ms) {
59 FL_UNUSED(delta_ms);
60
61 ui_state out;
62 vis_selector.Update(now_ms);
63 color_selector.Update();
64 int32_t curr_val = vis_selector.curr_val();
65 FL_DBG("curr_val: " << curr_val);
66
67 out.color_scheme = color_selector.curr_val();
68
69 //bool notecolor_on = custom_notecolor_select.Read();
70
71 //Serial.print("color selector: "); Serial.println(out.color_scheme);
72
73 //float velocity = read_velocity_bias();
74 //float color_selector = read_color_selector();
75
76 //Serial.print("velocity: "); Serial.print(velocity); Serial.print(", color_selector: "); Serial.print(color_selector);
77
78 //if (notecolor_on) {
79 // Serial.print(", notecolor_on: "); Serial.print(notecolor_on);
80 //}
81
82 //Serial.print("color_scheme: "); Serial.print(out.color_scheme); Serial.print(", vis selector: "); Serial.print(curr_val);
83
84 //Serial.println("");
85
86 //Serial.print("curr_val: "); Serial.print(curr_val);// Serial.print(", button state: "); Serial.println(vis_selector.button_.curr_val());;
87
88 out.which_visualizer = static_cast<Painter::VisState>(curr_val % Painter::kNumVisStates);
89 return out;
90}
#define FL_DBG
Definition log.h:388
Centralized logging categories for FastLED hardware interfaces and subsystems.
#define FL_UNUSED(x)
@ kNumVisStates
Definition Painter.h:21
int which_visualizer
Definition ui_state.h:13
int color_scheme
Definition ui_state.h:14
CountingButton vis_selector(PIN_VIS_SELECT)
ui_state ui_update(uint32_t now_ms, uint32_t delta_ms)
Definition ui_state.cpp:58
#define PIN_COLOR_SELECT
Definition ui_state.cpp:36
#define PIN_POT_VEL_SENSOR
Definition ui_state.cpp:32
#define PIN_VIS_SELECT
Definition ui_state.cpp:35
ColorSelector color_selector(PIN_COLOR_SELECT)
void ui_init()
Definition ui_state.cpp:54
#define PIN_POT_COLOR_SENSOR
Definition ui_state.cpp:31
float read_velocity_bias()
Definition ui_state.cpp:45
Potentiometer color_pot(PIN_POT_COLOR_SENSOR)
float read_color_selector()
Definition ui_state.cpp:41
Potentiometer velocity_pot(PIN_POT_VEL_SENSOR)