![](/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:
- 2:bbbacfd62773
- Parent:
- 1:e8452b75301e
- Child:
- 3:5f3bb4ab449a
--- a/main.cpp Fri Feb 08 20:50:00 2019 +0000 +++ b/main.cpp Sat Feb 09 23:45:33 2019 +0000 @@ -108,6 +108,7 @@ // ************************************************************************************************************** int received = 9; +int serialCounter = 0; int count = 0; int maxCount = 7; //max number of menu items @@ -179,10 +180,74 @@ */ uint8_t c = 0; // for 485 link - + + + int serialToolNumber = 0; + int stage = 0; // for serial parsing + int Tens = 0; + int Ones = 0; + + dir = 0; while(1) { + /* + while (device.readable()) + { + c = device.getc(); + + + if (c == '+'){ + currentToolNo = currentToolNo +1; + if (currentToolNo > numTools){ + currentToolNo = 1; + } + } + + else if (c == '-'){ + currentToolNo = currentToolNo - 1; + if (currentToolNo > 1){ + currentToolNo = numTools; + } + } + } + */ + + while (device.readable()) + { + + + c = device.getc(); + + if (c == 'M'){ + // stage = 1; + + c = device.getc(); + if (c == '+'){ + + // tft.setTextColor(WHITE); + // tft.setCursor(100, 100); + // tft.printf("%d", c); + currentToolNo = currentToolNo +1; + if (currentToolNo > numTools){ + currentToolNo = 1; + } + } + + else if (c == '-'){ + currentToolNo = currentToolNo - 1; + if (currentToolNo < 1){ + currentToolNo = numTools; + } + } + + } + } + + + + + //myled = 1; if (t.read() > 1200){ // timer can only hold 30 min, so reset after 20 @@ -436,7 +501,7 @@ //**************************** RS485 link *************************************** //dir =0; // receiver enable - +/* if (device.readable()) { c = device.getc(); @@ -452,6 +517,173 @@ tft.printf("1"); } +*/ + +/* +while (device.readable()) + { + c = device.getc(); + + if (c == 'T'){ // Actual tool number sent over serial + + index = 1; + + } + + + if (c == 'M'){ // magazine + or - sent over serial + index = 5; + } + + if (index == 1){ + c = device.getc(); + if (c == '1'){ // hundreds place to know we are sending 3 digits + index = 2; + } + } + + + + if (index == 2){ // tool number 10's column + + c = device.getc(); + + if (c=='0'){ + Tens = 0; + index = 4; + + } + + else if (c=='1'){ + Tens = 1; + index = 4; + + } + + else if (c=='2'){ + Tens = 2; + index = 4; + + } + + else if (c=='3'){ + Tens = 3; + index = 4; + + } + + else if (c=='4'){ + Tens = 4; + index = 4; + } + + else if (c=='5'){ //max number of tools is 50 + Tens = 5; + index = 4; + } + + } + + if (index == 4){ // tool number ones column + + c = device.getc(); + + if (c=='0'){ + Ones = 0; + + } + + else if (c=='1'){ + Ones = 1; + + + } + + else if (c=='2'){ + Ones = 2; + + } + + else if (c=='3'){ + Ones = 3; + + } + + else if (c=='4'){ + Ones = 4; + } + + else if (c=='5'){ + Ones = 5; + } + + else if (c=='6'){ + Ones = 6; + } + + else if (c=='7'){ + Ones = 7; + } + + else if (c=='8'){ + Ones = 8; + } + + else if (c=='9'){ + Ones = 9; + } + + else if (c=='0'){ + Ones = 0; + } + + + + serialToolNumber = ((Tens * 10) + Ones); + + currentToolNo = serialToolNumber; // update tool number + + index=0; + + } + + if (index == 5){ // magazine monitoring + + + + c = device.getc(); + + if (c == 'U'){ + + + currentToolNo = (currentToolNo +1); + if (currentToolNo > numTools){ + currentToolNo = 1; + } + index = 0; + } + else if (c == 'D'){ + + tft.setTextColor(WHITE); + tft.setCursor(100, 100); + tft.printf("1"); + + currentToolNo = (currentToolNo -1); + if (currentToolNo < 1){ + currentToolNo = numTools; + } + index = 0; + } + +} +} +*/ + + + + + } } +