FastLED 3.9.7
Loading...
Searching...
No Matches
ui_state.cpp
1
2
3#include "../shared/defs.h"
4
5
6#if ENABLE_SKETCH
7
8
9#include "./ui_state.h"
10#include "shared/Painter.h"
11#include "fl/dbg.h"
12
13#include <Arduino.h>
14
15//#define UI_V1 // Based off the old midi shield with hand assmebled buttons.
16#define UI_V2 // Based on a new midi shield with buttons. https://learn.sparkfun.com/tutorials/midi-shield-hookup-guide
17#define UI_DBG
18
19#ifdef __STM32F1__
20// Missing A-type pins, just use digital pins mapped to analog.
21#define PIN_POT_COLOR_SENSOR D3
22#define PIN_POT_VEL_SENSOR D4
23#else
24#define PIN_POT_COLOR_SENSOR A3
25#define PIN_POT_VEL_SENSOR A4
26#endif
27
28#define PIN_VIS_SELECT 2
29#define PIN_COLOR_SELECT 4
30
31Potentiometer velocity_pot(PIN_POT_VEL_SENSOR);
32Potentiometer color_pot(PIN_POT_COLOR_SENSOR);
33
34float read_color_selector() {
35 return color_pot.Read();
36}
37
38float read_velocity_bias() {
39 return velocity_pot.Read();
40}
41
42
43//DigitalButton custom_notecolor_select(4);
44ColorSelector color_selector(PIN_COLOR_SELECT);
45CountingButton vis_selector(PIN_VIS_SELECT);
46
47void ui_init() {
48}
49
50
51ui_state ui_update(uint32_t now_ms, uint32_t delta_ms) {
52 ui_state out;
53 vis_selector.Update(now_ms);
54 color_selector.Update();
55 int32_t curr_val = vis_selector.curr_val();
56 FASTLED_DBG("curr_val: " << curr_val);
57
58 out.color_scheme = color_selector.curr_val();
59
60 //bool notecolor_on = custom_notecolor_select.Read();
61
62 //Serial.print("color selector: "); Serial.println(out.color_scheme);
63
64 //float velocity = read_velocity_bias();
65 //float color_selector = read_color_selector();
66
67 //Serial.print("velocity: "); Serial.print(velocity); Serial.print(", color_selector: "); Serial.print(color_selector);
68
69 //if (notecolor_on) {
70 // Serial.print(", notecolor_on: "); Serial.print(notecolor_on);
71 //}
72
73 //Serial.print("color_scheme: "); Serial.print(out.color_scheme); Serial.print(", vis selector: "); Serial.print(curr_val);
74
75 //Serial.println("");
76
77 //Serial.print("curr_val: "); Serial.print(curr_val);// Serial.print(", button state: "); Serial.println(vis_selector.button_.curr_val());;
78
79 out.which_visualizer = static_cast<Painter::VisState>(curr_val % Painter::kNumVisStates);
80 return out;
81}
82
83
84#endif // ENABLE_SKETCH