int curvedByte(int x, float gamma = 1.45, int lim = 255) {
float normx = x / (lim * 1.0);
float normy = pow(normx, gamma);
int y = (int)(0.5 + normy * lim);
return y;
}
void setup() {
Serial.begin(9600);
for (int x=0; x<64; x++) {
int pwmVal = curvedByte(x, 1.5, 64);
Serial.print(x, DEC); Serial.print(" -> "); Serial.println(pwmVal, DEC);
}
/*
for (int temp = 20; temp <= 50; temp++) {
int mapped = constrain( map( temp, 20, 50, 10, 255), 10, 255);
int curved = curvedByte(mapped, 1.45);
curved = constrain(curved, 10, 255);
Serial.print(temp), Serial.print(" -> "), Serial.print(mapped);
Serial.print(" ( "), Serial.print(curved), Serial.println(" )");
}
*/
/*
for (float temp = 20.0; temp < 50.0; temp+= 1.0) {
int mapped = map( constrain(temp, 20.0, 50.0), 20.0, 50.0, 0, 255);
Serial.print(temp), Serial.print(" -> "), Serial.println(mapped);
}
for (int x=0; x<256; x++) {
int pwmVal = curvedByte(x, 1.1);
Serial.print(x, DEC); Serial.print(" -> "); Serial.println(pwmVal, DEC);
}
*/
}
/*
void setup() {
Serial.begin(9600);
float gamma = 1.5;
for (int x=0; x<256; x++) {
float normx = x / 255.0;
float normy = pow (normx, gamma);
int y = (int) (0.5 + normy * 255);
Serial.print("x: "); Serial.print(x, DEC);
Serial.print(" y: "); Serial.println(y, DEC);
}
}
*/
void loop() {}
/*
void setup() {
Serial.begin(9600);
for(uint32_t i = 0; i<1000; i+=10){
Serial.print(i), Serial.print(" "), Serial.println(Exponent(i));
delay(50);
}
}
uint32_t Exponent(uint32_t num){
uint32_t output = pow(2, (num / ((1000 * log10(2))/(log10(255))))) - 1;
return output;
}
void loop() {}
*/