lcd lib
Dependencies: mbed LCD_DISCO_F469NI TS_DISCO_F469NI BSP_DISCO_F469NI EasyCAT_lib
Diff: main.cpp
- Revision:
- 2:4a0d3be00487
- Parent:
- 1:8574e7a8fcde
- Child:
- 4:186727e0bdea
--- a/main.cpp Fri Jul 12 12:04:18 2019 +0000 +++ b/main.cpp Fri Mar 11 09:18:13 2022 +0000 @@ -1,12 +1,10 @@ //--------------------------------------------------------------- // -// Demo program for -// F469_Button and Slider library -// //--------------------------------------------------------------- #include "mbed.h" #include "F469_BUTTON.hpp" #include "F469_SLIDER.hpp" +#include "EasyCAT.h" // EasyCAT library to interface the LAN9252 DigitalOut led_green(LED1); DigitalOut led_orange(LED2); @@ -16,10 +14,68 @@ TS_DISCO_F469NI ts_; LCD_DISCO_F469NI lcd_; +EasyCAT EASYCAT; // EasyCAT istantiation char char_SliderDisplayValue[4]; // String Value to display for the Slider Control value uint16_t SliderDisplayValue_; // Variable used to access Slider Control Value in F469SLIDER.cpp +//---- global variables --------------------------------------------------------------------------- +int menu = 0; + +UWORD ContaUp; // used for sawthoot test generation +UWORD ContaDown; // + +unsigned long Millis = 0; +unsigned long Millis2 = 0; +unsigned long PreviousSaw = 0; +unsigned long PreviousCycle = 0; + +int8_t stand = 0; // data to test +int8_t start = 0; // data to test +int8_t stepping = 0; // data to test +int8_t endStep = 0; // data to test + +int8_t enable = 0; // data to test +int8_t enable_Lateral = 0; // data to test +int8_t quick_Stop = 0; // data to test +int8_t clear_Fault = 0; // data to test + +float Standing_Time = 2.0 ; +char Standing_Time_S[10]; +float Step_Time = 2.0 ; +char Step_Time_S[10]; +float Wait_COM_Tr_Time = 0.5 ; +char Wait_COM_Tr_Time_S[10]; +int COM_Tr_Threshold = 20 ; +char COM_Tr_Threshold_S[10]; + +int8_t Ethercat = 0 ; +char Ethercat_S[10]; +float Running_Time = 0.0 ; +char Running_Time_S[20]; +int State_Step = 0 ; +char State_Step_S[10]; +int Status_Driver = 0 ; +char Status_Driver_S[10]; +int END = 0 ; +char END_S[10]; + +//---- declarations for Arduino "millis()" emulation ----------------------- + +static Ticker uS_Tick; +static volatile uint32_t MillisVal = 0; + +void InitMillis(void); +void mS_Tick(void); + +inline static uint32_t millis (void) +{ + return MillisVal; +}; + + + +//--------------------------------------------------------------------------------------------- int main() { led_green = 1; // Switch off all LEDs @@ -28,120 +84,530 @@ led_blue = 1; lcd_.Clear(LCD_COLOR_WHITE); // Set LCD Background colour - - // Slider sld1(lcd_, ts_, 20, 350, 220, 40, 5, 1, 20, - // LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 1, "Slider1", Font20); // Define sld1 slider - // sld1.Render(); // Draw sld1 Slider - - // Slider Slider2(lcd_, ts_, 300, 350, 300, 40, 50, 1, 100, - // LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "Slider2", Font20); // Define Slider2 slider - // Slider2.Render(); // Draw Slider2 Slider - - Button btn1(lcd_, ts_, 20, 100, 120, 60, - LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 1, "BUTTON1", Font20); // Define btn1 button - btn1.Render(); // Draw btn1 button - Button btn2(lcd_, ts_, 160, 100, 120, 60, - LCD_COLOR_DARKBLUE, LCD_COLOR_GREEN, 1, "BUTTON2", Font20); // Define test button - btn2.Render(); // Draw test button + // Set Text colour to Black + + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.SetFont(&Font24); // Font size 24 + lcd_.DisplayStringAt(10, 20, (uint8_t *)" Status EtherCAT: ", LEFT_MODE); // Display main header text + lcd_.SetFont(&Font24); + lcd_.DisplayStringAt(400, 20, (uint8_t *)" Running Time: ", LEFT_MODE); // Display main header text + lcd_.SetFont(&Font24); + lcd_.DisplayStringAt(10, 60, (uint8_t *)" State Step: ", LEFT_MODE); // Display main header text + lcd_.SetFont(&Font24); + lcd_.DisplayStringAt(400, 60, (uint8_t *)" Status Driver: ", LEFT_MODE); // Display main header text + lcd_.SetFont(&Font24); + lcd_.DisplayStringAt(10, 440, (uint8_t *)" END ? : ", LEFT_MODE); // Display main header text + lcd_.DrawHLine(20, 90, 760); + lcd_.DrawHLine(20, 91, 760); + + lcd_.SetTextColor(LCD_COLOR_RED); + lcd_.SetFont(&Font24); // Font size 24 + lcd_.DisplayStringAt(10, 110, (uint8_t *)" Driver Controle ", LEFT_MODE); // Display main header text + + Button btn1(lcd_, ts_, 20, 160, 160, 70, + LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, "Enable", Font20); // Define btn1 button + btn1.Render(); // Draw btn1 button + + Button btn2(lcd_, ts_, 220, 160, 160, 70, + LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, "Lateral", Font20); // Define test button + btn2.Render(); // Draw btn2 button + Button btn3(lcd_, ts_, 420, 160, 160, 70, + LCD_COLOR_BROWN, LCD_COLOR_GRAY, 1, "Quick Stop", Font20); // Define btn3 button + btn3.Render(); // Draw btn3 button - // Button show(lcd_, ts_, 300, 100, 120, 60, - // LCD_COLOR_BROWN, LCD_COLOR_GRAY, 1, "SHOW", Font20); // Define hide button - // show.Hide(); + Button btn4(lcd_, ts_, 620, 160, 160, 70, + LCD_COLOR_BROWN, LCD_COLOR_GRAY, 1, "Clear Fault", Font20); // Define btn4 button + btn4.Render(); // Draw btn3 button - // Button hide(lcd_, ts_, 300, 100, 120, 60, - // LCD_COLOR_BROWN, LCD_COLOR_GRAY, 1, "HIDE", Font20); // Define hide button - // hide.Render(); // Draw hide button + lcd_.SetTextColor(LCD_COLOR_RED); + lcd_.SetFont(&Font24); // Font size 24 + lcd_.DisplayStringAt(10, 250, (uint8_t *)" Step Control ", LEFT_MODE); // Display main header text + + + Button button3D1(lcd_, ts_, 20, 300, 160, 70, + LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "Stand", Font20); // Define button3D1 button + button3D1.Render(); - // Button button3D(lcd_, ts_, 580, 100, 160, 60, - // LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "3D BUTTON", Font20); // Define button3D button - // button3D.Render(); // Draw 3Dbutton button - - + Button button3D2(lcd_, ts_, 220, 300, 160, 70, + LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "Start", Font20); // Define button3D2 button + button3D2.Render(); + + Button button3D3(lcd_, ts_, 420, 300, 160, 70, + LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "Stepping", Font20); // Define button3D3 button + button3D3.Render(); + Button button3D4(lcd_, ts_, 620, 300, 160, 70, + LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "EndStep", Font20); // Define button3D3 button + button3D4.Render(); + + lcd_.SetTextColor(LCD_COLOR_RED); + lcd_.SetFont(&Font24); // Font size 24 + lcd_.DisplayStringAt(280, 440, (uint8_t *)" MOTION PROJECT ", LEFT_MODE); // Display main header text + + Button btn5(lcd_, ts_, 660, 410, 120, 60, + LCD_COLOR_ORANGE, LCD_COLOR_GRAY, 1, "Next", Font20); // Define btn4 button + btn5.Render(); + + // printf ("\nEasyCAT - Generic EtherCAT slave\n"); // print the banner - lcd_.SetTextColor(LCD_COLOR_BLACK); // Set Text colour to Black - lcd_.SetFont(&Font20); // Font size 20 - lcd_.DisplayStringAt(5, 5, (uint8_t *)"Button example for DISCO_F469", LEFT_MODE); // Display main header text + InitMillis(); // init Arduino "millis()" emulation - lcd_.SetFont(&Font16); // Font size 16 - lcd_.DisplayStringAt(5, 45, (uint8_t *)"More text", LEFT_MODE); // Display secondary header text - + ContaDown.Word = 0x0000; + ContaUp.Word = 0x0000; while (true) // Main program loop - { + { led_green = 1; // Switch off all LEDs led_orange = 1; led_red = 1; - led_blue = 1; - - - + led_blue = 1; + + if (btn1.Press() ) // Check if btn1 button was touched and run instructions if true + { + if (enable==0) + { + enable=1; + } + else enable=0; + lcd_.SetFont(&Font16); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(5, 460, (uint8_t *)"Enable pressed - switch on orange LED", LEFT_MODE); + led_orange = 0; + wait(0.2); + lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE); + + } + // End btn1 button instructions + if (btn2.Press()) // Check if test button was touched and run instructions if true + { + if (enable_Lateral==0) + { + enable_Lateral=1; + } + else enable_Lateral=0; + lcd_.SetFont(&Font16); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(5, 460, (uint8_t *)"Enable Lateral pressed - switch on red LED", LEFT_MODE); + led_red = 0; + wait(0.2); + lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE); + + } // End test button instructions - - - - - if (btn1.Press()) // Check if btn1 button was touched and run instructions if true + if (btn3.Press()) // Check if 3Dbutton button was touched and run instructions if true { + if (quick_Stop==0) + { + quick_Stop=1; + } + else quick_Stop=0; lcd_.SetFont(&Font16); lcd_.SetTextColor(LCD_COLOR_BLACK); - lcd_.DisplayStringAt(5, 200, (uint8_t *)"Button1 pressed - switch on orange LED", LEFT_MODE); - led_orange = 0; - wait(0.5); - lcd_.DisplayStringAt(5, 200, (uint8_t *)" ", LEFT_MODE); - } // End btn1 button instructions - - if (btn2.Press()) // Check if test button was touched and run instructions if true + lcd_.DisplayStringAt(5, 460, (uint8_t *)"Quick Stop pressed - switch on blue LED", LEFT_MODE); + led_blue = 0; + wait(0.2); + lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE); + } // End 3D button instructions + if (btn4.Press()) // Check if test button was touched and run instructions if true { + if (clear_Fault==0) + { + clear_Fault=1; + } + else clear_Fault=0; lcd_.SetFont(&Font16); lcd_.SetTextColor(LCD_COLOR_BLACK); - lcd_.DisplayStringAt(5, 200, (uint8_t *)"TEST pressed - switch on red LED", LEFT_MODE); + lcd_.DisplayStringAt(5, 460, (uint8_t *)"Clear Fault pressed - switch on red LED", LEFT_MODE); led_red = 0; - wait(0.5); - lcd_.DisplayStringAt(5, 200, (uint8_t *)" ", LEFT_MODE); + wait(0.2); + lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE); + + } + + + if (button3D1.Press() ) // Check if btn1 button was touched and run instructions if true + { + if (stand==0) + { + stand=1; + } + else stand=0; + lcd_.SetFont(&Font16); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(5, 460, (uint8_t *)"Stand pressed - switch on orange LED", LEFT_MODE); + led_orange = 0; + wait(0.2); + lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE); + + } + // End btn1 button instructions + + if (button3D2.Press()) // Check if test button was touched and run instructions if true + { + if (start==0) + { + start=1; + } + else start=0; + lcd_.SetFont(&Font16); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(5, 460, (uint8_t *)"Start pressed - switch on red LED", LEFT_MODE); + led_red = 0; + wait(0.2); + lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE); } // End test button instructions - /* if (hide.Press()) // Check if hide button was touched and run instructions if true + if (button3D3.Press()) // Check if 3Dbutton button was touched and run instructions if true { + if (stepping==0) + { + stepping=1; + } + else stepping=0; lcd_.SetFont(&Font16); lcd_.SetTextColor(LCD_COLOR_BLACK); - lcd_.DisplayStringAt(5, 200, (uint8_t *)"Hide pressed - Hide other buttons", LEFT_MODE); - led_green = 0; - btn1.Hide(); // Hide btn1 button - test.Hide(); // Hide test button - hide.Hide(); - show.Render(); - wait(0.5); - lcd_.DisplayStringAt(5, 200, (uint8_t *)" ", LEFT_MODE); - } // End hide button instructions - + lcd_.DisplayStringAt(5, 460, (uint8_t *)"Stepping pressed - switch on blue LED", LEFT_MODE); + led_blue = 0; + wait(0.2); + lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE); + } - if (show.Press()) // Check if hide button was touched and run instructions if true - { + if (button3D4.Press()) // Check if 3Dbutton button was touched and run instructions if true + { + if (endStep==0) + { + endStep=1; + } + else endStep=0; lcd_.SetFont(&Font16); lcd_.SetTextColor(LCD_COLOR_BLACK); - lcd_.DisplayStringAt(5, 200, (uint8_t *)"UNHIDE pressed - Restore other buttons", LEFT_MODE); - led_blue = 0; - wait(0.5); - lcd_.DisplayStringAt(5, 200, (uint8_t *)" ", LEFT_MODE); - show.Hide(); // Hide show button before drawing new button in same place - hide.Render(); // Draw hide button after hiding button in same position - btn1.Render(); // Draw btn1 button - test.Render(); // Draw test button - - } + lcd_.DisplayStringAt(5, 460, (uint8_t *)"EndStep pressed - switch on blue LED", LEFT_MODE); + led_blue = 0; + wait(0.2); + lcd_.DisplayStringAt(5, 460, (uint8_t *)" ", LEFT_MODE); + } - if (button3D.Press()) // Check if 3Dbutton button was touched and run instructions if true - { - lcd_.SetFont(&Font16); + if ( btn5.Press() ) // Check if btn1 button was touched and run instructions if true + { menu = 1 ; + lcd_.Clear(LCD_COLOR_WHITE); + led_orange = 0; + wait(0.1); + led_orange = 1; // Set LCD Background colour + + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.SetFont(&Font24); // Font size 24 + lcd_.DisplayStringAt(20, 65, (uint8_t *)"Standing Time", LEFT_MODE); // Display main header text + sprintf(Standing_Time_S, "%0.2f", Standing_Time); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(320, 65, (uint8_t *)Standing_Time_S, LEFT_MODE); + Button btn11(lcd_, ts_, 400, 40, 160, 70, + LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, " + ", Font24); // Define btn1 button + btn11.Render(); + Button btn12(lcd_, ts_, 600, 40, 160, 70, + LCD_COLOR_RED , LCD_COLOR_DARKBLUE, 1, " - ", Font24); // Define btn1 button + btn12.Render(); + + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.SetFont(&Font24); // Font size 24 + lcd_.DisplayStringAt(20, 165, (uint8_t *)"Step Time", LEFT_MODE); // Display main header text + sprintf(Step_Time_S, "%0.2f", Step_Time); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(320, 165, (uint8_t *)Step_Time_S, LEFT_MODE); + Button btn13(lcd_, ts_, 400, 140, 160, 70, + LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, " + ", Font24); // Define btn1 button + btn13.Render(); + Button btn14(lcd_, ts_, 600, 140, 160, 70, + LCD_COLOR_RED , LCD_COLOR_DARKBLUE, 1, " - ", Font24); // Define btn1 button + btn14.Render(); + + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.SetFont(&Font24); // Font size 24 + lcd_.DisplayStringAt(20, 265, (uint8_t *)"Wait COM Tr Time", LEFT_MODE); // Display main header text + sprintf(Wait_COM_Tr_Time_S, "%0.2f", Wait_COM_Tr_Time); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(320, 265, (uint8_t *)Wait_COM_Tr_Time_S, LEFT_MODE); + Button btn15(lcd_, ts_, 400, 240, 160, 70, + LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, " + ", Font24); // Define btn1 button + btn15.Render(); + Button btn16(lcd_, ts_, 600, 240, 160, 70, + LCD_COLOR_RED , LCD_COLOR_DARKBLUE, 1, " - ", Font24); // Define btn1 button + btn16.Render(); + + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.SetFont(&Font24); // Font size 24 + lcd_.DisplayStringAt(20, 365, (uint8_t *)"COM Tr Threshold", LEFT_MODE); // Display main header text + sprintf(COM_Tr_Threshold_S, "%d", COM_Tr_Threshold); + lcd_.SetFont(&Font24); lcd_.SetTextColor(LCD_COLOR_BLACK); - lcd_.DisplayStringAt(5, 200, (uint8_t *)"3D Button pressed - switch on blue LED", LEFT_MODE); - led_blue = 0; - wait(0.5); - lcd_.DisplayStringAt(5, 200, (uint8_t *)" ", LEFT_MODE); - } // End 3D button instructions -*/ + lcd_.DisplayStringAt(320, 365, (uint8_t *)COM_Tr_Threshold_S, LEFT_MODE); + lcd_.DisplayStringAt(370, 365, (uint8_t *)"%", LEFT_MODE); + Button btn17(lcd_, ts_, 400, 340, 160, 70, + LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, " + ", Font24); // Define btn1 button + btn17.Render(); + Button btn18(lcd_, ts_, 600, 340, 160, 70, + LCD_COLOR_RED , LCD_COLOR_DARKBLUE, 1, " - ", Font24); // Define btn1 button + btn18.Render(); + + Button btn6(lcd_, ts_, 20, 410, 120, 60, + LCD_COLOR_ORANGE, LCD_COLOR_GRAY, 1, "Back", Font20); // Define btn4 button + btn6.Render(); + + lcd_.SetTextColor(LCD_COLOR_RED); + lcd_.SetFont(&Font24); // Font size 24 + lcd_.DisplayStringAt(280, 440, (uint8_t *)" MOTION PROJECT ", LEFT_MODE); // Display main header text + + while (menu==1) + { if (btn11.Press() ) // Check if btn1 button was touched and run instructions if true + { + Standing_Time = Standing_Time + 0.5 ; + sprintf(Standing_Time_S, "%0.2f", Standing_Time); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(320, 65, (uint8_t *)" ", LEFT_MODE); + lcd_.DisplayStringAt(320, 65, (uint8_t *)Standing_Time_S, LEFT_MODE); + + } + if (btn12.Press() ) // Check if btn1 button was touched and run instructions if true + { if (Standing_Time>0) + { + Standing_Time = Standing_Time - 0.5 ; + sprintf(Standing_Time_S, "%0.2f", Standing_Time); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(320, 65, (uint8_t *)" ", LEFT_MODE); + lcd_.DisplayStringAt(320, 65, (uint8_t *)Standing_Time_S, LEFT_MODE); + } + } + if (btn13.Press() ) // Check if btn1 button was touched and run instructions if true + { + Step_Time = Step_Time + 0.5 ; + sprintf(Step_Time_S, "%0.2f", Step_Time); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(320, 165, (uint8_t *)" ", LEFT_MODE); + lcd_.DisplayStringAt(320, 165, (uint8_t *)Step_Time_S, LEFT_MODE); + + } + if (btn14.Press() ) // Check if btn1 button was touched and run instructions if true + { if (Step_Time>0) + { + Step_Time = Step_Time - 0.5 ; + sprintf(Step_Time_S, "%0.2f", Step_Time); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(320, 165, (uint8_t *)" ", LEFT_MODE); + lcd_.DisplayStringAt(320, 165, (uint8_t *)Step_Time_S, LEFT_MODE); + } + } + if (btn15.Press() ) // Check if btn1 button was touched and run instructions if true + { + Wait_COM_Tr_Time = Wait_COM_Tr_Time + 0.5 ; + sprintf(Wait_COM_Tr_Time_S, "%0.2f", Wait_COM_Tr_Time); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(320, 265, (uint8_t *)" ", LEFT_MODE); + lcd_.DisplayStringAt(320, 265, (uint8_t *)Wait_COM_Tr_Time_S, LEFT_MODE); + + } + if (btn16.Press() ) // Check if btn1 button was touched and run instructions if true + { if (Wait_COM_Tr_Time>0) + { + Wait_COM_Tr_Time = Wait_COM_Tr_Time - 0.5 ; + sprintf(Wait_COM_Tr_Time_S, "%0.2f", Wait_COM_Tr_Time); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(320, 265, (uint8_t *)" ", LEFT_MODE); + lcd_.DisplayStringAt(320, 265, (uint8_t *)Wait_COM_Tr_Time_S, LEFT_MODE); + } + } + if (btn17.Press() ) // Check if btn1 button was touched and run instructions if true + { + COM_Tr_Threshold = COM_Tr_Threshold + 5 ; + sprintf(COM_Tr_Threshold_S, "%d", COM_Tr_Threshold); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(320, 365, (uint8_t *)" ", LEFT_MODE); + lcd_.DisplayStringAt(320, 365, (uint8_t *)COM_Tr_Threshold_S, LEFT_MODE); + + } + if (btn18.Press() ) // Check if btn1 button was touched and run instructions if true + { if (COM_Tr_Threshold>0) + { + COM_Tr_Threshold = COM_Tr_Threshold - 5 ; + sprintf(COM_Tr_Threshold_S, "%d", COM_Tr_Threshold); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(320, 365, (uint8_t *)" ", LEFT_MODE); + lcd_.DisplayStringAt(320, 365, (uint8_t *)COM_Tr_Threshold_S, LEFT_MODE); + } + } + if (btn6.Press() ) // Check if btn1 button was touched and run instructions if true + { + menu=0; + led_orange = 0; + lcd_.Clear(LCD_COLOR_WHITE); // Set LCD Background colour + lcd_.SetTextColor(LCD_COLOR_BLACK); // Set Text colour to Black + lcd_.SetFont(&Font24); // Font size 24 + lcd_.DisplayStringAt(10, 20, (uint8_t *)" Status EtherCAT: ", LEFT_MODE); // Display main header text + lcd_.SetFont(&Font24); + lcd_.DisplayStringAt(400, 20, (uint8_t *)" Running Time: ", LEFT_MODE); // Display main header text + lcd_.SetFont(&Font24); + lcd_.DisplayStringAt(10, 60, (uint8_t *)" State Step: ", LEFT_MODE); // Display main header text + lcd_.SetFont(&Font24); + lcd_.DisplayStringAt(400, 60, (uint8_t *)" Status Driver: ", LEFT_MODE); // Display main header text + lcd_.SetFont(&Font24); + lcd_.DisplayStringAt(10, 440, (uint8_t *)" END ? : ", LEFT_MODE); // Display main header text + lcd_.DrawHLine(20, 90, 760); + lcd_.DrawHLine(20, 91, 760); + + lcd_.SetTextColor(LCD_COLOR_RED); + lcd_.SetFont(&Font24); // Font size 24 + lcd_.DisplayStringAt(10, 110, (uint8_t *)" Driver Controle ", LEFT_MODE); // Display main header text + + Button btn1(lcd_, ts_, 20, 160, 160, 70, + LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, "Enable", Font20); // Define btn1 button + btn1.Render(); // Draw btn1 button + + Button btn2(lcd_, ts_, 220, 160, 160, 70, + LCD_COLOR_GREEN , LCD_COLOR_DARKBLUE, 1, "Lateral", Font20); // Define test button + btn2.Render(); // Draw btn2 button + Button btn3(lcd_, ts_, 420, 160, 160, 70, + LCD_COLOR_BROWN, LCD_COLOR_GRAY, 1, "Quick Stop", Font20); // Define btn3 button + btn3.Render(); // Draw btn3 button + + Button btn4(lcd_, ts_, 620, 160, 160, 70, + LCD_COLOR_BROWN, LCD_COLOR_GRAY, 1, "Clear Fault", Font20); // Define btn4 button + btn4.Render(); // Draw btn3 button + + lcd_.SetTextColor(LCD_COLOR_RED); + lcd_.SetFont(&Font24); // Font size 24 + lcd_.DisplayStringAt(10, 250, (uint8_t *)" Step Control ", LEFT_MODE); // Display main header text + + + Button button3D1(lcd_, ts_, 20, 300, 160, 70, + LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "Stand", Font20); // Define button3D1 button + button3D1.Render(); + + Button button3D2(lcd_, ts_, 220, 300, 160, 70, + LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "Start", Font20); // Define button3D2 button + button3D2.Render(); + + Button button3D3(lcd_, ts_, 420, 300, 160, 70, + LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "Stepping", Font20); // Define button3D3 button + button3D3.Render(); + Button button3D4(lcd_, ts_, 620, 300, 160, 70, + LCD_COLOR_BLUE, LCD_COLOR_YELLOW, 2, "EndStep", Font20); // Define button3D3 button + button3D4.Render(); + + lcd_.SetTextColor(LCD_COLOR_RED); + lcd_.SetFont(&Font24); // Font size 24 + lcd_.DisplayStringAt(280, 440, (uint8_t *)" MOTION PROJECT ", LEFT_MODE); // Display main header text + + Button btn5(lcd_, ts_, 660, 410, 120, 60, + LCD_COLOR_ORANGE, LCD_COLOR_GRAY, 1, "Next", Font20); // Define btn4 button + btn5.Render(); + + wait(0.2); + } + wait(0.02f); + } + } // End test button instructions // End 3D button instructions + wait(0.02f); + + Millis = millis(); // + if (Millis - PreviousCycle >= 10) // each 10 mS + { // + PreviousCycle = Millis; // + + EASYCAT.MainTask(); // execute the EasyCAT task + + + + EASYCAT.BufferIn.Cust.Standing_Time_T= Standing_Time; + + EASYCAT.BufferIn.Cust.Step_Time_T= Step_Time; + + EASYCAT.BufferIn.Cust.Wait_COM_Tr_Time_T= Wait_COM_Tr_Time; + + EASYCAT.BufferIn.Cust.COM_Tr_Threshold_T= (COM_Tr_Threshold/100); + + + + EASYCAT.BufferIn.Cust.Stand= stand; + + EASYCAT.BufferIn.Cust.Start = start; + + EASYCAT.BufferIn.Cust.Stepping = stepping; + + EASYCAT.BufferIn.Cust.EndStep = endStep; + + EASYCAT.BufferIn.Cust.Enable= enable; + + EASYCAT.BufferIn.Cust.EnableLateral = enable_Lateral; + + EASYCAT.BufferIn.Cust.QuickStop = quick_Stop; + + EASYCAT.BufferIn.Cust.ClearFault = clear_Fault; + + //Ethercat = EASYCAT.BufferOut.Cust.EtherCAT; + + //Running_Time = EASYCAT.BufferOut.Cust.Running_Time_T ; + + //State_Step = EASYCAT.BufferOut.Cust.State_Step_T ; + + //Status_Driver = EASYCAT.BufferOut.Cust.Status_Driver_T ; + + //END = EASYCAT.BufferOut.Cust.END_T ; + + + } + sprintf(Ethercat_S, "%d", Ethercat); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(320, 20, (uint8_t *)Ethercat_S, LEFT_MODE); // Display main header text + + + sprintf(Running_Time_S, "%0.2f", Running_Time); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(700, 20, (uint8_t *)Running_Time_S, LEFT_MODE); // Display main header text + + sprintf(State_Step_S, "%d", State_Step); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(320, 60, (uint8_t *)State_Step_S, LEFT_MODE); // Display main header text + + sprintf(Status_Driver_S, "%d", Status_Driver); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(700, 60, (uint8_t *)Status_Driver_S, LEFT_MODE); // Display main header text + + sprintf(END_S, "%d", END); + lcd_.SetFont(&Font24); + lcd_.SetTextColor(LCD_COLOR_BLACK); + lcd_.DisplayStringAt(150, 440, (uint8_t *)END_S, LEFT_MODE); // Display main header text } // End Main program loop } // End Main program + + +//--- functions for Arduino "millis()" emulation ------------------------------------- + + +void InitMillis(void) +{ + uS_Tick.attach (&mS_Tick, 0.001); +} + +void mS_Tick(void) +{ + MillisVal++; +} +void Menu0(void) +{ + + } \ No newline at end of file