Voss Connection Detection  1
Detect a connector click using realtime code on Bela hardware
leds.h
Go to the documentation of this file.
1 #pragma once
2 #include <Bela.h>
3 #include "config.h"
4 
15 class Leds {
16 
17  public:
18 
22  enum Led {
26  wrist = 0,
30  thumb = 1,
35  vibrator = 2,
40  };
44  enum LedState {
48  off = 0,
52  on = 1,
61  };
62 
68  Leds(BelaContext* ctx);
69 
82  void setState(Led led,LedState ledstate,float period=LED_HOLD_TIME,
83  float dutycycle=0.5);
91  LedState getState(Led led) const {return _ledstate[(int) led];}
92 
98  void processBuf(BelaContext* ctx);
99  void processFrame(BelaContext* ctx, us frame);
100  private:
101  bool processLed(Led led);
102  bool _on[4];
103 
104  float dT;
105  float _timer[4] = {0,0,0,0};
106  LedState _ledstate[4] = {off, off, off, off};
107  float _blinkDutyCycle[4] = {0.5, 0.5, 0.5, 0.5};
108  float _blinkPeriod[4] = {LED_HOLD_TIME, LED_HOLD_TIME,
110 };
111 
112 
Leds::processBuf
void processBuf(BelaContext *ctx)
Run this function in render.
Definition: leds.cpp:57
Leds::Leds
Leds(BelaContext *ctx)
Initialize LED controller and state machine.
Definition: leds.cpp:6
Leds::on
@ on
Burn permanently.
Definition: leds.h:52
Leds::setState
void setState(Led led, LedState ledstate, float period=LED_HOLD_TIME, float dutycycle=0.5)
Set a certain LED in a certain state. The state blink_once will - after it has blinked - automaticall...
Definition: leds.cpp:79
Leds::controlbox
@ controlbox
Control box led.
Definition: leds.h:39
Leds::off
@ off
No light.
Definition: leds.h:48
Leds::blink_permanent
@ blink_permanent
Blink all the time.
Definition: leds.h:56
Leds::processFrame
void processFrame(BelaContext *ctx, us frame)
Definition: leds.cpp:71
Leds::vibrator
@ vibrator
The vibrator, which is not really an LED but can be controlled the same way.
Definition: leds.h:35
Leds::Led
Led
Led enumeration.
Definition: leds.h:22
Leds
Let physical LEDs burn, blink or blink once.
Definition: leds.h:15
Leds::wrist
@ wrist
Led on wrist.
Definition: leds.h:26
Leds::blink_once
@ blink_once
Blink once.
Definition: leds.h:60
us
unsigned int us
Used to much to not abbreviate.
Definition: config.h:38
config.h
Configuration parameters for connection detection.
Leds::getState
LedState getState(Led led) const
Get the current led state.
Definition: leds.h:91
LED_HOLD_TIME
const float LED_HOLD_TIME
Definition: config.h:133
Leds::LedState
LedState
A state in which a certain LED can be set.
Definition: leds.h:44
Leds::thumb
@ thumb
Led on thumb.
Definition: leds.h:30