Junjie Wang
/
humanoid
NYP
Fork of a_NYP_humanoid by
main.cpp@3:1345f959c490, 2018-05-02 (annotated)
- Committer:
- mr_wang
- Date:
- Wed May 02 07:49:13 2018 +0000
- Revision:
- 3:1345f959c490
- Parent:
- 2:7d574b1ab3cd
ahah
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mr_wang | 0:0ea84b3cf851 | 1 | #include "mbed.h" |
mr_wang | 0:0ea84b3cf851 | 2 | #include "rtos.h" |
mr_wang | 3:1345f959c490 | 3 | #include "servo.h" |
mr_wang | 0:0ea84b3cf851 | 4 | #include "accgyro.h" |
mr_wang | 0:0ea84b3cf851 | 5 | //Serial pc(USBTX, USBRX); |
mr_wang | 0:0ea84b3cf851 | 6 | DigitalOut led2(LED2); |
mr_wang | 3:1345f959c490 | 7 | Thread event_thread; |
mr_wang | 3:1345f959c490 | 8 | Thread ACCGYRO_thread; |
mr_wang | 3:1345f959c490 | 9 | Thread SERVO_thread; |
mr_wang | 3:1345f959c490 | 10 | EventQueue event_queue; |
mr_wang | 0:0ea84b3cf851 | 11 | |
mr_wang | 0:0ea84b3cf851 | 12 | int main() |
ha731548874 | 2:7d574b1ab3cd | 13 | { |
mr_wang | 3:1345f959c490 | 14 | ACCGYRO_thread.start(ACCGYRO_init); |
mr_wang | 3:1345f959c490 | 15 | SERVO_thread.start(SERVO_init); |
mr_wang | 3:1345f959c490 | 16 | //SERVO_init(); |
mr_wang | 3:1345f959c490 | 17 | //event_thread.start(callback(&event_queue, &EventQueue::dispatch_forever)); |
mr_wang | 3:1345f959c490 | 18 | //ACCGYRO_init(); |
mr_wang | 3:1345f959c490 | 19 | event_thread.start(callback(&event_queue, &EventQueue::dispatch_forever)); |
mr_wang | 0:0ea84b3cf851 | 20 | //Thread::wait(osWaitForever); |
mr_wang | 3:1345f959c490 | 21 | event_queue.call_every(1000, SERVO_task); |
mr_wang | 3:1345f959c490 | 22 | event_queue.call_every(1000, ACCGYRO_task); |
mr_wang | 0:0ea84b3cf851 | 23 | //q.dispatch(); |
mr_wang | 0:0ea84b3cf851 | 24 | //eventqueue.call_every(1000,printf,"LSM6DSL [acc/mg]: %6ld\r\n", ACCGYRO_get_gyro_x()); |
mr_wang | 0:0ea84b3cf851 | 25 | //q.dispatch(); |
mr_wang | 0:0ea84b3cf851 | 26 | while(1) |
mr_wang | 0:0ea84b3cf851 | 27 | { |
mr_wang | 3:1345f959c490 | 28 | //eventqueue.call(printf,"LSM6DSL [acc/mg]: %6ld\r\n", ACCGYRO_get_gyro_x()); |
mr_wang | 0:0ea84b3cf851 | 29 | led2 = !led2; |
mr_wang | 0:0ea84b3cf851 | 30 | wait(1); |
mr_wang | 0:0ea84b3cf851 | 31 | //q.dispatch(); |
mr_wang | 0:0ea84b3cf851 | 32 | //q.call(printf, "*\n"); |
mr_wang | 0:0ea84b3cf851 | 33 | //printf("*"); |
mr_wang | 0:0ea84b3cf851 | 34 | //Thread::wait(1000); |
mr_wang | 0:0ea84b3cf851 | 35 | //printf("LSM6DSL [acc/mg]: %6ld\r\n", ACCGYRO_get_gyro_x()); |
mr_wang | 0:0ea84b3cf851 | 36 | //printf("LSM6DSL [gyro/mdps]: %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]); |
mr_wang | 0:0ea84b3cf851 | 37 | } |
mr_wang | 0:0ea84b3cf851 | 38 | } |