Lidar

Dependencies:   TS_DISCO_F746NG mbed BufferedSerial LCD_DISCO_F746NG mbed-rtos Trigo BSP_DISCO_F746NG

Committer:
Carminio
Date:
Thu Nov 24 09:50:36 2016 +0000
Revision:
3:43ab856b5efa
Parent:
2:8f71c97fe9d7
Child:
4:0df95765b1b0
Ver. ok debug pulsante stop

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Carminio 0:88706d6abbf7 1 #include "mbed.h"
Carminio 0:88706d6abbf7 2 #include "Serial.h"
Carminio 0:88706d6abbf7 3 #include "BufferedSerial.h"
Carminio 0:88706d6abbf7 4 #include "Communication.h"
Carminio 0:88706d6abbf7 5 #include "Motor.h"
Carminio 0:88706d6abbf7 6 #include <stdlib.h>
Carminio 0:88706d6abbf7 7 #include <stdio.h>
Carminio 0:88706d6abbf7 8 #include "LCD_DISCO_F746NG.h"
Carminio 1:1ff3fe3679c1 9 #include "TS_DISCO_F746NG.h"
Carminio 0:88706d6abbf7 10
Carminio 3:43ab856b5efa 11
Carminio 0:88706d6abbf7 12 //Dichiarazione oggetti
Carminio 3:43ab856b5efa 13 //DigitalIn myStartButton(USER_BUTTON);
Carminio 3:43ab856b5efa 14 InterruptIn myStopButton(USER_BUTTON);
Carminio 0:88706d6abbf7 15 Motor lid_Motor(PWM_OUT);
Carminio 0:88706d6abbf7 16 Communication SendCommands;
Carminio 1:1ff3fe3679c1 17 LCD_DISCO_F746NG lcd;
Carminio 1:1ff3fe3679c1 18 TS_DISCO_F746NG ts;
Carminio 1:1ff3fe3679c1 19
Carminio 1:1ff3fe3679c1 20 //Dichiarazione variabili
Carminio 1:1ff3fe3679c1 21 uint16_t x, y;
Carminio 1:1ff3fe3679c1 22 uint8_t idx;
Carminio 2:8f71c97fe9d7 23 uint8_t start=1;
Carminio 0:88706d6abbf7 24
Carminio 3:43ab856b5efa 25 void pressed()
Carminio 3:43ab856b5efa 26 {
Carminio 3:43ab856b5efa 27 SendCommands.Stop();
Carminio 3:43ab856b5efa 28 wait_ms(100);
Carminio 3:43ab856b5efa 29 lid_Motor.StopMotor_Scan();
Carminio 3:43ab856b5efa 30 }
Carminio 3:43ab856b5efa 31
Carminio 3:43ab856b5efa 32
Carminio 0:88706d6abbf7 33 int main() {
Carminio 0:88706d6abbf7 34 // Initialize Display
Carminio 0:88706d6abbf7 35 lcd.Clear(LCD_COLOR_BLACK);
Carminio 0:88706d6abbf7 36 lcd.SetBackColor(LCD_COLOR_BLACK);
Carminio 0:88706d6abbf7 37 lcd.SetTextColor(LCD_COLOR_GREEN);
Carminio 0:88706d6abbf7 38 wait(0.3);
Carminio 0:88706d6abbf7 39 lcd.SetFont(&Font24);
Carminio 0:88706d6abbf7 40 lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"SLAMTEC LIDAR A2", CENTER_MODE);
Carminio 2:8f71c97fe9d7 41 lcd.SetFont(&Font8);
Carminio 2:8f71c97fe9d7 42 lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"STMicroelectronics", RIGHT_MODE);
Carminio 2:8f71c97fe9d7 43 lcd.DisplayStringAt(0, LINE(2), (uint8_t *)"D. Ruggiero 2016", RIGHT_MODE);
Carminio 2:8f71c97fe9d7 44
Carminio 1:1ff3fe3679c1 45 // Configure buttons and TFT display
Carminio 1:1ff3fe3679c1 46 TS_StateTypeDef TS_State;
Carminio 1:1ff3fe3679c1 47 lcd.SetTextColor(LCD_COLOR_GREEN);
Carminio 2:8f71c97fe9d7 48 lcd.FillRect(136, 200, 200, 50); ///Disegna bottone Verde
Carminio 2:8f71c97fe9d7 49
Carminio 2:8f71c97fe9d7 50 lcd.SetFont(&Font24);
Carminio 1:1ff3fe3679c1 51 lcd.SetBackColor(LCD_COLOR_GREEN);
Carminio 1:1ff3fe3679c1 52 lcd.SetTextColor(LCD_COLOR_BLACK);
Carminio 2:8f71c97fe9d7 53 lcd.DisplayStringAt(202, LINE(9), (uint8_t *)"SCAN", LEFT_MODE);
Carminio 2:8f71c97fe9d7 54
Carminio 2:8f71c97fe9d7 55 while(start) {
Carminio 1:1ff3fe3679c1 56
Carminio 1:1ff3fe3679c1 57 // Initialize TFT display
Carminio 1:1ff3fe3679c1 58 ts.GetState(&TS_State);
Carminio 1:1ff3fe3679c1 59 if (TS_State.touchDetected) {
Carminio 1:1ff3fe3679c1 60 for (idx = 0; idx < TS_State.touchDetected; idx++) {
Carminio 1:1ff3fe3679c1 61 x = TS_State.touchX[idx];
Carminio 1:1ff3fe3679c1 62 y = TS_State.touchY[idx];
Carminio 1:1ff3fe3679c1 63 }
Carminio 2:8f71c97fe9d7 64
Carminio 2:8f71c97fe9d7 65 if((x>=136) && (x<=336) && (y>=200) && (y<=250)) {
Carminio 2:8f71c97fe9d7 66 lcd.Clear(LCD_COLOR_BLACK);
Carminio 0:88706d6abbf7 67
Carminio 0:88706d6abbf7 68 // Initialize UART
Carminio 0:88706d6abbf7 69 SendCommands.confUART();
Carminio 0:88706d6abbf7 70
Carminio 0:88706d6abbf7 71 // Perform a device reset
Carminio 0:88706d6abbf7 72 // SendCommands.Reset();
Carminio 0:88706d6abbf7 73
Carminio 0:88706d6abbf7 74 // Send Get_Health command
Carminio 0:88706d6abbf7 75 // SendCommands.Get_Health();
Carminio 0:88706d6abbf7 76
Carminio 0:88706d6abbf7 77 // Send Get_Info command
Carminio 0:88706d6abbf7 78 // SendCommands.Get_Info();
Carminio 0:88706d6abbf7 79
Carminio 0:88706d6abbf7 80 // Start motor (PWM: Frequency 25KHz, Duty cycle 60%)
Carminio 0:88706d6abbf7 81 lid_Motor.StartMotor_Scan();
Carminio 3:43ab856b5efa 82
Carminio 0:88706d6abbf7 83 // Start scan
Carminio 0:88706d6abbf7 84 SendCommands.Scan();
Carminio 2:8f71c97fe9d7 85 start=0;
Carminio 2:8f71c97fe9d7 86 }
Carminio 1:1ff3fe3679c1 87 }
Carminio 0:88706d6abbf7 88 }
Carminio 3:43ab856b5efa 89
Carminio 3:43ab856b5efa 90 //while(1) {
Carminio 3:43ab856b5efa 91 // if (myStartButton == 1) {
Carminio 3:43ab856b5efa 92 // SendCommands.Stop();
Carminio 3:43ab856b5efa 93 // wait_ms(100);
Carminio 3:43ab856b5efa 94 // lid_Motor.StopMotor_Scan();
Carminio 3:43ab856b5efa 95 // }
Carminio 3:43ab856b5efa 96 // }
Carminio 3:43ab856b5efa 97
Carminio 3:43ab856b5efa 98 //while(1) {
Carminio 3:43ab856b5efa 99 // myStopButton.rise(&pressed);
Carminio 3:43ab856b5efa 100 // }
Carminio 3:43ab856b5efa 101
Carminio 3:43ab856b5efa 102 //while(1) {
Carminio 3:43ab856b5efa 103 // // Initialize TFT display
Carminio 3:43ab856b5efa 104 // ts.GetState(&TS_State);
Carminio 3:43ab856b5efa 105 // if (TS_State.touchDetected) {
Carminio 3:43ab856b5efa 106 // SendCommands.Stop();
Carminio 3:43ab856b5efa 107 // wait_ms(100);
Carminio 3:43ab856b5efa 108 // lid_Motor.StopMotor_Scan();
Carminio 3:43ab856b5efa 109 // }
Carminio 3:43ab856b5efa 110 // }
Carminio 0:88706d6abbf7 111 }
Carminio 3:43ab856b5efa 112
Carminio 3:43ab856b5efa 113