Display code

Dependencies:   mbed reScale RotaryEncoder RPG Adafruit_ST7735 Adafruit_GFX PinDetect Ee24xx08 mRotaryEncoder

Committer:
BETZtechnik
Date:
Thu Oct 03 17:38:45 2019 +0000
Revision:
12:1e974964272e
Parent:
11:ce51026d8702
Child:
13:83cb3b5c69de
before adding ATC auto modes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
BETZtechnik 11:ce51026d8702 1 #include "mbed.h"
BETZtechnik 0:09419d572e90 2 #include "Adafruit_ST7735.h"
BETZtechnik 1:e8452b75301e 3 #include "RPG.h"
BETZtechnik 0:09419d572e90 4 #include "reScale.h"
BETZtechnik 0:09419d572e90 5 #include "Ee24xx08.h"
BETZtechnik 6:84ea3ec0660d 6 #include "mRotaryEncoder.h"
BETZtechnik 0:09419d572e90 7
BETZtechnik 0:09419d572e90 8
BETZtechnik 0:09419d572e90 9 // DISPLAY INIT:
BETZtechnik 0:09419d572e90 10
BETZtechnik 0:09419d572e90 11 #define BLACK 0x0000
BETZtechnik 0:09419d572e90 12 #define BLUE 0x001F
BETZtechnik 0:09419d572e90 13 #define RED 0xF800
BETZtechnik 0:09419d572e90 14 #define GREEN 0x07E0
BETZtechnik 0:09419d572e90 15 #define CYAN 0x07FF
BETZtechnik 0:09419d572e90 16 #define MAGENTA 0xF81F
BETZtechnik 11:ce51026d8702 17 #define YELLOW 0xFFE0
BETZtechnik 0:09419d572e90 18 #define WHITE 0xFFFF
BETZtechnik 0:09419d572e90 19
BETZtechnik 6:84ea3ec0660d 20 /* EEPROM Memory map:
BETZtechnik 6:84ea3ec0660d 21
BETZtechnik 11:ce51026d8702 22 1 - 50: N1 angles
BETZtechnik 6:84ea3ec0660d 23 51 - 100: Settings
BETZtechnik 6:84ea3ec0660d 24 101- 150: N2 angles
BETZtechnik 6:84ea3ec0660d 25 151- 200: Twitch settings
BETZtechnik 6:84ea3ec0660d 26 200- 250: unused
BETZtechnik 11:ce51026d8702 27 */
BETZtechnik 6:84ea3ec0660d 28
BETZtechnik 1:e8452b75301e 29 #define currentToolAddress 51
BETZtechnik 1:e8452b75301e 30 #define numToolsAddress 52
BETZtechnik 1:e8452b75301e 31 #define numNozAddress 53
BETZtechnik 6:84ea3ec0660d 32 #define versionAddress 54 // 0= basic, 1=pro
BETZtechnik 6:84ea3ec0660d 33 #define syncAddress 55
BETZtechnik 6:84ea3ec0660d 34 #define n1DirAddress 56
BETZtechnik 6:84ea3ec0660d 35 #define n2DirAddress 57
BETZtechnik 6:84ea3ec0660d 36
BETZtechnik 6:84ea3ec0660d 37
BETZtechnik 0:09419d572e90 38
BETZtechnik 0:09419d572e90 39
BETZtechnik 1:e8452b75301e 40 //DigitalOut myled(P1_13);
BETZtechnik 1:e8452b75301e 41
BETZtechnik 0:09419d572e90 42
BETZtechnik 0:09419d572e90 43 I2C iic(P0_5, P0_4);
BETZtechnik 5:69155b34efd6 44
BETZtechnik 1:e8452b75301e 45
BETZtechnik 1:e8452b75301e 46 DigitalOut dir(P0_21);
BETZtechnik 1:e8452b75301e 47
BETZtechnik 0:09419d572e90 48
BETZtechnik 0:09419d572e90 49 Ee24xx08 eeprom(&iic);
BETZtechnik 0:09419d572e90 50
BETZtechnik 1:e8452b75301e 51 Adafruit_ST7735 tft(P0_9, P0_8, P0_6, P0_2, P0_22, P0_7); // MOSI, MISO, SCLK, SSEL, TFT_DC, TFT_RST
BETZtechnik 0:09419d572e90 52
BETZtechnik 6:84ea3ec0660d 53 int maxServo = 2500;
BETZtechnik 6:84ea3ec0660d 54 int minServo = 500;
BETZtechnik 6:84ea3ec0660d 55 reScale servo1Scale(-90,90,minServo,maxServo); //
BETZtechnik 0:09419d572e90 56
BETZtechnik 11:ce51026d8702 57 PwmOut myServo(P1_13); //display board
BETZtechnik 1:e8452b75301e 58 //PwmOut myServo(D4);
BETZtechnik 0:09419d572e90 59
BETZtechnik 1:e8452b75301e 60 //DigitalIn tUpButton(P2_11);
BETZtechnik 1:e8452b75301e 61 //DigitalIn tDownButton(P2_12);
BETZtechnik 1:e8452b75301e 62 DigitalIn encoderFalseButton(P0_23); // FALSE!!! push button of knob
BETZtechnik 1:e8452b75301e 63 DigitalIn encoderButton(P0_20); // push button of knob
BETZtechnik 1:e8452b75301e 64 DigitalIn backButton(P0_15); // back button
BETZtechnik 6:84ea3ec0660d 65 DigitalIn aButton(P0_1); // ISP and A button
BETZtechnik 0:09419d572e90 66
BETZtechnik 1:e8452b75301e 67 Timer t;
BETZtechnik 6:84ea3ec0660d 68 Timer tw;
BETZtechnik 1:e8452b75301e 69 int lastBackButton;
BETZtechnik 1:e8452b75301e 70 int lastDownButton;
BETZtechnik 1:e8452b75301e 71 int lastEncoderButton;
BETZtechnik 12:1e974964272e 72 int encoderPressed =0; // flag for state
BETZtechnik 12:1e974964272e 73 int encoderPressedTime= 0;
BETZtechnik 1:e8452b75301e 74
BETZtechnik 11:ce51026d8702 75 int encoderMove = 0;
BETZtechnik 6:84ea3ec0660d 76
BETZtechnik 1:e8452b75301e 77 int dirt = 0;
BETZtechnik 0:09419d572e90 78
BETZtechnik 11:ce51026d8702 79 int main()
BETZtechnik 11:ce51026d8702 80 {
BETZtechnik 1:e8452b75301e 81
BETZtechnik 1:e8452b75301e 82 // ************************************** SCREEN INIT *************************************************
BETZtechnik 1:e8452b75301e 83
BETZtechnik 11:ce51026d8702 84 tft.initR(INITR_GREENTAB); // initialize a ST7735S chip, black tab
BETZtechnik 11:ce51026d8702 85
BETZtechnik 11:ce51026d8702 86 tft.setRotation(3);
BETZtechnik 11:ce51026d8702 87 tft.fillScreen(BLACK);
BETZtechnik 11:ce51026d8702 88 tft.setCursor(30,120);
BETZtechnik 11:ce51026d8702 89 tft.setTextColor(BLUE);
BETZtechnik 11:ce51026d8702 90 tft.setTextWrap(false);
BETZtechnik 11:ce51026d8702 91 tft.printf("AccuBlast v1.3");
BETZtechnik 11:ce51026d8702 92
BETZtechnik 11:ce51026d8702 93 tft.setCursor(4, 4);
BETZtechnik 11:ce51026d8702 94 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 95 tft.setTextSize(2);
BETZtechnik 11:ce51026d8702 96 tft.printf("N1");
BETZtechnik 11:ce51026d8702 97
BETZtechnik 11:ce51026d8702 98 tft.setCursor(80, 4);
BETZtechnik 11:ce51026d8702 99 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 100 tft.setTextSize(2);
BETZtechnik 11:ce51026d8702 101 tft.printf("N2");
BETZtechnik 11:ce51026d8702 102
BETZtechnik 11:ce51026d8702 103 tft.setCursor(4, 28);
BETZtechnik 11:ce51026d8702 104 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 105 tft.setTextSize(2);
BETZtechnik 11:ce51026d8702 106 tft.printf("T");
BETZtechnik 11:ce51026d8702 107
BETZtechnik 11:ce51026d8702 108 tft.setCursor(4, 50);
BETZtechnik 11:ce51026d8702 109 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 110 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 111 tft.printf("Twitch:");
BETZtechnik 11:ce51026d8702 112
BETZtechnik 11:ce51026d8702 113 tft.setCursor(4, 65);
BETZtechnik 11:ce51026d8702 114 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 115 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 116 tft.printf("Sync:");
BETZtechnik 11:ce51026d8702 117
BETZtechnik 11:ce51026d8702 118 tft.setCursor(4, 80);
BETZtechnik 11:ce51026d8702 119 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 120 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 121 tft.printf("AUX 1:");
BETZtechnik 11:ce51026d8702 122
BETZtechnik 11:ce51026d8702 123 tft.setCursor(4, 95);
BETZtechnik 11:ce51026d8702 124 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 125 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 126 tft.printf("AUX 2:");
BETZtechnik 11:ce51026d8702 127
BETZtechnik 11:ce51026d8702 128 tft.setCursor(4, 110);
BETZtechnik 11:ce51026d8702 129 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 130 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 131 tft.printf("AUX 3:");
BETZtechnik 11:ce51026d8702 132
BETZtechnik 11:ce51026d8702 133 tft.setCursor(75, 95);
BETZtechnik 11:ce51026d8702 134 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 135 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 136 tft.printf("Num Tls");
BETZtechnik 11:ce51026d8702 137
BETZtechnik 11:ce51026d8702 138 tft.setCursor(75, 110);
BETZtechnik 11:ce51026d8702 139 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 140 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 141 tft.printf("Num Noz");
BETZtechnik 11:ce51026d8702 142
BETZtechnik 11:ce51026d8702 143 tft.setCursor(75, 50);
BETZtechnik 11:ce51026d8702 144 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 145 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 146 tft.printf("N1 dir:");
BETZtechnik 11:ce51026d8702 147
BETZtechnik 11:ce51026d8702 148 tft.setCursor(75, 65);
BETZtechnik 11:ce51026d8702 149 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 150 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 151 tft.printf("N2 dir:");
BETZtechnik 11:ce51026d8702 152
BETZtechnik 11:ce51026d8702 153 tft.setCursor(75, 80);
BETZtechnik 11:ce51026d8702 154 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 155 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 156 tft.printf("version:");
BETZtechnik 6:84ea3ec0660d 157
BETZtechnik 11:ce51026d8702 158 // **************************************************************************************************************
BETZtechnik 11:ce51026d8702 159 int version = 0; // 0= basic, 1=pro
BETZtechnik 11:ce51026d8702 160 int lastVersion = 99;
BETZtechnik 11:ce51026d8702 161
BETZtechnik 11:ce51026d8702 162 int sync = 0; // sync setting for N1 and N1
BETZtechnik 11:ce51026d8702 163 int lastSync = 99;
BETZtechnik 11:ce51026d8702 164 int syncSpread = 0;
BETZtechnik 11:ce51026d8702 165 int syncFlag =0; ///// for count/ sync = 2 issue. 2019-09-11
BETZtechnik 11:ce51026d8702 166
BETZtechnik 11:ce51026d8702 167 int n1Dir = 0; // direction of knob for N1
BETZtechnik 11:ce51026d8702 168 int lastN1Dir = 99;
BETZtechnik 11:ce51026d8702 169
BETZtechnik 11:ce51026d8702 170 int n2Dir = 0; // direction of knob for N2
BETZtechnik 11:ce51026d8702 171 int lastN2Dir = 99;
BETZtechnik 11:ce51026d8702 172
BETZtechnik 11:ce51026d8702 173 int index = 0;
BETZtechnik 6:84ea3ec0660d 174
BETZtechnik 11:ce51026d8702 175 int count = 0;
BETZtechnik 11:ce51026d8702 176 int maxCount = 12; //max number of menu items
BETZtechnik 11:ce51026d8702 177 int lastCount = 99;
BETZtechnik 6:84ea3ec0660d 178
BETZtechnik 11:ce51026d8702 179 int twitch = 0;
BETZtechnik 11:ce51026d8702 180 int lastTwitch = 300;
BETZtechnik 11:ce51026d8702 181 int lastTwitchMove = 0;
BETZtechnik 11:ce51026d8702 182 int twitchStart = 0; // has twitching begun?
BETZtechnik 11:ce51026d8702 183 int twitchDirection = 0; // 0 is up, 1 is down.
BETZtechnik 11:ce51026d8702 184 int maxTwitch = 0;
BETZtechnik 11:ce51026d8702 185 int minTwitch = 0;
BETZtechnik 11:ce51026d8702 186
BETZtechnik 11:ce51026d8702 187 int tw1 = 5; // stages of servo write to control speed of sweep. 11.11 Ms = 1 degree
BETZtechnik 11:ce51026d8702 188 int tw2 = 10;
BETZtechnik 11:ce51026d8702 189 int tw3 = 15;
BETZtechnik 11:ce51026d8702 190
BETZtechnik 11:ce51026d8702 191 int twReadMs = 100; // interval of twitch changes us.
BETZtechnik 11:ce51026d8702 192
BETZtechnik 11:ce51026d8702 193 //************* Pull previous setting from eeprom *******************
BETZtechnik 6:84ea3ec0660d 194
BETZtechnik 11:ce51026d8702 195 char tempToolNo = 0; // last tool in spindle
BETZtechnik 11:ce51026d8702 196 eeprom.read(currentToolAddress, &tempToolNo);
BETZtechnik 11:ce51026d8702 197 int currentToolNo = (int)tempToolNo;
BETZtechnik 11:ce51026d8702 198
BETZtechnik 11:ce51026d8702 199 char tempNumTools = 0; // number of tools in ATC
BETZtechnik 11:ce51026d8702 200 eeprom.read(numToolsAddress, &tempNumTools);
BETZtechnik 11:ce51026d8702 201 int numTools = (int)tempNumTools;
BETZtechnik 11:ce51026d8702 202
BETZtechnik 11:ce51026d8702 203 char tempNumNoz = 0; // number of nozzles installed
BETZtechnik 11:ce51026d8702 204 eeprom.read(numNozAddress, &tempNumNoz);
BETZtechnik 11:ce51026d8702 205 int numNoz = (int)tempNumNoz;
BETZtechnik 11:ce51026d8702 206
BETZtechnik 11:ce51026d8702 207 char tempLastAngle = 0; // last angle of last tool in spindle N1
BETZtechnik 11:ce51026d8702 208 eeprom.read(currentToolNo, &tempLastAngle);
BETZtechnik 11:ce51026d8702 209 int lastAngle = (int)tempLastAngle;
BETZtechnik 11:ce51026d8702 210 lastAngle = lastAngle - 90; // Not storing signed int, so signed value is 45 less than what was stored to memory.
BETZtechnik 11:ce51026d8702 211
BETZtechnik 11:ce51026d8702 212 char tempLastAngleN2 = 0; // last angle of last tool in spindle
BETZtechnik 11:ce51026d8702 213 eeprom.read(currentToolNo+100, &tempLastAngleN2);
BETZtechnik 11:ce51026d8702 214 int lastAngleN2 = (int)tempLastAngleN2;
BETZtechnik 11:ce51026d8702 215 lastAngleN2 = lastAngleN2 - 90; // Not storing signed int, so signed value is 45 less than what was stored to memory.
BETZtechnik 11:ce51026d8702 216
BETZtechnik 11:ce51026d8702 217 char tempLastTwitch = 0; // last Twitch setting for the current tool in spindle
BETZtechnik 11:ce51026d8702 218 eeprom.read(currentToolNo + 150, &tempLastTwitch);
BETZtechnik 11:ce51026d8702 219 twitch = (int)tempLastTwitch; // should be 1, 2 or 3.
BETZtechnik 11:ce51026d8702 220
BETZtechnik 11:ce51026d8702 221 char tempLastVersion = 0; // version of system. 0=basic, 1=pro
BETZtechnik 11:ce51026d8702 222 eeprom.read(versionAddress, &tempLastVersion);
BETZtechnik 11:ce51026d8702 223 version = (int)tempLastVersion;
BETZtechnik 11:ce51026d8702 224
BETZtechnik 11:ce51026d8702 225 char tempLastSync = 0; // previous sync setting
BETZtechnik 11:ce51026d8702 226 eeprom.read(syncAddress, &tempLastSync);
BETZtechnik 11:ce51026d8702 227 sync = (int)tempLastSync;
BETZtechnik 11:ce51026d8702 228
BETZtechnik 11:ce51026d8702 229 char tempLastN1Dir = 0; // previous N1 knob direction setting
BETZtechnik 11:ce51026d8702 230 eeprom.read(n1DirAddress, &tempLastN1Dir);
BETZtechnik 11:ce51026d8702 231 n1Dir = (int)tempLastN1Dir;
BETZtechnik 11:ce51026d8702 232
BETZtechnik 6:84ea3ec0660d 233 char tempLastN2Dir = 0; // previous N2 knob direction setting
BETZtechnik 11:ce51026d8702 234 eeprom.read(n2DirAddress, &tempLastN2Dir);
BETZtechnik 11:ce51026d8702 235 n2Dir = (int)tempLastN2Dir;
BETZtechnik 0:09419d572e90 236
BETZtechnik 1:e8452b75301e 237
BETZtechnik 11:ce51026d8702 238 /*EEprom test over 2 digits:
BETZtechnik 11:ce51026d8702 239 int test1 = 150;
BETZtechnik 11:ce51026d8702 240 eeprom.write(199, test1);
BETZtechnik 11:ce51026d8702 241 wait(1);
BETZtechnik 11:ce51026d8702 242 char tempN2char = 0;
BETZtechnik 11:ce51026d8702 243 eeprom.read(199, &tempN2char);
BETZtechnik 11:ce51026d8702 244 int tempN2 = (int)tempN2char;
BETZtechnik 11:ce51026d8702 245 tft.setCursor(130,120);
BETZtechnik 11:ce51026d8702 246 tft.setTextColor(RED);
BETZtechnik 11:ce51026d8702 247 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 248 tft.printf("%d", tempN2);
BETZtechnik 11:ce51026d8702 249 */
BETZtechnik 11:ce51026d8702 250
BETZtechnik 11:ce51026d8702 251
BETZtechnik 11:ce51026d8702 252 //******************** Button debounce *********************************
BETZtechnik 11:ce51026d8702 253
BETZtechnik 11:ce51026d8702 254
BETZtechnik 11:ce51026d8702 255
BETZtechnik 11:ce51026d8702 256 backButton.mode(PullUp); // button pull up
BETZtechnik 11:ce51026d8702 257 //tDownButton.mode(PullUp); // button pull up
BETZtechnik 11:ce51026d8702 258 encoderButton.mode(PullUp);
BETZtechnik 11:ce51026d8702 259 encoderFalseButton.mode(PullUp);
BETZtechnik 11:ce51026d8702 260 aButton.mode(PullUp);
BETZtechnik 11:ce51026d8702 261
BETZtechnik 11:ce51026d8702 262 t.start(); // starts timer
BETZtechnik 11:ce51026d8702 263 lastBackButton = t.read_ms();
BETZtechnik 11:ce51026d8702 264 lastDownButton = t.read_ms();
BETZtechnik 11:ce51026d8702 265 lastEncoderButton = t.read_ms();
BETZtechnik 12:1e974964272e 266 encoderPressedTime= t.read_ms();
BETZtechnik 11:ce51026d8702 267
BETZtechnik 11:ce51026d8702 268 //****************************************************************************
BETZtechnik 11:ce51026d8702 269
BETZtechnik 11:ce51026d8702 270 int lastToolNo = 99;
BETZtechnik 11:ce51026d8702 271 int lastNumTools = -1; // trigger to write eeprom value for number of tools
BETZtechnik 11:ce51026d8702 272
BETZtechnik 11:ce51026d8702 273 int lastNumNoz = 0; //trigger display for number of nozzles after startup
BETZtechnik 11:ce51026d8702 274
BETZtechnik 11:ce51026d8702 275 int n1Pos = lastAngle; //Set servo to last known postition prior to power off
BETZtechnik 11:ce51026d8702 276 int lastN1Pos = 150;
BETZtechnik 0:09419d572e90 277
BETZtechnik 11:ce51026d8702 278 int n2Pos = lastAngleN2;
BETZtechnik 11:ce51026d8702 279 int lastN2Pos = 150;
BETZtechnik 11:ce51026d8702 280
BETZtechnik 11:ce51026d8702 281 int servo1Pos = 0;
BETZtechnik 11:ce51026d8702 282
BETZtechnik 11:ce51026d8702 283
BETZtechnik 11:ce51026d8702 284 // RPG rpg1(P2_2,P1_20,P0_23); // RPG (PinName pA, PinName pB, PinName pPB)P0_23 is unconnected!! ;
BETZtechnik 11:ce51026d8702 285 //mRotaryEncoder Enc(P2_2,P1_20,P0_23, PullUp, 500);
BETZtechnik 11:ce51026d8702 286 mRotaryEncoder Enc(P1_20,P2_2,P0_23, PullUp, 1000);
BETZtechnik 11:ce51026d8702 287
BETZtechnik 11:ce51026d8702 288 myServo.period_ms(20);
BETZtechnik 11:ce51026d8702 289
BETZtechnik 11:ce51026d8702 290 /*
BETZtechnik 11:ce51026d8702 291 char t1Ang = 200;
BETZtechnik 11:ce51026d8702 292 char t1Read = 0;
BETZtechnik 11:ce51026d8702 293
BETZtechnik 11:ce51026d8702 294 eeprom.write(1, t1Ang);
BETZtechnik 11:ce51026d8702 295 wait(1);
BETZtechnik 11:ce51026d8702 296 eeprom.read(1, &t1Read);
BETZtechnik 11:ce51026d8702 297
BETZtechnik 0:09419d572e90 298
BETZtechnik 11:ce51026d8702 299 tft.setCursor(30,110);
BETZtechnik 11:ce51026d8702 300 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 301 tft.setTextWrap(true);
BETZtechnik 11:ce51026d8702 302 // tft.printf("%s\r\n",t1Read);
BETZtechnik 11:ce51026d8702 303 tft.printf("%d", currentTool);
BETZtechnik 11:ce51026d8702 304 */
BETZtechnik 11:ce51026d8702 305
BETZtechnik 11:ce51026d8702 306 uint8_t c = 0; // for 485 link
BETZtechnik 11:ce51026d8702 307
BETZtechnik 11:ce51026d8702 308
BETZtechnik 11:ce51026d8702 309 int serialToolNumber = 0;
BETZtechnik 11:ce51026d8702 310 int stage = 0; // for serial parsing
BETZtechnik 11:ce51026d8702 311 int Tens = 0;
BETZtechnik 11:ce51026d8702 312 int Ones = 0;
BETZtechnik 11:ce51026d8702 313
BETZtechnik 11:ce51026d8702 314 dir = 0;
BETZtechnik 11:ce51026d8702 315
BETZtechnik 11:ce51026d8702 316 wait(2);
BETZtechnik 11:ce51026d8702 317 Serial device(P0_14, P0_13, 19200); // RS 485 TX RX?
BETZtechnik 11:ce51026d8702 318
BETZtechnik 0:09419d572e90 319 while(1) {
BETZtechnik 11:ce51026d8702 320
BETZtechnik 11:ce51026d8702 321
BETZtechnik 11:ce51026d8702 322
BETZtechnik 11:ce51026d8702 323 /*
BETZtechnik 11:ce51026d8702 324 while (device.readable())
BETZtechnik 11:ce51026d8702 325 {
BETZtechnik 11:ce51026d8702 326 c = device.getc();
BETZtechnik 11:ce51026d8702 327
BETZtechnik 11:ce51026d8702 328
BETZtechnik 11:ce51026d8702 329 if (c == '+'){
BETZtechnik 11:ce51026d8702 330 currentToolNo = currentToolNo +1;
BETZtechnik 11:ce51026d8702 331 if (currentToolNo > numTools){
BETZtechnik 11:ce51026d8702 332 currentToolNo = 1;
BETZtechnik 11:ce51026d8702 333 }
BETZtechnik 11:ce51026d8702 334 }
BETZtechnik 11:ce51026d8702 335
BETZtechnik 11:ce51026d8702 336 else if (c == '-'){
BETZtechnik 11:ce51026d8702 337 currentToolNo = currentToolNo - 1;
BETZtechnik 11:ce51026d8702 338 if (currentToolNo > 1){
BETZtechnik 11:ce51026d8702 339 currentToolNo = numTools;
BETZtechnik 11:ce51026d8702 340 }
BETZtechnik 11:ce51026d8702 341 }
BETZtechnik 11:ce51026d8702 342 }
BETZtechnik 11:ce51026d8702 343 */
BETZtechnik 11:ce51026d8702 344
BETZtechnik 11:ce51026d8702 345 /*
BETZtechnik 11:ce51026d8702 346 while (device.readable())
BETZtechnik 11:ce51026d8702 347 {
BETZtechnik 11:ce51026d8702 348
BETZtechnik 11:ce51026d8702 349
BETZtechnik 11:ce51026d8702 350 c = device.getc();
BETZtechnik 11:ce51026d8702 351
BETZtechnik 11:ce51026d8702 352 if (c == 'M'){
BETZtechnik 11:ce51026d8702 353 // stage = 1;
BETZtechnik 2:bbbacfd62773 354
BETZtechnik 11:ce51026d8702 355 c = device.getc();
BETZtechnik 11:ce51026d8702 356 if (c == '+'){
BETZtechnik 11:ce51026d8702 357
BETZtechnik 11:ce51026d8702 358 // tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 359 // tft.setCursor(100, 100);
BETZtechnik 11:ce51026d8702 360 // tft.printf("%d", c);
BETZtechnik 11:ce51026d8702 361 currentToolNo = currentToolNo +1;
BETZtechnik 11:ce51026d8702 362 if (currentToolNo > numTools){
BETZtechnik 11:ce51026d8702 363 currentToolNo = 1;
BETZtechnik 11:ce51026d8702 364 }
BETZtechnik 11:ce51026d8702 365 }
BETZtechnik 11:ce51026d8702 366
BETZtechnik 11:ce51026d8702 367 else if (c == '-'){
BETZtechnik 11:ce51026d8702 368 currentToolNo = currentToolNo - 1;
BETZtechnik 11:ce51026d8702 369 if (currentToolNo < 1){
BETZtechnik 11:ce51026d8702 370 currentToolNo = numTools;
BETZtechnik 11:ce51026d8702 371 }
BETZtechnik 11:ce51026d8702 372 }
BETZtechnik 11:ce51026d8702 373
BETZtechnik 11:ce51026d8702 374 }
BETZtechnik 11:ce51026d8702 375 }
BETZtechnik 11:ce51026d8702 376
BETZtechnik 11:ce51026d8702 377 */
BETZtechnik 11:ce51026d8702 378
BETZtechnik 11:ce51026d8702 379
BETZtechnik 11:ce51026d8702 380
BETZtechnik 11:ce51026d8702 381 //myled = 1;
BETZtechnik 11:ce51026d8702 382
BETZtechnik 11:ce51026d8702 383 if (t.read() > 1200) { // timer can only hold 30 min, so reset after 20
BETZtechnik 11:ce51026d8702 384 t.reset();
BETZtechnik 11:ce51026d8702 385 lastBackButton = t.read_ms();
BETZtechnik 11:ce51026d8702 386 lastDownButton = t.read_ms();
BETZtechnik 11:ce51026d8702 387 lastEncoderButton = t.read_ms();
BETZtechnik 11:ce51026d8702 388 }
BETZtechnik 1:e8452b75301e 389
BETZtechnik 6:84ea3ec0660d 390
BETZtechnik 6:84ea3ec0660d 391
BETZtechnik 11:ce51026d8702 392 if (backButton == 0) { //Back button was pressed so back to default selection
BETZtechnik 11:ce51026d8702 393 count = 0;
BETZtechnik 11:ce51026d8702 394 }
BETZtechnik 11:ce51026d8702 395
BETZtechnik 12:1e974964272e 396 // ************************* encoder button
BETZtechnik 12:1e974964272e 397 if (encoderButton == 0 && encoderPressed == 0 && (t.read_ms() > (lastEncoderButton + 200))) {
BETZtechnik 12:1e974964272e 398 encoderPressed = 1;
BETZtechnik 12:1e974964272e 399 encoderPressedTime = t.read_ms();
BETZtechnik 12:1e974964272e 400 }
BETZtechnik 12:1e974964272e 401
BETZtechnik 12:1e974964272e 402 if (encoderButton == 0 && encoderPressed == 1 && (t.read_ms() < (encoderPressedTime + 20))) {
BETZtechnik 12:1e974964272e 403 count = count + 1; //Reset count if PB pressed
BETZtechnik 12:1e974964272e 404 lastEncoderButton = t.read_ms();
BETZtechnik 12:1e974964272e 405 encoderPressed = 0;
BETZtechnik 12:1e974964272e 406 }
BETZtechnik 12:1e974964272e 407
BETZtechnik 12:1e974964272e 408 if (encoderButton == 1 && encoderPressed == 1 && (t.read_ms() < (encoderPressedTime + 10))) {
BETZtechnik 12:1e974964272e 409 encoderPressed = 0;
BETZtechnik 12:1e974964272e 410 }
BETZtechnik 12:1e974964272e 411
BETZtechnik 12:1e974964272e 412
BETZtechnik 12:1e974964272e 413 if (count > maxCount) {
BETZtechnik 12:1e974964272e 414 count = 0;
BETZtechnik 12:1e974964272e 415 }
BETZtechnik 12:1e974964272e 416
BETZtechnik 12:1e974964272e 417 if (count > maxCount) {
BETZtechnik 12:1e974964272e 418 count = 0;
BETZtechnik 12:1e974964272e 419 }
BETZtechnik 12:1e974964272e 420
BETZtechnik 12:1e974964272e 421
BETZtechnik 12:1e974964272e 422
BETZtechnik 12:1e974964272e 423
BETZtechnik 12:1e974964272e 424 // ******************************
BETZtechnik 12:1e974964272e 425 /*
BETZtechnik 11:ce51026d8702 426 if (encoderButton == 0) {
BETZtechnik 11:ce51026d8702 427 if (t.read_ms() > (lastEncoderButton + 50)) { // from 200
BETZtechnik 11:ce51026d8702 428 count = count + 1; //Reset count if PB pressed
BETZtechnik 11:ce51026d8702 429 }
BETZtechnik 11:ce51026d8702 430 if (count > maxCount) {
BETZtechnik 11:ce51026d8702 431 count = 0;
BETZtechnik 11:ce51026d8702 432 }
BETZtechnik 11:ce51026d8702 433 lastEncoderButton = t.read_ms();
BETZtechnik 11:ce51026d8702 434
BETZtechnik 11:ce51026d8702 435 if (count > maxCount) {
BETZtechnik 11:ce51026d8702 436 count = 0;
BETZtechnik 11:ce51026d8702 437 }
BETZtechnik 11:ce51026d8702 438 }
BETZtechnik 12:1e974964272e 439 */
BETZtechnik 12:1e974964272e 440 //************************************
BETZtechnik 11:ce51026d8702 441
BETZtechnik 11:ce51026d8702 442 //****************************************************************************************
BETZtechnik 11:ce51026d8702 443
BETZtechnik 11:ce51026d8702 444 if (version == 0) { //Basic runs the servo direct from the display unit
BETZtechnik 11:ce51026d8702 445 if (twitch == 0) {
BETZtechnik 11:ce51026d8702 446 tw.stop();
BETZtechnik 11:ce51026d8702 447 twitchStart = 0;
BETZtechnik 11:ce51026d8702 448 twitchDirection = 0;
BETZtechnik 11:ce51026d8702 449 servo1Pos = servo1Scale.from(n1Pos);
BETZtechnik 11:ce51026d8702 450 }
BETZtechnik 11:ce51026d8702 451
BETZtechnik 11:ce51026d8702 452 if (twitch > 0) {
BETZtechnik 11:ce51026d8702 453 if (twitchStart == 0) {
BETZtechnik 11:ce51026d8702 454 tw.start(); // start timer for nozzle sweep
BETZtechnik 11:ce51026d8702 455 servo1Pos = servo1Scale.from(n1Pos);
BETZtechnik 11:ce51026d8702 456 lastTwitchMove = tw.read_ms(); // store time of last nozzle movement
BETZtechnik 11:ce51026d8702 457 minTwitch = servo1Pos; // store original servo postion for bottom of sweep
BETZtechnik 11:ce51026d8702 458 maxTwitch = servo1Pos + 1000; // 11.11mS per degree of sweep, 55 = 5 degrees of sweep. This should be a viariable set on the display.
BETZtechnik 11:ce51026d8702 459 twitchStart = 1;
BETZtechnik 11:ce51026d8702 460 }
BETZtechnik 11:ce51026d8702 461 if ((twitchStart == 1) && (tw.read_ms() > (lastTwitchMove + twReadMs))) {
BETZtechnik 11:ce51026d8702 462 if (twitchDirection == 0) { //going up
BETZtechnik 11:ce51026d8702 463 servo1Pos = servo1Pos + 100; // add variable amount of uS to the servo signal
BETZtechnik 11:ce51026d8702 464
BETZtechnik 11:ce51026d8702 465 tft.setCursor(130,120);
BETZtechnik 11:ce51026d8702 466 tft.setTextColor(RED);
BETZtechnik 11:ce51026d8702 467 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 468 tft.printf("%d", servo1Pos);
BETZtechnik 11:ce51026d8702 469
BETZtechnik 11:ce51026d8702 470
BETZtechnik 11:ce51026d8702 471 if (servo1Pos > maxServo) {
BETZtechnik 11:ce51026d8702 472 servo1Pos = maxServo;
BETZtechnik 11:ce51026d8702 473 twitchDirection = 1; //reverse direction
BETZtechnik 11:ce51026d8702 474 }
BETZtechnik 11:ce51026d8702 475 if (servo1Pos > maxTwitch) {
BETZtechnik 11:ce51026d8702 476 servo1Pos = maxTwitch;
BETZtechnik 11:ce51026d8702 477 twitchDirection = 1; //reverse direction
BETZtechnik 11:ce51026d8702 478 }
BETZtechnik 11:ce51026d8702 479 lastTwitchMove = tw.read_ms();
BETZtechnik 11:ce51026d8702 480 }
BETZtechnik 11:ce51026d8702 481
BETZtechnik 11:ce51026d8702 482 if (twitchDirection == 1) { // going down
BETZtechnik 11:ce51026d8702 483 servo1Pos = servo1Pos - 100; // add variable amount of Ms to the servo signal
BETZtechnik 11:ce51026d8702 484 if (servo1Pos < minServo) {
BETZtechnik 11:ce51026d8702 485 servo1Pos = minServo;
BETZtechnik 11:ce51026d8702 486 twitchDirection = 0; //reverse direction
BETZtechnik 11:ce51026d8702 487 }
BETZtechnik 11:ce51026d8702 488 if (servo1Pos < minTwitch) {
BETZtechnik 11:ce51026d8702 489 servo1Pos = minTwitch;
BETZtechnik 11:ce51026d8702 490 twitchDirection = 0; //reverse direction
BETZtechnik 11:ce51026d8702 491 }
BETZtechnik 11:ce51026d8702 492 lastTwitchMove = tw.read_ms();
BETZtechnik 11:ce51026d8702 493 }
BETZtechnik 11:ce51026d8702 494 }
BETZtechnik 11:ce51026d8702 495 }
BETZtechnik 11:ce51026d8702 496
BETZtechnik 11:ce51026d8702 497 myServo.pulsewidth_us(servo1Pos);
BETZtechnik 11:ce51026d8702 498 }
BETZtechnik 11:ce51026d8702 499
BETZtechnik 11:ce51026d8702 500
BETZtechnik 11:ce51026d8702 501 //********************** update display values **********************************************
BETZtechnik 11:ce51026d8702 502
BETZtechnik 11:ce51026d8702 503
BETZtechnik 11:ce51026d8702 504 if (currentToolNo != lastToolNo) {
BETZtechnik 11:ce51026d8702 505 /*
BETZtechnik 11:ce51026d8702 506 tft.fillRect(103, 2, 55,25, BLACK);
BETZtechnik 11:ce51026d8702 507 tft.setCursor(105, 4);
BETZtechnik 11:ce51026d8702 508 */
BETZtechnik 11:ce51026d8702 509 tft.setCursor(22, 28);
BETZtechnik 11:ce51026d8702 510 tft.setTextColor(BLACK);
BETZtechnik 11:ce51026d8702 511 tft.setTextSize(2);
BETZtechnik 11:ce51026d8702 512 tft.printf("%d", lastToolNo);
BETZtechnik 11:ce51026d8702 513 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 514 //tft.setTextSize(2);
BETZtechnik 11:ce51026d8702 515 // tft.printf("T");
BETZtechnik 11:ce51026d8702 516 tft.setCursor(22,28);
BETZtechnik 11:ce51026d8702 517 tft.printf("%d", currentToolNo);
BETZtechnik 11:ce51026d8702 518
BETZtechnik 11:ce51026d8702 519 tempLastAngle = 0;
BETZtechnik 11:ce51026d8702 520 eeprom.read(currentToolNo, &tempLastAngle);
BETZtechnik 11:ce51026d8702 521 lastAngle = (int)tempLastAngle;
BETZtechnik 11:ce51026d8702 522 lastAngle = lastAngle - 90; // Not storing signed int, so signed value is 90 less than what was stored to memory.
BETZtechnik 11:ce51026d8702 523 n1Pos = lastAngle;
BETZtechnik 11:ce51026d8702 524
BETZtechnik 11:ce51026d8702 525 tempLastAngleN2 = 0;
BETZtechnik 11:ce51026d8702 526 eeprom.read(currentToolNo+100, &tempLastAngleN2);
BETZtechnik 11:ce51026d8702 527 int lastAngleN2 = (int)tempLastAngleN2;
BETZtechnik 11:ce51026d8702 528 lastAngleN2 = lastAngleN2 - 90; // Not storing signed int, so signed value is 45 less than what was stored to memory.
BETZtechnik 11:ce51026d8702 529 n2Pos = lastAngleN2;
BETZtechnik 11:ce51026d8702 530
BETZtechnik 11:ce51026d8702 531 if (count == 0) { // if knob is on N1 adjust and ATC changes tools, update enc value)
BETZtechnik 11:ce51026d8702 532 Enc.Set(n1Pos); // test for ATC following issue!
BETZtechnik 11:ce51026d8702 533 }
BETZtechnik 11:ce51026d8702 534
BETZtechnik 11:ce51026d8702 535 eeprom.write(currentToolAddress, currentToolNo);
BETZtechnik 11:ce51026d8702 536 wait(0.1);
BETZtechnik 11:ce51026d8702 537 tempLastTwitch = 0;
BETZtechnik 11:ce51026d8702 538 eeprom.read(currentToolNo + 150, &tempLastTwitch); // pull up previous twitch setting.
BETZtechnik 11:ce51026d8702 539 twitch = (int)tempLastTwitch;
BETZtechnik 11:ce51026d8702 540 lastToolNo = currentToolNo;
BETZtechnik 11:ce51026d8702 541 }
BETZtechnik 11:ce51026d8702 542
BETZtechnik 11:ce51026d8702 543
BETZtechnik 11:ce51026d8702 544 if (n1Pos != lastN1Pos) {
BETZtechnik 11:ce51026d8702 545 tft.setCursor(40, 4);
BETZtechnik 11:ce51026d8702 546 tft.setTextColor(BLACK);
BETZtechnik 11:ce51026d8702 547 tft.setTextSize(2);
BETZtechnik 11:ce51026d8702 548 tft.printf("%d", lastN1Pos);
BETZtechnik 11:ce51026d8702 549 tft.setCursor(40,4);
BETZtechnik 11:ce51026d8702 550 tft.setTextColor(GREEN);
BETZtechnik 11:ce51026d8702 551 tft.setTextSize(2);
BETZtechnik 11:ce51026d8702 552 tft.printf("%d", n1Pos);
BETZtechnik 11:ce51026d8702 553 eeprom.write(currentToolNo, n1Pos + 90); // store new angle in eeprom, add 90 because its an unsigned value.
BETZtechnik 11:ce51026d8702 554 //wait(0.1); // adjusted from 1
BETZtechnik 11:ce51026d8702 555 dir=1;
BETZtechnik 11:ce51026d8702 556 device.printf("N");
BETZtechnik 11:ce51026d8702 557 device.printf("%d", n1Pos + 190); //send over RS485 add 190 so no negative values and always 3 digits.
BETZtechnik 11:ce51026d8702 558 //device.printf("N245"); // TEST!!!
BETZtechnik 11:ce51026d8702 559 // tft.setCursor(100, 50);
BETZtechnik 11:ce51026d8702 560 // tft.setTextSize(2);
BETZtechnik 11:ce51026d8702 561 // tft.printf("%d", n1Pos + 145);
BETZtechnik 11:ce51026d8702 562 wait(0.05);
BETZtechnik 11:ce51026d8702 563 dir=0;
BETZtechnik 11:ce51026d8702 564
BETZtechnik 11:ce51026d8702 565 //Enc.Set(n1Pos); // test!!
BETZtechnik 11:ce51026d8702 566
BETZtechnik 11:ce51026d8702 567 lastN1Pos = n1Pos;
BETZtechnik 11:ce51026d8702 568 syncFlag =1; // set the flag after lastN1Pos has run once to allow REV sync setting in count ==0 2019-09-11
BETZtechnik 11:ce51026d8702 569 }
BETZtechnik 11:ce51026d8702 570
BETZtechnik 11:ce51026d8702 571 if (n2Pos != lastN2Pos && numNoz == 2) {
BETZtechnik 11:ce51026d8702 572 tft.setCursor(115, 4);
BETZtechnik 11:ce51026d8702 573 tft.setTextColor(BLACK);
BETZtechnik 11:ce51026d8702 574 tft.setTextSize(2);
BETZtechnik 11:ce51026d8702 575 tft.printf("%d", lastN2Pos);
BETZtechnik 11:ce51026d8702 576 tft.setCursor(115, 4);
BETZtechnik 11:ce51026d8702 577 tft.setTextColor(GREEN);
BETZtechnik 11:ce51026d8702 578 tft.setTextSize(2);
BETZtechnik 11:ce51026d8702 579 tft.printf("%d", n2Pos);
BETZtechnik 11:ce51026d8702 580 eeprom.write(currentToolNo +100, n2Pos + 90); // store new angle in eeprom, add 90 because its an unsigned value.
BETZtechnik 11:ce51026d8702 581 //wait(0.1); // adjusted from 1
BETZtechnik 11:ce51026d8702 582 dir=1;
BETZtechnik 11:ce51026d8702 583 device.printf("N");
BETZtechnik 11:ce51026d8702 584 device.printf("%d", n2Pos + 390); //send over RS485 add 390 so no negative values and always 3 digits.
BETZtechnik 11:ce51026d8702 585 //device.printf("N245"); // TEST!!!
BETZtechnik 11:ce51026d8702 586 // tft.setCursor(100, 50);
BETZtechnik 11:ce51026d8702 587 // tft.setTextSize(2);
BETZtechnik 11:ce51026d8702 588 // tft.printf("%d", n1Pos + 145);
BETZtechnik 11:ce51026d8702 589 wait(0.05);
BETZtechnik 11:ce51026d8702 590 dir=0;
BETZtechnik 11:ce51026d8702 591 lastN2Pos = n2Pos;
BETZtechnik 11:ce51026d8702 592 }
BETZtechnik 11:ce51026d8702 593
BETZtechnik 11:ce51026d8702 594
BETZtechnik 11:ce51026d8702 595 if (numTools != lastNumTools) {
BETZtechnik 11:ce51026d8702 596 tft.setCursor(133, 95);
BETZtechnik 11:ce51026d8702 597 tft.setTextColor(BLACK);
BETZtechnik 11:ce51026d8702 598 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 599 tft.printf("%d", lastNumTools);
BETZtechnik 11:ce51026d8702 600 tft.setCursor(133,95);
BETZtechnik 11:ce51026d8702 601 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 602 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 603 tft.printf("%d", numTools);
BETZtechnik 11:ce51026d8702 604 eeprom.write(numToolsAddress, numTools); // store new angle in eeprom, add 45 because its an unsigned value.
BETZtechnik 11:ce51026d8702 605 //wait(0.1); // adjusted from 1
BETZtechnik 11:ce51026d8702 606 lastNumTools = numTools;
BETZtechnik 11:ce51026d8702 607 }
BETZtechnik 11:ce51026d8702 608
BETZtechnik 11:ce51026d8702 609 if (numNoz != lastNumNoz) {
BETZtechnik 11:ce51026d8702 610 tft.setCursor(133, 110);
BETZtechnik 11:ce51026d8702 611 tft.setTextColor(BLACK);
BETZtechnik 11:ce51026d8702 612 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 613 tft.printf("%d", lastNumNoz);
BETZtechnik 11:ce51026d8702 614 tft.setCursor(133,110);
BETZtechnik 11:ce51026d8702 615 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 616 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 617 tft.printf("%d", numNoz);
BETZtechnik 11:ce51026d8702 618 eeprom.write(numNozAddress, numNoz); // store new angle in eeprom, add 45 because its an unsigned value.
BETZtechnik 11:ce51026d8702 619 //wait(0.1); // adjusted from 1
BETZtechnik 11:ce51026d8702 620
BETZtechnik 11:ce51026d8702 621 if (numNoz == 2) {
BETZtechnik 11:ce51026d8702 622 tft.setCursor(80, 4);
BETZtechnik 11:ce51026d8702 623 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 624 tft.setTextSize(2);
BETZtechnik 11:ce51026d8702 625 tft.printf("N2");
BETZtechnik 11:ce51026d8702 626 tft.drawRect(78,2,74,18,WHITE);
BETZtechnik 11:ce51026d8702 627 }
BETZtechnik 11:ce51026d8702 628 if (numNoz == 1) {
BETZtechnik 11:ce51026d8702 629 tft.setCursor(80, 4);
BETZtechnik 11:ce51026d8702 630 tft.setTextColor(BLACK);
BETZtechnik 11:ce51026d8702 631 tft.setTextSize(2);
BETZtechnik 11:ce51026d8702 632 tft.printf("N2");
BETZtechnik 11:ce51026d8702 633 tft.setCursor(115, 4);
BETZtechnik 11:ce51026d8702 634 tft.printf("%d", n2Pos);
BETZtechnik 11:ce51026d8702 635 tft.drawRect(78,2,74,18,BLACK);
BETZtechnik 11:ce51026d8702 636 }
BETZtechnik 11:ce51026d8702 637 lastNumNoz = numNoz;
BETZtechnik 11:ce51026d8702 638 }
BETZtechnik 11:ce51026d8702 639
BETZtechnik 11:ce51026d8702 640
BETZtechnik 11:ce51026d8702 641 if (twitch != lastTwitch) {
BETZtechnik 11:ce51026d8702 642 tft.setCursor(52, 50);
BETZtechnik 11:ce51026d8702 643 tft.setTextColor(BLACK);
BETZtechnik 11:ce51026d8702 644 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 645 tft.printf("%d", lastTwitch);
BETZtechnik 11:ce51026d8702 646 tft.setCursor(52, 50);
BETZtechnik 11:ce51026d8702 647 tft.setTextColor(GREEN);
BETZtechnik 11:ce51026d8702 648 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 649 tft.printf("%d", twitch);
BETZtechnik 11:ce51026d8702 650 dir=1;
BETZtechnik 11:ce51026d8702 651 device.printf("W");
BETZtechnik 11:ce51026d8702 652 device.printf("%d", twitch);
BETZtechnik 11:ce51026d8702 653 wait(0.05);
BETZtechnik 11:ce51026d8702 654 dir=0;
BETZtechnik 11:ce51026d8702 655 eeprom.write(currentToolNo +150, twitch); // store new twitch setting
BETZtechnik 11:ce51026d8702 656 lastN1Pos = 999; // trigger sending servo values to module
BETZtechnik 11:ce51026d8702 657 lastN2Pos = 999;
BETZtechnik 11:ce51026d8702 658 lastTwitch = twitch;
BETZtechnik 11:ce51026d8702 659 }
BETZtechnik 11:ce51026d8702 660
BETZtechnik 11:ce51026d8702 661 if (sync != lastSync) { //
BETZtechnik 11:ce51026d8702 662 tft.setCursor(52, 65);
BETZtechnik 11:ce51026d8702 663 tft.setTextColor(BLACK);
BETZtechnik 11:ce51026d8702 664 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 665 if (lastSync == 0) {
BETZtechnik 11:ce51026d8702 666 tft.printf("OFF");
BETZtechnik 11:ce51026d8702 667 }
BETZtechnik 11:ce51026d8702 668 if (lastSync == 1) {
BETZtechnik 11:ce51026d8702 669 tft.printf("ON");
BETZtechnik 11:ce51026d8702 670 }
BETZtechnik 11:ce51026d8702 671
BETZtechnik 11:ce51026d8702 672 tft.setCursor(52, 65);
BETZtechnik 11:ce51026d8702 673 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 674 if (sync == 0) {
BETZtechnik 11:ce51026d8702 675 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 676 tft.printf("OFF");
BETZtechnik 11:ce51026d8702 677 }
BETZtechnik 11:ce51026d8702 678 if (sync == 1) {
BETZtechnik 11:ce51026d8702 679 tft.setTextColor(GREEN);
BETZtechnik 11:ce51026d8702 680 tft.printf("ON");
BETZtechnik 11:ce51026d8702 681 }
BETZtechnik 11:ce51026d8702 682
BETZtechnik 11:ce51026d8702 683
BETZtechnik 11:ce51026d8702 684 eeprom.write(syncAddress, sync); // store new twitch setting
BETZtechnik 11:ce51026d8702 685 syncSpread = (n2Pos - n1Pos);
BETZtechnik 11:ce51026d8702 686
BETZtechnik 11:ce51026d8702 687 lastSync = sync;
BETZtechnik 11:ce51026d8702 688
BETZtechnik 11:ce51026d8702 689 }
BETZtechnik 11:ce51026d8702 690
BETZtechnik 11:ce51026d8702 691 if (n1Dir != lastN1Dir) { //
BETZtechnik 11:ce51026d8702 692 tft.setCursor(132, 50);
BETZtechnik 11:ce51026d8702 693 tft.setTextColor(BLACK);
BETZtechnik 11:ce51026d8702 694 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 695 if (lastN1Dir == 0) {
BETZtechnik 11:ce51026d8702 696 tft.printf("NOR");
BETZtechnik 11:ce51026d8702 697 }
BETZtechnik 11:ce51026d8702 698 if (lastN1Dir == 1) {
BETZtechnik 11:ce51026d8702 699 tft.printf("REV");
BETZtechnik 11:ce51026d8702 700 }
BETZtechnik 11:ce51026d8702 701 tft.setCursor(132, 50);
BETZtechnik 11:ce51026d8702 702 if (n1Dir == 0) {
BETZtechnik 11:ce51026d8702 703 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 704 tft.printf("NOR");
BETZtechnik 11:ce51026d8702 705 }
BETZtechnik 11:ce51026d8702 706 if (n1Dir == 1) {
BETZtechnik 11:ce51026d8702 707 tft.setTextColor(GREEN);
BETZtechnik 11:ce51026d8702 708 tft.printf("REV");
BETZtechnik 11:ce51026d8702 709 }
BETZtechnik 11:ce51026d8702 710 eeprom.write(n1DirAddress, n1Dir); // store new twitch setting
BETZtechnik 11:ce51026d8702 711 lastN1Dir = n1Dir;
BETZtechnik 11:ce51026d8702 712
BETZtechnik 11:ce51026d8702 713 dir=1;
BETZtechnik 11:ce51026d8702 714 device.printf("D1");
BETZtechnik 11:ce51026d8702 715 device.printf("%d", n1Dir);
BETZtechnik 11:ce51026d8702 716 wait(0.05);
BETZtechnik 11:ce51026d8702 717 dir=0;
BETZtechnik 11:ce51026d8702 718
BETZtechnik 11:ce51026d8702 719 }
BETZtechnik 11:ce51026d8702 720
BETZtechnik 11:ce51026d8702 721 if (n2Dir != lastN2Dir) { //
BETZtechnik 11:ce51026d8702 722 tft.setCursor(132, 65);
BETZtechnik 11:ce51026d8702 723 tft.setTextColor(BLACK);
BETZtechnik 11:ce51026d8702 724 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 725 if (lastN2Dir == 0) {
BETZtechnik 11:ce51026d8702 726 tft.printf("NOR");
BETZtechnik 11:ce51026d8702 727 }
BETZtechnik 11:ce51026d8702 728 if (lastN2Dir == 1) {
BETZtechnik 11:ce51026d8702 729 tft.printf("REV");
BETZtechnik 11:ce51026d8702 730 }
BETZtechnik 11:ce51026d8702 731 tft.setCursor(132, 65);
BETZtechnik 11:ce51026d8702 732 if (n2Dir == 0) {
BETZtechnik 11:ce51026d8702 733 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 734 tft.printf("NOR");
BETZtechnik 11:ce51026d8702 735 }
BETZtechnik 11:ce51026d8702 736 if (n2Dir == 1) {
BETZtechnik 11:ce51026d8702 737 tft.setTextColor(GREEN);
BETZtechnik 11:ce51026d8702 738 tft.printf("REV");
BETZtechnik 11:ce51026d8702 739 }
BETZtechnik 11:ce51026d8702 740 eeprom.write(n2DirAddress, n2Dir); // store new twitch setting
BETZtechnik 11:ce51026d8702 741 lastN2Dir = n2Dir;
BETZtechnik 11:ce51026d8702 742
BETZtechnik 11:ce51026d8702 743 dir=1;
BETZtechnik 11:ce51026d8702 744 device.printf("D2");
BETZtechnik 11:ce51026d8702 745 device.printf("%d", n2Dir);
BETZtechnik 11:ce51026d8702 746 wait(0.05);
BETZtechnik 11:ce51026d8702 747 dir=0;
BETZtechnik 11:ce51026d8702 748
BETZtechnik 11:ce51026d8702 749 }
BETZtechnik 11:ce51026d8702 750
BETZtechnik 11:ce51026d8702 751 if (version != lastVersion) { //
BETZtechnik 11:ce51026d8702 752 tft.setCursor(132, 80);
BETZtechnik 11:ce51026d8702 753 tft.setTextColor(BLACK);
BETZtechnik 11:ce51026d8702 754 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 755 if (lastVersion == 0) {
BETZtechnik 11:ce51026d8702 756 tft.printf("BAS");
BETZtechnik 11:ce51026d8702 757 }
BETZtechnik 11:ce51026d8702 758 if (lastVersion == 1) {
BETZtechnik 11:ce51026d8702 759 tft.printf("PRO");
BETZtechnik 11:ce51026d8702 760 }
BETZtechnik 11:ce51026d8702 761 tft.setCursor(132, 80);
BETZtechnik 11:ce51026d8702 762 if (version == 0) {
BETZtechnik 11:ce51026d8702 763 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 764 tft.setTextSize(1);
BETZtechnik 11:ce51026d8702 765 tft.printf("BAS");
BETZtechnik 11:ce51026d8702 766 }
BETZtechnik 11:ce51026d8702 767 if (version == 1) {
BETZtechnik 11:ce51026d8702 768 tft.setTextColor(RED);
BETZtechnik 11:ce51026d8702 769 tft.printf("PRO");
BETZtechnik 11:ce51026d8702 770 }
BETZtechnik 11:ce51026d8702 771 eeprom.write(versionAddress, version); // store new twitch setting
BETZtechnik 11:ce51026d8702 772 lastVersion = version;
BETZtechnik 11:ce51026d8702 773 }
BETZtechnik 6:84ea3ec0660d 774
BETZtechnik 6:84ea3ec0660d 775 // ************* Rectangles for identifying active selection *****************************
BETZtechnik 6:84ea3ec0660d 776
BETZtechnik 11:ce51026d8702 777 if (count != lastCount) {
BETZtechnik 11:ce51026d8702 778
BETZtechnik 11:ce51026d8702 779 if (count ==0) {
BETZtechnik 11:ce51026d8702 780 Enc.Set(n1Pos);
BETZtechnik 11:ce51026d8702 781 lastN1Pos = n1Pos; ////*******************************2019-09-11 WAS FIX FOR SYNC REV RST = 90
BETZtechnik 11:ce51026d8702 782 }
BETZtechnik 11:ce51026d8702 783
BETZtechnik 11:ce51026d8702 784 else if (count == 1) {
BETZtechnik 11:ce51026d8702 785 Enc.Set(n2Pos);
BETZtechnik 11:ce51026d8702 786 }
BETZtechnik 11:ce51026d8702 787
BETZtechnik 11:ce51026d8702 788 else if (count == 2) {
BETZtechnik 11:ce51026d8702 789 Enc.Set(currentToolNo);
BETZtechnik 11:ce51026d8702 790 }
BETZtechnik 11:ce51026d8702 791
BETZtechnik 11:ce51026d8702 792 else if (count == 3) {
BETZtechnik 11:ce51026d8702 793 Enc.Set(twitch);
BETZtechnik 11:ce51026d8702 794 }
BETZtechnik 11:ce51026d8702 795
BETZtechnik 11:ce51026d8702 796 else if (count == 4) {
BETZtechnik 11:ce51026d8702 797 Enc.Set(sync);
BETZtechnik 11:ce51026d8702 798 }
BETZtechnik 11:ce51026d8702 799
BETZtechnik 11:ce51026d8702 800 else if (count == 8) {
BETZtechnik 11:ce51026d8702 801 Enc.Set(n1Dir);
BETZtechnik 11:ce51026d8702 802 }
BETZtechnik 11:ce51026d8702 803
BETZtechnik 11:ce51026d8702 804 else if (count == 9) {
BETZtechnik 11:ce51026d8702 805 Enc.Set(n2Dir);
BETZtechnik 11:ce51026d8702 806 }
BETZtechnik 11:ce51026d8702 807
BETZtechnik 11:ce51026d8702 808 else if (count == 10) {
BETZtechnik 11:ce51026d8702 809 Enc.Set(version);
BETZtechnik 11:ce51026d8702 810 }
BETZtechnik 6:84ea3ec0660d 811
BETZtechnik 11:ce51026d8702 812 else if (count == 11) {
BETZtechnik 11:ce51026d8702 813 Enc.Set(numTools);
BETZtechnik 11:ce51026d8702 814 }
BETZtechnik 11:ce51026d8702 815
BETZtechnik 11:ce51026d8702 816 else if (count == 12) {
BETZtechnik 11:ce51026d8702 817 Enc.Set(numNoz);
BETZtechnik 11:ce51026d8702 818 }
BETZtechnik 11:ce51026d8702 819
BETZtechnik 11:ce51026d8702 820
BETZtechnik 11:ce51026d8702 821
BETZtechnik 11:ce51026d8702 822 // clear old boxes (white or black)
BETZtechnik 11:ce51026d8702 823 if (lastCount == 0) {
BETZtechnik 11:ce51026d8702 824 tft.drawRect(2,2,74,18,WHITE);
BETZtechnik 11:ce51026d8702 825 }
BETZtechnik 11:ce51026d8702 826
BETZtechnik 11:ce51026d8702 827 else if ((lastCount == 1) && (numNoz == 2)) {
BETZtechnik 11:ce51026d8702 828 tft.drawRect(78,2,74,18,WHITE);
BETZtechnik 11:ce51026d8702 829 }
BETZtechnik 11:ce51026d8702 830
BETZtechnik 11:ce51026d8702 831 else if (lastCount == 2) {
BETZtechnik 11:ce51026d8702 832 tft.drawRect(20,26,28,18,BLACK);
BETZtechnik 11:ce51026d8702 833 }
BETZtechnik 11:ce51026d8702 834
BETZtechnik 11:ce51026d8702 835 else if (lastCount == 3) {
BETZtechnik 11:ce51026d8702 836 tft.drawRect(50,48,20,12,BLACK);
BETZtechnik 11:ce51026d8702 837 }
BETZtechnik 11:ce51026d8702 838
BETZtechnik 11:ce51026d8702 839 else if (lastCount == 4) {
BETZtechnik 11:ce51026d8702 840 tft.drawRect(50,63,20,12,BLACK);
BETZtechnik 11:ce51026d8702 841 }
BETZtechnik 11:ce51026d8702 842
BETZtechnik 11:ce51026d8702 843 else if (lastCount == 5) {
BETZtechnik 11:ce51026d8702 844 tft.drawRect(50,78,20,12,BLACK);
BETZtechnik 11:ce51026d8702 845 }
BETZtechnik 11:ce51026d8702 846
BETZtechnik 11:ce51026d8702 847 else if (lastCount == 6) {
BETZtechnik 11:ce51026d8702 848 tft.drawRect(50,93,20,12,BLACK);
BETZtechnik 11:ce51026d8702 849 }
BETZtechnik 6:84ea3ec0660d 850
BETZtechnik 11:ce51026d8702 851 else if (lastCount == 7) {
BETZtechnik 11:ce51026d8702 852 tft.drawRect(50,108,20,12,BLACK);
BETZtechnik 11:ce51026d8702 853 }
BETZtechnik 11:ce51026d8702 854
BETZtechnik 11:ce51026d8702 855 else if (lastCount == 8) {
BETZtechnik 11:ce51026d8702 856 tft.drawRect(130,48,20,12,BLACK);
BETZtechnik 11:ce51026d8702 857 }
BETZtechnik 11:ce51026d8702 858
BETZtechnik 11:ce51026d8702 859 else if (lastCount == 9) {
BETZtechnik 11:ce51026d8702 860 tft.drawRect(130,63,20,12,BLACK);
BETZtechnik 11:ce51026d8702 861 }
BETZtechnik 11:ce51026d8702 862
BETZtechnik 11:ce51026d8702 863 else if (lastCount == 10) {
BETZtechnik 11:ce51026d8702 864 tft.drawRect(130,78,20,12,BLACK);
BETZtechnik 11:ce51026d8702 865 }
BETZtechnik 6:84ea3ec0660d 866
BETZtechnik 11:ce51026d8702 867 else if (lastCount == 11) {
BETZtechnik 11:ce51026d8702 868 tft.drawRect(130,93,20,12,BLACK);
BETZtechnik 11:ce51026d8702 869 }
BETZtechnik 11:ce51026d8702 870
BETZtechnik 11:ce51026d8702 871 else if (lastCount == 12) {
BETZtechnik 11:ce51026d8702 872 tft.drawRect(130,108,20,12,BLACK);
BETZtechnik 11:ce51026d8702 873 }
BETZtechnik 11:ce51026d8702 874
BETZtechnik 11:ce51026d8702 875 // Set new box
BETZtechnik 6:84ea3ec0660d 876
BETZtechnik 11:ce51026d8702 877 if (count == 0) { // N1 adjust
BETZtechnik 11:ce51026d8702 878 tft.drawRect(2,2,74,18,GREEN);
BETZtechnik 11:ce51026d8702 879 }
BETZtechnik 11:ce51026d8702 880
BETZtechnik 11:ce51026d8702 881 else if ((count == 1) && (numNoz == 2)) { // N2 adjust
BETZtechnik 11:ce51026d8702 882 tft.drawRect(78,2,74,18,GREEN);
BETZtechnik 11:ce51026d8702 883 }
BETZtechnik 11:ce51026d8702 884
BETZtechnik 11:ce51026d8702 885 else if (count == 2) {
BETZtechnik 11:ce51026d8702 886 tft.drawRect(20,26,28,18,GREEN);
BETZtechnik 11:ce51026d8702 887 }
BETZtechnik 6:84ea3ec0660d 888
BETZtechnik 11:ce51026d8702 889 else if (count == 3) {
BETZtechnik 11:ce51026d8702 890 tft.drawRect(50,48,20,12,GREEN);
BETZtechnik 11:ce51026d8702 891 }
BETZtechnik 6:84ea3ec0660d 892
BETZtechnik 11:ce51026d8702 893 else if (count == 4) {
BETZtechnik 11:ce51026d8702 894 tft.drawRect(50,63,20,12,GREEN);
BETZtechnik 11:ce51026d8702 895 }
BETZtechnik 6:84ea3ec0660d 896
BETZtechnik 11:ce51026d8702 897 else if (count == 5) {
BETZtechnik 11:ce51026d8702 898 tft.drawRect(50,78,20,12,GREEN);
BETZtechnik 11:ce51026d8702 899 }
BETZtechnik 6:84ea3ec0660d 900
BETZtechnik 11:ce51026d8702 901 else if (count == 6) {
BETZtechnik 11:ce51026d8702 902 tft.drawRect(50,93,20,12,GREEN);
BETZtechnik 11:ce51026d8702 903 }
BETZtechnik 6:84ea3ec0660d 904
BETZtechnik 11:ce51026d8702 905 else if (count == 7) {
BETZtechnik 11:ce51026d8702 906 tft.drawRect(50,108,20,12,GREEN);
BETZtechnik 11:ce51026d8702 907 }
BETZtechnik 6:84ea3ec0660d 908
BETZtechnik 11:ce51026d8702 909 else if (count == 8) {
BETZtechnik 11:ce51026d8702 910 tft.drawRect(130,48,20,12,GREEN);
BETZtechnik 11:ce51026d8702 911 }
BETZtechnik 6:84ea3ec0660d 912
BETZtechnik 11:ce51026d8702 913 else if (count == 9) {
BETZtechnik 11:ce51026d8702 914 tft.drawRect(130,63,20,12,GREEN);
BETZtechnik 11:ce51026d8702 915 }
BETZtechnik 6:84ea3ec0660d 916
BETZtechnik 11:ce51026d8702 917 else if (count == 10) {
BETZtechnik 11:ce51026d8702 918 tft.drawRect(130,78,20,12,GREEN);
BETZtechnik 11:ce51026d8702 919 }
BETZtechnik 6:84ea3ec0660d 920
BETZtechnik 11:ce51026d8702 921 else if (count == 11) {
BETZtechnik 11:ce51026d8702 922 tft.drawRect(130,93,20,12,GREEN);
BETZtechnik 11:ce51026d8702 923 }
BETZtechnik 6:84ea3ec0660d 924
BETZtechnik 11:ce51026d8702 925 else if (count == 12) {
BETZtechnik 11:ce51026d8702 926 tft.drawRect(130,108,20,12,GREEN);
BETZtechnik 11:ce51026d8702 927 }
BETZtechnik 6:84ea3ec0660d 928
BETZtechnik 11:ce51026d8702 929 lastCount = count;
BETZtechnik 11:ce51026d8702 930 }
BETZtechnik 6:84ea3ec0660d 931
BETZtechnik 6:84ea3ec0660d 932
BETZtechnik 6:84ea3ec0660d 933
BETZtechnik 6:84ea3ec0660d 934
BETZtechnik 11:ce51026d8702 935
BETZtechnik 11:ce51026d8702 936 //****************** ENCODER ACTIONS ************************************************
BETZtechnik 11:ce51026d8702 937 if (count == 0) { // knob controls servo value
BETZtechnik 11:ce51026d8702 938
BETZtechnik 11:ce51026d8702 939 if (n1Pos != Enc.Get()) {
BETZtechnik 11:ce51026d8702 940 //n1Pos = Enc.Get(); 2019-09-12
BETZtechnik 11:ce51026d8702 941 if (sync == 0 && n1Dir ==0) { // n1 fwd
BETZtechnik 11:ce51026d8702 942 n1Pos = Enc.Get();
BETZtechnik 11:ce51026d8702 943 }
BETZtechnik 11:ce51026d8702 944
BETZtechnik 11:ce51026d8702 945 if (sync == 0 && n1Dir ==1) { // n1 rev
BETZtechnik 11:ce51026d8702 946 n1Pos = n1Pos + (n1Pos - Enc.Get());
BETZtechnik 11:ce51026d8702 947 Enc.Set(n1Pos);
BETZtechnik 11:ce51026d8702 948 }
BETZtechnik 11:ce51026d8702 949
BETZtechnik 11:ce51026d8702 950
BETZtechnik 11:ce51026d8702 951 if (n1Pos > 90) {
BETZtechnik 11:ce51026d8702 952 n1Pos = 90;
BETZtechnik 11:ce51026d8702 953 Enc.Set(90);
BETZtechnik 11:ce51026d8702 954 }
BETZtechnik 11:ce51026d8702 955
BETZtechnik 11:ce51026d8702 956 if (n1Pos < -90) {
BETZtechnik 11:ce51026d8702 957 n1Pos = -90;
BETZtechnik 11:ce51026d8702 958 Enc.Set(-90);
BETZtechnik 11:ce51026d8702 959 }
BETZtechnik 11:ce51026d8702 960
BETZtechnik 11:ce51026d8702 961 //***
BETZtechnik 11:ce51026d8702 962
BETZtechnik 11:ce51026d8702 963 if (sync == 1 && n1Dir == 0 && n2Dir == 0) { // PASS 2019-09-12
BETZtechnik 11:ce51026d8702 964 encoderMove = (Enc.Get() - n1Pos); // save direction change, positive or negative
BETZtechnik 11:ce51026d8702 965 if (encoderMove > 0 && n1Pos < 90 && n2Pos <90) { // Move is positive // stop both nozzles once ONE reaches limit.
BETZtechnik 11:ce51026d8702 966 n1Pos = Enc.Get();
BETZtechnik 11:ce51026d8702 967 n2Pos = n2Pos + encoderMove;
BETZtechnik 11:ce51026d8702 968 encoderMove =0;
BETZtechnik 11:ce51026d8702 969 //Enc.Set(n1Pos);
BETZtechnik 11:ce51026d8702 970 }
BETZtechnik 11:ce51026d8702 971
BETZtechnik 11:ce51026d8702 972 if (encoderMove < 0 && n1Pos > -90 && n2Pos >-90) { // Move is positive // stop both nozzles once ONE reaches limit.
BETZtechnik 11:ce51026d8702 973 n1Pos = Enc.Get();
BETZtechnik 11:ce51026d8702 974 n2Pos = n2Pos + encoderMove;
BETZtechnik 11:ce51026d8702 975 encoderMove =0;
BETZtechnik 11:ce51026d8702 976 // Enc.Set(n1Pos);
BETZtechnik 11:ce51026d8702 977 }
BETZtechnik 11:ce51026d8702 978 Enc.Set(n1Pos); // reset encoder so it doesnt store counts past +90/ -90
BETZtechnik 11:ce51026d8702 979
BETZtechnik 11:ce51026d8702 980 }
BETZtechnik 11:ce51026d8702 981
BETZtechnik 11:ce51026d8702 982 if (sync == 1 && n1Dir == 1 && n2Dir == 0) {
BETZtechnik 11:ce51026d8702 983 encoderMove = ( n1Pos - Enc.Get()); // save direction change, positive or negative
BETZtechnik 11:ce51026d8702 984 if (encoderMove > 0 && n1Pos > -90 && n2Pos <90) { // Move is positive // stop both nozzles once ONE reaches limit.
BETZtechnik 11:ce51026d8702 985 n1Pos = (n1Pos + encoderMove);
BETZtechnik 11:ce51026d8702 986 Enc.Set(n1Pos);
BETZtechnik 11:ce51026d8702 987 n2Pos = (n2Pos - encoderMove);
BETZtechnik 11:ce51026d8702 988 encoderMove=0;
BETZtechnik 11:ce51026d8702 989 }
BETZtechnik 6:84ea3ec0660d 990
BETZtechnik 11:ce51026d8702 991 if (encoderMove < 0 && n1Pos < 90 && n2Pos > -90) { // Move is positive // stop both nozzles once ONE reaches limit.
BETZtechnik 11:ce51026d8702 992 n1Pos = (n1Pos + encoderMove);
BETZtechnik 11:ce51026d8702 993 Enc.Set(n1Pos);
BETZtechnik 11:ce51026d8702 994 n2Pos = (n2Pos - encoderMove);
BETZtechnik 11:ce51026d8702 995 encoderMove=0;
BETZtechnik 11:ce51026d8702 996 }
BETZtechnik 11:ce51026d8702 997 Enc.Set(n1Pos); // reset encoder so it doesnt store counts past +90/ -90
BETZtechnik 11:ce51026d8702 998
BETZtechnik 11:ce51026d8702 999 }
BETZtechnik 11:ce51026d8702 1000
BETZtechnik 11:ce51026d8702 1001
BETZtechnik 11:ce51026d8702 1002 if (sync == 1 && n1Dir == 0 && n2Dir == 1) {
BETZtechnik 11:ce51026d8702 1003 encoderMove = (Enc.Get() - n1Pos); // save direction change, positive or negative
BETZtechnik 11:ce51026d8702 1004 if (encoderMove < 0 && n1Pos > -90 && n2Pos <90) { // Move is positive // stop both nozzles once ONE reaches limit.
BETZtechnik 11:ce51026d8702 1005 n1Pos = (n1Pos + encoderMove);
BETZtechnik 11:ce51026d8702 1006 Enc.Set(n1Pos);
BETZtechnik 11:ce51026d8702 1007 n2Pos = (n2Pos - encoderMove);
BETZtechnik 11:ce51026d8702 1008 encoderMove=0;
BETZtechnik 11:ce51026d8702 1009 }
BETZtechnik 11:ce51026d8702 1010
BETZtechnik 11:ce51026d8702 1011 if (encoderMove > 0 && n1Pos < 90 && n2Pos > -90) { // Move is positive // stop both nozzles once ONE reaches limit.
BETZtechnik 11:ce51026d8702 1012 n1Pos = (n1Pos + encoderMove);
BETZtechnik 11:ce51026d8702 1013 Enc.Set(n1Pos);
BETZtechnik 11:ce51026d8702 1014 n2Pos = (n2Pos - encoderMove);
BETZtechnik 11:ce51026d8702 1015 encoderMove=0;
BETZtechnik 11:ce51026d8702 1016 }
BETZtechnik 11:ce51026d8702 1017 Enc.Set(n1Pos); // reset encoder so it doesnt store counts past +90/ -90
BETZtechnik 11:ce51026d8702 1018 }
BETZtechnik 11:ce51026d8702 1019
BETZtechnik 11:ce51026d8702 1020
BETZtechnik 1:e8452b75301e 1021
BETZtechnik 11:ce51026d8702 1022 if (sync == 1 && n1Dir == 1 && n2Dir == 1) {
BETZtechnik 11:ce51026d8702 1023 encoderMove = (Enc.Get() - n1Pos); // save direction change, positive or negative
BETZtechnik 11:ce51026d8702 1024 if (encoderMove > 0 && n1Pos > -90 && n2Pos >-90) { // Move is positive // stop both nozzles once ONE reaches limit.
BETZtechnik 11:ce51026d8702 1025 n1Pos = (n1Pos - encoderMove);
BETZtechnik 11:ce51026d8702 1026 Enc.Set(n1Pos);
BETZtechnik 11:ce51026d8702 1027 n2Pos = (n2Pos - encoderMove);
BETZtechnik 11:ce51026d8702 1028 encoderMove=0;
BETZtechnik 11:ce51026d8702 1029 }
BETZtechnik 1:e8452b75301e 1030
BETZtechnik 11:ce51026d8702 1031 if (encoderMove < 0 && n1Pos < 90 && n2Pos < 90) { // Move is positive // stop both nozzles once ONE reaches limit.
BETZtechnik 11:ce51026d8702 1032 n1Pos = (n1Pos - encoderMove);
BETZtechnik 11:ce51026d8702 1033 Enc.Set(n1Pos);
BETZtechnik 11:ce51026d8702 1034 n2Pos = (n2Pos - encoderMove);
BETZtechnik 11:ce51026d8702 1035 encoderMove=0;
BETZtechnik 11:ce51026d8702 1036 }
BETZtechnik 11:ce51026d8702 1037 Enc.Set(n1Pos); // reset encoder so it doesnt store counts past +90/ -90
BETZtechnik 11:ce51026d8702 1038 }
BETZtechnik 11:ce51026d8702 1039
BETZtechnik 6:84ea3ec0660d 1040 }
BETZtechnik 11:ce51026d8702 1041 if (n1Pos > 90) {
BETZtechnik 11:ce51026d8702 1042 n1Pos =90;
BETZtechnik 11:ce51026d8702 1043 }
BETZtechnik 11:ce51026d8702 1044 if (n1Pos < -90) {
BETZtechnik 11:ce51026d8702 1045 n1Pos = -90;
BETZtechnik 6:84ea3ec0660d 1046 }
BETZtechnik 11:ce51026d8702 1047 if (n2Pos > 90) {
BETZtechnik 11:ce51026d8702 1048 n2Pos =90;
BETZtechnik 6:84ea3ec0660d 1049 }
BETZtechnik 11:ce51026d8702 1050 if (n2Pos < -90) {
BETZtechnik 11:ce51026d8702 1051 n2Pos = -90;
BETZtechnik 11:ce51026d8702 1052 }
BETZtechnik 11:ce51026d8702 1053 }
BETZtechnik 1:e8452b75301e 1054
BETZtechnik 0:09419d572e90 1055
BETZtechnik 11:ce51026d8702 1056 //***************************
BETZtechnik 11:ce51026d8702 1057 if (count == 1) { // knob controls servo value
BETZtechnik 11:ce51026d8702 1058
BETZtechnik 11:ce51026d8702 1059 if (n2Pos != Enc.Get()) {
BETZtechnik 11:ce51026d8702 1060 encoderMove = (Enc.Get() - n2Pos); // save direction change, positive or negative
BETZtechnik 11:ce51026d8702 1061
BETZtechnik 11:ce51026d8702 1062 if (n2Dir == 0 && encoderMove >0 && n2Pos < 90){ // normal direction
BETZtechnik 11:ce51026d8702 1063 n2Pos = n2Pos + encoderMove;
BETZtechnik 11:ce51026d8702 1064 encoderMove=0;
BETZtechnik 11:ce51026d8702 1065 }
BETZtechnik 11:ce51026d8702 1066 if (n2Dir == 0 && encoderMove <0 && n2Pos > -90){ // normal direction
BETZtechnik 11:ce51026d8702 1067 n2Pos = n2Pos + encoderMove;
BETZtechnik 11:ce51026d8702 1068 encoderMove=0;
BETZtechnik 11:ce51026d8702 1069 }
BETZtechnik 1:e8452b75301e 1070
BETZtechnik 11:ce51026d8702 1071 if (n2Dir == 1 && encoderMove <0 && n2Pos < 90){ // reverse direction
BETZtechnik 11:ce51026d8702 1072 n2Pos = n2Pos - encoderMove;
BETZtechnik 11:ce51026d8702 1073 encoderMove=0;
BETZtechnik 11:ce51026d8702 1074 }
BETZtechnik 11:ce51026d8702 1075 if (n2Dir == 1 && encoderMove >0 && n2Pos > -90){ // reverse direction
BETZtechnik 11:ce51026d8702 1076 n2Pos = n2Pos - encoderMove;
BETZtechnik 11:ce51026d8702 1077 encoderMove=0;
BETZtechnik 11:ce51026d8702 1078 }
BETZtechnik 11:ce51026d8702 1079 Enc.Set(n2Pos); // reset encoder so it doesnt store counts past +90/ -90
BETZtechnik 11:ce51026d8702 1080 if (n2Pos > 90){
BETZtechnik 11:ce51026d8702 1081 n2Pos = 90;
BETZtechnik 11:ce51026d8702 1082 }
BETZtechnik 11:ce51026d8702 1083 if (n2Pos < -90){
BETZtechnik 11:ce51026d8702 1084 n2Pos = -90;
BETZtechnik 11:ce51026d8702 1085 }
BETZtechnik 10:dd8d89133b28 1086 }
BETZtechnik 10:dd8d89133b28 1087
BETZtechnik 11:ce51026d8702 1088 }
BETZtechnik 11:ce51026d8702 1089 //****************************
BETZtechnik 11:ce51026d8702 1090 if (count == 2) { //knob controls tool number
BETZtechnik 11:ce51026d8702 1091
BETZtechnik 11:ce51026d8702 1092 currentToolNo = Enc.Get();
BETZtechnik 11:ce51026d8702 1093 if (currentToolNo > numTools) {
BETZtechnik 11:ce51026d8702 1094 currentToolNo = numTools;
BETZtechnik 11:ce51026d8702 1095 }
BETZtechnik 11:ce51026d8702 1096 if (currentToolNo < 1) {
BETZtechnik 11:ce51026d8702 1097 currentToolNo = 1;
BETZtechnik 11:ce51026d8702 1098 Enc.Set(1);
BETZtechnik 11:ce51026d8702 1099 }
BETZtechnik 11:ce51026d8702 1100 }
BETZtechnik 11:ce51026d8702 1101 //****************************
BETZtechnik 11:ce51026d8702 1102 if (count == 3) { // Knob controls twitch setting
BETZtechnik 11:ce51026d8702 1103 twitch = Enc.Get();
BETZtechnik 11:ce51026d8702 1104 if (twitch < 0) {
BETZtechnik 11:ce51026d8702 1105 twitch = 0;
BETZtechnik 11:ce51026d8702 1106 Enc.Set(0);
BETZtechnik 11:ce51026d8702 1107 }
BETZtechnik 11:ce51026d8702 1108 if (twitch > 3) {
BETZtechnik 11:ce51026d8702 1109 twitch = 3;
BETZtechnik 11:ce51026d8702 1110 Enc.Set(3);
BETZtechnik 11:ce51026d8702 1111 }
BETZtechnik 0:09419d572e90 1112 }
BETZtechnik 11:ce51026d8702 1113 //****************************
BETZtechnik 11:ce51026d8702 1114 if (count == 4) { // Knob controls sync setting. 1=off, 2=sync, 3=rev
BETZtechnik 11:ce51026d8702 1115 sync = Enc.Get();
BETZtechnik 11:ce51026d8702 1116 if (sync < 0) {
BETZtechnik 11:ce51026d8702 1117 sync= 0;
BETZtechnik 11:ce51026d8702 1118 Enc.Set(0);
BETZtechnik 11:ce51026d8702 1119 }
BETZtechnik 11:ce51026d8702 1120 if (sync > 1) {
BETZtechnik 11:ce51026d8702 1121 sync = 1;
BETZtechnik 11:ce51026d8702 1122 Enc.Set(1);
BETZtechnik 11:ce51026d8702 1123 }
BETZtechnik 11:ce51026d8702 1124 }
BETZtechnik 11:ce51026d8702 1125 //****************************
BETZtechnik 11:ce51026d8702 1126 // 5,6,7 AUX?
BETZtechnik 11:ce51026d8702 1127 if (count == 8) { // knob controls the direction of rotation for N1
BETZtechnik 11:ce51026d8702 1128 n1Dir = Enc.Get();
BETZtechnik 0:09419d572e90 1129
BETZtechnik 11:ce51026d8702 1130 if (n1Dir > 1) {
BETZtechnik 11:ce51026d8702 1131 n1Dir = 1;
BETZtechnik 11:ce51026d8702 1132 Enc.Set(1);
BETZtechnik 11:ce51026d8702 1133 }
BETZtechnik 11:ce51026d8702 1134
BETZtechnik 11:ce51026d8702 1135 if (n1Dir < 0) {
BETZtechnik 11:ce51026d8702 1136 n1Dir =0;
BETZtechnik 11:ce51026d8702 1137 Enc.Set(0);
BETZtechnik 11:ce51026d8702 1138 }
BETZtechnik 1:e8452b75301e 1139 }
BETZtechnik 11:ce51026d8702 1140 //****************************
BETZtechnik 11:ce51026d8702 1141 if (count == 9) { // knob controls the direction of rotation for N2
BETZtechnik 11:ce51026d8702 1142 n2Dir = Enc.Get();
BETZtechnik 11:ce51026d8702 1143
BETZtechnik 11:ce51026d8702 1144 if (n2Dir > 1) {
BETZtechnik 11:ce51026d8702 1145 n2Dir = 1;
BETZtechnik 11:ce51026d8702 1146 Enc.Set(1);
BETZtechnik 11:ce51026d8702 1147 }
BETZtechnik 0:09419d572e90 1148
BETZtechnik 11:ce51026d8702 1149 if (n2Dir < 0) {
BETZtechnik 11:ce51026d8702 1150 n2Dir =0;
BETZtechnik 11:ce51026d8702 1151 Enc.Set(0);
BETZtechnik 11:ce51026d8702 1152 }
BETZtechnik 6:84ea3ec0660d 1153 }
BETZtechnik 11:ce51026d8702 1154 //****************************
BETZtechnik 11:ce51026d8702 1155 if (count == 10) { // knob controls the version
BETZtechnik 11:ce51026d8702 1156 version = Enc.Get();
BETZtechnik 11:ce51026d8702 1157
BETZtechnik 11:ce51026d8702 1158 if (version > 1) {
BETZtechnik 11:ce51026d8702 1159 version = 1;
BETZtechnik 11:ce51026d8702 1160 Enc.Set(1);
BETZtechnik 11:ce51026d8702 1161 }
BETZtechnik 1:e8452b75301e 1162
BETZtechnik 11:ce51026d8702 1163 if (version < 0) {
BETZtechnik 11:ce51026d8702 1164 version =0;
BETZtechnik 11:ce51026d8702 1165 Enc.Set(0);
BETZtechnik 11:ce51026d8702 1166 }
BETZtechnik 6:84ea3ec0660d 1167 }
BETZtechnik 11:ce51026d8702 1168 //****************************
BETZtechnik 11:ce51026d8702 1169 if (count == 11) { //knob controls tool number
BETZtechnik 11:ce51026d8702 1170 numTools = Enc.Get();
BETZtechnik 11:ce51026d8702 1171 if (numTools > 50) {
BETZtechnik 11:ce51026d8702 1172 numTools = 50;
BETZtechnik 11:ce51026d8702 1173 Enc.Set(50);
BETZtechnik 11:ce51026d8702 1174 }
BETZtechnik 11:ce51026d8702 1175 if (numTools < 1) {
BETZtechnik 11:ce51026d8702 1176 numTools = 1;
BETZtechnik 11:ce51026d8702 1177 Enc.Set(1);
BETZtechnik 11:ce51026d8702 1178 }
BETZtechnik 6:84ea3ec0660d 1179 }
BETZtechnik 11:ce51026d8702 1180 //****************************
BETZtechnik 11:ce51026d8702 1181 if (count == 12) { //knob controls tool number
BETZtechnik 11:ce51026d8702 1182 numNoz = Enc.Get();
BETZtechnik 11:ce51026d8702 1183 if (numNoz> 2) {
BETZtechnik 11:ce51026d8702 1184 numNoz = 2;
BETZtechnik 11:ce51026d8702 1185 Enc.Set(2);
BETZtechnik 11:ce51026d8702 1186 }
BETZtechnik 11:ce51026d8702 1187 if (numNoz < 1) {
BETZtechnik 11:ce51026d8702 1188 numNoz = 1;
BETZtechnik 11:ce51026d8702 1189 Enc.Set(1);
BETZtechnik 11:ce51026d8702 1190 }
BETZtechnik 6:84ea3ec0660d 1191 }
BETZtechnik 6:84ea3ec0660d 1192
BETZtechnik 6:84ea3ec0660d 1193
BETZtechnik 1:e8452b75301e 1194
BETZtechnik 1:e8452b75301e 1195 //**************************** RS485 link ***************************************
BETZtechnik 4:d3c19705042b 1196
BETZtechnik 11:ce51026d8702 1197 while (device.readable()) {
BETZtechnik 11:ce51026d8702 1198 c = device.getc();
BETZtechnik 11:ce51026d8702 1199
BETZtechnik 11:ce51026d8702 1200 if (c == 'T') { // Actual tool number sent over serial
BETZtechnik 11:ce51026d8702 1201
BETZtechnik 11:ce51026d8702 1202 index = 1;
BETZtechnik 11:ce51026d8702 1203
BETZtechnik 11:ce51026d8702 1204 }
BETZtechnik 11:ce51026d8702 1205
BETZtechnik 11:ce51026d8702 1206
BETZtechnik 11:ce51026d8702 1207 if (c == 'M') { // magazine + or - sent over serial
BETZtechnik 11:ce51026d8702 1208 index = 5;
BETZtechnik 11:ce51026d8702 1209 }
BETZtechnik 2:bbbacfd62773 1210
BETZtechnik 11:ce51026d8702 1211 if (index == 1) {
BETZtechnik 11:ce51026d8702 1212 c = device.getc();
BETZtechnik 11:ce51026d8702 1213 if (c == '1') { // hundreds place to know we are sending 3 digits
BETZtechnik 11:ce51026d8702 1214 index = 2;
BETZtechnik 11:ce51026d8702 1215 }
BETZtechnik 11:ce51026d8702 1216 }
BETZtechnik 11:ce51026d8702 1217
BETZtechnik 11:ce51026d8702 1218
BETZtechnik 11:ce51026d8702 1219
BETZtechnik 11:ce51026d8702 1220 if (index == 2) { // tool number 10's column
BETZtechnik 11:ce51026d8702 1221
BETZtechnik 11:ce51026d8702 1222 c = device.getc();
BETZtechnik 11:ce51026d8702 1223
BETZtechnik 11:ce51026d8702 1224 if (c=='0') {
BETZtechnik 11:ce51026d8702 1225 Tens = 0;
BETZtechnik 11:ce51026d8702 1226 index = 4;
BETZtechnik 11:ce51026d8702 1227
BETZtechnik 11:ce51026d8702 1228 }
BETZtechnik 11:ce51026d8702 1229
BETZtechnik 11:ce51026d8702 1230 else if (c=='1') {
BETZtechnik 11:ce51026d8702 1231 Tens = 1;
BETZtechnik 2:bbbacfd62773 1232 index = 4;
BETZtechnik 11:ce51026d8702 1233
BETZtechnik 11:ce51026d8702 1234 }
BETZtechnik 11:ce51026d8702 1235
BETZtechnik 11:ce51026d8702 1236 else if (c=='2') {
BETZtechnik 11:ce51026d8702 1237 Tens = 2;
BETZtechnik 11:ce51026d8702 1238 index = 4;
BETZtechnik 11:ce51026d8702 1239
BETZtechnik 11:ce51026d8702 1240 }
BETZtechnik 11:ce51026d8702 1241
BETZtechnik 11:ce51026d8702 1242 else if (c=='3') {
BETZtechnik 11:ce51026d8702 1243 Tens = 3;
BETZtechnik 11:ce51026d8702 1244 index = 4;
BETZtechnik 11:ce51026d8702 1245
BETZtechnik 11:ce51026d8702 1246 }
BETZtechnik 11:ce51026d8702 1247
BETZtechnik 11:ce51026d8702 1248 else if (c=='4') {
BETZtechnik 11:ce51026d8702 1249 Tens = 4;
BETZtechnik 11:ce51026d8702 1250 index = 4;
BETZtechnik 2:bbbacfd62773 1251 }
BETZtechnik 11:ce51026d8702 1252
BETZtechnik 11:ce51026d8702 1253 else if (c=='5') { //max number of tools is 50
BETZtechnik 11:ce51026d8702 1254 Tens = 5;
BETZtechnik 11:ce51026d8702 1255 index = 4;
BETZtechnik 11:ce51026d8702 1256 }
BETZtechnik 11:ce51026d8702 1257
BETZtechnik 11:ce51026d8702 1258 }
BETZtechnik 11:ce51026d8702 1259
BETZtechnik 11:ce51026d8702 1260 if (index == 4) { // tool number ones column
BETZtechnik 2:bbbacfd62773 1261
BETZtechnik 11:ce51026d8702 1262 c = device.getc();
BETZtechnik 11:ce51026d8702 1263
BETZtechnik 11:ce51026d8702 1264 if (c=='0') {
BETZtechnik 11:ce51026d8702 1265 Ones = 0;
BETZtechnik 2:bbbacfd62773 1266
BETZtechnik 11:ce51026d8702 1267 }
BETZtechnik 11:ce51026d8702 1268
BETZtechnik 11:ce51026d8702 1269 else if (c=='1') {
BETZtechnik 11:ce51026d8702 1270 Ones = 1;
BETZtechnik 2:bbbacfd62773 1271
BETZtechnik 2:bbbacfd62773 1272
BETZtechnik 11:ce51026d8702 1273 }
BETZtechnik 11:ce51026d8702 1274
BETZtechnik 11:ce51026d8702 1275 else if (c=='2') {
BETZtechnik 11:ce51026d8702 1276 Ones = 2;
BETZtechnik 11:ce51026d8702 1277
BETZtechnik 11:ce51026d8702 1278 }
BETZtechnik 11:ce51026d8702 1279
BETZtechnik 11:ce51026d8702 1280 else if (c=='3') {
BETZtechnik 11:ce51026d8702 1281 Ones = 3;
BETZtechnik 11:ce51026d8702 1282
BETZtechnik 11:ce51026d8702 1283 }
BETZtechnik 11:ce51026d8702 1284
BETZtechnik 11:ce51026d8702 1285 else if (c=='4') {
BETZtechnik 11:ce51026d8702 1286 Ones = 4;
BETZtechnik 11:ce51026d8702 1287 }
BETZtechnik 11:ce51026d8702 1288
BETZtechnik 11:ce51026d8702 1289 else if (c=='5') {
BETZtechnik 11:ce51026d8702 1290 Ones = 5;
BETZtechnik 11:ce51026d8702 1291 }
BETZtechnik 11:ce51026d8702 1292
BETZtechnik 11:ce51026d8702 1293 else if (c=='6') {
BETZtechnik 11:ce51026d8702 1294 Ones = 6;
BETZtechnik 11:ce51026d8702 1295 }
BETZtechnik 11:ce51026d8702 1296
BETZtechnik 11:ce51026d8702 1297 else if (c=='7') {
BETZtechnik 11:ce51026d8702 1298 Ones = 7;
BETZtechnik 11:ce51026d8702 1299 }
BETZtechnik 11:ce51026d8702 1300
BETZtechnik 11:ce51026d8702 1301 else if (c=='8') {
BETZtechnik 11:ce51026d8702 1302 Ones = 8;
BETZtechnik 11:ce51026d8702 1303 }
BETZtechnik 11:ce51026d8702 1304
BETZtechnik 11:ce51026d8702 1305 else if (c=='9') {
BETZtechnik 11:ce51026d8702 1306 Ones = 9;
BETZtechnik 11:ce51026d8702 1307 }
BETZtechnik 11:ce51026d8702 1308
BETZtechnik 11:ce51026d8702 1309 else if (c=='0') {
BETZtechnik 11:ce51026d8702 1310 Ones = 0;
BETZtechnik 2:bbbacfd62773 1311 }
BETZtechnik 11:ce51026d8702 1312
BETZtechnik 11:ce51026d8702 1313
BETZtechnik 11:ce51026d8702 1314
BETZtechnik 11:ce51026d8702 1315 serialToolNumber = ((Tens * 10) + Ones);
BETZtechnik 12:1e974964272e 1316
BETZtechnik 12:1e974964272e 1317 count = 0; // 2019-09-23 to make sure the new tool isn't overwritten.
BETZtechnik 11:ce51026d8702 1318
BETZtechnik 11:ce51026d8702 1319 currentToolNo = serialToolNumber; // update tool number
BETZtechnik 11:ce51026d8702 1320
BETZtechnik 11:ce51026d8702 1321 index=0;
BETZtechnik 11:ce51026d8702 1322
BETZtechnik 11:ce51026d8702 1323 }
BETZtechnik 11:ce51026d8702 1324
BETZtechnik 11:ce51026d8702 1325 if (index == 5) { // magazine monitoring
BETZtechnik 11:ce51026d8702 1326
BETZtechnik 11:ce51026d8702 1327
BETZtechnik 11:ce51026d8702 1328
BETZtechnik 11:ce51026d8702 1329 c = device.getc();
BETZtechnik 11:ce51026d8702 1330
BETZtechnik 11:ce51026d8702 1331 if (c == '+') {
BETZtechnik 11:ce51026d8702 1332
BETZtechnik 11:ce51026d8702 1333
BETZtechnik 11:ce51026d8702 1334 currentToolNo = (currentToolNo +1);
BETZtechnik 11:ce51026d8702 1335 if (currentToolNo > numTools) {
BETZtechnik 11:ce51026d8702 1336 currentToolNo = 1;
BETZtechnik 11:ce51026d8702 1337 }
BETZtechnik 11:ce51026d8702 1338 index = 0;
BETZtechnik 11:ce51026d8702 1339 } else if (c == '-') {
BETZtechnik 11:ce51026d8702 1340 /*
BETZtechnik 11:ce51026d8702 1341 tft.setTextColor(WHITE);
BETZtechnik 11:ce51026d8702 1342 tft.setCursor(100, 100);
BETZtechnik 11:ce51026d8702 1343 tft.printf("1");
BETZtechnik 11:ce51026d8702 1344 */
BETZtechnik 11:ce51026d8702 1345 currentToolNo = (currentToolNo -1);
BETZtechnik 11:ce51026d8702 1346 if (currentToolNo < 1) {
BETZtechnik 11:ce51026d8702 1347 currentToolNo = numTools;
BETZtechnik 11:ce51026d8702 1348 }
BETZtechnik 11:ce51026d8702 1349 index = 0;
BETZtechnik 11:ce51026d8702 1350 }
BETZtechnik 11:ce51026d8702 1351
BETZtechnik 11:ce51026d8702 1352 }
BETZtechnik 11:ce51026d8702 1353 }
BETZtechnik 11:ce51026d8702 1354
BETZtechnik 11:ce51026d8702 1355 }
BETZtechnik 2:bbbacfd62773 1356 }
BETZtechnik 4:d3c19705042b 1357