Kheirddine Zaillel / Mbed 2 deprecated ZAILLEL_Interface

Dependencies:   TS_DISCO_F746NG mbed BufferedSerial LCD_DISCO_F746NG mbed-rtos Trigo BSP_DISCO_F746NG

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Main.cpp Source File

Main.cpp

00001 #include "mbed.h"
00002 #include "rtos.h"
00003 #include "Serial.h"
00004 #include "BufferedSerial.h"
00005 #include "Communication.h"
00006 #include "Motor.h"
00007 #include <stdlib.h>
00008 #include <stdio.h>
00009 #include "LCD_DISCO_F746NG.h"
00010 #include "TS_DISCO_F746NG.h"
00011 #include "Capture.h"
00012 
00013 DigitalIn myStopButton(USER_BUTTON);
00014 Motor lid_Motor(PWM_OUT);
00015 Communication SendCommands;
00016 LCD_DISCO_F746NG lcd;
00017 TS_DISCO_F746NG ts;
00018 LCD_DISCO_F746NG lcd_Thread;
00019 
00020 
00021 TS_StateTypeDef TS_State;
00022 
00023 uint16_t x,y;
00024 uint8_t idx;
00025 uint8_t start=1;
00026 
00027 
00028 void Fond(int offsetX, int offsetY)
00029 {
00030     int x = 0;
00031     int y = 0;
00032     uint32_t* dataPtr = (uint32_t*)Capture.data;
00033     while(y < Capture.height) {
00034         while(x < Capture.width) {
00035             BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
00036             dataPtr++;
00037             x++;
00038         }
00039         x = 0;
00040         y++;
00041     }
00042 }
00043 
00044 void StopLidar_thread(void const *args) {                 
00045     wait(1);
00046     while(true) {
00047          if (myStopButton==1) {
00048                 SendCommands.Stop();
00049                 wait_ms(10);
00050                 lid_Motor.StopMotor_Scan();
00051                 wait_ms(10);
00052                 SendCommands.Reset();
00053                 wait_ms(10);
00054                 lcd_Thread.DisplayOff();
00055         }
00056      }
00057 }
00058 
00059 
00060 int main() {
00061     
00062     Thread StopLidar__th(StopLidar_thread);           // THREAD 
00063     
00064    /*    PREMIERE INTERFACE
00065    
00066     lcd.Clear(LCD_COLOR_BLACK);
00067     lcd.SetBackColor(LCD_COLOR_BLACK);
00068     lcd.SetTextColor(LCD_COLOR_GREEN);
00069     wait(0.3);
00070     lcd.SetFont(&Font24);
00071     lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"LIDAR ", CENTER_MODE);
00072     lcd.SetFont(&Font8);
00073     lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"K.ZAILLEL", RIGHT_MODE);
00074 
00075 
00076     lcd.SetTextColor(LCD_COLOR_GREEN);
00077     lcd.FillRect(136, 200, 200, 50);  
00078 
00079     lcd.SetFont(&Font24);
00080     lcd.SetBackColor(LCD_COLOR_GREEN);
00081     lcd.SetTextColor(LCD_COLOR_BLACK);
00082     lcd.DisplayStringAt(202, LINE(9), (uint8_t *)"SCAN", LEFT_MODE);*/
00083  
00084   while(start) {
00085       Fond(0,0);
00086       ts.GetState(&TS_State);                                  
00087       if (TS_State.touchDetected) {                                           
00088           for (idx = 0; idx < TS_State.touchDetected; idx++) {
00089                 x = TS_State.touchX[idx];
00090                 y = TS_State.touchY[idx];
00091           }
00092 
00093      if((x>=136) && (x<=336) && (y>=200) && (y<=250)) {               // Bouton SCAN  
00094     lcd.Clear(LCD_COLOR_BLACK);
00095     lcd.SetBackColor(LCD_COLOR_BLACK);
00096     lcd.SetTextColor(LCD_COLOR_GREEN);
00097     wait(0.3);
00098     lcd.SetFont(&Font16);
00099     lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Scanning ... ", CENTER_MODE);     
00100                 
00101           
00102    
00103 //   Init UART
00104      SendCommands.confUART();
00105 
00106   // RESET
00107 //   SendCommands.Reset();
00108 
00109   // Get_Health command
00110 //   SendCommands.Get_Health();
00111 
00112   //  Get_Info command
00113 //   SendCommands.Get_Info();
00114 
00115   // Start motor 
00116      lid_Motor.StartMotor_Scan();
00117      
00118 //   Scan
00119      SendCommands.Scan();
00120      start=0;
00121         }
00122     }
00123  }
00124    
00125 }
00126 
00127