svoe

Dependencies:   mbed mbed-STM32F103C8T6 MPU6050_1

main.cpp

Committer:
dima285
Date:
2019-08-06
Branch:
svoe
Revision:
23:bc05a104be10
Parent:
22:14e85f2068c7

File content as of revision 23:bc05a104be10:

#include "stm32f103c8t6.h"
#include "mbed.h"
#include "VL53L1X.h"
#include "common.h"
#include "gyro.h"
#include "motor.h"
#include "serva.h"
#include "echo.h"
#include "motion.h"
#include "wifi.h"
#include "realtime.h"
#include "system.h"
#include "sound.h"



int main() {
    //int k,l;
    wait_ms(500);
    system_init();
    start_recognizer();
    //play(1);
    delay_counter = 4;
    motion_flag = 0;
    motion_mode = STOP;
    serva(-90);
    serva_counter = 0;
    
    //wait(20);
   
    
    while(1){
        //myled = 1; //SMErT' !!!!!!! 
        while(realtime_flag == 0){}
        //myled = 0;
        //myled = 0; //inverse connection
        gyro.read(&gx,&gy,&gz,&ax,&ay,&az); //doesn't work in interrupt // reading - 500 uS 
        ax_filter();
//constant speed motion: distance_to_target = (x_diff/x_prop) * target.speed
        if (fall_flag == 1) vstavai();
        //balance_coord(); 
        balance_motion_PID();    
        if(external_command != 0) command_process(); 
        if (echo_delay_counter++ > 2) {echo_delay_counter = 0; rt_scan();}      //echo every 3 csycles
        free_walk();//motion
        //motion_1D();
        
        //voice_command_process();
        //if (k++ > 200) {k = 0;/*play(rand()%10+1);*/} else { target.x = trajectory[int(k/100)][0];target.y = trajectory[int(k/100)][1]; target.azimuth = trajectory[int(k/100)][2];}
        //if (l++ > 25) {l = 0; wifi.printf("%u", glaz.read());}
        realtime_flag = 0;// myled = 1;
        }
    //while(1){proc_counter++;}
}