From d7c77c3fe2e07b8d357d7b967ab9a599767c5eee Mon Sep 17 00:00:00 2001 From: dongie Date: Fri, 30 May 2014 19:28:46 +0900 Subject: [PATCH 1/2] formatting fixes and rename one of ADC channels. --- src/drv_adc.c | 4 ++-- src/drv_adc.h | 2 +- src/serial.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/drv_adc.c b/src/drv_adc.c index 965522c77..0da40a908 100755 --- a/src/drv_adc.c +++ b/src/drv_adc.c @@ -27,8 +27,8 @@ void adcInit(drv_adc_config_t *init) // optional ADC5 input on rev.5 hardware if (hse_value == 12000000) { numChannels++; - adcConfig[ADC_EXTERNAL1].adcChannel = ADC_Channel_5; - adcConfig[ADC_EXTERNAL1].dmaIndex = numChannels - 1; + adcConfig[ADC_EXTERNAL_PAD].adcChannel = ADC_Channel_5; + adcConfig[ADC_EXTERNAL_PAD].dmaIndex = numChannels - 1; } // another channel can be stolen from PWM for current measurement or other things if (init->powerAdcChannel > 0) { diff --git a/src/drv_adc.h b/src/drv_adc.h index 1f09b2e79..123021690 100755 --- a/src/drv_adc.h +++ b/src/drv_adc.h @@ -2,7 +2,7 @@ typedef enum { ADC_BATTERY = 0, - ADC_EXTERNAL1 = 1, + ADC_EXTERNAL_PAD = 1, ADC_EXTERNAL_CURRENT = 2, ADC_CHANNEL_MAX = 3 } AdcChannel; diff --git a/src/serial.c b/src/serial.c index 99ba54495..992a24c66 100755 --- a/src/serial.c +++ b/src/serial.c @@ -474,9 +474,9 @@ static void evaluateCommand(void) serialize8((uint8_t)constrain(vbat, 0, 255)); serialize16(mAhdrawn); // milliamphours drawn from battery serialize16(rssi); - if(mcfg.multiwiicurrentoutput) { - serialize16((uint16_t)constrain((abs(amperage)*10), 0, 0xFFFF)); // send amperage in 0.001 A steps - } else + if (mcfg.multiwiicurrentoutput) + serialize16((uint16_t)constrain((abs(amperage) * 10), 0, 0xFFFF)); // send amperage in 0.001 A steps + else serialize16((uint16_t)abs(amperage)); // send amperage in 0.01 A steps break; case MSP_RC_TUNING: From 3c0f0f7ed4c4108a584374a1cc8c313c8cec42f3 Mon Sep 17 00:00:00 2001 From: dongie Date: Fri, 30 May 2014 21:37:22 +0900 Subject: [PATCH 2/2] fixed frsky temeletry gps output to match with what is actually expected. props to KC_703 for spotting this stuff. --- src/telemetry_frsky.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/telemetry_frsky.c b/src/telemetry_frsky.c index 8d737d9f4..5297dc822 100644 --- a/src/telemetry_frsky.c +++ b/src/telemetry_frsky.c @@ -122,20 +122,36 @@ static void sendTime(void) serialize16(seconds % 60); } +// Frsky pdf: dddmm.mmmm +// .mmmm is returned in decimal fraction of minutes. +static void frskyGPStoDDDMM_MMMM(int32_t mwiigps, int16_t *dddmm, int16_t *mmmm) +{ + int32_t absgps, deg, min; + absgps = abs(mwiigps); + deg = absgps / 10000000; + absgps = (absgps - deg * 10000000) * 60; // absgps = Minutes left * 10^7 + min = absgps / 10000000; // minutes left + *dddmm = deg * 100 + min; + *mmmm = (absgps - min * 10000000) / 1000; +} + static void sendGPS(void) { + int16_t ddd, mmm; + + frskyGPStoDDDMM_MMMM(GPS_coord[LAT], &ddd, &mmm); sendDataHead(ID_LATITUDE_BP); - serialize16(abs(GPS_coord[LAT]) / 100000); + serialize16(ddd); sendDataHead(ID_LATITUDE_AP); - serialize16((abs(GPS_coord[LAT]) / 10) % 10000); - + serialize16(mmm); sendDataHead(ID_N_S); serialize16(GPS_coord[LAT] < 0 ? 'S' : 'N'); + frskyGPStoDDDMM_MMMM(GPS_coord[LON], &ddd, &mmm); sendDataHead(ID_LONGITUDE_BP); - serialize16(abs(GPS_coord[LON]) / 100000); + serialize16(ddd); sendDataHead(ID_LONGITUDE_AP); - serialize16((abs(GPS_coord[LON]) / 10) % 10000); + serialize16(mmm); sendDataHead(ID_E_W); serialize16(GPS_coord[LON] < 0 ? 'W' : 'E'); }