![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Display code
Dependencies: mbed reScale RotaryEncoder RPG Adafruit_ST7735 Adafruit_GFX PinDetect Ee24xx08 mRotaryEncoder
Diff: main.cpp
- Revision:
- 12:1e974964272e
- Parent:
- 11:ce51026d8702
- Child:
- 13:83cb3b5c69de
diff -r ce51026d8702 -r 1e974964272e main.cpp --- 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