1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

ET OSD, WIP. Encoding of voltage and GPS data is now known

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@750 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
FredericG 2010-06-12 17:44:24 +00:00 committed by FredericG
parent ac771996ba
commit f8b793e54d

View File

@ -26,6 +26,7 @@
#include "openpilot.h" #include "openpilot.h"
// //
// Configuration // Configuration
// //
@ -53,21 +54,108 @@
// Private variables // Private variables
// //
// | Header / cmd?| | V | | 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,0x91,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFD,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x91,0x0A};
// uint8_t msg[63] = {0x03,0x3F,0x03,0x00,0x00,0x00,0x00,0x00,0x8F,0x0A,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0xFD,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x57,0x37,0x90,0x45,0x00,0x24,0x09,0x00,0x24,0x03,0x00,0x00,0x90,0x00,0x54,0x54,0x00,0x00,0x52,0x11,0x20,0x00,0x00,0x06,0x2B,0x00,0x8F,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,0x00,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 newGpsData=FALSE;
static void WriteToMsg8(uint8_t index, uint8_t value)
{
if (value>100)
value = 100;
msg[index] = ((value/10) << 4) + (value%10);
}
static void WriteToMsg16(uint8_t index, uint16_t value)
{
WriteToMsg8(index, value % 100);
WriteToMsg8(index+1, value / 100);
}
static void WriteToMsg32(uint8_t index, uint32_t value)
{
WriteToMsg16(index, value % 10000);
WriteToMsg16(index+2, value / 10000);
}
static void SetHomeDir(uint32_t dir)
{
int etDir;
etDir = dir - 89;
if (etDir < 0)
etDir += 360;
WriteToMsg16(47, etDir);
}
static void SetAltitude(uint32_t altitudeMeter)
{
WriteToMsg32(49, altitudeMeter*10);
}
static void SetVoltage(uint32_t milliVolt)
{
msg[18] = (milliVolt / 6444)<<4;
msg[10] = (milliVolt % 6444)*256/6444;
}
// //
// Private functions // Private functions
// //
static void Task(void* parameters) static void Task(void* parameters)
{ {
uint8_t msg[63] = {0x03,0x3F,0x03,00,00,00,00,00,0x91,0x0A,0x00,00,00,00,00,00,00,0xFD,0x17,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0x91,0x0A}; int dir=0;
int alt=100;
int voltage = 0;
PIOS_COM_ChangeBaud(DEBUG_PORT, 57600); PIOS_COM_ChangeBaud(DEBUG_PORT, 57600);
DEBUG_MSG("OSD ET Std Started\n\r"); DEBUG_MSG("OSD ET Std Started\n\r");
while (1) while (1)
{ {
msg[10]++; SetHomeDir(dir);
dir++;
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 (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));
@ -76,6 +164,7 @@ static void Task(void* parameters)
vTaskDelay(100 / portTICK_RATE_MS); vTaskDelay(100 / portTICK_RATE_MS);
} }
} }