libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
ctrl.h
Go to the documentation of this file.
1#pragma once
2#ifndef DSY_KNOB_H
3#define DSY_KNOB_H
4#include <stdint.h>
5
6#ifdef __cplusplus
7namespace daisy
8{
18{
19 public:
24
34 float sr,
35 bool flip = false,
36 bool invert = false,
37 float slew_seconds = 0.002f);
38
45 void InitBipolarCv(uint16_t *adcptr, float sr);
46
53 float Process();
54
56 inline float Value() const { return val_; }
57
61 // using conditionals since clamp() is unavailable
62 inline void SetCoeff(float val)
63 {
64 val = val > 1.f ? 1.f : val;
65 val = val < 0.f ? 0.f : val;
66
67 coeff_ = val;
68 }
69
74 inline void SetScale(const float scale) { scale_ = scale; }
75
80 inline void SetOffset(const float offset) { offset_ = offset; }
81
83 inline uint16_t GetRawValue() { return *raw_; }
84
86 inline float GetRawFloat() { return (float)(*raw_) / 65535.f; }
87
92
93 private:
94 uint16_t *raw_;
95 float coeff_, samplerate_, val_;
96 float scale_, offset_;
97 bool flip_;
98 bool invert_;
99 bool is_bipolar_;
100 float slew_seconds_;
101};
102} // namespace daisy
103#endif
104#endif
Hardware Interface for control inputs Primarily designed for ADC input controls such as potentiomet...
Definition ctrl.h:18
float Value() const
Definition ctrl.h:56
AnalogControl()
Definition ctrl.h:21
void SetCoeff(float val)
Definition ctrl.h:62
float GetRawFloat()
Definition ctrl.h:86
void SetSampleRate(float sample_rate)
void Init(uint16_t *adcptr, float sr, bool flip=false, bool invert=false, float slew_seconds=0.002f)
uint16_t GetRawValue()
Definition ctrl.h:83
void SetScale(const float scale)
Definition ctrl.h:74
void SetOffset(const float offset)
Definition ctrl.h:80
void InitBipolarCv(uint16_t *adcptr, float sr)
~AnalogControl()
Definition ctrl.h:23
Definition leddriver.h:33
Hardware defines and helpers for daisy field platform.
Definition index.h:2