Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed reScale USBDevice
Diff: main.cpp
- Revision:
- 23:1e974964272e
- Parent:
- 22:ce51026d8702
- Child:
- 24:83cb3b5c69de
--- a/main.cpp Sun Sep 15 18:41:03 2019 +0000
+++ b/main.cpp Thu Oct 03 17:38:45 2019 +0000
@@ -69,6 +69,8 @@
int lastBackButton;
int lastDownButton;
int lastEncoderButton;
+int encoderPressed =0; // flag for state
+int encoderPressedTime= 0;
int encoderMove = 0;
@@ -261,6 +263,7 @@
lastBackButton = t.read_ms();
lastDownButton = t.read_ms();
lastEncoderButton = t.read_ms();
+ encoderPressedTime= t.read_ms();
//****************************************************************************
@@ -390,6 +393,36 @@
count = 0;
}
+// ************************* encoder button
+ if (encoderButton == 0 && encoderPressed == 0 && (t.read_ms() > (lastEncoderButton + 200))) {
+ encoderPressed = 1;
+ encoderPressedTime = t.read_ms();
+ }
+
+ if (encoderButton == 0 && encoderPressed == 1 && (t.read_ms() < (encoderPressedTime + 20))) {
+ count = count + 1; //Reset count if PB pressed
+ lastEncoderButton = t.read_ms();
+ encoderPressed = 0;
+ }
+
+ if (encoderButton == 1 && encoderPressed == 1 && (t.read_ms() < (encoderPressedTime + 10))) {
+ encoderPressed = 0;
+ }
+
+
+ if (count > maxCount) {
+ count = 0;
+ }
+
+ if (count > maxCount) {
+ count = 0;
+ }
+
+
+
+
+// ******************************
+/*
if (encoderButton == 0) {
if (t.read_ms() > (lastEncoderButton + 50)) { // from 200
count = count + 1; //Reset count if PB pressed
@@ -403,7 +436,8 @@
count = 0;
}
}
-
+ */
+//************************************
//****************************************************************************************
@@ -1279,6 +1313,8 @@
serialToolNumber = ((Tens * 10) + Ones);
+
+ count = 0; // 2019-09-23 to make sure the new tool isn't overwritten.
currentToolNo = serialToolNumber; // update tool number