lcd lib

Dependencies:   mbed LCD_DISCO_F469NI TS_DISCO_F469NI BSP_DISCO_F469NI EasyCAT_lib

Committer:
haddad1995
Date:
Mon Apr 25 12:22:12 2022 +0000
Revision:
4:186727e0bdea
Parent:
2:4a0d3be00487
update;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wsteenberg 0:ebf3f36f3a64 1 //---------------------------------------------------------------
haddad1995 4:186727e0bdea 2 // Motion Touch Screen
wsteenberg 0:ebf3f36f3a64 3 //---------------------------------------------------------------
wsteenberg 0:ebf3f36f3a64 4 #include "mbed.h"
wsteenberg 0:ebf3f36f3a64 5 #include "F469_BUTTON.hpp"
wsteenberg 0:ebf3f36f3a64 6 #include "F469_SLIDER.hpp"
haddad1995 2:4a0d3be00487 7 #include "EasyCAT.h" // EasyCAT library to interface the LAN9252
wsteenberg 0:ebf3f36f3a64 8
wsteenberg 0:ebf3f36f3a64 9 DigitalOut led_green(LED1);
wsteenberg 0:ebf3f36f3a64 10 DigitalOut led_orange(LED2);
wsteenberg 0:ebf3f36f3a64 11 DigitalOut led_red(LED3);
wsteenberg 0:ebf3f36f3a64 12 DigitalOut led_blue(LED4);
wsteenberg 0:ebf3f36f3a64 13
wsteenberg 0:ebf3f36f3a64 14 TS_DISCO_F469NI ts_;
wsteenberg 0:ebf3f36f3a64 15 LCD_DISCO_F469NI lcd_;
wsteenberg 0:ebf3f36f3a64 16
haddad1995 2:4a0d3be00487 17 EasyCAT EASYCAT; // EasyCAT istantiation
wsteenberg 0:ebf3f36f3a64 18
wsteenberg 0:ebf3f36f3a64 19 char char_SliderDisplayValue[4]; // String Value to display for the Slider Control value
wsteenberg 0:ebf3f36f3a64 20 uint16_t SliderDisplayValue_; // Variable used to access Slider Control Value in F469SLIDER.cpp
wsteenberg 0:ebf3f36f3a64 21
haddad1995 2:4a0d3be00487 22 //---- global variables ---------------------------------------------------------------------------
haddad1995 2:4a0d3be00487 23 int menu = 0;
haddad1995 2:4a0d3be00487 24
haddad1995 2:4a0d3be00487 25 UWORD ContaUp; // used for sawthoot test generation
haddad1995 2:4a0d3be00487 26 UWORD ContaDown; //
haddad1995 2:4a0d3be00487 27
haddad1995 4:186727e0bdea 28 unsigned long Millis = 0; // Time counter
haddad1995 4:186727e0bdea 29 unsigned long Millis2 = 0; // Time counter 2
haddad1995 4:186727e0bdea 30 unsigned long PreviousSaw = 0; // Time counter
haddad1995 4:186727e0bdea 31 unsigned long PreviousCycle = 0; // Time counter
haddad1995 2:4a0d3be00487 32
haddad1995 4:186727e0bdea 33 int8_t stand = 0; // data to Send
haddad1995 4:186727e0bdea 34 int8_t start = 0; // data to Send
haddad1995 4:186727e0bdea 35 int8_t stepping = 0; // data to Send
haddad1995 4:186727e0bdea 36 int8_t endStep = 0; // data to Send
haddad1995 2:4a0d3be00487 37
haddad1995 4:186727e0bdea 38 int8_t enable = 0; // data to Send
haddad1995 4:186727e0bdea 39 char enable_S[10]; // TO print Data
haddad1995 4:186727e0bdea 40 int8_t enable_Lateral = 0; // data to Send
haddad1995 4:186727e0bdea 41 char enable_Lateral_S[10]; // TO print Data
haddad1995 4:186727e0bdea 42 int8_t quick_Stop = 0; // data to Send
haddad1995 4:186727e0bdea 43 int8_t clear_Fault = 0; // data to Send
haddad1995 2:4a0d3be00487 44
haddad1995 4:186727e0bdea 45 float Standing_Time = 2.0 ; // data to Send
haddad1995 4:186727e0bdea 46 char Standing_Time_S[10]; // TO print Data
haddad1995 4:186727e0bdea 47 float Step_Time = 2.0 ; // data to Send
haddad1995 4:186727e0bdea 48 char Step_Time_S[10]; // TO print Data
haddad1995 4:186727e0bdea 49 float Wait_COM_Tr_Time = 0.5 ; // data to Send
haddad1995 4:186727e0bdea 50 char Wait_COM_Tr_Time_S[10]; // TO print Data
haddad1995 4:186727e0bdea 51 float COM_Tr_Threshold = 20 ; // data to Send
haddad1995 4:186727e0bdea 52 char COM_Tr_Threshold_S[10]; // TO print Data
haddad1995 2:4a0d3be00487 53
haddad1995 4:186727e0bdea 54 uint8_t Ethercat = 0 ; // data to Receive
haddad1995 4:186727e0bdea 55 char Ethercat_S[10]; // TO print Data
haddad1995 4:186727e0bdea 56 float Running_Time = 0.0 ; // data to Receive
haddad1995 4:186727e0bdea 57 char Running_Time_S[20]; // TO print Data
haddad1995 4:186727e0bdea 58 uint8_t State_Step = 0 ; // data to Receive
haddad1995 4:186727e0bdea 59 char State_Step_S[10]; // TO print Data
haddad1995 4:186727e0bdea 60 uint8_t Status_Driver = 0 ;// data to Receive
haddad1995 4:186727e0bdea 61 char Status_Driver_S[10]; // TO print Data
haddad1995 4:186727e0bdea 62 uint8_t END = 0 ;// data to Receive
haddad1995 4:186727e0bdea 63 char END_S[10]; // TO print Data
haddad1995 2:4a0d3be00487 64
haddad1995 2:4a0d3be00487 65 //---- declarations for Arduino "millis()" emulation -----------------------
haddad1995 2:4a0d3be00487 66
haddad1995 2:4a0d3be00487 67 static Ticker uS_Tick;
haddad1995 2:4a0d3be00487 68 static volatile uint32_t MillisVal = 0;
haddad1995 2:4a0d3be00487 69
haddad1995 2:4a0d3be00487 70 void InitMillis(void);
haddad1995 2:4a0d3be00487 71 void mS_Tick(void);
haddad1995 2:4a0d3be00487 72
haddad1995 2:4a0d3be00487 73 inline static uint32_t millis (void)
haddad1995 2:4a0d3be00487 74 {
haddad1995 2:4a0d3be00487 75 return MillisVal;
haddad1995 2:4a0d3be00487 76 };
haddad1995 2:4a0d3be00487 77
haddad1995 2:4a0d3be00487 78
haddad1995 2:4a0d3be00487 79
haddad1995 2:4a0d3be00487 80 //---------------------------------------------------------------------------------------------
wsteenberg 0:ebf3f36f3a64 81 int main()
wsteenberg 0:ebf3f36f3a64 82 {
wsteenberg 0:ebf3f36f3a64 83 led_green = 1; // Switch off all LEDs
wsteenberg 0:ebf3f36f3a64 84 led_orange = 1;
wsteenberg 0:ebf3f36f3a64 85 led_red = 1;
wsteenberg 0:ebf3f36f3a64 86 led_blue = 1;
haddad1995 4:186727e0bdea 87 EASYCAT.Init();
wsteenberg 0:ebf3f36f3a64 88 lcd_.Clear(LCD_COLOR_WHITE); // Set LCD Background colour
wsteenberg 0:ebf3f36f3a64 89
haddad1995 2:4a0d3be00487 90 // Set Text colour to Black
haddad1995 2:4a0d3be00487 91
haddad1995 2:4a0d3be00487 92 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 93 lcd_.SetFont(&Font24); // Font size 24
haddad1995 2:4a0d3be00487 94 lcd_.DisplayStringAt(10, 20, (uint8_t *)" Status EtherCAT: ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 95 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 96 lcd_.DisplayStringAt(400, 20, (uint8_t *)" Running Time: ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 97 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 98 lcd_.DisplayStringAt(10, 60, (uint8_t *)" State Step: ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 99 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 100 lcd_.DisplayStringAt(400, 60, (uint8_t *)" Status Driver: ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 101 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 102 lcd_.DisplayStringAt(10, 440, (uint8_t *)" END ? : ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 103 lcd_.DrawHLine(20, 90, 760);
haddad1995 2:4a0d3be00487 104 lcd_.DrawHLine(20, 91, 760);
haddad1995 2:4a0d3be00487 105
haddad1995 2:4a0d3be00487 106 lcd_.SetTextColor(LCD_COLOR_RED);
haddad1995 2:4a0d3be00487 107 lcd_.SetFont(&Font24); // Font size 24
haddad1995 2:4a0d3be00487 108 lcd_.DisplayStringAt(10, 110, (uint8_t *)" Driver Controle ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 109
haddad1995 2:4a0d3be00487 110 Button btn1(lcd_, ts_, 20, 160, 160, 70,
haddad1995 2:4a0d3be00487 111 LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, "Enable", Font20); // Define btn1 button
haddad1995 4:186727e0bdea 112 btn1.Render();
haddad1995 4:186727e0bdea 113 lcd_.SetFont(&Font24);
haddad1995 4:186727e0bdea 114 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 115 sprintf(enable_S, "%d", enable);
haddad1995 4:186727e0bdea 116 lcd_.DisplayStringAt(90, 136, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 117 lcd_.DisplayStringAt(90, 136, (uint8_t *)enable_S, LEFT_MODE); // Draw Enable button
haddad1995 2:4a0d3be00487 118
haddad1995 2:4a0d3be00487 119 Button btn2(lcd_, ts_, 220, 160, 160, 70,
haddad1995 2:4a0d3be00487 120 LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, "Lateral", Font20); // Define test button
haddad1995 4:186727e0bdea 121 btn2.Render();
haddad1995 4:186727e0bdea 122 lcd_.SetFont(&Font24);
haddad1995 4:186727e0bdea 123 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 124 sprintf(enable_Lateral_S, "%d", enable_Lateral);
haddad1995 4:186727e0bdea 125 lcd_.DisplayStringAt(290, 136, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 126 lcd_.DisplayStringAt(290, 136, (uint8_t *)enable_Lateral_S, LEFT_MODE); // Draw Lateral button
haddad1995 2:4a0d3be00487 127 Button btn3(lcd_, ts_, 420, 160, 160, 70,
haddad1995 4:186727e0bdea 128 LCD_COLOR_BROWN, LCD_COLOR_GRAY, 1, "Quick Stop", Font20); // Define Quick Stop button
haddad1995 4:186727e0bdea 129 btn3.Render(); // Draw Quick Stop button
wsteenberg 0:ebf3f36f3a64 130
haddad1995 2:4a0d3be00487 131 Button btn4(lcd_, ts_, 620, 160, 160, 70,
haddad1995 4:186727e0bdea 132 LCD_COLOR_BROWN, LCD_COLOR_GRAY, 1, "Clear Fault", Font20); // Define Clear Fault button
haddad1995 4:186727e0bdea 133 btn4.Render(); // Draw Clear Fault button
wsteenberg 0:ebf3f36f3a64 134
haddad1995 2:4a0d3be00487 135 lcd_.SetTextColor(LCD_COLOR_RED);
haddad1995 2:4a0d3be00487 136 lcd_.SetFont(&Font24); // Font size 24
haddad1995 2:4a0d3be00487 137 lcd_.DisplayStringAt(10, 250, (uint8_t *)" Step Control ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 138
haddad1995 2:4a0d3be00487 139
haddad1995 2:4a0d3be00487 140 Button button3D1(lcd_, ts_, 20, 300, 160, 70,
haddad1995 4:186727e0bdea 141 LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "Stand", Font20); // Define Stand button
haddad1995 2:4a0d3be00487 142 button3D1.Render();
wsteenberg 0:ebf3f36f3a64 143
haddad1995 2:4a0d3be00487 144 Button button3D2(lcd_, ts_, 220, 300, 160, 70,
haddad1995 4:186727e0bdea 145 LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "Start", Font20); // Define Start button
haddad1995 2:4a0d3be00487 146 button3D2.Render();
haddad1995 2:4a0d3be00487 147
haddad1995 2:4a0d3be00487 148 Button button3D3(lcd_, ts_, 420, 300, 160, 70,
haddad1995 4:186727e0bdea 149 LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "Stepping", Font20); // Define Stepping button
haddad1995 2:4a0d3be00487 150 button3D3.Render();
haddad1995 2:4a0d3be00487 151 Button button3D4(lcd_, ts_, 620, 300, 160, 70,
haddad1995 4:186727e0bdea 152 LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "EndStep", Font20); // Define EndStep button
haddad1995 2:4a0d3be00487 153 button3D4.Render();
haddad1995 2:4a0d3be00487 154
haddad1995 2:4a0d3be00487 155 lcd_.SetTextColor(LCD_COLOR_RED);
haddad1995 2:4a0d3be00487 156 lcd_.SetFont(&Font24); // Font size 24
haddad1995 2:4a0d3be00487 157 lcd_.DisplayStringAt(280, 440, (uint8_t *)" MOTION PROJECT ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 158
haddad1995 2:4a0d3be00487 159 Button btn5(lcd_, ts_, 660, 410, 120, 60,
haddad1995 4:186727e0bdea 160 LCD_COLOR_ORANGE, LCD_COLOR_GRAY, 1, "Next", Font20); // Define Next button
haddad1995 2:4a0d3be00487 161 btn5.Render();
haddad1995 4:186727e0bdea 162
wsteenberg 0:ebf3f36f3a64 163
haddad1995 4:186727e0bdea 164 InitMillis(); // init "millis()" emulation
wsteenberg 0:ebf3f36f3a64 165
haddad1995 2:4a0d3be00487 166 ContaDown.Word = 0x0000;
haddad1995 2:4a0d3be00487 167 ContaUp.Word = 0x0000;
wsteenberg 0:ebf3f36f3a64 168
wsteenberg 0:ebf3f36f3a64 169 while (true) // Main program loop
haddad1995 2:4a0d3be00487 170 {
wsteenberg 0:ebf3f36f3a64 171 led_green = 1; // Switch off all LEDs
wsteenberg 0:ebf3f36f3a64 172 led_orange = 1;
wsteenberg 0:ebf3f36f3a64 173 led_red = 1;
haddad1995 2:4a0d3be00487 174 led_blue = 1;
haddad1995 2:4a0d3be00487 175
haddad1995 4:186727e0bdea 176 if (btn1.Press() ) // Check if Enable button was touched and run instructions if true
haddad1995 2:4a0d3be00487 177 {
haddad1995 2:4a0d3be00487 178 if (enable==0)
haddad1995 2:4a0d3be00487 179 {
haddad1995 2:4a0d3be00487 180 enable=1;
haddad1995 2:4a0d3be00487 181 }
haddad1995 2:4a0d3be00487 182 else enable=0;
haddad1995 4:186727e0bdea 183 lcd_.SetFont(&Font24);
haddad1995 4:186727e0bdea 184 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 185 sprintf(enable_S, "%d", enable);
haddad1995 4:186727e0bdea 186 lcd_.DisplayStringAt(90, 136, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 187 lcd_.DisplayStringAt(90, 136, (uint8_t *)enable_S, LEFT_MODE);
haddad1995 2:4a0d3be00487 188 lcd_.SetFont(&Font16);
haddad1995 2:4a0d3be00487 189 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 190 lcd_.DisplayStringAt(5, 460, (uint8_t *)"Enable pressed - switch on orange LED", LEFT_MODE);
haddad1995 2:4a0d3be00487 191 led_orange = 0;
haddad1995 2:4a0d3be00487 192 wait(0.2);
haddad1995 2:4a0d3be00487 193 lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE);
haddad1995 2:4a0d3be00487 194
haddad1995 2:4a0d3be00487 195 }
haddad1995 4:186727e0bdea 196 // End Enable button instructions
haddad1995 4:186727e0bdea 197 if (btn2.Press()) // Check if Enable Lateral button was touched and run instructions if true
haddad1995 2:4a0d3be00487 198 {
haddad1995 2:4a0d3be00487 199 if (enable_Lateral==0)
haddad1995 2:4a0d3be00487 200 {
haddad1995 2:4a0d3be00487 201 enable_Lateral=1;
haddad1995 2:4a0d3be00487 202 }
haddad1995 2:4a0d3be00487 203 else enable_Lateral=0;
haddad1995 4:186727e0bdea 204 lcd_.SetFont(&Font24);
haddad1995 4:186727e0bdea 205 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 206 sprintf(enable_Lateral_S, "%d", enable_Lateral);
haddad1995 4:186727e0bdea 207 lcd_.DisplayStringAt(290, 136, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 208 lcd_.DisplayStringAt(290, 136, (uint8_t *)enable_Lateral_S, LEFT_MODE);
haddad1995 2:4a0d3be00487 209 lcd_.SetFont(&Font16);
haddad1995 2:4a0d3be00487 210 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 211 lcd_.DisplayStringAt(5, 460, (uint8_t *)"Enable Lateral pressed - switch on red LED", LEFT_MODE);
haddad1995 2:4a0d3be00487 212 led_red = 0;
haddad1995 2:4a0d3be00487 213 wait(0.2);
haddad1995 2:4a0d3be00487 214 lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE);
haddad1995 2:4a0d3be00487 215
haddad1995 4:186727e0bdea 216 } // End Enable Lateral button instructions
dcspencer 1:8574e7a8fcde 217
haddad1995 4:186727e0bdea 218 if (btn3.Press()) // Check if Quick Stop button was touched and run instructions if true
wsteenberg 0:ebf3f36f3a64 219 {
haddad1995 2:4a0d3be00487 220 if (quick_Stop==0)
haddad1995 2:4a0d3be00487 221 {
haddad1995 2:4a0d3be00487 222 quick_Stop=1;
haddad1995 2:4a0d3be00487 223 }
haddad1995 2:4a0d3be00487 224 else quick_Stop=0;
wsteenberg 0:ebf3f36f3a64 225 lcd_.SetFont(&Font16);
wsteenberg 0:ebf3f36f3a64 226 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 227 lcd_.DisplayStringAt(5, 460, (uint8_t *)"Quick Stop pressed - switch on blue LED", LEFT_MODE);
haddad1995 2:4a0d3be00487 228 led_blue = 0;
haddad1995 2:4a0d3be00487 229 wait(0.2);
haddad1995 2:4a0d3be00487 230 lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 231 } // End Quick Stop button instructions
haddad1995 4:186727e0bdea 232 if (btn4.Press()) // Check if Clear Fault button was touched and run instructions if true
wsteenberg 0:ebf3f36f3a64 233 {
haddad1995 2:4a0d3be00487 234 if (clear_Fault==0)
haddad1995 2:4a0d3be00487 235 {
haddad1995 2:4a0d3be00487 236 clear_Fault=1;
haddad1995 2:4a0d3be00487 237 }
haddad1995 2:4a0d3be00487 238 else clear_Fault=0;
wsteenberg 0:ebf3f36f3a64 239 lcd_.SetFont(&Font16);
wsteenberg 0:ebf3f36f3a64 240 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 241 lcd_.DisplayStringAt(5, 460, (uint8_t *)"Clear Fault pressed - switch on red LED", LEFT_MODE);
wsteenberg 0:ebf3f36f3a64 242 led_red = 0;
haddad1995 2:4a0d3be00487 243 wait(0.2);
haddad1995 2:4a0d3be00487 244 lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE);
haddad1995 2:4a0d3be00487 245
haddad1995 2:4a0d3be00487 246 }
haddad1995 2:4a0d3be00487 247
haddad1995 2:4a0d3be00487 248
haddad1995 4:186727e0bdea 249 if (button3D1.Press() ) // Check if Stand button was touched and run instructions if true
haddad1995 2:4a0d3be00487 250 {
haddad1995 2:4a0d3be00487 251 if (stand==0)
haddad1995 2:4a0d3be00487 252 {
haddad1995 2:4a0d3be00487 253 stand=1;
haddad1995 2:4a0d3be00487 254 }
haddad1995 2:4a0d3be00487 255 else stand=0;
haddad1995 2:4a0d3be00487 256 lcd_.SetFont(&Font16);
haddad1995 2:4a0d3be00487 257 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 258 lcd_.DisplayStringAt(5, 460, (uint8_t *)"Stand pressed - switch on orange LED", LEFT_MODE);
haddad1995 2:4a0d3be00487 259 led_orange = 0;
haddad1995 2:4a0d3be00487 260 wait(0.2);
haddad1995 2:4a0d3be00487 261 lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE);
haddad1995 2:4a0d3be00487 262
haddad1995 2:4a0d3be00487 263 }
haddad1995 4:186727e0bdea 264 // End Stand button instructions
haddad1995 2:4a0d3be00487 265
haddad1995 4:186727e0bdea 266 if (button3D2.Press()) // Check if Start button was touched and run instructions if true
haddad1995 2:4a0d3be00487 267 {
haddad1995 2:4a0d3be00487 268 if (start==0)
haddad1995 2:4a0d3be00487 269 {
haddad1995 2:4a0d3be00487 270 start=1;
haddad1995 2:4a0d3be00487 271 }
haddad1995 2:4a0d3be00487 272 else start=0;
haddad1995 2:4a0d3be00487 273 lcd_.SetFont(&Font16);
haddad1995 2:4a0d3be00487 274 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 275 lcd_.DisplayStringAt(5, 460, (uint8_t *)"Start pressed - switch on red LED", LEFT_MODE);
haddad1995 2:4a0d3be00487 276 led_red = 0;
haddad1995 2:4a0d3be00487 277 wait(0.2);
haddad1995 2:4a0d3be00487 278 lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE);
wsteenberg 0:ebf3f36f3a64 279
haddad1995 4:186727e0bdea 280 } // End Start button instructions
wsteenberg 0:ebf3f36f3a64 281
haddad1995 4:186727e0bdea 282 if (button3D3.Press()) // Check if Stepping button was touched and run instructions if true
wsteenberg 0:ebf3f36f3a64 283 {
haddad1995 2:4a0d3be00487 284 if (stepping==0)
haddad1995 2:4a0d3be00487 285 {
haddad1995 2:4a0d3be00487 286 stepping=1;
haddad1995 2:4a0d3be00487 287 }
haddad1995 2:4a0d3be00487 288 else stepping=0;
wsteenberg 0:ebf3f36f3a64 289 lcd_.SetFont(&Font16);
wsteenberg 0:ebf3f36f3a64 290 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 291 lcd_.DisplayStringAt(5, 460, (uint8_t *)"Stepping pressed - switch on blue LED", LEFT_MODE);
haddad1995 2:4a0d3be00487 292 led_blue = 0;
haddad1995 2:4a0d3be00487 293 wait(0.2);
haddad1995 2:4a0d3be00487 294 lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE);
haddad1995 2:4a0d3be00487 295 }
wsteenberg 0:ebf3f36f3a64 296
haddad1995 4:186727e0bdea 297 if (button3D4.Press()) // Check if EndStep button was touched and run instructions if true
haddad1995 2:4a0d3be00487 298 {
haddad1995 2:4a0d3be00487 299 if (endStep==0)
haddad1995 2:4a0d3be00487 300 {
haddad1995 2:4a0d3be00487 301 endStep=1;
haddad1995 2:4a0d3be00487 302 }
haddad1995 2:4a0d3be00487 303 else endStep=0;
wsteenberg 0:ebf3f36f3a64 304 lcd_.SetFont(&Font16);
wsteenberg 0:ebf3f36f3a64 305 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 306 lcd_.DisplayStringAt(5, 460, (uint8_t *)"EndStep pressed - switch on blue LED", LEFT_MODE);
haddad1995 2:4a0d3be00487 307 led_blue = 0;
haddad1995 2:4a0d3be00487 308 wait(0.2);
haddad1995 2:4a0d3be00487 309 lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE);
haddad1995 2:4a0d3be00487 310 }
wsteenberg 0:ebf3f36f3a64 311
haddad1995 4:186727e0bdea 312 if ( btn5.Press() ) // Check if next button was touched and run instructions if true
haddad1995 2:4a0d3be00487 313 { menu = 1 ;
haddad1995 2:4a0d3be00487 314 lcd_.Clear(LCD_COLOR_WHITE);
haddad1995 2:4a0d3be00487 315 led_orange = 0;
haddad1995 2:4a0d3be00487 316 wait(0.1);
haddad1995 2:4a0d3be00487 317 led_orange = 1; // Set LCD Background colour
haddad1995 2:4a0d3be00487 318
haddad1995 2:4a0d3be00487 319 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 320 lcd_.SetFont(&Font24); // Font size 24
haddad1995 4:186727e0bdea 321 lcd_.DisplayStringAt(20, 45, (uint8_t *)"Standing Time", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 322 sprintf(Standing_Time_S, "%0.2f", Standing_Time);
haddad1995 2:4a0d3be00487 323 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 324 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 325 lcd_.DisplayStringAt(320, 45, (uint8_t *)Standing_Time_S, LEFT_MODE);
haddad1995 4:186727e0bdea 326
haddad1995 4:186727e0bdea 327 Button btn11(lcd_, ts_, 400, 20, 150, 60,
haddad1995 4:186727e0bdea 328 LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, " + ", Font24); // Define + button
haddad1995 2:4a0d3be00487 329 btn11.Render();
haddad1995 4:186727e0bdea 330 Button btn12(lcd_, ts_, 600, 20, 150, 60,
haddad1995 4:186727e0bdea 331 LCD_COLOR_RED , LCD_COLOR_DARKBLUE, 1, " - ", Font24); // Define - button
haddad1995 2:4a0d3be00487 332 btn12.Render();
haddad1995 2:4a0d3be00487 333
haddad1995 2:4a0d3be00487 334 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 335 lcd_.SetFont(&Font24); // Font size 24
haddad1995 4:186727e0bdea 336 lcd_.DisplayStringAt(20, 145, (uint8_t *)"Step Time", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 337 sprintf(Step_Time_S, "%0.2f", Step_Time);
haddad1995 2:4a0d3be00487 338 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 339 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 340 lcd_.DisplayStringAt(320, 145, (uint8_t *)Step_Time_S, LEFT_MODE);
haddad1995 4:186727e0bdea 341 Button btn13(lcd_, ts_, 400, 120, 150, 60,
haddad1995 4:186727e0bdea 342 LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, " + ", Font24); // Define + button
haddad1995 2:4a0d3be00487 343 btn13.Render();
haddad1995 4:186727e0bdea 344 Button btn14(lcd_, ts_, 600, 120, 150, 60,
haddad1995 4:186727e0bdea 345 LCD_COLOR_RED , LCD_COLOR_DARKBLUE, 1, " - ", Font24); // Define - button
haddad1995 2:4a0d3be00487 346 btn14.Render();
haddad1995 2:4a0d3be00487 347
haddad1995 2:4a0d3be00487 348 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 349 lcd_.SetFont(&Font24); // Font size 24
haddad1995 4:186727e0bdea 350 lcd_.DisplayStringAt(20, 245, (uint8_t *)"Wait COM Tr Time", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 351 sprintf(Wait_COM_Tr_Time_S, "%0.2f", Wait_COM_Tr_Time);
haddad1995 2:4a0d3be00487 352 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 353 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 354 lcd_.DisplayStringAt(320, 245, (uint8_t *)Wait_COM_Tr_Time_S, LEFT_MODE);
haddad1995 4:186727e0bdea 355 Button btn15(lcd_, ts_, 400, 220, 150, 60,
haddad1995 4:186727e0bdea 356 LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, " + ", Font24); // Define + button
haddad1995 2:4a0d3be00487 357 btn15.Render();
haddad1995 4:186727e0bdea 358 Button btn16(lcd_, ts_, 600, 220, 150, 60,
haddad1995 4:186727e0bdea 359 LCD_COLOR_RED , LCD_COLOR_DARKBLUE, 1, " - ", Font24); // Define - button
haddad1995 2:4a0d3be00487 360 btn16.Render();
haddad1995 2:4a0d3be00487 361
haddad1995 2:4a0d3be00487 362 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 363 lcd_.SetFont(&Font24); // Font size 24
haddad1995 4:186727e0bdea 364 lcd_.DisplayStringAt(20, 345, (uint8_t *)"COM Tr Threshold", LEFT_MODE); // Display main header text
haddad1995 4:186727e0bdea 365 sprintf(COM_Tr_Threshold_S, "%0.1f", COM_Tr_Threshold);
haddad1995 2:4a0d3be00487 366 lcd_.SetFont(&Font24);
wsteenberg 0:ebf3f36f3a64 367 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 368 lcd_.DisplayStringAt(320, 345, (uint8_t *)COM_Tr_Threshold_S, LEFT_MODE);
haddad1995 4:186727e0bdea 369 lcd_.DisplayStringAt(360, 345, (uint8_t *)" %", LEFT_MODE);
haddad1995 4:186727e0bdea 370 Button btn17(lcd_, ts_, 400, 320, 150, 60,
haddad1995 4:186727e0bdea 371 LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, " + ", Font24); // Define + button
haddad1995 2:4a0d3be00487 372 btn17.Render();
haddad1995 4:186727e0bdea 373 Button btn18(lcd_, ts_, 600, 320, 150, 60,
haddad1995 4:186727e0bdea 374 LCD_COLOR_RED , LCD_COLOR_DARKBLUE, 1, " - ", Font24); // Define - button
haddad1995 2:4a0d3be00487 375 btn18.Render();
haddad1995 2:4a0d3be00487 376
haddad1995 2:4a0d3be00487 377 Button btn6(lcd_, ts_, 20, 410, 120, 60,
haddad1995 4:186727e0bdea 378 LCD_COLOR_ORANGE, LCD_COLOR_GRAY, 1, "Back", Font20); // Define Back button
haddad1995 2:4a0d3be00487 379 btn6.Render();
haddad1995 4:186727e0bdea 380
haddad1995 4:186727e0bdea 381 Button btn7(lcd_, ts_, 650, 400, 140, 70,
haddad1995 4:186727e0bdea 382 LCD_COLOR_ORANGE, LCD_COLOR_GRAY, 1, "Reset", Font20); // Define Reset button
haddad1995 4:186727e0bdea 383 btn7.Render();
haddad1995 2:4a0d3be00487 384
haddad1995 2:4a0d3be00487 385 lcd_.SetTextColor(LCD_COLOR_RED);
haddad1995 2:4a0d3be00487 386 lcd_.SetFont(&Font24); // Font size 24
haddad1995 2:4a0d3be00487 387 lcd_.DisplayStringAt(280, 440, (uint8_t *)" MOTION PROJECT ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 388
haddad1995 2:4a0d3be00487 389 while (menu==1)
haddad1995 4:186727e0bdea 390 { if (btn11.Press() ) // Check if + button was touched and run instructions if true
haddad1995 2:4a0d3be00487 391 {
haddad1995 2:4a0d3be00487 392 Standing_Time = Standing_Time + 0.5 ;
haddad1995 2:4a0d3be00487 393 sprintf(Standing_Time_S, "%0.2f", Standing_Time);
haddad1995 2:4a0d3be00487 394 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 395 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 396 lcd_.DisplayStringAt(320, 45, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 397 lcd_.DisplayStringAt(320, 45, (uint8_t *)Standing_Time_S, LEFT_MODE);
haddad1995 2:4a0d3be00487 398
haddad1995 2:4a0d3be00487 399 }
haddad1995 4:186727e0bdea 400 if (btn12.Press() ) // Check if - button was touched and run instructions if true
haddad1995 2:4a0d3be00487 401 { if (Standing_Time>0)
haddad1995 2:4a0d3be00487 402 {
haddad1995 2:4a0d3be00487 403 Standing_Time = Standing_Time - 0.5 ;
haddad1995 2:4a0d3be00487 404 sprintf(Standing_Time_S, "%0.2f", Standing_Time);
haddad1995 2:4a0d3be00487 405 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 406 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 407 lcd_.DisplayStringAt(320, 45, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 408 lcd_.DisplayStringAt(320, 45, (uint8_t *)Standing_Time_S, LEFT_MODE);
haddad1995 2:4a0d3be00487 409 }
haddad1995 2:4a0d3be00487 410 }
haddad1995 4:186727e0bdea 411 if (btn13.Press() ) // Check if + button was touched and run instructions if true
haddad1995 2:4a0d3be00487 412 {
haddad1995 2:4a0d3be00487 413 Step_Time = Step_Time + 0.5 ;
haddad1995 2:4a0d3be00487 414 sprintf(Step_Time_S, "%0.2f", Step_Time);
haddad1995 2:4a0d3be00487 415 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 416 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 417 lcd_.DisplayStringAt(320, 145, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 418 lcd_.DisplayStringAt(320, 145, (uint8_t *)Step_Time_S, LEFT_MODE);
haddad1995 2:4a0d3be00487 419
haddad1995 2:4a0d3be00487 420 }
haddad1995 4:186727e0bdea 421 if (btn14.Press() ) // Check if - button was touched and run instructions if true
haddad1995 2:4a0d3be00487 422 { if (Step_Time>0)
haddad1995 2:4a0d3be00487 423 {
haddad1995 2:4a0d3be00487 424 Step_Time = Step_Time - 0.5 ;
haddad1995 2:4a0d3be00487 425 sprintf(Step_Time_S, "%0.2f", Step_Time);
haddad1995 2:4a0d3be00487 426 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 427 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 428 lcd_.DisplayStringAt(320, 145, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 429 lcd_.DisplayStringAt(320, 145, (uint8_t *)Step_Time_S, LEFT_MODE);
haddad1995 2:4a0d3be00487 430 }
haddad1995 2:4a0d3be00487 431 }
haddad1995 4:186727e0bdea 432 if (btn15.Press() ) // Check if + button was touched and run instructions if true
haddad1995 2:4a0d3be00487 433 {
haddad1995 2:4a0d3be00487 434 Wait_COM_Tr_Time = Wait_COM_Tr_Time + 0.5 ;
haddad1995 2:4a0d3be00487 435 sprintf(Wait_COM_Tr_Time_S, "%0.2f", Wait_COM_Tr_Time);
haddad1995 2:4a0d3be00487 436 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 437 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 438 lcd_.DisplayStringAt(320, 245, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 439 lcd_.DisplayStringAt(320, 245, (uint8_t *)Wait_COM_Tr_Time_S, LEFT_MODE);
haddad1995 2:4a0d3be00487 440
haddad1995 2:4a0d3be00487 441 }
haddad1995 4:186727e0bdea 442 if (btn16.Press() ) // Check if - button was touched and run instructions if true
haddad1995 2:4a0d3be00487 443 { if (Wait_COM_Tr_Time>0)
haddad1995 2:4a0d3be00487 444 {
haddad1995 2:4a0d3be00487 445 Wait_COM_Tr_Time = Wait_COM_Tr_Time - 0.5 ;
haddad1995 2:4a0d3be00487 446 sprintf(Wait_COM_Tr_Time_S, "%0.2f", Wait_COM_Tr_Time);
haddad1995 2:4a0d3be00487 447 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 448 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 449 lcd_.DisplayStringAt(320, 245, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 450 lcd_.DisplayStringAt(320, 245, (uint8_t *)Wait_COM_Tr_Time_S, LEFT_MODE);
haddad1995 2:4a0d3be00487 451 }
haddad1995 2:4a0d3be00487 452 }
haddad1995 4:186727e0bdea 453 if (btn17.Press() ) // Check if + button was touched and run instructions if true
haddad1995 2:4a0d3be00487 454 {
haddad1995 2:4a0d3be00487 455 COM_Tr_Threshold = COM_Tr_Threshold + 5 ;
haddad1995 4:186727e0bdea 456 sprintf(COM_Tr_Threshold_S, "%0.1f", COM_Tr_Threshold);
haddad1995 2:4a0d3be00487 457 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 458 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 459 lcd_.DisplayStringAt(320, 345, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 460 lcd_.DisplayStringAt(320, 345, (uint8_t *)COM_Tr_Threshold_S, LEFT_MODE);
haddad1995 4:186727e0bdea 461 lcd_.DisplayStringAt(360, 345, (uint8_t *)" %", LEFT_MODE);
haddad1995 2:4a0d3be00487 462
haddad1995 2:4a0d3be00487 463 }
haddad1995 4:186727e0bdea 464 if (btn18.Press() ) // Check if - button was touched and run instructions if true
haddad1995 2:4a0d3be00487 465 { if (COM_Tr_Threshold>0)
haddad1995 2:4a0d3be00487 466 {
haddad1995 2:4a0d3be00487 467 COM_Tr_Threshold = COM_Tr_Threshold - 5 ;
haddad1995 4:186727e0bdea 468 sprintf(COM_Tr_Threshold_S, "%0.1f", COM_Tr_Threshold);
haddad1995 2:4a0d3be00487 469 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 470 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 471 lcd_.DisplayStringAt(320, 345, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 472 lcd_.DisplayStringAt(320, 345, (uint8_t *)COM_Tr_Threshold_S, LEFT_MODE);
haddad1995 4:186727e0bdea 473 lcd_.DisplayStringAt(360, 345, (uint8_t *)" %", LEFT_MODE);
haddad1995 2:4a0d3be00487 474 }
haddad1995 2:4a0d3be00487 475 }
haddad1995 4:186727e0bdea 476 if (btn7.Press() ) // Check if Reset button was touched and run instructions if true
haddad1995 4:186727e0bdea 477 {
haddad1995 4:186727e0bdea 478 Standing_Time = 2.0 ;
haddad1995 4:186727e0bdea 479 Step_Time = 2.0 ;
haddad1995 4:186727e0bdea 480 Wait_COM_Tr_Time = 0.5 ;
haddad1995 4:186727e0bdea 481 COM_Tr_Threshold = 20 ;
haddad1995 4:186727e0bdea 482
haddad1995 4:186727e0bdea 483 stand = 0;
haddad1995 4:186727e0bdea 484 start = 0;
haddad1995 4:186727e0bdea 485 stepping = 0;
haddad1995 4:186727e0bdea 486 endStep = 0;
haddad1995 4:186727e0bdea 487
haddad1995 4:186727e0bdea 488 enable=0;
haddad1995 4:186727e0bdea 489 enable_Lateral = 0;
haddad1995 4:186727e0bdea 490 quick_Stop = 0;
haddad1995 4:186727e0bdea 491 clear_Fault = 0;
haddad1995 4:186727e0bdea 492
haddad1995 4:186727e0bdea 493 Ethercat=0;
haddad1995 4:186727e0bdea 494 Running_Time=0;
haddad1995 4:186727e0bdea 495 State_Step=0;
haddad1995 4:186727e0bdea 496 Status_Driver=0;
haddad1995 4:186727e0bdea 497 END=0;
haddad1995 4:186727e0bdea 498
haddad1995 4:186727e0bdea 499 lcd_.SetFont(&Font24);
haddad1995 4:186727e0bdea 500 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 501
haddad1995 4:186727e0bdea 502 sprintf(Standing_Time_S, "%0.2f", Standing_Time);
haddad1995 4:186727e0bdea 503 lcd_.DisplayStringAt(320, 45, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 504 lcd_.DisplayStringAt(320, 45, (uint8_t *)Standing_Time_S, LEFT_MODE);
haddad1995 4:186727e0bdea 505
haddad1995 4:186727e0bdea 506 sprintf(Step_Time_S, "%0.2f", Step_Time);
haddad1995 4:186727e0bdea 507 lcd_.DisplayStringAt(320, 145, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 508 lcd_.DisplayStringAt(320, 145, (uint8_t *)Step_Time_S, LEFT_MODE);
haddad1995 4:186727e0bdea 509
haddad1995 4:186727e0bdea 510 sprintf(Wait_COM_Tr_Time_S, "%0.2f", Wait_COM_Tr_Time);
haddad1995 4:186727e0bdea 511 lcd_.DisplayStringAt(320, 245, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 512 lcd_.DisplayStringAt(320, 245, (uint8_t *)Wait_COM_Tr_Time_S, LEFT_MODE);
haddad1995 4:186727e0bdea 513
haddad1995 4:186727e0bdea 514 sprintf(COM_Tr_Threshold_S, "%0.1f", COM_Tr_Threshold);
haddad1995 4:186727e0bdea 515 lcd_.DisplayStringAt(320, 345, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 516 lcd_.DisplayStringAt(320, 345, (uint8_t *)COM_Tr_Threshold_S, LEFT_MODE);
haddad1995 4:186727e0bdea 517 lcd_.DisplayStringAt(360, 345, (uint8_t *)" %", LEFT_MODE);
haddad1995 4:186727e0bdea 518 }
haddad1995 4:186727e0bdea 519 if (btn6.Press() ) // Check if btn back button was touched and run instructions if true
haddad1995 2:4a0d3be00487 520 {
haddad1995 2:4a0d3be00487 521 menu=0;
haddad1995 2:4a0d3be00487 522 led_orange = 0;
haddad1995 2:4a0d3be00487 523 lcd_.Clear(LCD_COLOR_WHITE); // Set LCD Background colour
haddad1995 2:4a0d3be00487 524 lcd_.SetTextColor(LCD_COLOR_BLACK); // Set Text colour to Black
haddad1995 2:4a0d3be00487 525 lcd_.SetFont(&Font24); // Font size 24
haddad1995 2:4a0d3be00487 526 lcd_.DisplayStringAt(10, 20, (uint8_t *)" Status EtherCAT: ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 527 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 528 lcd_.DisplayStringAt(400, 20, (uint8_t *)" Running Time: ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 529 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 530 lcd_.DisplayStringAt(10, 60, (uint8_t *)" State Step: ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 531 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 532 lcd_.DisplayStringAt(400, 60, (uint8_t *)" Status Driver: ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 533 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 534 lcd_.DisplayStringAt(10, 440, (uint8_t *)" END ? : ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 535 lcd_.DrawHLine(20, 90, 760);
haddad1995 2:4a0d3be00487 536 lcd_.DrawHLine(20, 91, 760);
haddad1995 2:4a0d3be00487 537
haddad1995 2:4a0d3be00487 538 lcd_.SetTextColor(LCD_COLOR_RED);
haddad1995 2:4a0d3be00487 539 lcd_.SetFont(&Font24); // Font size 24
haddad1995 2:4a0d3be00487 540 lcd_.DisplayStringAt(10, 110, (uint8_t *)" Driver Controle ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 541
haddad1995 2:4a0d3be00487 542 Button btn1(lcd_, ts_, 20, 160, 160, 70,
haddad1995 4:186727e0bdea 543 LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, "Enable", Font20); // Define Enable button
haddad1995 4:186727e0bdea 544 btn1.Render();
haddad1995 4:186727e0bdea 545 lcd_.SetFont(&Font24);
haddad1995 4:186727e0bdea 546 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 547 sprintf(enable_S, "%d", enable);
haddad1995 4:186727e0bdea 548 lcd_.DisplayStringAt(90, 136, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 549 lcd_.DisplayStringAt(90, 136, (uint8_t *)enable_S, LEFT_MODE); // Draw btn1 button
haddad1995 2:4a0d3be00487 550
haddad1995 2:4a0d3be00487 551 Button btn2(lcd_, ts_, 220, 160, 160, 70,
haddad1995 4:186727e0bdea 552 LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, "Lateral", Font20); // Define Lateral button
haddad1995 4:186727e0bdea 553 btn2.Render(); // Draw Lateral button
haddad1995 4:186727e0bdea 554 lcd_.SetFont(&Font24);
haddad1995 4:186727e0bdea 555 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 556 sprintf(enable_Lateral_S, "%d", enable_Lateral);
haddad1995 4:186727e0bdea 557 lcd_.DisplayStringAt(290, 136, (uint8_t *)" ", LEFT_MODE);
haddad1995 4:186727e0bdea 558 lcd_.DisplayStringAt(290, 136, (uint8_t *)enable_Lateral_S, LEFT_MODE);
haddad1995 4:186727e0bdea 559
haddad1995 2:4a0d3be00487 560 Button btn3(lcd_, ts_, 420, 160, 160, 70,
haddad1995 4:186727e0bdea 561 LCD_COLOR_BROWN, LCD_COLOR_GRAY, 1, "Quick Stop", Font20); // Define Quick Stop button
haddad1995 4:186727e0bdea 562 btn3.Render(); // Draw Quick Stop button
haddad1995 2:4a0d3be00487 563
haddad1995 2:4a0d3be00487 564 Button btn4(lcd_, ts_, 620, 160, 160, 70,
haddad1995 4:186727e0bdea 565 LCD_COLOR_BROWN, LCD_COLOR_GRAY, 1, "Clear Fault", Font20); // Define Clear Fault button
haddad1995 4:186727e0bdea 566 btn4.Render(); // Draw Clear Fault button
haddad1995 2:4a0d3be00487 567
haddad1995 2:4a0d3be00487 568 lcd_.SetTextColor(LCD_COLOR_RED);
haddad1995 2:4a0d3be00487 569 lcd_.SetFont(&Font24); // Font size 24
haddad1995 2:4a0d3be00487 570 lcd_.DisplayStringAt(10, 250, (uint8_t *)" Step Control ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 571
haddad1995 2:4a0d3be00487 572
haddad1995 2:4a0d3be00487 573 Button button3D1(lcd_, ts_, 20, 300, 160, 70,
haddad1995 4:186727e0bdea 574 LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "Stand", Font20); // Define Stand button
haddad1995 2:4a0d3be00487 575 button3D1.Render();
haddad1995 2:4a0d3be00487 576
haddad1995 2:4a0d3be00487 577 Button button3D2(lcd_, ts_, 220, 300, 160, 70,
haddad1995 4:186727e0bdea 578 LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "Start", Font20); // Define Start button
haddad1995 2:4a0d3be00487 579 button3D2.Render();
haddad1995 2:4a0d3be00487 580
haddad1995 2:4a0d3be00487 581 Button button3D3(lcd_, ts_, 420, 300, 160, 70,
haddad1995 4:186727e0bdea 582 LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "Stepping", Font20); // Define Stepping button
haddad1995 2:4a0d3be00487 583 button3D3.Render();
haddad1995 2:4a0d3be00487 584 Button button3D4(lcd_, ts_, 620, 300, 160, 70,
haddad1995 4:186727e0bdea 585 LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "EndStep", Font20); // Define EndStep button
haddad1995 2:4a0d3be00487 586 button3D4.Render();
haddad1995 2:4a0d3be00487 587
haddad1995 2:4a0d3be00487 588 lcd_.SetTextColor(LCD_COLOR_RED);
haddad1995 2:4a0d3be00487 589 lcd_.SetFont(&Font24); // Font size 24
haddad1995 2:4a0d3be00487 590 lcd_.DisplayStringAt(280, 440, (uint8_t *)" MOTION PROJECT ", LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 591
haddad1995 2:4a0d3be00487 592 Button btn5(lcd_, ts_, 660, 410, 120, 60,
haddad1995 4:186727e0bdea 593 LCD_COLOR_ORANGE, LCD_COLOR_GRAY, 1, "Next", Font20); // Define Next button
haddad1995 2:4a0d3be00487 594 btn5.Render();
haddad1995 2:4a0d3be00487 595
haddad1995 2:4a0d3be00487 596 wait(0.2);
haddad1995 2:4a0d3be00487 597 }
haddad1995 2:4a0d3be00487 598 wait(0.02f);
haddad1995 2:4a0d3be00487 599 }
haddad1995 2:4a0d3be00487 600 } // End test button instructions // End 3D button instructions
haddad1995 2:4a0d3be00487 601
wsteenberg 0:ebf3f36f3a64 602 wait(0.02f);
haddad1995 2:4a0d3be00487 603
haddad1995 2:4a0d3be00487 604 Millis = millis(); //
haddad1995 4:186727e0bdea 605 if (Millis - PreviousCycle >= 10) // each 10 mS Send Data to SpeedGoat
haddad1995 2:4a0d3be00487 606 { //
haddad1995 2:4a0d3be00487 607 PreviousCycle = Millis; //
haddad1995 2:4a0d3be00487 608
haddad1995 2:4a0d3be00487 609 EASYCAT.MainTask(); // execute the EasyCAT task
haddad1995 2:4a0d3be00487 610
haddad1995 2:4a0d3be00487 611
haddad1995 2:4a0d3be00487 612
haddad1995 2:4a0d3be00487 613 EASYCAT.BufferIn.Cust.Standing_Time_T= Standing_Time;
haddad1995 2:4a0d3be00487 614
haddad1995 2:4a0d3be00487 615 EASYCAT.BufferIn.Cust.Step_Time_T= Step_Time;
haddad1995 2:4a0d3be00487 616
haddad1995 2:4a0d3be00487 617 EASYCAT.BufferIn.Cust.Wait_COM_Tr_Time_T= Wait_COM_Tr_Time;
haddad1995 2:4a0d3be00487 618
haddad1995 2:4a0d3be00487 619 EASYCAT.BufferIn.Cust.COM_Tr_Threshold_T= (COM_Tr_Threshold/100);
haddad1995 2:4a0d3be00487 620
haddad1995 2:4a0d3be00487 621
haddad1995 2:4a0d3be00487 622
haddad1995 2:4a0d3be00487 623 EASYCAT.BufferIn.Cust.Stand= stand;
haddad1995 2:4a0d3be00487 624
haddad1995 2:4a0d3be00487 625 EASYCAT.BufferIn.Cust.Start = start;
haddad1995 2:4a0d3be00487 626
haddad1995 2:4a0d3be00487 627 EASYCAT.BufferIn.Cust.Stepping = stepping;
haddad1995 2:4a0d3be00487 628
haddad1995 2:4a0d3be00487 629 EASYCAT.BufferIn.Cust.EndStep = endStep;
haddad1995 2:4a0d3be00487 630
haddad1995 2:4a0d3be00487 631 EASYCAT.BufferIn.Cust.Enable= enable;
haddad1995 2:4a0d3be00487 632
haddad1995 2:4a0d3be00487 633 EASYCAT.BufferIn.Cust.EnableLateral = enable_Lateral;
haddad1995 2:4a0d3be00487 634
haddad1995 2:4a0d3be00487 635 EASYCAT.BufferIn.Cust.QuickStop = quick_Stop;
haddad1995 2:4a0d3be00487 636
haddad1995 2:4a0d3be00487 637 EASYCAT.BufferIn.Cust.ClearFault = clear_Fault;
haddad1995 2:4a0d3be00487 638
haddad1995 4:186727e0bdea 639 Ethercat = EASYCAT.BufferOut.Cust.EtherCAT;
haddad1995 2:4a0d3be00487 640
haddad1995 4:186727e0bdea 641 Running_Time = EASYCAT.BufferOut.Cust.Running_Time_T ;
haddad1995 2:4a0d3be00487 642
haddad1995 4:186727e0bdea 643 State_Step = EASYCAT.BufferOut.Cust.State_Step_T ;
haddad1995 2:4a0d3be00487 644
haddad1995 4:186727e0bdea 645 Status_Driver = EASYCAT.BufferOut.Cust.Status_Driver_T ;
haddad1995 2:4a0d3be00487 646
haddad1995 4:186727e0bdea 647 END = EASYCAT.BufferOut.Cust.END_T ;
haddad1995 2:4a0d3be00487 648
haddad1995 2:4a0d3be00487 649 }
haddad1995 2:4a0d3be00487 650 sprintf(Ethercat_S, "%d", Ethercat);
haddad1995 2:4a0d3be00487 651 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 652 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 653 lcd_.DisplayStringAt(320, 20, (uint8_t *)Ethercat_S, LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 654
haddad1995 2:4a0d3be00487 655
haddad1995 4:186727e0bdea 656 sprintf(Running_Time_S, "%0.1f", Running_Time);
haddad1995 2:4a0d3be00487 657 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 658 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 659 lcd_.DisplayStringAt(680, 20, (uint8_t *)Running_Time_S, LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 660
haddad1995 2:4a0d3be00487 661 sprintf(State_Step_S, "%d", State_Step);
haddad1995 2:4a0d3be00487 662 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 663 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 664 lcd_.DisplayStringAt(320, 60, (uint8_t *)State_Step_S, LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 665
haddad1995 2:4a0d3be00487 666 sprintf(Status_Driver_S, "%d", Status_Driver);
haddad1995 2:4a0d3be00487 667 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 668 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 4:186727e0bdea 669 lcd_.DisplayStringAt(680, 60, (uint8_t *)Status_Driver_S, LEFT_MODE); // Display main header text
haddad1995 2:4a0d3be00487 670
haddad1995 2:4a0d3be00487 671 sprintf(END_S, "%d", END);
haddad1995 2:4a0d3be00487 672 lcd_.SetFont(&Font24);
haddad1995 2:4a0d3be00487 673 lcd_.SetTextColor(LCD_COLOR_BLACK);
haddad1995 2:4a0d3be00487 674 lcd_.DisplayStringAt(150, 440, (uint8_t *)END_S, LEFT_MODE); // Display main header text
wsteenberg 0:ebf3f36f3a64 675 } // End Main program loop
wsteenberg 0:ebf3f36f3a64 676 } // End Main program
haddad1995 2:4a0d3be00487 677
haddad1995 2:4a0d3be00487 678
haddad1995 4:186727e0bdea 679 //--- functions "millis()" emulation -------------------------------------
haddad1995 2:4a0d3be00487 680
haddad1995 2:4a0d3be00487 681
haddad1995 2:4a0d3be00487 682 void InitMillis(void)
haddad1995 2:4a0d3be00487 683 {
haddad1995 2:4a0d3be00487 684 uS_Tick.attach (&mS_Tick, 0.001);
haddad1995 2:4a0d3be00487 685 }
haddad1995 2:4a0d3be00487 686
haddad1995 2:4a0d3be00487 687 void mS_Tick(void)
haddad1995 2:4a0d3be00487 688 {
haddad1995 2:4a0d3be00487 689 MillisVal++;
haddad1995 2:4a0d3be00487 690 }
haddad1995 2:4a0d3be00487 691 void Menu0(void)
haddad1995 2:4a0d3be00487 692 {
haddad1995 2:4a0d3be00487 693
haddad1995 2:4a0d3be00487 694 }