NYP

Dependencies:   LSM6DSL

Fork of a_NYP_humanoid by Lin ShengKun

main.cpp

Committer:
ha731548874
Date:
2018-05-02
Revision:
2:7d574b1ab3cd
Parent:
0:0ea84b3cf851
Child:
3:1345f959c490

File content as of revision 2:7d574b1ab3cd:

#include "mbed.h"
#include "rtos.h"

#include "accgyro.h"
//Serial pc(USBTX, USBRX);
DigitalOut led2(LED2);
Thread eventthread;
EventQueue eventqueue;

int main()
{   
    SERVO_init();
    ACCGYRO_init();
    eventthread.start(callback(&eventqueue, &EventQueue::dispatch_forever));
    //ACCGYRO_thread.start(ACCGYRO_init);
    //Thread::wait(osWaitForever);
    //eventqueue.call_every(1000, SERVO_task);
    eventqueue.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]);
    }
}