1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Merge remote-tracking branch 'origin/OP-174_Sambas_BaroAlt_to_ETOSD'

This commit is contained in:
James Cotton 2011-05-07 04:41:13 -05:00
commit fef1e2dc2e

View File

@ -34,6 +34,7 @@
#include "flightbatterystate.h"
#include "gpsposition.h"
#include "attitudeactual.h"
#include "baroaltitude.h"
//
// Configuration
@ -62,6 +63,8 @@
#define OSD_ADDRESS 0x30
#define OSDMSG_V_LS_IDX 10
#define OSDMSG_BALT_IDX1 11
#define OSDMSG_BALT_IDX2 12
#define OSDMSG_A_LS_IDX 17
#define OSDMSG_VA_MS_IDX 18
#define OSDMSG_LAT_IDX 33
@ -99,14 +102,15 @@ static const char *DumpConfFilePath = "/etosd/dump.ocf";
// Private variables
//
// | Header / cmd?| | V | | V | | LAT: 37 57.0000 | LONG: 24 00.4590 | | Hom<-179| Alt 545.4 m | |#sat|stat|
// | Header / cmd?| | V | E3 | V | | LAT: 37 57.0000 | LONG: 24 00.4590 | | Hom<-179| Alt 545.4 m | |#sat|stat|
// 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
uint8_t msg[63] =
{ 0x03, 0x3F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
{ 0x03, 0x3F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x0A, 0x00, 0xE4, 0x30, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x60, 0x10, 0x02, 0x00, 0x00, 0x90, 0x00,
0x54, 0x54, 0x00, 0x00, 0x33, 0x28, 0x13, 0x00, 0x00, 0x08, 0x00, 0x00, 0x90, 0x0A };
static volatile bool newPosData = FALSE;
static volatile bool newBattData = FALSE;
static volatile bool newBaroData = FALSE;
static enum
{
@ -167,6 +171,16 @@ static void SetCourse(uint16_t dir)
WriteToMsg16(OSDMSG_HOME_IDX, dir);
}
static void SetBaroAltitude(int16_t altitudeMeter)
{
// calculated formula
// ET OSD uses first update as zeropoint and then +- from that
altitudeMeter=(4571-altitudeMeter)/0.37;
msg[OSDMSG_BALT_IDX1] = (uint8_t)(altitudeMeter&0x00FF);
msg[OSDMSG_BALT_IDX2] = (altitudeMeter >> 8)&0x3F;
}
static void SetAltitude(uint32_t altitudeMeter)
{
WriteToMsg32(OSDMSG_ALT_IDX, altitudeMeter * 10);
@ -202,6 +216,11 @@ static void GPSPositionUpdatedCb(UAVObjEvent * ev)
newPosData = TRUE;
}
static void BaroAltitudeUpdatedCb(UAVObjEvent * ev)
{
newBaroData = TRUE;
}
static bool Read(uint32_t start, uint8_t length, uint8_t * buffer)
{
uint8_t cmd[5];
@ -451,6 +470,14 @@ static void Run(void)
} else {
msg[OSDMSG_GPS_STAT] &= ~OSDMSG_GPS_STAT_HB_FLAG;
}
if (newBaroData) {
BaroAltitudeData baroData;
BaroAltitudeGet(&baroData);
SetBaroAltitude(baroData.Altitude);
newBaroData = FALSE;
}
DEBUG_MSG("SendMsg %d\n",cnt);
{
@ -470,7 +497,6 @@ static void Run(void)
}
cnt++;
}
static void onTimer(UAVObjEvent * ev)
@ -522,6 +548,7 @@ int32_t OsdEtStdInitialize(void)
{
GPSPositionConnectCallback(GPSPositionUpdatedCb);
FlightBatteryStateConnectCallback(FlightBatteryStateUpdatedCb);
BaroAltitudeConnectCallback(BaroAltitudeUpdatedCb);
memset(&ev,0,sizeof(UAVObjEvent));
EventPeriodicCallbackCreate(&ev, onTimer, 100 / portTICK_RATE_MS);