From 36bbf6a9fb77671dc4020e6a562eaf63ff5b362d Mon Sep 17 00:00:00 2001 From: pschatzmann Date: Sat, 2 Nov 2024 13:58:22 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20doxygen=20from=20@=20pschatzma?= =?UTF-8?q?nn/arduino-audio-tools@81cbbb64431d6cf362bc0a13a802351433d6b965?= =?UTF-8?q?=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _audio_actions_8h_source.html | 411 ++++++------ _audio_board_stream_8h_source.html | 547 ++++++++------- _audio_kit_8h_source.html | 10 +- _synthesizer_8h_source.html | 4 +- ...udio__tools_1_1_audio_actions-members.html | 15 +- classaudio__tools_1_1_audio_actions.html | 32 +- ..._tools_1_1_audio_board_stream-members.html | 97 +-- classaudio__tools_1_1_audio_board_stream.html | 12 + functions.html | 16 +- functions_f.html | 5 +- functions_func.html | 18 +- functions_func_f.html | 5 +- functions_func_~.html | 3 + functions_~.html | 3 + hierarchy.html | 2 +- search/all_1.js | 52 +- search/all_10.js | 180 ++--- search/all_11.js | 18 +- search/all_12.js | 186 +++--- search/all_13.js | 628 +++++++++--------- search/all_14.js | 126 ++-- search/all_15.js | 36 +- search/all_16.js | 154 ++--- search/all_17.js | 70 +- search/all_18.js | 2 +- search/all_19.js | 4 +- search/all_1a.js | 51 +- search/all_6.js | 69 +- search/all_7.js | 136 ++-- search/all_8.js | 54 +- search/all_9.js | 212 +++--- search/all_a.js | 6 +- search/all_b.js | 8 +- search/all_c.js | 78 +-- search/all_d.js | 166 ++--- search/all_e.js | 52 +- search/all_f.js | 68 +- search/classes_0.js | 222 +++---- search/classes_1.js | 46 +- search/classes_10.js | 16 +- search/classes_11.js | 84 +-- search/classes_12.js | 136 ++-- search/classes_13.js | 58 +- search/classes_14.js | 18 +- search/classes_15.js | 122 ++-- search/classes_16.js | 26 +- search/classes_2.js | 92 +-- search/classes_3.js | 56 +- search/classes_4.js | 30 +- search/classes_5.js | 96 +-- search/classes_6.js | 52 +- search/classes_7.js | 34 +- search/classes_8.js | 62 +- search/classes_9.js | 6 +- search/classes_a.js | 2 +- search/classes_b.js | 42 +- search/classes_c.js | 72 +- search/classes_d.js | 30 +- search/classes_e.js | 32 +- search/classes_f.js | 58 +- search/enums_0.js | 6 +- search/enums_1.js | 2 +- search/enums_2.js | 2 +- search/enums_3.js | 2 +- search/enums_4.js | 2 +- search/enums_5.js | 8 +- search/enums_6.js | 8 +- search/enums_7.js | 2 +- search/enums_8.js | 2 +- search/enums_9.js | 2 +- search/files_0.js | 10 +- search/files_1.js | 18 +- search/files_2.js | 2 +- search/files_3.js | 2 +- search/functions_0.js | 2 +- search/functions_1.js | 148 ++--- search/functions_10.js | 4 +- search/functions_11.js | 90 +-- search/functions_12.js | 484 +++++++------- search/functions_13.js | 52 +- search/functions_14.js | 14 +- search/functions_15.js | 22 +- search/functions_16.js | 46 +- search/functions_17.js | 51 +- search/functions_2.js | 26 +- search/functions_3.js | 102 +-- search/functions_4.js | 64 +- search/functions_5.js | 32 +- search/functions_6.js | 67 +- search/functions_7.js | 82 +-- search/functions_8.js | 24 +- search/functions_9.js | 124 ++-- search/functions_a.js | 4 +- search/functions_b.js | 40 +- search/functions_c.js | 76 +-- search/functions_d.js | 20 +- search/functions_e.js | 40 +- search/functions_f.js | 110 +-- search/groups_0.js | 2 +- search/groups_1.js | 4 +- search/groups_2.js | 14 +- search/groups_3.js | 4 +- search/groups_4.js | 10 +- search/groups_5.js | 6 +- search/groups_6.js | 4 +- search/groups_7.js | 2 +- search/groups_8.js | 6 +- search/groups_9.js | 2 +- search/groups_a.js | 6 +- search/groups_b.js | 4 +- search/groups_c.js | 4 +- search/groups_d.js | 2 +- search/groups_e.js | 6 +- search/groups_f.js | 4 +- search/namespaces_0.js | 4 +- search/namespaces_1.js | 2 +- search/namespaces_2.js | 2 +- search/pages_0.js | 2 +- search/related_0.js | 2 +- search/typedefs_0.js | 2 +- search/typedefs_1.js | 2 +- search/typedefs_2.js | 2 +- search/typedefs_3.js | 2 +- search/variables_0.js | 6 +- search/variables_1.js | 12 +- search/variables_10.js | 10 +- search/variables_11.js | 6 +- search/variables_12.js | 2 +- search/variables_13.js | 4 +- search/variables_2.js | 14 +- search/variables_3.js | 14 +- search/variables_4.js | 4 +- search/variables_5.js | 18 +- search/variables_6.js | 26 +- search/variables_7.js | 2 +- search/variables_8.js | 18 +- search/variables_9.js | 2 +- search/variables_a.js | 4 +- search/variables_b.js | 8 +- search/variables_c.js | 12 +- search/variables_d.js | 20 +- search/variables_e.js | 12 +- search/variables_f.js | 8 +- ..._1_1_audio_actions_1_1_action-members.html | 13 +- ...o__tools_1_1_audio_actions_1_1_action.html | 17 +- 145 files changed, 3588 insertions(+), 3464 deletions(-) diff --git a/_audio_actions_8h_source.html b/_audio_actions_8h_source.html index 64cf1215ac..8f821f1295 100644 --- a/_audio_actions_8h_source.html +++ b/_audio_actions_8h_source.html @@ -107,204 +107,237 @@
41  void (*actionOff)(bool pinStatus, int pin, void *ref) = nullptr;
42  void *ref = nullptr;
43  unsigned long debounceTimeout = 0;
-
44  ActiveLogic activeLogic;
+
44  ActiveLogic activeLogic = ActiveHigh;
45  bool lastState = true;
46  bool enabled = true;
47 
49  int debounceDelayValue = DEBOUNCE_DELAY;
50  int touchLimit = TOUCH_LIMIT;
51 
-
52  bool readValue() {
-
53 #ifdef USE_TOUCH_READ
-
54  bool result;
-
55  if (this->activeLogic == ActiveTouch) {
-
56  int value = touchRead(this->pin);
-
57  result = value <= touchLimit;
-
58  if (result) {
-
59  // retry to confirm reading
-
60  value = touchRead(this->pin);
-
61  result = value <= touchLimit;
-
62  LOGI("touch pin: %d value %d (limit: %d) -> %s", this->pin, value,
-
63  touchLimit, result ? "true" : "false");
-
64  }
-
65  } else {
-
66  result = digitalRead(this->pin);
-
67  }
-
68  return result;
-
69 #else
-
70  return digitalRead(this->pin);
-
71 #endif
-
72  }
-
73 
-
74  void process() {
-
75  if (this->enabled) {
-
76  bool value = readValue();
-
77  if (this->actionOn != nullptr && this->actionOff != nullptr) {
-
78  // we have on and off action defined
-
79  if (value != this->lastState) {
-
80  //LOGI("processActions: case with on and off");
-
81  // execute action -> reports active instead of pin state
-
82  if ((value && this->activeLogic == ActiveHigh) ||
-
83  (!value && this->activeLogic == ActiveLow)) {
-
84  this->actionOn(true, this->pin, this->ref);
-
85  } else {
-
86  this->actionOff(false, this->pin, this->ref);
-
87  }
-
88  this->lastState = value;
-
89  }
-
90  } else if (this->activeLogic == ActiveChange) {
-
91  bool active = value;
-
92  // reports pin state
-
93  if (value != this->lastState && millis() > this->debounceTimeout) {
-
94  //LOGI("processActions: ActiveChange");
-
95  // execute action
-
96  this->actionOn(active, this->pin, this->ref);
-
97  this->lastState = value;
-
98  this->debounceTimeout = millis() + debounceDelayValue;
-
99  }
-
100  } else {
-
101  bool active = (this->activeLogic == ActiveLow) ? !value : value;
-
102  if (active &&
-
103  (active != this->lastState || millis() > this->debounceTimeout)) {
-
104  // LOGI("processActions: %d Active %d - %d", this->pin, value,
-
105  // execute action
-
106  this->actionOn(active, this->pin, this->ref);
-
107  this->lastState = active;
-
108  this->debounceTimeout = millis() + debounceDelayValue;
-
109  }
-
110  }
-
111  }
-
112  }
-
113  };
-
114 
-
116  AudioActions(bool useInterrupt = false) {
-
117  selfAudioActions = this;
-
118  setUsePinInterrupt(useInterrupt);
-
119  }
-
120 
-
122  void add(int pin, void (*actionOn)(bool pinStatus, int pin, void *ref),
-
123  ActiveLogic activeLogic = ActiveLow, void *ref = nullptr) {
-
124  add(pin, actionOn, nullptr, activeLogic, ref);
-
125  }
-
126 
-
128  void add(int pin, void (*actionOn)(bool pinStatus, int pin, void *ref),
-
129  void (*actionOff)(bool pinStatus, int pin, void *ref),
-
130  ActiveLogic activeLogicPar = ActiveLow, void *ref = nullptr) {
-
131  LOGI("ActionLogic::add pin: %d / logic: %d", pin, activeLogicPar);
-
132  if (pin >= 0) {
-
133  // setup pin mode
-
134  setupPin(pin, activeLogicPar);
-
135 
-
136  Action *p_action = findAction(pin);
-
137  if (p_action) {
-
138  // replace value
-
139  p_action->actionOn = actionOn;
-
140  p_action->actionOff = actionOff;
-
141  p_action->activeLogic = activeLogicPar;
-
142  p_action->ref = ref;
-
143  } else {
-
144  // add value
-
145  Action action;
-
146  action.pin = pin;
-
147  action.actionOn = actionOn;
-
148  action.actionOff = actionOff;
-
149  action.activeLogic = activeLogicPar;
-
150  action.ref = ref;
-
151 
-
152  action.debounceDelayValue = debounceDelayValue;
-
153  action.touchLimit = touchLimit;
-
154 
-
155  actions.push_back(action);
-
156  }
-
157  } else {
-
158  LOGW("pin %d -> Ignored", pin);
-
159  }
-
160  }
-
161 
-
163  void setEnabled(int pin, bool enabled) {
-
164  Action *p_action = findAction(pin);
-
165  if (p_action) {
-
166  p_action->enabled = enabled;
-
167  }
-
168  }
-
169 
-
174  void processActions() {
-
175  static int pos = 0;
-
176  if (actions.empty())
-
177  return;
-
178  // execute action
-
179  actions[pos].process();
-
180  pos++;
-
181  if (pos >= actions.size()) {
-
182  pos = 0;
-
183  }
-
184  }
-
185 
-
187  void processAllActions() {
-
188  for (Action &action : actions) {
-
189  action.process();
-
190  }
-
191  }
-
192 
-
194  Action *findAction(int pin) {
-
195  for (Action &action : actions) {
-
196  if (action.pin == pin) {
-
197  return &action;
-
198  }
-
199  }
-
200  return nullptr;
-
201  }
-
202 
-
204  void setDebounceDelay(int value) { debounceDelayValue = value; }
-
206  void setTouchLimit(int value) { touchLimit = value; }
-
208  void setUsePinInterrupt(bool active) { use_pin_interrupt = active; }
-
210  void setPinMode(bool active) { use_pin_mode = active; }
-
211 
-
212 protected:
-
213  int debounceDelayValue = DEBOUNCE_DELAY;
-
214  int touchLimit = TOUCH_LIMIT;
-
215  bool use_pin_interrupt = false;
-
216  bool use_pin_mode = true;
-
217 
-
218  Vector<Action> actions{0};
-
219 
-
220  static void audioActionsISR() { selfAudioActions->processAllActions(); }
-
221 
-
222  void setupPin(int pin, ActiveLogic logic) {
-
223  // in the audio-driver library the pins are already set up
-
224  if (use_pin_mode) {
-
225  if (logic == ActiveLow) {
-
226  pinMode(pin, INPUT_PULLUP);
-
227  LOGI("pin %d -> INPUT_PULLUP", pin);
-
228  } else {
-
229  pinMode(pin, INPUT);
-
230  LOGI("pin %d -> INPUT", pin);
-
231  }
-
232  }
-
233 
-
234 #if !defined(IS_MIN_DESKTOP)
-
235  if (use_pin_interrupt) {
-
236  attachInterrupt(digitalPinToInterrupt(pin), audioActionsISR, CHANGE);
-
237  }
-
238 #endif
-
239  }
-
240 };
+
52  virtual int id() {
+
53  return pin;
+
54  }
+
55 
+
56  virtual bool readValue() {
+
57 #ifdef USE_TOUCH_READ
+
58  bool result;
+
59  if (this->activeLogic == ActiveTouch) {
+
60  int value = touchRead(this->pin);
+
61  result = value <= touchLimit;
+
62  if (result) {
+
63  // retry to confirm reading
+
64  value = touchRead(this->pin);
+
65  result = value <= touchLimit;
+
66  LOGI("touch pin: %d value %d (limit: %d) -> %s", this->pin, value,
+
67  touchLimit, result ? "true" : "false");
+
68  }
+
69  } else {
+
70  result = digitalRead(this->pin);
+
71  }
+
72  return result;
+
73 #else
+
74  return digitalRead(this->pin);
+
75 #endif
+
76  }
+
77 
+
78  virtual void process() {
+
79  if (this->enabled) {
+
80  bool value = readValue();
+
81  if (this->actionOn != nullptr && this->actionOff != nullptr) {
+
82  // we have on and off action defined
+
83  if (value != this->lastState) {
+
84  //LOGI("processActions: case with on and off");
+
85  // execute action -> reports active instead of pin state
+
86  if ((value && this->activeLogic == ActiveHigh) ||
+
87  (!value && this->activeLogic == ActiveLow)) {
+
88  this->actionOn(true, this->pin, this->ref);
+
89  } else {
+
90  this->actionOff(false, this->pin, this->ref);
+
91  }
+
92  this->lastState = value;
+
93  }
+
94  } else if (this->activeLogic == ActiveChange) {
+
95  bool active = value;
+
96  // reports pin state
+
97  if (value != this->lastState && millis() > this->debounceTimeout) {
+
98  //LOGI("processActions: ActiveChange");
+
99  // execute action
+
100  this->actionOn(active, this->pin, this->ref);
+
101  this->lastState = value;
+
102  this->debounceTimeout = millis() + debounceDelayValue;
+
103  }
+
104  } else {
+
105  bool active = (this->activeLogic == ActiveLow) ? !value : value;
+
106  if (active &&
+
107  (active != this->lastState || millis() > this->debounceTimeout)) {
+
108  // LOGI("processActions: %d Active %d - %d", this->pin, value,
+
109  // execute action
+
110  this->actionOn(active, this->pin, this->ref);
+
111  this->lastState = active;
+
112  this->debounceTimeout = millis() + debounceDelayValue;
+
113  }
+
114  }
+
115  }
+
116  }
+
117  };
+
118 
+
120  AudioActions(bool useInterrupt = false) {
+
121  selfAudioActions = this;
+
122  setUsePinInterrupt(useInterrupt);
+
123  }
+
124 
+
126  ~AudioActions() {
+
127  clear();
+
128  }
+
129 
+
131  void add(Action &action){
+
132  insertAction(action);
+
133  }
+
134 
+
136  void add(int pin, void (*actionOn)(bool pinStatus, int pin, void *ref),
+
137  ActiveLogic activeLogic = ActiveLow, void *ref = nullptr) {
+
138  add(pin, actionOn, nullptr, activeLogic, ref);
+
139  }
+
140 
+
142  void add(int pin, void (*actionOn)(bool pinStatus, int pin, void *ref),
+
143  void (*actionOff)(bool pinStatus, int pin, void *ref),
+
144  ActiveLogic activeLogicPar = ActiveLow, void *ref = nullptr) {
+
145  LOGI("ActionLogic::add pin: %d / logic: %d", pin, activeLogicPar);
+
146  if (pin >= 0) {
+
147  // setup pin mode
+
148  setupPin(pin, activeLogicPar);
+
149 
+
150  // add value
+
151  Action& action = *new Action();
+
152  action.pin = pin;
+
153  action.actionOn = actionOn;
+
154  action.actionOff = actionOff;
+
155  action.activeLogic = activeLogicPar;
+
156  action.ref = ref;
+
157  action.debounceDelayValue = debounceDelayValue;
+
158  action.touchLimit = touchLimit;
+
159 
+
160  insertAction(action);
+
161  } else {
+
162  LOGW("pin %d -> Ignored", pin);
+
163  }
+
164  }
+
165 
+
167  void setEnabled(int pin, bool enabled) {
+
168  Action *p_action = findAction(pin);
+
169  if (p_action) {
+
170  p_action->enabled = enabled;
+
171  }
+
172  }
+
173 
+
178  void processActions() {
+
179  static int pos = 0;
+
180  if (actions.empty())
+
181  return;
+
182  // execute action
+
183  actions[pos]->process();
+
184  pos++;
+
185  if (pos >= actions.size()) {
+
186  pos = 0;
+
187  }
+
188  }
+
189 
+
191  void processAllActions() {
+
192  for (Action *action : actions) {
+
193  action->process();
+
194  }
+
195  }
+
196 
+
198  Action *findAction(int id) {
+
199  for (Action *action : actions) {
+
200  if (action->id() == id) {
+
201  return action;
+
202  }
+
203  }
+
204  return nullptr;
+
205  }
+
206 
+
208  int findActionIdx(int id) {
+
209  int pos = 0;
+
210  for (Action *action : actions) {
+
211  if (action->id() == id) {
+
212  return pos;
+
213  }
+
214  pos++;
+
215  }
+
216  return -1;
+
217  }
+
218 
+
220  void setDebounceDelay(int value) { debounceDelayValue = value; }
+
222  void setTouchLimit(int value) { touchLimit = value; }
+
224  void setUsePinInterrupt(bool active) { use_pin_interrupt = active; }
+
226  void setPinMode(bool active) { use_pin_mode = active; }
+
227 
+
228  void clear() {
+
229  for (Action *act : actions){
+
230  delete(act);
+
231  }
+
232  actions.reset();
+
233  }
+
234 
+
235 protected:
+
236  int debounceDelayValue = DEBOUNCE_DELAY;
+
237  int touchLimit = TOUCH_LIMIT;
+
238  bool use_pin_interrupt = false;
+
239  bool use_pin_mode = true;
+
240  Vector<Action*> actions{0};
241 
-
242 } // namespace audio_tools
+
242  void insertAction(Action& action){
+
243  int idx = findActionIdx(action.id());
+
244  if (idx >= 0) {
+
245  // replace old action
+
246  delete(actions[idx]);
+
247  actions[idx] = &action;
+
248  } else {
+
249  // add new action
+
250  actions.push_back(&action);
+
251  }
+
252  }
+
253 
+
254  static void audioActionsISR() { selfAudioActions->processAllActions(); }
+
255 
+
256  void setupPin(int pin, ActiveLogic logic) {
+
257  // in the audio-driver library the pins are already set up
+
258  if (use_pin_mode) {
+
259  if (logic == ActiveLow) {
+
260  pinMode(pin, INPUT_PULLUP);
+
261  LOGI("pin %d -> INPUT_PULLUP", pin);
+
262  } else {
+
263  pinMode(pin, INPUT);
+
264  LOGI("pin %d -> INPUT", pin);
+
265  }
+
266  }
+
267 
+
268 #if !defined(IS_MIN_DESKTOP)
+
269  if (use_pin_interrupt) {
+
270  attachInterrupt(digitalPinToInterrupt(pin), audioActionsISR, CHANGE);
+
271  }
+
272 #endif
+
273  }
+
274 };
+
275 
+
276 } // namespace audio_tools
int digitalRead(int pin)
e.g. for AudioActions
Definition: NoArduino.h:206
A simple class to assign functions to gpio pins e.g. to implement a simple navigation control or volu...
Definition: AudioActions.h:29
-
AudioActions(bool useInterrupt=false)
Default constructor.
Definition: AudioActions.h:116
-
void add(int pin, void(*actionOn)(bool pinStatus, int pin, void *ref), ActiveLogic activeLogic=ActiveLow, void *ref=nullptr)
Adds an action.
Definition: AudioActions.h:122
-
void setTouchLimit(int value)
Defines the touch limit (Default 20)
Definition: AudioActions.h:206
-
void setDebounceDelay(int value)
Defines the debounce delay.
Definition: AudioActions.h:204
-
void processActions()
Execute all actions if the corresponding pin is low To minimize the runtime: With each call we proces...
Definition: AudioActions.h:174
-
void add(int pin, void(*actionOn)(bool pinStatus, int pin, void *ref), void(*actionOff)(bool pinStatus, int pin, void *ref), ActiveLogic activeLogicPar=ActiveLow, void *ref=nullptr)
Adds an action.
Definition: AudioActions.h:128
-
void processAllActions()
Execute all actions.
Definition: AudioActions.h:187
-
void setUsePinInterrupt(bool active)
Use interrupts instead of processActions() call in loop.
Definition: AudioActions.h:208
-
void setEnabled(int pin, bool enabled)
enable/disable pin actions
Definition: AudioActions.h:163
-
Action * findAction(int pin)
Determines the action for the pin.
Definition: AudioActions.h:194
-
void setPinMode(bool active)
setup pin mode when true
Definition: AudioActions.h:210
-
Vector implementation which provides the most important methods as defined by std::vector....
Definition: Vector.h:21
+
int findActionIdx(int id)
Determines the action for the pin/id.
Definition: AudioActions.h:208
+
AudioActions(bool useInterrupt=false)
Default constructor.
Definition: AudioActions.h:120
+
void add(int pin, void(*actionOn)(bool pinStatus, int pin, void *ref), ActiveLogic activeLogic=ActiveLow, void *ref=nullptr)
Adds an action.
Definition: AudioActions.h:136
+
void setTouchLimit(int value)
Defines the touch limit (Default 20)
Definition: AudioActions.h:222
+
~AudioActions()
deletes all actions
Definition: AudioActions.h:126
+
void setDebounceDelay(int value)
Defines the debounce delay.
Definition: AudioActions.h:220
+
void processActions()
Execute all actions if the corresponding pin is low To minimize the runtime: With each call we proces...
Definition: AudioActions.h:178
+
void add(Action &action)
Adds an Action.
Definition: AudioActions.h:131
+
Action * findAction(int id)
Determines the action for the pin/id.
Definition: AudioActions.h:198
+
void add(int pin, void(*actionOn)(bool pinStatus, int pin, void *ref), void(*actionOff)(bool pinStatus, int pin, void *ref), ActiveLogic activeLogicPar=ActiveLow, void *ref=nullptr)
Adds an action.
Definition: AudioActions.h:142
+
void processAllActions()
Execute all actions.
Definition: AudioActions.h:191
+
void setUsePinInterrupt(bool active)
Use interrupts instead of processActions() call in loop.
Definition: AudioActions.h:224
+
void setEnabled(int pin, bool enabled)
enable/disable pin actions
Definition: AudioActions.h:167
+
void setPinMode(bool active)
setup pin mode when true
Definition: AudioActions.h:226
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AudioConfig.h:821
uint32_t millis()
Returns the milliseconds since the start.
Definition: Time.h:12
Definition: AudioActions.h:38
diff --git a/_audio_board_stream_8h_source.html b/_audio_board_stream_8h_source.html index 5d75cbeb85..285a287162 100644 --- a/_audio_board_stream_8h_source.html +++ b/_audio_board_stream_8h_source.html @@ -78,273 +78,305 @@
7 namespace audio_tools {
8 
19 class AudioBoardStream : public I2SCodecStream {
-
20 public:
-
28  AudioBoardStream(audio_driver::AudioBoard &board) : I2SCodecStream(board) {
-
29  // pin mode already set up by driver library
-
30  actions.setPinMode(false);
-
31  }
-
32 
-
33  bool begin() override { return I2SCodecStream::begin(); }
-
34 
-
35  bool begin(I2SCodecConfig cfg) override { return I2SCodecStream::begin(cfg); }
-
36 
-
41  void processActions() {
-
42  // TRACED();
-
43  actions.processActions();
-
44  yield();
-
45  }
-
46 
-
55  void addAction(int pin, void (*action)(bool, int, void *),
-
56  void *ref = nullptr) {
-
57  TRACEI();
-
58  // determine logic from config
-
59  AudioActions::ActiveLogic activeLogic = getActionLogic(pin);
-
60  actions.add(pin, action, activeLogic, ref == nullptr ? this : ref);
-
61  }
-
62 
-
72  void addAction(int pin, void (*action)(bool, int, void *),
-
73  AudioActions::ActiveLogic activeLogic, void *ref = nullptr) {
-
74  TRACEI();
-
75  actions.add(pin, action, activeLogic, ref == nullptr ? this : ref);
-
76  }
-
77 
-
79  AudioActions &audioActions() { return actions; }
-
80 
-
81  AudioActions &getActions() { return actions; }
-
82 
-
88  void incrementVolume(float inc) {
-
89  float current_volume = getVolume();
-
90  float new_volume = current_volume + inc;
-
91  LOGI("incrementVolume: %f -> %f", current_volume, new_volume);
-
92  setVolume(new_volume);
-
93  }
-
94 
-
99  static void actionVolumeUp(bool, int, void *ref) {
-
100  TRACEI();
-
101  AudioBoardStream *self = (AudioBoardStream*)ref;
-
102  self->incrementVolume(+self->actionVolumeIncrementValue());
-
103  }
-
104 
-
109  static void actionVolumeDown(bool, int, void *ref) {
-
110  TRACEI();
-
111  AudioBoardStream *self = (AudioBoardStream*)ref;
-
112  self->incrementVolume(-self->actionVolumeIncrementValue());
+
20  struct AudioBoardAction : public AudioActions::Action {
+
21  AudioBoardAction(AudioBoard &board, AudioDriverKey key) {
+
22  this->key = key;
+
23  this->p_board = &board;
+
24  }
+
25  AudioDriverKey key;
+
26  AudioBoard *p_board;
+
27  int id() override { return key | 0x400; }
+
28  bool readValue() override { return p_board->isKeyPressed(key); }
+
29  };
+
30 
+
31  public:
+
39  AudioBoardStream(audio_driver::AudioBoard &board) : I2SCodecStream(board) {
+
40  // pin mode already set up by driver library
+
41  actions.setPinMode(false);
+
42  }
+
43 
+
44  bool begin() override { return I2SCodecStream::begin(); }
+
45 
+
46  bool begin(I2SCodecConfig cfg) override { return I2SCodecStream::begin(cfg); }
+
47 
+
52  void processActions() {
+
53  // TRACED();
+
54  actions.processActions();
+
55  yield();
+
56  }
+
57 
+
58 
+
62  void addAction(AudioDriverKey key, void (*action)(bool, int, void *),
+
63  void *ref = nullptr) {
+
64  AudioBoardAction *abo = new AudioBoardAction(board(), key);
+
65  abo->actionOn = action;
+
66  abo->ref = (ref == nullptr) ? this : ref;
+
67  actions.add(*abo);
+
68  }
+
69 
+
73  void addAction(AudioDriverKey key, void (*actionOn)(bool, int, void *),
+
74  void (*actionOff)(bool, int, void *),
+
75  void *ref = nullptr) {
+
76 
+
77  AudioBoardAction *abo = new AudioBoardAction(board(), key);
+
78  abo->actionOn = actionOn;
+
79  abo->actionOn = actionOff;
+
80  abo->ref = (ref == nullptr) ? this : ref;
+
81  actions.add(*abo);
+
82  }
+
83 
+
92  void addAction(int pin, void (*action)(bool, int, void *),
+
93  void *ref = nullptr) {
+
94  TRACEI();
+
95  // determine logic from config
+
96  AudioActions::ActiveLogic activeLogic = getActionLogic(pin);
+
97  actions.add(pin, action, activeLogic, ref == nullptr ? this : ref);
+
98  }
+
99 
+
109  void addAction(int pin, void (*action)(bool, int, void *),
+
110  AudioActions::ActiveLogic activeLogic, void *ref = nullptr) {
+
111  TRACEI();
+
112  actions.add(pin, action, activeLogic, ref == nullptr ? this : ref);
113  }
114 
-
115 
-
120  static void actionStartStop(bool, int, void *ref) {
-
121  TRACEI();
-
122  AudioBoardStream *self = (AudioBoardStream*)ref;
-
123  self->active = !self->active;
-
124  self->setActive(self->active);
-
125  }
-
126 
-
131  static void actionStart(bool, int, void *ref) {
-
132  TRACEI();
-
133  AudioBoardStream *self = (AudioBoardStream*)ref;
-
134  self->active = true;
-
135  self->setActive(self->active);
-
136  }
-
137 
-
141  static void actionStop(bool, int, void *ref) {
-
142  TRACEI();
-
143  AudioBoardStream *self = (AudioBoardStream*)ref;
-
144  self->active = false;
-
145  self->setActive(self->active);
-
146  }
-
147 
-
153  static void actionHeadphoneDetection(bool, int, void *ref) {
-
154  AudioBoardStream *self = (AudioBoardStream*)ref;
-
155  if (self->pinHeadphoneDetect() >= 0) {
-
156 
-
157  // detect changes
-
158  bool isConnected = self->headphoneStatus();
-
159  if (self->headphoneIsConnected != isConnected) {
-
160  self->headphoneIsConnected = isConnected;
-
161 
-
162  // update if things have stabilized
-
163  bool powerActive = !isConnected;
-
164  LOGW("Headphone jack has been %s",
-
165  isConnected ? "inserted" : "removed");
-
166  self->setSpeakerActive(powerActive);
-
167  }
-
168  }
-
169  yield();
-
170  }
-
171 
-
178  GpioPin pinAuxin() { return getPinID(PinFunction::AUXIN_DETECT); }
-
179 
-
186  GpioPin pinHeadphoneDetect() {
-
187  return getPinID(PinFunction::HEADPHONE_DETECT);
-
188  }
-
189 
-
196  GpioPin pinPaEnable() { return getPinID(PinFunction::PA); }
-
197 
-
198  // /**
-
199  // * @brief Get the gpio number for adc detection
-
200  // *
-
201  // * @return -1 non-existent
-
202  // * Others gpio number
-
203  // */
-
204  // GpioPin pinAdcDetect() { return getPin(AUXIN_DETECT); }
-
205 
-
212  GpioPin pinInputRec() { return getPinID(PinFunction::KEY, 1); }
-
213 
-
220  GpioPin pinInputMode() { return getPinID(PinFunction::KEY, 2); }
-
221 
-
228  GpioPin pinInputSet() { return getPinID(PinFunction::KEY, 4); }
-
229 
-
236  GpioPin pinInputPlay() { return getPinID(PinFunction::KEY, 3); }
-
237 
-
244  GpioPin pinVolumeUp() { return getPinID(PinFunction::KEY, 6); }
-
245 
-
252  GpioPin pinVolumeDown() { return getPinID(PinFunction::KEY, 5); }
-
253 
-
260  GpioPin pinLed(int idx) { return getPinID(PinFunction::LED, idx); }
-
261 
-
263  void setSpeakerActive(bool active) { setPAPower(active); }
+
116  AudioActions &audioActions() { return actions; }
+
117 
+
118  AudioActions &getActions() { return actions; }
+
119 
+
125  void incrementVolume(float inc) {
+
126  float current_volume = getVolume();
+
127  float new_volume = current_volume + inc;
+
128  LOGI("incrementVolume: %f -> %f", current_volume, new_volume);
+
129  setVolume(new_volume);
+
130  }
+
131 
+
136  static void actionVolumeUp(bool, int, void *ref) {
+
137  TRACEI();
+
138  AudioBoardStream *self = (AudioBoardStream *)ref;
+
139  self->incrementVolume(+self->actionVolumeIncrementValue());
+
140  }
+
141 
+
146  static void actionVolumeDown(bool, int, void *ref) {
+
147  TRACEI();
+
148  AudioBoardStream *self = (AudioBoardStream *)ref;
+
149  self->incrementVolume(-self->actionVolumeIncrementValue());
+
150  }
+
151 
+
156  static void actionStartStop(bool, int, void *ref) {
+
157  TRACEI();
+
158  AudioBoardStream *self = (AudioBoardStream *)ref;
+
159  self->active = !self->active;
+
160  self->setActive(self->active);
+
161  }
+
162 
+
167  static void actionStart(bool, int, void *ref) {
+
168  TRACEI();
+
169  AudioBoardStream *self = (AudioBoardStream *)ref;
+
170  self->active = true;
+
171  self->setActive(self->active);
+
172  }
+
173 
+
177  static void actionStop(bool, int, void *ref) {
+
178  TRACEI();
+
179  AudioBoardStream *self = (AudioBoardStream *)ref;
+
180  self->active = false;
+
181  self->setActive(self->active);
+
182  }
+
183 
+
189  static void actionHeadphoneDetection(bool, int, void *ref) {
+
190  AudioBoardStream *self = (AudioBoardStream *)ref;
+
191  if (self->pinHeadphoneDetect() >= 0) {
+
192  // detect changes
+
193  bool isConnected = self->headphoneStatus();
+
194  if (self->headphoneIsConnected != isConnected) {
+
195  self->headphoneIsConnected = isConnected;
+
196 
+
197  // update if things have stabilized
+
198  bool powerActive = !isConnected;
+
199  LOGW("Headphone jack has been %s",
+
200  isConnected ? "inserted" : "removed");
+
201  self->setSpeakerActive(powerActive);
+
202  }
+
203  }
+
204  yield();
+
205  }
+
206 
+
213  GpioPin pinAuxin() { return getPinID(PinFunction::AUXIN_DETECT); }
+
214 
+
221  GpioPin pinHeadphoneDetect() {
+
222  return getPinID(PinFunction::HEADPHONE_DETECT);
+
223  }
+
224 
+
231  GpioPin pinPaEnable() { return getPinID(PinFunction::PA); }
+
232 
+
233  // /**
+
234  // * @brief Get the gpio number for adc detection
+
235  // *
+
236  // * @return -1 non-existent
+
237  // * Others gpio number
+
238  // */
+
239  // GpioPin pinAdcDetect() { return getPin(AUXIN_DETECT); }
+
240 
+
247  GpioPin pinInputRec() { return getPinID(PinFunction::KEY, 1); }
+
248 
+
255  GpioPin pinInputMode() { return getPinID(PinFunction::KEY, 2); }
+
256 
+
263  GpioPin pinInputSet() { return getPinID(PinFunction::KEY, 4); }
264 
-
271  bool headphoneStatus() {
-
272  int headphoneGpioPin = pinHeadphoneDetect();
-
273  return headphoneGpioPin > 0 ? !digitalRead(headphoneGpioPin) : false;
-
274  }
-
275 
-
279  void setActive(bool active) { setMute(!active); }
+
271  GpioPin pinInputPlay() { return getPinID(PinFunction::KEY, 3); }
+
272 
+
279  GpioPin pinVolumeUp() { return getPinID(PinFunction::KEY, 6); }
280 
-
282  void addStartStopAction() {
-
283  // pin conflicts for pinInputMode() with the SD CS pin for AIThinker and
-
284  // buttons
-
285  int sd_cs = getSdCsPin();
-
286  int input_mode = pinInputMode();
-
287  if (input_mode != -1 && (input_mode != sd_cs || !cfg.sd_active)) {
-
288  LOGD("actionInputMode")
-
289  addAction(input_mode, actionStartStop);
-
290  }
-
291  }
-
292 
-
294  void addVolumeActions() {
-
295  // pin conflicts with SD Lyrat SD CS GpioPin and buttons / Conflict on
-
296  // Audiokit V. 2957
-
297  int sd_cs = getSdCsPin();
-
298  int vol_up = pinVolumeUp();
-
299  int vol_down = pinVolumeDown();
-
300  if ((vol_up != -1 && vol_down != -1) &&
-
301  (!cfg.sd_active || (vol_down != sd_cs && vol_up != sd_cs))) {
-
302  LOGD("actionVolumeDown")
-
303  addAction(vol_down, actionVolumeDown);
-
304  LOGD("actionVolumeUp")
-
305  addAction(vol_up, actionVolumeUp);
-
306  } else {
-
307  LOGW("Volume Buttons ignored because of conflict: %d ", pinVolumeDown());
-
308  }
+
287  GpioPin pinVolumeDown() { return getPinID(PinFunction::KEY, 5); }
+
288 
+
295  GpioPin pinLed(int idx) { return getPinID(PinFunction::LED, idx); }
+
296 
+
298  void setSpeakerActive(bool active) { setPAPower(active); }
+
299 
+
306  bool headphoneStatus() {
+
307  int headphoneGpioPin = pinHeadphoneDetect();
+
308  return headphoneGpioPin > 0 ? !digitalRead(headphoneGpioPin) : false;
309  }
310 
-
312  void addHeadphoneDetectionAction() {
-
313  // pin conflicts with AIThinker A101: key6 and headphone detection
-
314  int head_phone = pinHeadphoneDetect();
-
315  if (head_phone != -1 && (getPinID(PinFunction::KEY, 6) != head_phone)) {
-
316  actions.add(head_phone, actionHeadphoneDetection,
-
317  AudioActions::ActiveChange, this);
-
318  }
-
319  }
-
320 
-
324  void addDefaultActions() {
-
325  TRACEI();
-
326  addHeadphoneDetectionAction();
-
327  addStartStopAction();
-
328  addVolumeActions();
-
329  }
-
330 
-
332  void setActionVolumeIncrementValue(float value){
-
333  action_increment_value = value;
-
334  }
-
335 
-
336  float actionVolumeIncrementValue() {
-
337  return action_increment_value;
-
338  }
-
339 
-
340 protected:
-
341  AudioActions actions;
-
342  bool headphoneIsConnected = false;
-
343  bool active = true;
-
344  float action_increment_value = 0.02;
+
314  void setActive(bool active) { setMute(!active); }
+
315 
+
317  void addStartStopAction() {
+
318  // pin conflicts for pinInputMode() with the SD CS pin for AIThinker and
+
319  // buttons
+
320  int sd_cs = getSdCsPin();
+
321  int input_mode = pinInputMode();
+
322  if (input_mode != -1 && (input_mode != sd_cs || !cfg.sd_active)) {
+
323  LOGD("actionInputMode")
+
324  addAction(input_mode, actionStartStop);
+
325  }
+
326  }
+
327 
+
329  void addVolumeActions() {
+
330  // pin conflicts with SD Lyrat SD CS GpioPin and buttons / Conflict on
+
331  // Audiokit V. 2957
+
332  int sd_cs = getSdCsPin();
+
333  int vol_up = pinVolumeUp();
+
334  int vol_down = pinVolumeDown();
+
335  if ((vol_up != -1 && vol_down != -1) &&
+
336  (!cfg.sd_active || (vol_down != sd_cs && vol_up != sd_cs))) {
+
337  LOGD("actionVolumeDown")
+
338  addAction(vol_down, actionVolumeDown);
+
339  LOGD("actionVolumeUp")
+
340  addAction(vol_up, actionVolumeUp);
+
341  } else {
+
342  LOGW("Volume Buttons ignored because of conflict: %d ", pinVolumeDown());
+
343  }
+
344  }
345 
-
346  int getSdCsPin() {
-
347  static GpioPin sd_cs = -2;
-
348  // execute only once
-
349  if (sd_cs != -2)
-
350  return sd_cs;
-
351 
-
352  auto sd_opt = getPins().getSPIPins(PinFunction::SD);
-
353  if (sd_opt) {
-
354  sd_cs = sd_opt.value().cs;
-
355  } else {
-
356  // no spi -> no sd
-
357  LOGI("No sd defined -> sd_active=false")
-
358  cfg.sd_active = false;
-
359  sd_cs = -1;
-
360  }
-
361  return sd_cs;
-
362  }
-
363 
-
365  AudioActions::ActiveLogic getActionLogic(int pin) {
-
366  auto opt = board().getPins().getPin(pin);
-
367  PinLogic logic = PinLogic::Input;
-
368  if (opt)
-
369  logic = opt.value().pin_logic;
-
370  switch (logic) {
-
371  case PinLogic::Input:
-
372  case PinLogic::InputActiveLow:
-
373  return AudioActions::ActiveLow;
-
374  case PinLogic::InputActiveHigh:
-
375  return AudioActions::ActiveHigh;
-
376  case PinLogic::InputActiveTouch:
-
377  return AudioActions::ActiveTouch;
-
378  default:
-
379  return AudioActions::ActiveLow;
-
380  }
-
381  }
-
382 };
-
383 
-
384 } // namespace audio_tools
+
347  void addHeadphoneDetectionAction() {
+
348  // pin conflicts with AIThinker A101: key6 and headphone detection
+
349  int head_phone = pinHeadphoneDetect();
+
350  if (head_phone != -1 && (getPinID(PinFunction::KEY, 6) != head_phone)) {
+
351  actions.add(head_phone, actionHeadphoneDetection,
+
352  AudioActions::ActiveChange, this);
+
353  }
+
354  }
+
355 
+
360  void addDefaultActions() {
+
361  TRACEI();
+
362  addHeadphoneDetectionAction();
+
363  addStartStopAction();
+
364  addVolumeActions();
+
365  }
+
366 
+
368  void setActionVolumeIncrementValue(float value) {
+
369  action_increment_value = value;
+
370  }
+
371 
+
372  float actionVolumeIncrementValue() { return action_increment_value; }
+
373 
+
374  bool isKeyPressed(int key) {
+
375  if (!board()) return false;
+
376  return board().isKeyPressed(key);
+
377  }
+
378 
+
379  protected:
+
380  AudioActions actions;
+
381  bool headphoneIsConnected = false;
+
382  bool active = true;
+
383  float action_increment_value = 0.02;
+
384 
+
385  int getSdCsPin() {
+
386  static GpioPin sd_cs = -2;
+
387  // execute only once
+
388  if (sd_cs != -2) return sd_cs;
+
389 
+
390  auto sd_opt = getPins().getSPIPins(PinFunction::SD);
+
391  if (sd_opt) {
+
392  sd_cs = sd_opt.value().cs;
+
393  } else {
+
394  // no spi -> no sd
+
395  LOGI("No sd defined -> sd_active=false")
+
396  cfg.sd_active = false;
+
397  sd_cs = -1;
+
398  }
+
399  return sd_cs;
+
400  }
+
401 
+
403  AudioActions::ActiveLogic getActionLogic(int pin) {
+
404  auto opt = board().getPins().getPin(pin);
+
405  PinLogic logic = PinLogic::Input;
+
406  if (opt) logic = opt.value().pin_logic;
+
407  switch (logic) {
+
408  case PinLogic::Input:
+
409  case PinLogic::InputActiveLow:
+
410  return AudioActions::ActiveLow;
+
411  case PinLogic::InputActiveHigh:
+
412  return AudioActions::ActiveHigh;
+
413  case PinLogic::InputActiveTouch:
+
414  return AudioActions::ActiveTouch;
+
415  default:
+
416  return AudioActions::ActiveLow;
+
417  }
+
418  }
+
419 };
+
420 
+
421 } // namespace audio_tools
int digitalRead(int pin)
e.g. for AudioActions
Definition: NoArduino.h:206
A simple class to assign functions to gpio pins e.g. to implement a simple navigation control or volu...
Definition: AudioActions.h:29
-
void add(int pin, void(*actionOn)(bool pinStatus, int pin, void *ref), ActiveLogic activeLogic=ActiveLow, void *ref=nullptr)
Adds an action.
Definition: AudioActions.h:122
-
void processActions()
Execute all actions if the corresponding pin is low To minimize the runtime: With each call we proces...
Definition: AudioActions.h:174
-
void setPinMode(bool active)
setup pin mode when true
Definition: AudioActions.h:210
+
void processActions()
Execute all actions if the corresponding pin is low To minimize the runtime: With each call we proces...
Definition: AudioActions.h:178
+
void add(Action &action)
Adds an Action.
Definition: AudioActions.h:131
+
void setPinMode(bool active)
setup pin mode when true
Definition: AudioActions.h:226
New functionality which replaces the AudioKitStream that is based on the legacy AudioKit library....
Definition: AudioBoardStream.h:19
-
GpioPin pinInputRec()
Get the record-button id for adc-button.
Definition: AudioBoardStream.h:212
-
void addAction(int pin, void(*action)(bool, int, void *), void *ref=nullptr)
Defines a new action that is executed when the indicated pin is active.
Definition: AudioBoardStream.h:55
-
GpioPin pinVolumeDown()
Get number for volume down function.
Definition: AudioBoardStream.h:252
-
static void actionVolumeUp(bool, int, void *ref)
Increase the volume.
Definition: AudioBoardStream.h:99
-
void setSpeakerActive(bool active)
the same as setPAPower()
Definition: AudioBoardStream.h:263
-
static void actionHeadphoneDetection(bool, int, void *ref)
Switch off the PA if the headphone in plugged in and switch it on again if the headphone is unplugged...
Definition: AudioBoardStream.h:153
-
static void actionVolumeDown(bool, int, void *ref)
Decrease the volume.
Definition: AudioBoardStream.h:109
-
void addAction(int pin, void(*action)(bool, int, void *), AudioActions::ActiveLogic activeLogic, void *ref=nullptr)
Defines a new action that is executed when the indicated pin is active.
Definition: AudioBoardStream.h:72
-
GpioPin pinLed(int idx)
Get LED pin.
Definition: AudioBoardStream.h:260
-
GpioPin pinAuxin()
Get the gpio number for auxin detection.
Definition: AudioBoardStream.h:178
-
AudioActions::ActiveLogic getActionLogic(int pin)
Determines the action logic (ActiveLow or ActiveTouch) for the pin.
Definition: AudioBoardStream.h:365
-
AudioActions & audioActions()
Provides access to the AudioActions.
Definition: AudioBoardStream.h:79
-
static void actionStartStop(bool, int, void *ref)
Toggle start stop.
Definition: AudioBoardStream.h:120
-
GpioPin pinPaEnable()
Get the gpio number for PA enable.
Definition: AudioBoardStream.h:196
-
GpioPin pinInputMode()
Get the number for mode-button.
Definition: AudioBoardStream.h:220
-
GpioPin pinInputPlay()
Get number for play function.
Definition: AudioBoardStream.h:236
-
GpioPin pinHeadphoneDetect()
Get the gpio number for headphone detection.
Definition: AudioBoardStream.h:186
-
GpioPin pinInputSet()
Get number for set function.
Definition: AudioBoardStream.h:228
-
bool begin(I2SCodecConfig cfg) override
Starts the I2S interface.
Definition: AudioBoardStream.h:35
-
void addHeadphoneDetectionAction()
Adds headphone determination.
Definition: AudioBoardStream.h:312
-
void processActions()
Process input keys and pins.
Definition: AudioBoardStream.h:41
-
void setActionVolumeIncrementValue(float value)
Defines the increment value used by actionVolumeDown/actionVolumeUp.
Definition: AudioBoardStream.h:332
-
void addDefaultActions()
Setup the supported default actions (volume, start/stop, headphone detection)
Definition: AudioBoardStream.h:324
-
void incrementVolume(float inc)
Relative volume control.
Definition: AudioBoardStream.h:88
-
AudioBoardStream(audio_driver::AudioBoard &board)
Default constructor: for available AudioBoard values check the audioboard variables in https://pschat...
Definition: AudioBoardStream.h:28
-
void setActive(bool active)
The oposite of setMute(): setActive(true) calls setMute(false)
Definition: AudioBoardStream.h:279
-
void addVolumeActions()
add volume up and volume down action
Definition: AudioBoardStream.h:294
-
void addStartStopAction()
add start/stop on inputMode
Definition: AudioBoardStream.h:282
-
GpioPin pinVolumeUp()
number for volume up function
Definition: AudioBoardStream.h:244
-
bool headphoneStatus()
Returns true if the headphone was detected.
Definition: AudioBoardStream.h:271
-
static void actionStart(bool, int, void *ref)
Start.
Definition: AudioBoardStream.h:131
-
static void actionStop(bool, int, void *ref)
Stop.
Definition: AudioBoardStream.h:141
+
void addAction(AudioDriverKey key, void(*actionOn)(bool, int, void *), void(*actionOff)(bool, int, void *), void *ref=nullptr)
Defines a new action that is executed when the Button is pressed and released.
Definition: AudioBoardStream.h:73
+
GpioPin pinInputRec()
Get the record-button id for adc-button.
Definition: AudioBoardStream.h:247
+
void addAction(int pin, void(*action)(bool, int, void *), void *ref=nullptr)
Defines a new action that is executed when the indicated pin is active.
Definition: AudioBoardStream.h:92
+
GpioPin pinVolumeDown()
Get number for volume down function.
Definition: AudioBoardStream.h:287
+
static void actionVolumeUp(bool, int, void *ref)
Increase the volume.
Definition: AudioBoardStream.h:136
+
void setSpeakerActive(bool active)
the same as setPAPower()
Definition: AudioBoardStream.h:298
+
static void actionHeadphoneDetection(bool, int, void *ref)
Switch off the PA if the headphone in plugged in and switch it on again if the headphone is unplugged...
Definition: AudioBoardStream.h:189
+
static void actionVolumeDown(bool, int, void *ref)
Decrease the volume.
Definition: AudioBoardStream.h:146
+
void addAction(int pin, void(*action)(bool, int, void *), AudioActions::ActiveLogic activeLogic, void *ref=nullptr)
Defines a new action that is executed when the indicated pin is active.
Definition: AudioBoardStream.h:109
+
void addAction(AudioDriverKey key, void(*action)(bool, int, void *), void *ref=nullptr)
Defines a new action that is executed when the Button is pressed.
Definition: AudioBoardStream.h:62
+
GpioPin pinLed(int idx)
Get LED pin.
Definition: AudioBoardStream.h:295
+
GpioPin pinAuxin()
Get the gpio number for auxin detection.
Definition: AudioBoardStream.h:213
+
AudioActions::ActiveLogic getActionLogic(int pin)
Determines the action logic (ActiveLow or ActiveTouch) for the pin.
Definition: AudioBoardStream.h:403
+
AudioActions & audioActions()
Provides access to the AudioActions.
Definition: AudioBoardStream.h:116
+
static void actionStartStop(bool, int, void *ref)
Toggle start stop.
Definition: AudioBoardStream.h:156
+
GpioPin pinPaEnable()
Get the gpio number for PA enable.
Definition: AudioBoardStream.h:231
+
GpioPin pinInputMode()
Get the number for mode-button.
Definition: AudioBoardStream.h:255
+
GpioPin pinInputPlay()
Get number for play function.
Definition: AudioBoardStream.h:271
+
GpioPin pinHeadphoneDetect()
Get the gpio number for headphone detection.
Definition: AudioBoardStream.h:221
+
GpioPin pinInputSet()
Get number for set function.
Definition: AudioBoardStream.h:263
+
bool begin(I2SCodecConfig cfg) override
Starts the I2S interface.
Definition: AudioBoardStream.h:46
+
void addHeadphoneDetectionAction()
Adds headphone determination.
Definition: AudioBoardStream.h:347
+
void processActions()
Process input keys and pins.
Definition: AudioBoardStream.h:52
+
void setActionVolumeIncrementValue(float value)
Defines the increment value used by actionVolumeDown/actionVolumeUp.
Definition: AudioBoardStream.h:368
+
void addDefaultActions()
Setup the supported default actions (volume, start/stop, headphone detection)
Definition: AudioBoardStream.h:360
+
void incrementVolume(float inc)
Relative volume control.
Definition: AudioBoardStream.h:125
+
AudioBoardStream(audio_driver::AudioBoard &board)
Default constructor: for available AudioBoard values check the audioboard variables in https://pschat...
Definition: AudioBoardStream.h:39
+
void setActive(bool active)
The oposite of setMute(): setActive(true) calls setMute(false)
Definition: AudioBoardStream.h:314
+
void addVolumeActions()
add volume up and volume down action
Definition: AudioBoardStream.h:329
+
void addStartStopAction()
add start/stop on inputMode
Definition: AudioBoardStream.h:317
+
GpioPin pinVolumeUp()
number for volume up function
Definition: AudioBoardStream.h:279
+
bool headphoneStatus()
Returns true if the headphone was detected.
Definition: AudioBoardStream.h:306
+
static void actionStart(bool, int, void *ref)
Start.
Definition: AudioBoardStream.h:167
+
static void actionStop(bool, int, void *ref)
Stop.
Definition: AudioBoardStream.h:177
I2S Stream which also sets up a codec chip and i2s.
Definition: I2SCodecStream.h:44
AudioBoard & board()
Provides the board.
Definition: I2SCodecStream.h:172
bool setMute(bool mute)
Mute / unmote.
Definition: I2SCodecStream.h:155
@@ -354,6 +386,7 @@
GpioPin getPinID(PinFunction function)
Provides the gpio for the indicated function.
Definition: I2SCodecStream.h:181
DriverPins & getPins()
Provides access to the pin information.
Definition: I2SCodecStream.h:196
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AudioConfig.h:821
+
Definition: AudioActions.h:38
Configuration for I2SCodecStream.
Definition: I2SCodecStream.h:24
diff --git a/_audio_kit_8h_source.html b/_audio_kit_8h_source.html index 801fda3247..f6a4d93749 100644 --- a/_audio_kit_8h_source.html +++ b/_audio_kit_8h_source.html @@ -377,12 +377,12 @@
355  TRACEI();
356  // determine logic from config
357  AudioActions::ActiveLogic activeLogic = getActionLogic(pin);
-
358  actions.add(pin, action, activeLogic, ref);
+
358  actions.add(pin, action, activeLogic, ref);
359  }
360 
370  void addAction(int pin, void (*action)(bool,int,void*), AudioActions::ActiveLogic activeLogic, void* ref=nullptr ) {
371  TRACEI();
-
372  actions.add(pin, action, activeLogic, ref);
+
372  actions.add(pin, action, activeLogic, ref);
373  }
374 
376  AudioActions &audioActions() {
@@ -505,7 +505,7 @@
615  // pin conflicts with AIThinker A101 and headphone detection
616  if (! (cfg.sd_active && AUDIOKIT_BOARD==6)) {
617  LOGD("actionHeadphoneDetection pin:%d",kit.pinHeadphoneDetect())
-
618  actions.add(kit.pinHeadphoneDetect(), actionHeadphoneDetection, AudioActions::ActiveChange);
+
618  actions.add(kit.pinHeadphoneDetect(), actionHeadphoneDetection, AudioActions::ActiveChange);
619  } else {
620  LOGW("Headphone detection ignored because of conflict: %d ",kit.pinHeadphoneDetect());
621  }
@@ -525,8 +525,8 @@
635 } // namespace audio_tools
A simple class to assign functions to gpio pins e.g. to implement a simple navigation control or volu...
Definition: AudioActions.h:29
-
void add(int pin, void(*actionOn)(bool pinStatus, int pin, void *ref), ActiveLogic activeLogic=ActiveLow, void *ref=nullptr)
Adds an action.
Definition: AudioActions.h:122
-
void processActions()
Execute all actions if the corresponding pin is low To minimize the runtime: With each call we proces...
Definition: AudioActions.h:174
+
void processActions()
Execute all actions if the corresponding pin is low To minimize the runtime: With each call we proces...
Definition: AudioActions.h:178
+
void add(Action &action)
Adds an Action.
Definition: AudioActions.h:131
Configuration for AudioKitStream: we use as subclass of I2SConfig.
Definition: AudioKit.h:23
AudioKitConfig toAudioKitConfig()
convert to config object needed by HAL
Definition: AudioKit.h:39
void setupI2SPins(RxTxMode rxtx_mode)
Defines the pins based on the information provided by the AudioKit project.
Definition: AudioKit.h:74
diff --git a/_synthesizer_8h_source.html b/_synthesizer_8h_source.html index 6f7b17ed80..526fc6a88c 100644 --- a/_synthesizer_8h_source.html +++ b/_synthesizer_8h_source.html @@ -266,7 +266,7 @@
231 
233  void setKeys(AudioActions &actions, SynthesizerKey* p_keys, AudioActions::ActiveLogic activeValue){
234  while (p_keys->note > 0){
-
235  actions.add(p_keys->pin, callbackKeyOn, callbackKeyOff, activeValue , new KeyParameter(this, p_keys->note));
+
235  actions.add(p_keys->pin, callbackKeyOn, callbackKeyOff, activeValue , new KeyParameter(this, p_keys->note));
236  p_keys++;
237  }
238  }
@@ -379,7 +379,7 @@
virtual int note()=0
Provides the actual midi note that is played.
virtual void keyOn(int nte, float tgt)=0
Provides the key on event to ADSR to start the sound.
A simple class to assign functions to gpio pins e.g. to implement a simple navigation control or volu...
Definition: AudioActions.h:29
-
void add(int pin, void(*actionOn)(bool pinStatus, int pin, void *ref), ActiveLogic activeLogic=ActiveLow, void *ref=nullptr)
Adds an action.
Definition: AudioActions.h:122
+
void add(Action &action)
Adds an Action.
Definition: AudioActions.h:131
size_t size()
Provides the actual number of defined effects.
Definition: AudioEffects.h:45
void addEffect(AudioEffect &effect)
Adds an effect object (by reference)
Definition: AudioEffects.h:27
AudioEffect * findEffect(int id)
Finds an effect by id.
Definition: AudioEffects.h:50
diff --git a/classaudio__tools_1_1_audio_actions-members.html b/classaudio__tools_1_1_audio_actions-members.html index f8bb9c06ec..c696c7085c 100644 --- a/classaudio__tools_1_1_audio_actions-members.html +++ b/classaudio__tools_1_1_audio_actions-members.html @@ -78,12 +78,16 @@ ActiveLogic enum name (defined in AudioActions)AudioActions ActiveLow enum value (defined in AudioActions)AudioActions ActiveTouch enum value (defined in AudioActions)AudioActions - add(int pin, void(*actionOn)(bool pinStatus, int pin, void *ref), ActiveLogic activeLogic=ActiveLow, void *ref=nullptr)AudioActionsinline - add(int pin, void(*actionOn)(bool pinStatus, int pin, void *ref), void(*actionOff)(bool pinStatus, int pin, void *ref), ActiveLogic activeLogicPar=ActiveLow, void *ref=nullptr)AudioActionsinline - AudioActions(bool useInterrupt=false)AudioActionsinline - audioActionsISR() (defined in AudioActions)AudioActionsinlineprotectedstatic + add(Action &action)AudioActionsinline + add(int pin, void(*actionOn)(bool pinStatus, int pin, void *ref), ActiveLogic activeLogic=ActiveLow, void *ref=nullptr)AudioActionsinline + add(int pin, void(*actionOn)(bool pinStatus, int pin, void *ref), void(*actionOff)(bool pinStatus, int pin, void *ref), ActiveLogic activeLogicPar=ActiveLow, void *ref=nullptr)AudioActionsinline + AudioActions(bool useInterrupt=false)AudioActionsinline + audioActionsISR() (defined in AudioActions)AudioActionsinlineprotectedstatic + clear() (defined in AudioActions)AudioActionsinline debounceDelayValue (defined in AudioActions)AudioActionsprotected - findAction(int pin)AudioActionsinline + findAction(int id)AudioActionsinline + findActionIdx(int id)AudioActionsinline + insertAction(Action &action) (defined in AudioActions)AudioActionsinlineprotected processActions()AudioActionsinline processAllActions()AudioActionsinline setDebounceDelay(int value)AudioActionsinline @@ -95,6 +99,7 @@ touchLimit (defined in AudioActions)AudioActionsprotected use_pin_interrupt (defined in AudioActions)AudioActionsprotected use_pin_mode (defined in AudioActions)AudioActionsprotected + ~AudioActions()AudioActionsinline