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
71 inline uint16_t GetRawValue() { return *raw_; }
72
74 inline float GetRawFloat() { return (float)(*raw_) / 65535.f; }
75
80
81 private:
82 uint16_t *raw_;
83 float coeff_, samplerate_, val_;
84 float scale_, offset_;
85 bool flip_;
86 bool invert_;
87 bool is_bipolar_;
88 float slew_seconds_;
89};
90} // namespace daisy
91#endif
92#endif
Hardware Interface for control inputs Primarily designed for ADC input controls such as potentiom...
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:74
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:71
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