Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

stabilized rotary encoder handling #449

Merged
merged 1 commit into from
Jun 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/js/remotebuzzer_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const API_DIR_NAME = 'api';
const API_FILE_NAME = 'config.php';
const PID = process.pid;
let rotaryClkPin, rotaryDtPin;
let cnt = 0;

/* LOGGING FUNCTION */
const log = function (...optionalParams) {
Expand Down Expand Up @@ -525,9 +526,14 @@ const watchRotaryClk = function watchRotaryClk(err, gpioValue) {
}

if (gpioValue) {
if (rotaryDtPin) {
if (rotaryClkPin) {
/* rotation */
photoboothAction('rotary-cw');
if (cnt < -3) {
photoboothAction('rotary-cw');
cnt = 0;
} else {
cnt--;
}
} else {
rotaryClkPin = true;
}
Expand All @@ -548,9 +554,14 @@ const watchRotaryDt = function watchRotaryDt(err, gpioValue) {
}

if (gpioValue) {
if (rotaryClkPin) {
if (rotaryDtPin) {
/* rotation */
photoboothAction('rotary-ccw');
if (cnt > 3) {
photoboothAction('rotary-ccw');
cnt = 0;
} else {
cnt++;
}
} else {
rotaryDtPin = true;
}
Expand Down