Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
rc.h
00001 Timer tick; 00002 InterruptIn rc(p11); 00003 short buf_ppm[6]; 00004 char i = 0, idx, cnt = 0; 00005 00006 00007 void get_PPM(){ 00008 switch (idx){ 00009 case 1: 00010 RC.roll = buf_ppm[2]; 00011 RC.throttle = buf_ppm[3]; 00012 RC.pitch = buf_ppm[4]; 00013 RC.yaw = buf_ppm[5]; 00014 RC.sw = buf_ppm[0]; 00015 break; 00016 00017 case 2: 00018 RC.roll = buf_ppm[3]; 00019 RC.throttle = buf_ppm[4]; 00020 RC.pitch = buf_ppm[5]; 00021 RC.yaw = buf_ppm[0]; 00022 RC.sw = buf_ppm[1]; 00023 break; 00024 00025 case 3: 00026 RC.roll = buf_ppm[4]; 00027 RC.throttle = buf_ppm[5]; 00028 RC.pitch = buf_ppm[0]; 00029 RC.yaw = buf_ppm[1]; 00030 RC.sw = buf_ppm[2]; 00031 break; 00032 00033 case 4: 00034 RC.roll = buf_ppm[5]; 00035 RC.throttle = buf_ppm[0]; 00036 RC.pitch = buf_ppm[1]; 00037 RC.yaw = buf_ppm[2]; 00038 RC.sw = buf_ppm[3]; 00039 break; 00040 00041 case 5: 00042 RC.roll = buf_ppm[0]; 00043 RC.throttle = buf_ppm[1]; 00044 RC.pitch = buf_ppm[2]; 00045 RC.yaw = buf_ppm[3]; 00046 RC.sw = buf_ppm[4]; 00047 break; 00048 00049 case 0: 00050 RC.roll = buf_ppm[1]; 00051 RC.throttle = buf_ppm[2]; 00052 RC.pitch = buf_ppm[3]; 00053 RC.yaw = buf_ppm[4]; 00054 RC.sw = buf_ppm[5]; 00055 break; 00056 00057 default: break; 00058 } 00059 test = buf_ppm[2]; 00060 if(cnt<100)test1 = test; 00061 return; 00062 } 00063 00064 00065 00066 void gets_PPM(){ 00067 test = buf_ppm[2]; 00068 if(cnt<100)test1 = test; 00069 //eyetosee(); 00070 } 00071 00072 void PPM_rise() { 00073 tick.stop(); // Stop timer 00074 buf_ppm[i]=tick.read_us(); // Read timer to buffer[i] i=turns 00075 tick.reset(); // Reset timer 00076 i++; // increment i. 00077 if(buf_ppm[i]>5000) idx = i; 00078 if(i==6) i = 0; 00079 get_PPM(); 00080 cnt++; 00081 if(cnt>200) cnt = 200; 00082 tick.start(); 00083 } 00084 00085 00086 /* 00087 Channel 1 = Roll 00088 Channel 2 = Throttle 00089 Channel 3 = Pitch 00090 Channel 4 = Yaw 00091 Channel 5 = Switch 00092 */
Generated on Fri Jul 15 2022 07:04:28 by
1.7.2