1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-05 21:52:10 +01:00

OP-174 ET OSD: barometric altitude works now, units must be set metric with E-Logger

This commit is contained in:
Sambas 2011-04-29 19:08:28 +03:00
parent f1927a3ced
commit 2413fd451f

View File

@ -34,6 +34,7 @@
#include "flightbatterystate.h" #include "flightbatterystate.h"
#include "gpsposition.h" #include "gpsposition.h"
#include "attitudeactual.h" #include "attitudeactual.h"
#include "baroaltitude.h"
// //
// Configuration // Configuration
@ -62,6 +63,8 @@
#define OSD_ADDRESS 0x30 #define OSD_ADDRESS 0x30
#define OSDMSG_V_LS_IDX 10 #define OSDMSG_V_LS_IDX 10
#define OSDMSG_BALT_IDX1 11
#define OSDMSG_BALT_IDX2 12
#define OSDMSG_A_LS_IDX 17 #define OSDMSG_A_LS_IDX 17
#define OSDMSG_VA_MS_IDX 18 #define OSDMSG_VA_MS_IDX 18
#define OSDMSG_LAT_IDX 33 #define OSDMSG_LAT_IDX 33
@ -99,14 +102,15 @@ static const char *DumpConfFilePath = "/etosd/dump.ocf";
// Private variables // 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 // 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] = 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, 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 }; 0x54, 0x54, 0x00, 0x00, 0x33, 0x28, 0x13, 0x00, 0x00, 0x08, 0x00, 0x00, 0x90, 0x0A };
static volatile bool newPosData = FALSE; static volatile bool newPosData = FALSE;
static volatile bool newBattData = FALSE; static volatile bool newBattData = FALSE;
static volatile bool newBaroData = FALSE;
static enum static enum
{ {
@ -167,6 +171,16 @@ static void SetCourse(uint16_t dir)
WriteToMsg16(OSDMSG_HOME_IDX, 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) static void SetAltitude(uint32_t altitudeMeter)
{ {
WriteToMsg32(OSDMSG_ALT_IDX, altitudeMeter * 10); WriteToMsg32(OSDMSG_ALT_IDX, altitudeMeter * 10);
@ -202,6 +216,11 @@ static void GPSPositionUpdatedCb(UAVObjEvent * ev)
newPosData = TRUE; newPosData = TRUE;
} }
static void BaroAltitudeUpdatedCb(UAVObjEvent * ev)
{
newBaroData = TRUE;
}
static bool Read(uint32_t start, uint8_t length, uint8_t * buffer) static bool Read(uint32_t start, uint8_t length, uint8_t * buffer)
{ {
uint8_t cmd[5]; uint8_t cmd[5];
@ -451,6 +470,14 @@ static void Run(void)
} else { } else {
msg[OSDMSG_GPS_STAT] &= ~OSDMSG_GPS_STAT_HB_FLAG; 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); DEBUG_MSG("SendMsg %d\n",cnt);
{ {
@ -470,7 +497,6 @@ static void Run(void)
} }
cnt++; cnt++;
} }
static void onTimer(UAVObjEvent * ev) static void onTimer(UAVObjEvent * ev)
@ -522,6 +548,7 @@ int32_t OsdEtStdInitialize(void)
{ {
GPSPositionConnectCallback(GPSPositionUpdatedCb); GPSPositionConnectCallback(GPSPositionUpdatedCb);
FlightBatteryStateConnectCallback(FlightBatteryStateUpdatedCb); FlightBatteryStateConnectCallback(FlightBatteryStateUpdatedCb);
BaroAltitudeConnectCallback(BaroAltitudeUpdatedCb);
memset(&ev,0,sizeof(UAVObjEvent)); memset(&ev,0,sizeof(UAVObjEvent));
EventPeriodicCallbackCreate(&ev, onTimer, 100 / portTICK_RATE_MS); EventPeriodicCallbackCreate(&ev, onTimer, 100 / portTICK_RATE_MS);