Добрый день!
В документации имеется пример правила с распознаванием нажатий для mcm8.
/* ---------------------------- /
/ 1. Single Press Counter: On action*/
/* ---------------------------- */
defineRule({
whenChanged: “wb-mcm8_20/Input 1 Single Press Counter”,
then: function (newValue, devName, cellName) {
dev[“wb-mdm3_58/K1”] = true;
}
});
/* ---------------------------- /
/ 2. Double Press Counter: Off action*/
/* ---------------------------- */
defineRule({
whenChanged: “wb-mcm8_20/Input 1 Double Press Counter”,
then: function (newValue, devName, cellName) {
dev[“wb-mdm3_58/K1”] = false;
}
});
/* --------------------------------------- /
/ 3. Long Press Counter: Increase brightness /
/ --------------------------------------- */
defineRule({
whenChanged: “wb-mcm8_20/Input 1 Long Press Counter”,
then: function (newValue, devName, cellName) {
// Start a timer that will increase the value of the control
startTicker(“input1_long_press”, 75);
}
});
// A rule that will increase the brightness on a timer
defineRule({
when: function () { return timers[“input1_long_press”].firing; },
then: function () {
var i = dev[“wb-mdm3_58/Channel 1”];
if (i < 100 && dev["wb-mcm8_20/Input 1"]) {
i++
dev["wb-mdm3_58/Channel 1"] = i
} else {
timers["input1_long_press"].stop();
}
}
});
/* -------------------------------------------- /
/ 4. Shortlong Press Counter: Decrease brightness /
/ -------------------------------------------- */
defineRule({
whenChanged: “wb-mcm8_20/Input 1 Shortlong Press Counter”,
then: function (newValue, devName, cellName) {
// Start a timer that will decrease the value of the control
startTicker(“input1_shortlong_press”, 75);
}
});
// A rule that will decrease the brightness on a timer
defineRule({
when: function () { return timers[“input1_shortlong_press”].firing; },
then: function () {
var i = dev[“wb-mdm3_58/Channel 1”];
if (i > 0 && dev["wb-mcm8_20/Input 1"]) {
i--
dev["wb-mdm3_58/Channel 1"] = i
} else {
timers["input1_shortlong_press"].stop();
}
}
});
Можно ли сделать повышение или понижение яркости только длинным нажатием? Если да, то подскажите пожалуйста как это сделать?