Bugfix.
- atan_t(x) for x>1 - incorrect switch type and missing analog
This commit is contained in:
parent
39cd83b171
commit
11c7d586d9
@ -305,8 +305,9 @@ Reverse (rotated 180°): <input type="checkbox" name="CV${i}">
|
||||
c += `<option value="2" ${t==2?"selected":""}>Pushbutton</option>`;
|
||||
c += `<option value="2" ${t==3?"selected":""}>Push inverted</option>`;
|
||||
c += `<option value="4" ${t==4?"selected":""}>Switch</option>`;
|
||||
c += `<option value="5" ${t==4?"selected":""}>Switch inverted</option>`;
|
||||
c += `<option value="5" ${t==5?"selected":""}>Switch inverted</option>`;
|
||||
c += `<option value="6" ${t==6?"selected":""}>Touch</option>`;
|
||||
c += `<option value="7" ${t==7?"selected":""}>Analog</option>`;
|
||||
c += `</select>`;
|
||||
c += `<span style="cursor: pointer;" onclick="off('${bt}')"> ×</span><br>`;
|
||||
gId("btns").innerHTML = c;
|
||||
|
File diff suppressed because one or more lines are too long
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// version code in format yymmddb (b = daily build)
|
||||
#define VERSION 2105230
|
||||
#define VERSION 2105231
|
||||
|
||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||
//#define WLED_USE_MY_CONFIG
|
||||
|
@ -58,6 +58,7 @@ float asin_t(float x) {
|
||||
return HALF_PI - acos_t(x);
|
||||
}
|
||||
|
||||
/*
|
||||
//https://stackoverflow.com/a/42542593
|
||||
#define A 0.0776509570923569
|
||||
#define B -0.287434475393028
|
||||
@ -68,6 +69,42 @@ float atan_t(float x) {
|
||||
float xx = x * x;
|
||||
return ((A*xx + B)*xx + C)*x;
|
||||
}
|
||||
*/
|
||||
//https://stackoverflow.com/a/42542593
|
||||
#define A 0.0776509570923569
|
||||
#define B -0.287434475393028
|
||||
#define C ((HALF_PI/2) - A - B)
|
||||
|
||||
//polynominal factors for approximation between 1 and 5
|
||||
#define C0 0.089494f
|
||||
#define C1 0.974207f
|
||||
#define C2 -0.326175f
|
||||
#define C3 0.05375f
|
||||
#define C4 -0.003445f
|
||||
|
||||
float atan_t(float x) {
|
||||
bool neg = (x < 0);
|
||||
#ifdef WLED_DEBUG_MATH
|
||||
float xinput = x;
|
||||
#endif
|
||||
x = std::abs(x);
|
||||
float res;
|
||||
if (x > 5.0f) { //atan(x) converges to pi/2 - (1/x) for large values
|
||||
res = HALF_PI - (1.0f/x);
|
||||
}
|
||||
else if (x > 1.0f) { //1 < x < 5
|
||||
float xx = x * x;
|
||||
res = (C4*xx*xx)+(C3*xx*x)+(C2*xx)+(C1*x)+C0;
|
||||
} else { //this approximation is only for x <= 1
|
||||
float xx = x * x;
|
||||
res = ((A*xx + B)*xx + C)*x;
|
||||
}
|
||||
if (neg) res = -res;
|
||||
#ifdef WLED_DEBUG_MATH
|
||||
Serial.printf("atan,%f,%f,%f\n",xinput,res,atan(xinput));
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
float floor_t(float x) {
|
||||
bool neg = x < 0;
|
||||
|
Loading…
Reference in New Issue
Block a user