Move log10 for audio volume from nodered to arduino pro mini and fix scaling

This commit is contained in:
interfisch 2017-06-11 00:22:50 +02:00
parent 4f6f68bc09
commit a8bf3fd7e0
1 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,4 @@
#include <math.h>
#define PIN_DATA_VOL_A 8
#define PIN_DATA_VOL_B 7
@ -106,6 +107,11 @@ void switchInputs(uint8_t channel, bool state) {
}
uint8_t logify(uint8_t volumelinear){
double volumelog=log10( ((double)volumelinear)/10.0 +1)*97;
return (int)volumelog;
}
// control a M62429 Chip for Volume Control
// function take from here: http://forum.arduino.cc/index.php?topic=244152.0
void setVolume(uint8_t volume, uint8_t dataPin) {
@ -171,7 +177,7 @@ void loop() {
}
int vol=ser.substring(2).toInt();
setVolume(vol,datapin);
setVolume(logify(vol),datapin);
} else if(command == 'r') { // relais