forked from melodyians/melodyian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
components_state.cpp
115 lines (83 loc) · 2.92 KB
/
components_state.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "components.h"
#include "types.h"
#include "constants_actions.h"
#include "helper_smoothing.h"
State::State() {
this->led_storage_ = new LEDStorage();
this->led_storage_->readFromEEPROM();
// TODO must update this if we get a low value. Saves some meory.
this->input_values = new InputValues(RED_CC);
// Default to "1000"
this->updateInput(RATE1_CC, (byte) 60);
// input_values->storeInput(RATE1_CC, (byte) 84); // Default to 1000
this->sound_state_ = new SoundState(112);
}
void State::updateInput(byte control_number, byte value) {
this->input_values->storeInput(control_number, value);
}
LEDStorage * State::led_storage() {
return this->led_storage_;
}
SoundState * State::sound_state() {
return this->sound_state_;
}
void State::setCurrentLEDValues(byte r, byte g, byte b) {
this->input_values->storeInput(RED_CC, r);
this->input_values->storeInput(GREEN_CC, g);
this->input_values->storeInput(BLUE_CC, b);
}
// Wrapper to input values
bool State::bypassRandomColor() {
return Smoothing::booleanButton(this->input_values->getValue(COLORJITTERBYPASS_CC));
}
bool State::bypassRandomNote() {
return Smoothing::booleanButton(this->input_values->getValue(NOTEJITTERBYPASS_CC));
}
float State::randomness() {
return Smoothing::mapByteToPercentage(this->input_values->getValue(JITTER_CC));
}
unsigned int State::decay() {
return (unsigned int) this->input_values->getValue(FADESPD_CC);
}
int State::rate() {
return Smoothing::smoothRateFader(this->input_values->getValue(RATE1_CC));
}
byte State::ledRedValue() {
return Smoothing::smoothRBGFader(this->input_values->getValue(RED_CC));
}
byte State::ledGreenValue() {
return Smoothing::smoothRBGFader(this->input_values->getValue(GREEN_CC));
}
byte State::ledBlueValue() {
return Smoothing::smoothRBGFader(this->input_values->getValue(BLUE_CC));
}
byte State::pulseValue() {
return this->input_values->getValue(DYNAMIC_CC);
}
bool State::colorOn() {
return Smoothing::booleanButton(this->input_values->getValue(SETCOLQ_CC));
}
bool State::recordEEPROMArmed() {
return Smoothing::booleanButton(this->input_values->getValue(ARMEEPROM_CC));
}
void State::disarmRecordEEPROM() {
this->input_values->storeInput(ARMEEPROM_CC, (byte) 0);
}
bool State::saveColorOn() {
return Smoothing::booleanButton(this->input_values->getValue(WRITECOLOR_CC));
}
bool State::soundActionOn() {
return this->melodyOneOn() || this->melodyTwoOn() || this->keyModeOn();
}
bool State::melodyOneOn() {
return Smoothing::booleanButton(this->input_values->getValue(MEL1TRIG_CC));
}
bool State::melodyTwoOn() {
return Smoothing::booleanButton(this->input_values->getValue(MEL2TRIG_CC));
}
bool State::keyModeOn() {
return Smoothing::booleanButton(this->input_values->getValue(KEYACT_CC));
}
bool State::midiPanicOn() {
return Smoothing::booleanButton(this->input_values->getValue(MIDIPANIC_CC));
}