kao yi
/
Bov3
wu
Fork of CCC by
servo_api.cpp@17:3dac99cf2b89, 2014-06-30 (annotated)
- Committer:
- backman
- Date:
- Mon Jun 30 03:37:05 2014 +0000
- Revision:
- 17:3dac99cf2b89
- Parent:
- 15:585df3979be8
wu
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
backman | 1:82bc25a7b68b | 1 | // 0~180 angle 1~2ms |
backman | 1:82bc25a7b68b | 2 | #include "mbed.h" |
backman | 1:82bc25a7b68b | 3 | #include "servo_api.h" |
backman | 1:82bc25a7b68b | 4 | |
backman | 1:82bc25a7b68b | 5 | |
backman | 15:585df3979be8 | 6 | #define right_end 0.037 //90 0.037 |
backman | 1:82bc25a7b68b | 7 | |
backman | 15:585df3979be8 | 8 | #define left_end 0.073 //-90 0.073 |
backman | 1:82bc25a7b68b | 9 | |
backman | 1:82bc25a7b68b | 10 | //memory opt |
backman | 1:82bc25a7b68b | 11 | // 5 degree seperate |
backman | 1:82bc25a7b68b | 12 | |
backman | 1:82bc25a7b68b | 13 | |
backman | 1:82bc25a7b68b | 14 | |
backman | 1:82bc25a7b68b | 15 | BX_servo::BX_servo(void){ |
backman | 1:82bc25a7b68b | 16 | |
backman | 1:82bc25a7b68b | 17 | |
backman | 1:82bc25a7b68b | 18 | angle = 0; |
backman | 1:82bc25a7b68b | 19 | |
backman | 1:82bc25a7b68b | 20 | servo_in= new PwmOut(PTB0); |
backman | 1:82bc25a7b68b | 21 | |
backman | 1:82bc25a7b68b | 22 | servo_in->period_ms(20); |
backman | 1:82bc25a7b68b | 23 | |
backman | 9:33b99cb45e99 | 24 | |
backman | 1:82bc25a7b68b | 25 | |
backman | 1:82bc25a7b68b | 26 | } |
backman | 1:82bc25a7b68b | 27 | |
backman | 1:82bc25a7b68b | 28 | |
backman | 1:82bc25a7b68b | 29 | |
backman | 1:82bc25a7b68b | 30 | |
backman | 1:82bc25a7b68b | 31 | |
backman | 1:82bc25a7b68b | 32 | |
backman | 9:33b99cb45e99 | 33 | float BX_servo::set_angle(float a){ |
backman | 15:585df3979be8 | 34 | |
backman | 15:585df3979be8 | 35 | /* |
backman | 10:03d5aa2511c4 | 36 | if( a>left_end ) |
backman | 10:03d5aa2511c4 | 37 | a=left_end; |
backman | 10:03d5aa2511c4 | 38 | else if(a< right_end) |
backman | 10:03d5aa2511c4 | 39 | a=right_end; |
backman | 15:585df3979be8 | 40 | */ |
backman | 10:03d5aa2511c4 | 41 | |
backman | 10:03d5aa2511c4 | 42 | |
backman | 10:03d5aa2511c4 | 43 | |
backman | 10:03d5aa2511c4 | 44 | |
backman | 1:82bc25a7b68b | 45 | |
backman | 1:82bc25a7b68b | 46 | angle=a; |
backman | 1:82bc25a7b68b | 47 | |
backman | 9:33b99cb45e99 | 48 | *servo_in=angle; |
backman | 1:82bc25a7b68b | 49 | |
backman | 1:82bc25a7b68b | 50 | |
backman | 1:82bc25a7b68b | 51 | |
backman | 1:82bc25a7b68b | 52 | return angle; |
backman | 1:82bc25a7b68b | 53 | |
backman | 1:82bc25a7b68b | 54 | } |