From 1c3d306c48600412b42a79abedc2a994f6089c05 Mon Sep 17 00:00:00 2001 From: 3djc Date: Thu, 13 Dec 2018 12:59:04 +0100 Subject: [PATCH] Tidy up --- radio/src/bitfield.h | 51 ---------------------------- radio/src/gui/128x64/model_setup.cpp | 1 + radio/src/gui/gui_common_arm.cpp | 6 ++-- radio/src/myeeprom.h | 14 +++++--- radio/src/opentx.h | 1 - radio/src/pulses/modules.h | 10 +++--- radio/src/pulses/pxx2.cpp | 1 - radio/src/telemetry/frsky.cpp | 1 - 8 files changed, 19 insertions(+), 66 deletions(-) delete mode 100644 radio/src/bitfield.h diff --git a/radio/src/bitfield.h b/radio/src/bitfield.h deleted file mode 100644 index 84b3632b5..000000000 --- a/radio/src/bitfield.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * This file is based on work published at http://www.coranac.com/documents/working-with-bits-and-bitfields - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef BITFIELD_H -#define BITFIELD_H - -// A set of bitfield handling macros -#define BF_BIT(n) ( 1<<(n) ) -#define BF_BIT_GET(y, mask) ( y & (mask) ) -#define BF_BIT_SET(y, mask) ( y |= (mask) ) -#define BF_BIT_CLEAR(y, mask) ( y &= ~(mask) ) -#define BF_BIT_FLIP(y, mask) ( y ^= (mask) ) -#define BF_SINGLE_BIT_GET(y, i) BF_BIT_GET(y, BF_BIT(i)) -#define BF_SINGLE_BIT_SET(y, i) BF_BIT_SET(y, BF_BIT(i)) - -//! Create a bitmask of length 'len'. -#define BF_BITMASK(len) ( BF_BIT(len)-1 ) - -//! Create a bitfield mask of length 'len' starting at bit 'start'. -#define BF_MASK(start, len) ( BF_BITMASK(len)<<(start) ) - -//! Prepare a bitmask for insertion or combining. -#define BF_PREP(x, start, len) ( ((x)&BF_BITMASK(len)) << (start) ) - -//! Extract a bitfield of length 'len' starting at bit 'start' from 'y'. -#define BF_GET(y, start, len) ( ((y)>>(start)) & BF_BITMASK(len) ) - -//! Insert 'len' bits of 'x 'into 'y', starting at bit 'start' from 'y'. -#define BF_SET(y, x, start, len) \ - ( y= ((y) &~ BF_MASK(start, len)) | BF_PREP(x, start, len) ) - -#endif //BITFIELD_H \ No newline at end of file diff --git a/radio/src/gui/128x64/model_setup.cpp b/radio/src/gui/128x64/model_setup.cpp index 2385ea836..bffa812c6 100644 --- a/radio/src/gui/128x64/model_setup.cpp +++ b/radio/src/gui/128x64/model_setup.cpp @@ -1239,6 +1239,7 @@ void menuModelSetup(event_t event) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.moduleData[moduleIdx].r9m.freq, 1); } } + break; #if defined(MULTIMODULE) case ITEM_MODEL_EXTERNAL_MODULE_AUTOBIND: diff --git a/radio/src/gui/gui_common_arm.cpp b/radio/src/gui/gui_common_arm.cpp index a2c2bbb78..771f6fb0a 100644 --- a/radio/src/gui/gui_common_arm.cpp +++ b/radio/src/gui/gui_common_arm.cpp @@ -502,7 +502,7 @@ bool isR9MModeAvailable(int mode) bool isR9MMFlex(int module) { - return g_model.moduleData[module].r9m.region == 0x02; + return g_model.moduleData[module].r9m.region == MODULE_R9M_REGION_FLEX; } bool isModuleAvailable(int module) @@ -526,7 +526,7 @@ bool isModuleAvailable(int module) return false; } #endif -#if !defined(PCBSKY9X) +#if defined(PCBTARANIS) || defined(PCBHORUS) if (module == MODULE_TYPE_R9M && g_model.moduleData[INTERNAL_MODULE].type != MODULE_TYPE_NONE) { return false; } @@ -548,7 +548,7 @@ bool isRfProtocolAvailable(int protocol) return false; } #endif -#if defined(pxx) +#if defined(PCBTARANIS) || defined(PCBHORUS) if (protocol != RF_PROTO_OFF && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_R9M) { return false; } diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 15713ab96..8f435befe 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -323,12 +323,18 @@ enum R9MSubTypes enum R9MRegion { - MODULE_REGION_R9M_FCC, - MODULE_REGION_R9M_EU, - MODULE_REGION_R9M_FLEX, - MODULE_REGION_R9M_LAST=MODULE_REGION_R9M_FLEX + MODULE_R9M_REGION_FCC, + MODULE_R9M_REGION_EU, + MODULE_R9M_REGION_FLEX, + MODULE_R9M_REGION_LAST=MODULE_R9M_REGION_FLEX }; +enum R9MFrenquency +{ + MODULE_R9M_FREQ_868MHZ + MODULE_R9M_FREQ_915MHZ, + MODULE_R9M_FREQ_LAST=MODULE_R9M_FREQ_915MHZ +}; enum MultiModuleRFProtocols { MM_RF_PROTO_CUSTOM = -1, diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 0039e0a3f..daf616120 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -27,7 +27,6 @@ #include #include "definitions.h" #include "opentx_types.h" -#include "bitfield.h" #if defined(STM32) #include "usbd_conf.h" #endif diff --git a/radio/src/pulses/modules.h b/radio/src/pulses/modules.h index cbc26a5df..8a8dd2bec 100644 --- a/radio/src/pulses/modules.h +++ b/radio/src/pulses/modules.h @@ -106,27 +106,27 @@ inline bool isModuleR9M(uint8_t idx) inline bool isModuleR9M_FCC(uint8_t idx) { - return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_REGION_R9M_FCC; + return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_R9M_REGION_FCC; } inline bool isModuleR9M_LBT(uint8_t idx) { - return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_REGION_R9M_EU; + return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_R9M_REGION_EU; } inline bool isModuleR9M_FCC_VARIANT(uint8_t idx) { - return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region != MODULE_REGION_R9M_EU; + return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region != MODULE_R9M_REGION_EU; } inline bool isModuleR9M_EUPLUS(uint8_t idx) { - return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_REGION_R9M_FLEX && g_model.moduleData[idx].r9m.freq == 0x00; + return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_R9M_REGION_FLEX && g_model.moduleData[idx].r9m.freq == MODULE_R9M_FREQ_868MHZ; } inline bool isModuleR9M_AU_PLUS(uint8_t idx) { - return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_REGION_R9M_FLEX && g_model.moduleData[idx].r9m.freq == 0x01; + return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_R9M_REGION_FLEX && g_model.moduleData[idx].r9m.freq == MODULE_R9M_FREQ_915MHZ; } diff --git a/radio/src/pulses/pxx2.cpp b/radio/src/pulses/pxx2.cpp index 7cce0f298..2ae1adfd8 100644 --- a/radio/src/pulses/pxx2.cpp +++ b/radio/src/pulses/pxx2.cpp @@ -45,7 +45,6 @@ void Pxx2Pulses::setupFrame(uint8_t port) #if defined(LUA) if (outputTelemetryBufferTrigger != 0x00 && outputTelemetryBufferSize > 0) { - TRACE("SENDING TELEM"); // primID (1 byte) + dataID (2 bytes) + value (4 bytes) for (uint8_t i=0; i<7; i++) { addByte(outputTelemetryBuffer[i]); diff --git a/radio/src/telemetry/frsky.cpp b/radio/src/telemetry/frsky.cpp index 22edba920..6b5d61edf 100644 --- a/radio/src/telemetry/frsky.cpp +++ b/radio/src/telemetry/frsky.cpp @@ -76,7 +76,6 @@ void processFrskyPXX2Data(uint8_t data) if (telemetryRxBuffer[0] == 0x0c) { sportProcessTelemetryPacketWithoutCrc(telemetryRxBuffer + 5 /* LEN, TYPE, RSSI/BAT, TP/SS/FW_T, FW_VER, Data ID */); - TRACE("Got TELEM data"); } } telemetryRxBufferCount = 0;