NYP

Dependencies:   LSM6DSL

Fork of a_NYP_humanoid by Lin ShengKun

main.cpp

Committer:
mr_wang
Date:
2018-05-02
Revision:
3:1345f959c490
Parent:
2:7d574b1ab3cd

File content as of revision 3:1345f959c490:

#include "mbed.h"
#include "rtos.h"
#include "servo.h"
#include "accgyro.h"
//Serial pc(USBTX, USBRX);
DigitalOut led2(LED2);
Thread event_thread;
Thread ACCGYRO_thread;
Thread SERVO_thread;
EventQueue event_queue;

int main()
{   
    ACCGYRO_thread.start(ACCGYRO_init);
    SERVO_thread.start(SERVO_init);
    //SERVO_init();
    //event_thread.start(callback(&event_queue, &EventQueue::dispatch_forever));
    //ACCGYRO_init();
    event_thread.start(callback(&event_queue, &EventQueue::dispatch_forever));
    //Thread::wait(osWaitForever);
    event_queue.call_every(1000, SERVO_task);
    event_queue.call_every(1000, ACCGYRO_task);
    //q.dispatch();
    //eventqueue.call_every(1000,printf,"LSM6DSL [acc/mg]:        %6ld\r\n", ACCGYRO_get_gyro_x());
    //q.dispatch();
    while(1)
    {
        //eventqueue.call(printf,"LSM6DSL [acc/mg]:        %6ld\r\n", ACCGYRO_get_gyro_x());
        led2 = !led2;
        wait(1);
        //q.dispatch();
        //q.call(printf, "*\n"); 
        //printf("*");
        //Thread::wait(1000);
        //printf("LSM6DSL [acc/mg]:        %6ld\r\n", ACCGYRO_get_gyro_x());
        //printf("LSM6DSL [gyro/mdps]:     %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]);
    }
}