Skip to content

A callback-based C++ Library to read potentiometer values through ADCs, map and forward them e.g as volume control

License

Notifications You must be signed in to change notification settings

lechk82/potiMapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

potiMapper

A callback-based C++ Library to read potentiometer values through ADCs, map and forward them e.g as volume control.

Example:

// ADC properties
#define ADC_MIN 43
#define ADC_MAX 1023
#define ADC_THRESHOLD 4

// Mapping properties
#define GAIN_MIN 0.0f
#define GAIN_MAX 1.0f
#define OFFSET 0.0f

potiMapper* poti = new potiMapper();

// setup your callbacks

void read_poti(int *val){
  // read poti value
  *val = analogRead(A1);
  // Serial.println(*val); // uncomment for ADC_MIN, ADC_MAX determination (calibration)
}
void write_poti(float *val, int *raw){
  // write mapped or raw poti value, print for test
  // Serial.println(*raw);
  Serial.println(*val);
}

void setup(){
  // init poti
  poti->init(   ADC_MIN,
                ADC_MAX,
                GAIN_MIN,
                GAIN_MAX,
                ADC_THRESHOLD,
                OFFSET,
                &read_poti,
                &write_poti);
}

void loop(){
  poti->update();
}

About

A callback-based C++ Library to read potentiometer values through ADCs, map and forward them e.g as volume control

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages