RPLIDAR A1M8 LCD

Dependencies:   TS_DISCO_F746NG mbed BufferedSerial LCD_DISCO_F746NG mbed-rtos Trigo BSP_DISCO_F746NG

Main.cpp

Committer:
Carminio
Date:
2016-11-24
Revision:
3:43ab856b5efa
Parent:
2:8f71c97fe9d7
Child:
4:0df95765b1b0

File content as of revision 3:43ab856b5efa:

#include "mbed.h"
#include "Serial.h"
#include "BufferedSerial.h"
#include "Communication.h"
#include "Motor.h"
#include <stdlib.h>
#include <stdio.h>
#include "LCD_DISCO_F746NG.h"
#include "TS_DISCO_F746NG.h"


//Dichiarazione oggetti
//DigitalIn myStartButton(USER_BUTTON);
InterruptIn myStopButton(USER_BUTTON);
Motor lid_Motor(PWM_OUT);
Communication SendCommands;
LCD_DISCO_F746NG lcd;
TS_DISCO_F746NG ts;

//Dichiarazione variabili
uint16_t x, y;
uint8_t idx;
uint8_t start=1;

void pressed()
{
  SendCommands.Stop();
  wait_ms(100);
  lid_Motor.StopMotor_Scan();
}


int main() {
//  Initialize Display
    lcd.Clear(LCD_COLOR_BLACK);
    lcd.SetBackColor(LCD_COLOR_BLACK);
    lcd.SetTextColor(LCD_COLOR_GREEN);
    wait(0.3);
    lcd.SetFont(&Font24);
    lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"SLAMTEC LIDAR A2", CENTER_MODE);
    lcd.SetFont(&Font8);
    lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"STMicroelectronics", RIGHT_MODE);
    lcd.DisplayStringAt(0, LINE(2), (uint8_t *)"D. Ruggiero 2016", RIGHT_MODE);

//  Configure buttons and TFT display
    TS_StateTypeDef TS_State;
    lcd.SetTextColor(LCD_COLOR_GREEN);
    lcd.FillRect(136, 200, 200, 50);  ///Disegna bottone Verde

    lcd.SetFont(&Font24);
    lcd.SetBackColor(LCD_COLOR_GREEN);
    lcd.SetTextColor(LCD_COLOR_BLACK);
    lcd.DisplayStringAt(202, LINE(9), (uint8_t *)"SCAN", LEFT_MODE);

  while(start) {
      
//    Initialize TFT display
      ts.GetState(&TS_State);
      if (TS_State.touchDetected) {
          for (idx = 0; idx < TS_State.touchDetected; idx++) {
                x = TS_State.touchX[idx];
                y = TS_State.touchY[idx];
          }

     if((x>=136) && (x<=336) && (y>=200) && (y<=250)) {    
     lcd.Clear(LCD_COLOR_BLACK);

//   Initialize UART
     SendCommands.confUART();

  // Perform a device reset
//   SendCommands.Reset();

  // Send Get_Health command
//   SendCommands.Get_Health();

  // Send Get_Info command
//   SendCommands.Get_Info();

  // Start motor (PWM: Frequency 25KHz, Duty cycle 60%)
     lid_Motor.StartMotor_Scan();
     
//   Start scan
     SendCommands.Scan();
     start=0;
        }
    }
 }

 //while(1) {
//    if (myStartButton == 1) { 
//        SendCommands.Stop();
//        wait_ms(100);
//        lid_Motor.StopMotor_Scan();
//   }
//  }

    //while(1) {
//    myStopButton.rise(&pressed);
//    }

    //while(1) {
//    //    Initialize TFT display
//      ts.GetState(&TS_State);
//      if (TS_State.touchDetected) {
//        SendCommands.Stop();
//        wait_ms(100);
//        lid_Motor.StopMotor_Scan();
//        }
//    }
}