[Crossfire] Cosmetics
This commit is contained in:
@@ -369,18 +369,18 @@ static int luaCrossfireTelemetryPop(lua_State * L)
|
||||
|
||||
static int luaCrossfireTelemetryPush(lua_State * L)
|
||||
{
|
||||
if (luaOutputTelemetryPacket.crossfire.command != 0) {
|
||||
if (luaOutputTelemetryPacket.crossfire.command != 0x00) {
|
||||
lua_pushboolean(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
luaOutputTelemetryPacket.crossfire.command = luaL_checkunsigned(L, 1);
|
||||
luaL_checktype(L, 2, LUA_TTABLE);
|
||||
luaOutputTelemetryPacket.crossfire.length = min<int>(sizeof(luaOutputTelemetryPacket.crossfire.data), luaL_len(L, 2));
|
||||
for (int i=0; i<luaOutputTelemetryPacket.crossfire.length; i++) {
|
||||
lua_rawgeti(L, 2, i+1);
|
||||
luaOutputTelemetryPacket.crossfire.data[i] = luaL_checkunsigned(L, -1);
|
||||
}
|
||||
luaOutputTelemetryPacket.crossfire.command = luaL_checkunsigned(L, 1);
|
||||
|
||||
lua_pushboolean(L, true);
|
||||
return 1;
|
||||
|
||||
@@ -190,6 +190,10 @@ void setupPulses(uint8_t port)
|
||||
if (luaOutputTelemetryPacket.crossfire.command) {
|
||||
len = createCrossfireRequestFrame(crossfire, &luaOutputTelemetryPacket);
|
||||
luaOutputTelemetryPacket.crossfire.clear();
|
||||
LOG_TELEMETRY_WRITE_START();
|
||||
for (uint32_t i=0; i<len; i++) {
|
||||
LOG_TELEMETRY_WRITE_BYTE(crossfire[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
@@ -87,24 +87,12 @@ void telemetryWakeup()
|
||||
|
||||
#if defined(CPUSTM32)
|
||||
uint8_t data;
|
||||
#if defined(LOG_TELEMETRY) && !defined(SIMU)
|
||||
static tmr10ms_t lastTime = 0;
|
||||
tmr10ms_t newTime = get_tmr10ms();
|
||||
struct gtm utm;
|
||||
gettime(&utm);
|
||||
#endif
|
||||
if (!telemetryFifo.isEmpty()) {
|
||||
LOG_TELEMETRY_WRITE_START();
|
||||
}
|
||||
while (telemetryFifo.pop(data)) {
|
||||
processTelemetryData(data);
|
||||
#if defined(LOG_TELEMETRY) && !defined(SIMU)
|
||||
extern FIL g_telemetryFile;
|
||||
if (lastTime != newTime) {
|
||||
f_printf(&g_telemetryFile, "\r\n%4d-%02d-%02d,%02d:%02d:%02d.%02d0: %02X", utm.tm_year+1900, utm.tm_mon+1, utm.tm_mday, utm.tm_hour, utm.tm_min, utm.tm_sec, g_ms100, data);
|
||||
lastTime = newTime;
|
||||
}
|
||||
else {
|
||||
f_printf(&g_telemetryFile, " %02X", data);
|
||||
}
|
||||
#endif
|
||||
LOG_TELEMETRY_WRITE_BYTE(data);
|
||||
}
|
||||
#elif defined(PCBSKY9X)
|
||||
if (telemetryProtocol == PROTOCOL_FRSKY_D_SECONDARY) {
|
||||
@@ -459,6 +447,26 @@ NOINLINE uint8_t getRssiAlarmValue(uint8_t alarm)
|
||||
return (45 - 3*alarm + g_model.frsky.rssiAlarms[alarm].value);
|
||||
}
|
||||
|
||||
#if defined(LOG_TELEMETRY) && !defined(SIMU)
|
||||
extern FIL g_telemetryFile;
|
||||
void logTelemetryWriteStart()
|
||||
{
|
||||
static tmr10ms_t lastTime = 0;
|
||||
tmr10ms_t newTime = get_tmr10ms();
|
||||
if (lastTime != newTime) {
|
||||
struct gtm utm;
|
||||
gettime(&utm);
|
||||
f_printf(&g_telemetryFile, "\r\n%4d-%02d-%02d,%02d:%02d:%02d.%02d0:", utm.tm_year+1900, utm.tm_mon+1, utm.tm_mday, utm.tm_hour, utm.tm_min, utm.tm_sec, g_ms100);
|
||||
lastTime = newTime;
|
||||
}
|
||||
}
|
||||
|
||||
void logTelemetryWriteByte(uint8_t data)
|
||||
{
|
||||
f_printf(&g_telemetryFile, " %02X", data);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LUA)
|
||||
Fifo<LuaTelemetryPacket, LUA_TELEMETRY_FIFO_SIZE> * luaInputTelemetryFifo = NULL;
|
||||
LuaTelemetryPacket luaOutputTelemetryPacket;
|
||||
|
||||
@@ -67,7 +67,6 @@ extern uint8_t telemetryState;
|
||||
#define TELEMETRY_RX_PACKET_SIZE 19 // 9 bytes (full packet), worst case 18 bytes with byte-stuffing (+1)
|
||||
#endif
|
||||
|
||||
|
||||
extern uint8_t telemetryRxBuffer[TELEMETRY_RX_PACKET_SIZE];
|
||||
extern uint8_t telemetryRxBufferCount;
|
||||
|
||||
@@ -149,4 +148,14 @@ inline uint8_t modelTelemetryProtocol()
|
||||
#include "telemetry_sensors.h"
|
||||
#endif
|
||||
|
||||
#if defined(LOG_TELEMETRY) && !defined(SIMU)
|
||||
void logTelemetryWriteStart();
|
||||
void logTelemetryWriteByte(uint8_t data);
|
||||
#define LOG_TELEMETRY_WRITE_START() logTelemetryWriteStart()
|
||||
#define LOG_TELEMETRY_WRITE_BYTE(data) logTelemetryWriteByte(data)
|
||||
#else
|
||||
#define LOG_TELEMETRY_WRITE_START()
|
||||
#define LOG_TELEMETRY_WRITE_BYTE(data)
|
||||
#endif
|
||||
|
||||
#endif // _TELEMETRY_H_
|
||||
|
||||
Reference in New Issue
Block a user