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

OSD: start displaying real data WIP

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@765 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
FredericG 2010-06-14 16:50:01 +00:00 committed by FredericG
parent 50d63d35fa
commit e3815bf8b8

View File

@ -25,12 +25,15 @@
#include "openpilot.h" #include "openpilot.h"
#include "flightbatterystate.h"
#include "positionactual.h"
// //
// Configuration // Configuration
// //
#define DEBUG_PORT COM_USART1 #define DEBUG_PORT PIOS_COM_TELEM_RF
#define STACK_SIZE 1024 #define STACK_SIZE 1024
#define TASK_PRIORITY (tskIDLE_PRIORITY + 3) #define TASK_PRIORITY (tskIDLE_PRIORITY + 3)
#define ENABLE_DEBUG_MSG #define ENABLE_DEBUG_MSG
@ -62,7 +65,8 @@
// uint8_t msg[63] = {0x03,0x3F,0x03,0x00,0x00,0x00,0x00,0x00,0x90,0x0A,0x8A,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x57,0x37,0x14,0x33,0x02,0x24,0x09,0x60,0x10,0x02,0x00,0x00,0x90,0x00,0x54,0x54,0x00,0x00,0x33,0x28,0x13,0x00,0x00,0x08,0x03,0x00,0x90,0x0A}; // uint8_t msg[63] = {0x03,0x3F,0x03,0x00,0x00,0x00,0x00,0x00,0x90,0x0A,0x8A,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x57,0x37,0x14,0x33,0x02,0x24,0x09,0x60,0x10,0x02,0x00,0x00,0x90,0x00,0x54,0x54,0x00,0x00,0x33,0x28,0x13,0x00,0x00,0x08,0x03,0x00,0x90,0x0A};
static bool fix=FALSE; static bool fix=FALSE;
static bool newGpsData=FALSE; static bool newPosData=FALSE;
static bool newBattData=FALSE;
static void WriteToMsg8(uint8_t index, uint8_t value) static void WriteToMsg8(uint8_t index, uint8_t value)
{ {
@ -106,61 +110,114 @@ static void SetVoltage(uint32_t milliVolt)
msg[10] = (milliVolt % 6444)*256/6444; msg[10] = (milliVolt % 6444)*256/6444;
} }
static void FlightBatteryStateUpdatedCb(UAVObjEvent* ev)
{
newBattData = TRUE;
}
static void PositionActualUpdatedCb(UAVObjEvent* ev)
{
newPosData = TRUE;
}
// //
// Private functions // Private functions
// //
static void Task(void* parameters) static void Task(void* parameters)
{ {
int dir=0; //int dir=0;
int alt=100; //int alt=100;
int voltage = 0; //int voltage = 0;
uint32_t cnt = 0;
PIOS_COM_ChangeBaud(DEBUG_PORT, 57600); PIOS_COM_ChangeBaud(DEBUG_PORT, 57600);
FlightBatteryStateConnectCallback(FlightBatteryStateUpdatedCb);
PositionActualConnectCallback(PositionActualUpdatedCb);
DEBUG_MSG("OSD ET Std Started\n\r"); DEBUG_MSG("OSD ET Std Started\n\r");
while (1) while (1)
{ {
SetHomeDir(dir); // SetHomeDir(dir);
dir++; // dir++;
if (dir>90) // if (dir>90)
// {
// fix=TRUE;
// }
// if (dir>360)
// {
// dir = 0;
// // Change coordinates
// msg[39]++;
// }
//
// SetAltitude(alt);
// alt++;
//
// SetVoltage(voltage);
// voltage += 50;
//
// // GPS status
// if (fix)
// msg[59] = 0x2B;
// else
// msg[59] = 0x03;
//
// if (newGpsData)
// {
// msg[59] |= 0x10;
// newGpsData = FALSE;
// }
// else
// {
// newGpsData = TRUE;
// }
if ( newBattData )
{ {
fix=TRUE; FlightBatteryStateData flightBatteryData;
}
if (dir>360) FlightBatteryStateGet(&flightBatteryData);
{
dir = 0; DEBUG_MSG("%5d Batt: V=%dmV\n\r", cnt, flightBatteryData.Tension);
// Change coordinates
msg[39]++; SetVoltage(flightBatteryData.Tension);
newBattData = FALSE;
} }
SetAltitude(alt); if (newPosData)
alt++;
SetVoltage(voltage);
voltage += 50;
// GPS status
if (fix)
msg[59] = 0x2B;
else
msg[59] = 0x03;
if (newGpsData)
{ {
PositionActualData positionData;
PositionActualGet(&positionData);
DEBUG_MSG("%5d Pos: #stat=%d #sats=%d\n\r", cnt, positionData.Status, positionData.Satellites);
if (positionData.Status == POSITIONACTUAL_STATUS_FIX3D)
msg[59] = 0x2B;
else
msg[59] = 0x03;
msg[59] |= 0x10; msg[59] |= 0x10;
newGpsData = FALSE;
msg[58] = positionData.Satellites;
newPosData = FALSE;
} }
else else
{ {
newGpsData = TRUE; msg[59] &= ~0x10;
} }
if (PIOS_I2C_LockDevice(5000 / portTICK_RATE_MS)) if (PIOS_I2C_LockDevice(5000 / portTICK_RATE_MS))
{ {
PIOS_I2C_Transfer(I2C_Write, 0x30<<1, msg, sizeof(msg)); PIOS_I2C_Transfer(I2C_Write, 0x30<<1, msg, sizeof(msg));
PIOS_I2C_UnlockDevice(); PIOS_I2C_UnlockDevice();
} }
cnt++;
vTaskDelay(100 / portTICK_RATE_MS); vTaskDelay(100 / portTICK_RATE_MS);
} }