![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Display code
Dependencies: mbed reScale RotaryEncoder RPG Adafruit_ST7735 Adafruit_GFX PinDetect Ee24xx08 mRotaryEncoder
Revision 13:83cb3b5c69de, committed 2019-10-06
- Comitter:
- BETZtechnik
- Date:
- Sun Oct 06 21:18:42 2019 +0000
- Parent:
- 12:1e974964272e
- Commit message:
- twitch hold working
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 03 17:38:45 2019 +0000 +++ b/main.cpp Sun Oct 06 21:18:42 2019 +0000 @@ -33,8 +33,8 @@ #define syncAddress 55 #define n1DirAddress 56 #define n2DirAddress 57 - - +#define autoModeAddress 58 // +#define aux2ModeAddress 59 //DigitalOut myled(P1_13); @@ -88,7 +88,7 @@ tft.setCursor(30,120); tft.setTextColor(BLUE); tft.setTextWrap(false); - tft.printf("AccuBlast v1.3"); + tft.printf("AccuBlast v1.4"); tft.setCursor(4, 4); tft.setTextColor(WHITE); @@ -118,12 +118,12 @@ tft.setCursor(4, 80); tft.setTextColor(WHITE); tft.setTextSize(1); - tft.printf("AUX 1:"); + tft.printf("AUTO:"); tft.setCursor(4, 95); tft.setTextColor(WHITE); tft.setTextSize(1); - tft.printf("AUX 2:"); + tft.printf("IN2mode:"); tft.setCursor(4, 110); tft.setTextColor(WHITE); @@ -169,6 +169,12 @@ int n2Dir = 0; // direction of knob for N2 int lastN2Dir = 99; + + int autoMode = 0; + int lastAutoMode = 99; + + int aux2Mode = 0; + int lastAux2Mode = 99; int index = 0; @@ -183,6 +189,7 @@ int twitchDirection = 0; // 0 is up, 1 is down. int maxTwitch = 0; int minTwitch = 0; + int twitchHold = 0; //marker for hold message recieved from Inputs board. int tw1 = 5; // stages of servo write to control speed of sweep. 11.11 Ms = 1 degree int tw2 = 10; @@ -234,6 +241,14 @@ eeprom.read(n2DirAddress, &tempLastN2Dir); n2Dir = (int)tempLastN2Dir; + char tempLastAuto = 0; // previous N2 knob direction setting + eeprom.read(autoModeAddress, &tempLastAuto); + autoMode = (int)tempLastAuto; + + char tempLastAux2 = 0; // previous N2 knob direction setting + eeprom.read(aux2ModeAddress, &tempLastAux2); + aux2Mode = (int)tempLastAux2; + /*EEprom test over 2 digits: int test1 = 150; @@ -747,6 +762,78 @@ dir=0; } + + if (autoMode != lastAutoMode) { // + tft.setCursor(52, 80); + tft.setTextColor(BLACK); + tft.setTextSize(1); + if (lastAutoMode == 0) { + tft.printf("OFF"); + } + if (lastAutoMode == 1) { + tft.printf("X7a"); + } + if (lastAutoMode == 2) { + tft.printf("Pul"); + } + + tft.setCursor(52, 80); + if (autoMode == 0) { + tft.setTextColor(WHITE); + tft.printf("OFF"); + } + if (autoMode == 1) { + tft.setTextColor(GREEN); + tft.printf("X7a"); + } + if (autoMode == 2) { + tft.setTextColor(GREEN); + tft.printf("Pul"); + } + eeprom.write(autoModeAddress, autoMode); // store new twitch setting + lastAutoMode = autoMode; + + dir=1; + device.printf("A"); //A for auto mode + device.printf("%d", autoMode); // send 0,1,2 etc. + wait(0.05); + dir=0; + + } + + if (aux2Mode != lastAux2Mode) { // + tft.setCursor(52, 95); + tft.setTextColor(BLACK); + tft.setTextSize(1); + if (lastAux2Mode == 0) { + tft.printf("OFF"); + } + if (lastAux2Mode == 1) { + tft.printf("TWP"); + } + + + tft.setCursor(52, 95); + if (aux2Mode == 0) { + tft.setTextColor(WHITE); + tft.printf("OFF"); + } + if (aux2Mode == 1) { + tft.setTextColor(GREEN); + tft.printf("TWP"); + } + + eeprom.write(aux2ModeAddress, aux2Mode); // store new twitch setting + lastAux2Mode = aux2Mode; + + dir=1; + device.printf("I"); //I for input + device.printf("%d", aux2Mode); // send 0,1,2 etc. + wait(0.05); + dir=0; + + } + if (version != lastVersion) { // tft.setCursor(132, 80); @@ -796,6 +883,14 @@ else if (count == 4) { Enc.Set(sync); } + + else if (count == 5) { + Enc.Set(autoMode); + } + + else if (count == 6) { + Enc.Set(aux2Mode); + } else if (count == 8) { Enc.Set(n1Dir); @@ -1123,6 +1218,34 @@ } } //**************************** + if (count == 5) { // Knob controls auto setting. 1=off, 2=sync, 3=rev + autoMode = Enc.Get(); + if (autoMode < 0) { + autoMode= 0; + Enc.Set(0); + } + if (autoMode > 2) { + autoMode = 2; + Enc.Set(2); + } + } + + //**************************** + if (count == 6) { // Knob controls auto setting. 1=off, 2=sync, 3=rev + aux2Mode = Enc.Get(); + if (aux2Mode < 0) { + aux2Mode= 0; + Enc.Set(0); + } + if (aux2Mode > 1) { + aux2Mode = 1; + Enc.Set(1); + } + } + + + //**************************** + // 5,6,7 AUX? if (count == 8) { // knob controls the direction of rotation for N1 n1Dir = Enc.Get(); @@ -1200,13 +1323,29 @@ if (c == 'T') { // Actual tool number sent over serial index = 1; - } if (c == 'M') { // magazine + or - sent over serial index = 5; } + + if (c == 'X') { // magazine + or - sent over serial + tft.setCursor(50, 30); + tft.setTextColor(RED); + tft.setTextSize(1.5); + tft.printf("TWITCH HOLD"); + index=0; + } + + if (c == 'Y') { // magazine + or - sent over serial + tft.setCursor(50, 30); + tft.setTextColor(BLACK); + tft.setTextSize(1.5); + tft.printf("TWITCH HOLD"); + index=0; + } + if (index == 1) { c = device.getc(); @@ -1214,6 +1353,8 @@ index = 2; } } + + @@ -1256,6 +1397,9 @@ } } + + + if (index == 4) { // tool number ones column