Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
B
brew
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
João Lino
brew
Commits
cd68831a
Commit
cd68831a
authored
Aug 12, 2015
by
João Lino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debouncing the rotary encoder.
parent
90cd14af
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
brew.ino
brew.ino
+8
-5
No files found.
brew.ino
View file @
cd68831a
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
#define ROTARY_ENCODER_CLK_PIN 3 // Used for generating interrupts using CLK signal
#define ROTARY_ENCODER_CLK_PIN 3 // Used for generating interrupts using CLK signal
#define ROTARY_ENCODER_DT_PIN 22 // Used for reading DT signal
#define ROTARY_ENCODER_DT_PIN 22 // Used for reading DT signal
#define ROTARY_ENCODER_SW_PIN 23 // Used for the push button switch
#define ROTARY_ENCODER_SW_PIN 23 // Used for the push button switch
#define ROTARY_ENCODER_DEBOUNCE_TIME
1
0 // Number of miliseconds to ignore new signals a signal is received
#define ROTARY_ENCODER_DEBOUNCE_TIME
4
0 // Number of miliseconds to ignore new signals a signal is received
// ++++++++++++++++++++++++ State Machine ++++++++++++++++++++++++
// ++++++++++++++++++++++++ State Machine ++++++++++++++++++++++++
#define SETTING_WELCOME_TIMEOUT 100
#define SETTING_WELCOME_TIMEOUT 100
...
@@ -147,6 +147,8 @@ volatile int rotaryEncoderMinPosition = 0;
...
@@ -147,6 +147,8 @@ volatile int rotaryEncoderMinPosition = 0;
volatile
int
rotaryEncoderSingleStep
=
1
;
volatile
int
rotaryEncoderSingleStep
=
1
;
volatile
int
rotaryEncoderMultiStep
=
1
;
volatile
int
rotaryEncoderMultiStep
=
1
;
volatile
boolean
onISR
=
false
;
// ++++++++++++++++++++++++ Heating Element Relay ++++++++++++++++++++++++
// ++++++++++++++++++++++++ Heating Element Relay ++++++++++++++++++++++++
int
iWindowSize
;
// Time frame to operate in
int
iWindowSize
;
// Time frame to operate in
unsigned
long
windowStartTime
;
unsigned
long
windowStartTime
;
...
@@ -172,12 +174,12 @@ void xSetupRotaryEncoder( eRotaryEncoderMode newMode, int newPosition, int newMa
...
@@ -172,12 +174,12 @@ void xSetupRotaryEncoder( eRotaryEncoderMode newMode, int newPosition, int newMa
}
}
void
isr
()
{
// Interrupt service routine is executed when a HIGH to LOW transition is detected on CLK
void
isr
()
{
// Interrupt service routine is executed when a HIGH to LOW transition is detected on CLK
repaint
=
true
;
refresh
=
true
;
unsigned
long
interruptTime
=
millis
();
unsigned
long
interruptTime
=
millis
();
unsigned
long
diff
=
interruptTime
-
lastInterruptTime
;
lastInterruptTime
=
interruptTime
;
// If interrupts come faster than [ROTARY_ENCODER_DEBOUNCE_TIME]ms, assume it's a bounce and ignore
// If interrupts come faster than [ROTARY_ENCODER_DEBOUNCE_TIME]ms, assume it's a bounce and ignore
if
(
(
interruptTime
-
lastInterruptTime
)
>
ROTARY_ENCODER_DEBOUNCE_TIME
)
{
if
(
diff
>
ROTARY_ENCODER_DEBOUNCE_TIME
)
{
switch
(
rotaryEncoderMode
)
{
switch
(
rotaryEncoderMode
)
{
// Input of rotary encoder controling menus
// Input of rotary encoder controling menus
...
@@ -264,7 +266,8 @@ void isr () { // Interrupt service routine is executed when a HIGH to LOW tr
...
@@ -264,7 +266,8 @@ void isr () { // Interrupt service routine is executed when a HIGH to LOW tr
}
}
}
}
lastInterruptTime
=
interruptTime
;
repaint
=
true
;
refresh
=
true
;
}
}
// ######################### START #########################
// ######################### START #########################
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment