format osd_ltm
// the routine sends attitude, fc volts and rssi ( if available)
#include "binary.h"
-#include "defines.h"
#include "config.h"
+#include "defines.h"
#include "rx_bayang.h" // for struct rxdebug;
#include <stdio.h>
-
#ifdef OSD_LTM_PROTOCOL
char crc;
@@ -21,32 +20,25 @@ char crc;
extern void buffer_add(int val);
-void Serial_print(char ch)
-{
+void Serial_print(char ch) {
buffer_add((int)ch);
}
-
-void sendbyte( char val)
-{
+void sendbyte(char val) {
crc ^= val;
Serial_print((char)val);
}
-void sendint( int val)
-{
+void sendint(int val) {
sendbyte((char)(val));
sendbyte((char)(val >> 8));
}
-void sendcrc()
-{
+void sendcrc() {
Serial_print((char)(crc));
}
-
-void sendheader()
-{
+void sendheader() {
sendbyte((char)'$');
sendbyte((char)'T');
}
@@ -59,8 +51,7 @@ void sendheader()
extern float attitude[];
-void send_a_frame()
-{
+void send_a_frame() {
sendheader();
Serial_print((char)'A');
crc = 0;
@@ -81,8 +72,7 @@ void send_a_frame()
// bits 0-1 : fix
// bits 2-7 : number of satellites
-void send_g_frame()
-{
+void send_g_frame() {
sendheader();
Serial_print('G');
crc = 0;
@@ -97,8 +87,7 @@ void send_g_frame()
// sendint(0); // alti2
// sending all above dummy data in one go for optimization
-for ( int i = 0 ; i < 6; i++)
- {
+ for (int i = 0; i < 6; i++) {
sendint(0);
}
@@ -119,12 +108,10 @@ extern int failsafe;
extern int rxmode;
extern char aux[];
-
//extern int packetpersecond;
extern struct rxdebug rxdebug;
-void send_s_frame()
-{
+void send_s_frame() {
sendheader();
Serial_print('S');
crc = 0;
@@ -132,7 +119,8 @@ void send_s_frame()
sendint(1000); // current mA
int rssi = rxdebug.packetpersecond;
-if (rssi > 255) rssi = 255;
+ if (rssi > 255)
+ rssi = 255;
sendbyte(rssi); // rssi
sendbyte(0); // airspeed
@@ -152,40 +140,28 @@ if (rssi > 255) rssi = 255;
sendcrc();
}
-
int osdcount = 0;
-void osdcycle()
-{
+void osdcycle() {
osdcount++;
- if (osdcount%30 == 29)
- {
+ if (osdcount % 30 == 29) {
send_a_frame();
return;
}
- if (osdcount%999 == 1)
- {
+ if (osdcount % 999 == 1) {
send_g_frame();
return;
}
- if (osdcount%332 == 5)
- {
+ if (osdcount % 332 == 5) {
send_s_frame();
return;
}
-
}
#else
// ods disabled - dummy functions
-void osdcycle()
-{
-
+void osdcycle() {
}
-
-
-
#endif
-
