![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
a
Dependencies: mbed
Fork of GIMBAL_SAMPLE4_PPM by
Diff: PPM/PPMIn.cpp
- Revision:
- 0:f0b20f502059
diff -r 000000000000 -r f0b20f502059 PPM/PPMIn.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PPM/PPMIn.cpp Thu May 24 10:19:44 2018 +0000 @@ -0,0 +1,46 @@ +#include "mbed.h" +#include "PPMIn.h" +#include "Pin_Assign.h" + +PpmIn::PpmIn(PinName pin): ppm(pin)//, pc_com(USBTX, USBRX) +{ + //pc_com.printf("Constructor say hi!"); + current_channel = 0; + state = false; + timer.start(); + ppm.rise(this, &PpmIn::rise); + +} + +uint16_t* PpmIn::getPpm() +{ + uint16_t* p_out[CHANNELS+2]; + *p_out = &channels[0]; + //pc_com.printf("%d",channels[0]); + return *p_out; +} + +void PpmIn::rise() +{ + uint16_t time = timer.read_us(); + + //pc.printf("%d\n",time); + + //pc_com.printf("Rise say hi!"); + // we are in synchro zone + if(time > 2500) + { + current_channel = 0; + // return values + state = true; + } + else + { + channels[current_channel] = timer.read_us(); + current_channel += 1; + } + + timer.reset(); + + //if (current_channel > (CHANNELS + 2 - 1)); //+frame and - 1 indexing of channels list +} \ No newline at end of file