Addet touch button and touch threshold.
Fixed some errors.
This commit is contained in:
parent
d40a555531
commit
4104dec87f
@ -19,10 +19,12 @@ void shortPressAction(uint8_t b)
|
|||||||
|
|
||||||
bool isButtonPressed(uint8_t i)
|
bool isButtonPressed(uint8_t i)
|
||||||
{
|
{
|
||||||
if (btnPin[i]>=0 && digitalRead(btnPin[i]) == LOW) return true;
|
if (btnPin[i]<0) return false;
|
||||||
#ifdef TOUCHPIN
|
//TODO: this may need switch statement (for inverted buttons)
|
||||||
if (touchRead(TOUCHPIN) <= TOUCH_THRESHOLD) return true;
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
if (buttonType[i]==BTN_TYPE_TOUCH && touchRead(btnPin[i]) <= touchThreshold) return true; else
|
||||||
#endif
|
#endif
|
||||||
|
if (digitalRead(btnPin[i]) == LOW) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +163,8 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
} else {
|
} else {
|
||||||
//TODO: fix JSON API call (and new install)
|
//TODO: fix JSON API call (and new install)
|
||||||
}
|
}
|
||||||
|
CJSON(touchThreshold,hw[F("btn")][F("touch-thershold")]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
JsonObject hw_btn_ins_0 = hw[F("btn")][F("ins")][0];
|
JsonObject hw_btn_ins_0 = hw[F("btn")][F("ins")][0];
|
||||||
CJSON(buttonType, hw_btn_ins_0["type"]);
|
CJSON(buttonType, hw_btn_ins_0["type"]);
|
||||||
@ -568,6 +570,7 @@ void serializeConfig() {
|
|||||||
hw_btn_ins_0_macros.add(macroLongPress[i]);
|
hw_btn_ins_0_macros.add(macroLongPress[i]);
|
||||||
hw_btn_ins_0_macros.add(macroDoublePress[i]);
|
hw_btn_ins_0_macros.add(macroDoublePress[i]);
|
||||||
}
|
}
|
||||||
|
hw_btn[F("touch-threshold")] = touchThreshold;
|
||||||
|
|
||||||
JsonObject hw_ir = hw.createNestedObject("ir");
|
JsonObject hw_ir = hw.createNestedObject("ir");
|
||||||
hw_ir["pin"] = irPin;
|
hw_ir["pin"] = irPin;
|
||||||
|
@ -159,6 +159,7 @@
|
|||||||
#define BTN_TYPE_PUSH_ACT_HIGH 3 //not implemented
|
#define BTN_TYPE_PUSH_ACT_HIGH 3 //not implemented
|
||||||
#define BTN_TYPE_SWITCH 4
|
#define BTN_TYPE_SWITCH 4
|
||||||
#define BTN_TYPE_SWITCH_ACT_HIGH 5 //not implemented
|
#define BTN_TYPE_SWITCH_ACT_HIGH 5 //not implemented
|
||||||
|
#define BTN_TYPE_TOUCH 6
|
||||||
|
|
||||||
//Ethernet board types
|
//Ethernet board types
|
||||||
#define WLED_NUM_ETH_TYPES 5
|
#define WLED_NUM_ETH_TYPES 5
|
||||||
|
@ -288,10 +288,11 @@ Reverse (rotated 180°): <input type="checkbox" name="CV${i}">
|
|||||||
var bt = "BT" + i;
|
var bt = "BT" + i;
|
||||||
var be = "BE" + i;
|
var be = "BE" + i;
|
||||||
c += `Button ${i} pin: <input type="number" min="-1" max="40" name="${bt}" onchange="UI()" value="${p}">`;
|
c += `Button ${i} pin: <input type="number" min="-1" max="40" name="${bt}" onchange="UI()" value="${p}">`;
|
||||||
c += `<select name="${bt}">`
|
c += `<select name="${be}">`
|
||||||
c += `<option name="${be}" value="0" ${t==0?"selected":""}>Disabled</option>`;
|
c += `<option value="0" ${t==0?"selected":""}>Disabled</option>`;
|
||||||
c += `<option name="${be}" value="2" ${t==2?"selected":""}>Pushbutton</option>`;
|
c += `<option value="2" ${t==2?"selected":""}>Pushbutton</option>`;
|
||||||
c += `<option name="${be}" value="4" ${t==4?"selected":""}>Switch</option>`;
|
c += `<option value="4" ${t==4?"selected":""}>Switch</option>`;
|
||||||
|
c += `<option value="6" ${t==6?"selected":""}>Touch</option>`;
|
||||||
c += `</select>`;
|
c += `</select>`;
|
||||||
c += `<span style="cursor: pointer;" onclick="off('${bt}')"> ×</span><br>`;
|
c += `<span style="cursor: pointer;" onclick="off('${bt}')"> ×</span><br>`;
|
||||||
gId("btns").innerHTML = c;
|
gId("btns").innerHTML = c;
|
||||||
@ -353,6 +354,7 @@ Reverse (rotated 180°): <input type="checkbox" name="CV${i}">
|
|||||||
Use less than <span id="wreason">800 LEDs per pin</span> for the best experience!<br>
|
Use less than <span id="wreason">800 LEDs per pin</span> for the best experience!<br>
|
||||||
</div><hr style="width:260px">
|
</div><hr style="width:260px">
|
||||||
<div id="btns"></div>
|
<div id="btns"></div>
|
||||||
|
Touch threshold: <input type="number" min="0" max="100" name="TT" required><br>
|
||||||
IR pin: <input type="number" min="-1" max="40" name="IR" onchange="UI()"><select name="IT">
|
IR pin: <input type="number" min="-1" max="40" name="IR" onchange="UI()"><select name="IT">
|
||||||
<option value="0">Remote disabled</option>
|
<option value="0">Remote disabled</option>
|
||||||
<option value="1">24-key RGB</option>
|
<option value="1">24-key RGB</option>
|
||||||
|
File diff suppressed because one or more lines are too long
@ -163,6 +163,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
touchThreshold = request->arg(F("TT")).toInt();
|
||||||
|
|
||||||
strip.ablMilliampsMax = request->arg(F("MA")).toInt();
|
strip.ablMilliampsMax = request->arg(F("MA")).toInt();
|
||||||
strip.milliampsPerLed = request->arg(F("LA")).toInt();
|
strip.milliampsPerLed = request->arg(F("LA")).toInt();
|
||||||
|
@ -437,6 +437,7 @@ WLED_GLOBAL bool buttonPressedBefore[WLED_MAX_BUTTONS] _INIT({false});
|
|||||||
WLED_GLOBAL bool buttonLongPressed[WLED_MAX_BUTTONS] _INIT({false});
|
WLED_GLOBAL bool buttonLongPressed[WLED_MAX_BUTTONS] _INIT({false});
|
||||||
WLED_GLOBAL unsigned long buttonPressedTime[WLED_MAX_BUTTONS] _INIT({0});
|
WLED_GLOBAL unsigned long buttonPressedTime[WLED_MAX_BUTTONS] _INIT({0});
|
||||||
WLED_GLOBAL unsigned long buttonWaitTime[WLED_MAX_BUTTONS] _INIT({0});
|
WLED_GLOBAL unsigned long buttonWaitTime[WLED_MAX_BUTTONS] _INIT({0});
|
||||||
|
WLED_GLOBAL byte touchThreshold _INIT(TOUCH_THRESHOLD);
|
||||||
|
|
||||||
// notifications
|
// notifications
|
||||||
WLED_GLOBAL bool notifyDirectDefault _INIT(notifyDirect);
|
WLED_GLOBAL bool notifyDirectDefault _INIT(notifyDirect);
|
||||||
|
@ -399,6 +399,7 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
oappend(itoa(buttonType[i],nS,10));
|
oappend(itoa(buttonType[i],nS,10));
|
||||||
oappend(SET_F(");"));
|
oappend(SET_F(");"));
|
||||||
}
|
}
|
||||||
|
sappend('v',SET_F("TT"),touchThreshold);
|
||||||
sappend('v',SET_F("IR"),irPin);
|
sappend('v',SET_F("IR"),irPin);
|
||||||
sappend('v',SET_F("IT"),irEnabled);
|
sappend('v',SET_F("IT"),irEnabled);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user