diff --git a/CREDITS.txt b/CREDITS.txt index 63135b139..c0b6df8a8 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -2018,3 +2018,12 @@ Gerard Falaise Kevin Raynor Lorenzo gh Jan Landeweer +David Bland +Manuel Spoerri +Jeff Jacobs +David Thorne +Maddox Philip +James Jewitt +Justin Digby +John Magnuson (monthly) +Holger Lippert diff --git a/radio/sdcard/horus/WIDGETS/Ghost/img/green.png b/radio/sdcard/horus/WIDGETS/Ghost/img/green.png new file mode 100644 index 000000000..27c3a85cc Binary files /dev/null and b/radio/sdcard/horus/WIDGETS/Ghost/img/green.png differ diff --git a/radio/sdcard/horus/WIDGETS/Ghost/img/orange.png b/radio/sdcard/horus/WIDGETS/Ghost/img/orange.png new file mode 100644 index 000000000..6f926c44b Binary files /dev/null and b/radio/sdcard/horus/WIDGETS/Ghost/img/orange.png differ diff --git a/radio/sdcard/horus/WIDGETS/Ghost/img/red.png b/radio/sdcard/horus/WIDGETS/Ghost/img/red.png new file mode 100644 index 000000000..86b8da84f Binary files /dev/null and b/radio/sdcard/horus/WIDGETS/Ghost/img/red.png differ diff --git a/radio/sdcard/horus/WIDGETS/Ghost/main.lua b/radio/sdcard/horus/WIDGETS/Ghost/main.lua index dfaef17c9..1e1c5c06d 100644 --- a/radio/sdcard/horus/WIDGETS/Ghost/main.lua +++ b/radio/sdcard/horus/WIDGETS/Ghost/main.lua @@ -16,6 +16,8 @@ ---- ######################################################################### local backgroundBitmap +local orangeLed +local greenLed local offsetX local offsetY local sensors = {} @@ -45,6 +47,8 @@ end local function create(zone, options) local wgt = { zone=zone, options=options} backgroundBitmap = Bitmap.open("/WIDGETS/Ghost/img/background.png") + orangeLed = Bitmap.open("/WIDGETS/Ghost/img/orange.png") + greenLed = Bitmap.open("/WIDGETS/Ghost/img/green.png") offsetX = (wgt.zone.w - 178) / 2 offsetY = (wgt.zone.h - 148) / 2 return wgt @@ -68,6 +72,14 @@ function refresh(wgt) end if getRSSI() ~= 0 then + if getValue("RFMD") == "Pure" then + if orangeLed ~= nil then + lcd.drawBitmap(orangeLed, wgt.zone.x + offsetX + 143, wgt.zone.y + offsetY) + end + elseif greenLed ~= nil then + lcd.drawBitmap(greenLed, wgt.zone.x + offsetX + 143, wgt.zone.y + offsetY) + end + getValues(wgt) -- RF Mode/Band diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 9b8713b51..fa2f4fd2c 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1837,6 +1837,7 @@ void moveTrimsToOffsets() // copy state of 3 primary to subtrim if (g_model.limitData[i].revert) diff = -diff; v += (diff * 125) / 128; + g_model.limitData[i].offset = limit((int16_t)-1000, (int16_t)v, (int16_t)1000); // make sure the offset doesn't go haywire } diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 284048491..fe42cdd5c 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -1131,6 +1131,7 @@ union ReusableBuffer #if defined(GHOST) struct { GhostMenuData line[GHST_MENU_LINES + 1]; + uint8_t menuFlags; uint8_t menuAction; uint8_t buttonAction; } ghostMenu; diff --git a/radio/src/pulses/ghost.cpp b/radio/src/pulses/ghost.cpp index 1847976e2..df4fa6f69 100755 --- a/radio/src/pulses/ghost.cpp +++ b/radio/src/pulses/ghost.cpp @@ -22,8 +22,6 @@ uint8_t createGhostMenuControlFrame(uint8_t * frame, int16_t * pulses) { - moduleState[EXTERNAL_MODULE].counter = GHST_FRAME_CHANNEL; - uint8_t * buf = frame; #if SPORT_MAX_BAUDRATE < 400000 *buf++ = g_eeGeneral.telemetryBaudrate == GHST_TELEMETRY_RATE_400K ? GHST_ADDR_MODULE_SYM : GHST_ADDR_MODULE_ASYM; @@ -118,5 +116,7 @@ void setupPulsesGhost() extmodulePulsesData.ghost.length = createGhostMenuControlFrame(pulses, &channelOutputs[g_model.moduleData[EXTERNAL_MODULE].channelsStart]); else extmodulePulsesData.ghost.length = createGhostChannelsFrame(pulses, &channelOutputs[g_model.moduleData[EXTERNAL_MODULE].channelsStart]); + + moduleState[EXTERNAL_MODULE].counter = GHST_FRAME_CHANNEL; } } diff --git a/radio/src/targets/taranis/extmodule_driver.cpp b/radio/src/targets/taranis/extmodule_driver.cpp index a5b6a4acd..4287c0f75 100644 --- a/radio/src/targets/taranis/extmodule_driver.cpp +++ b/radio/src/targets/taranis/extmodule_driver.cpp @@ -37,7 +37,8 @@ void extmoduleStop() GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_Init(EXTMODULE_USART_GPIO, &GPIO_InitStructure); - GPIO_ResetBits(EXTMODULE_USART_GPIO, EXTMODULE_TX_GPIO_PIN | EXTMODULE_RX_GPIO_PIN); + // TX and RX are inverted, we set it to HIGH + GPIO_SetBits(EXTMODULE_USART_GPIO, EXTMODULE_TX_GPIO_PIN | EXTMODULE_RX_GPIO_PIN); #endif EXTMODULE_TIMER->DIER &= ~(TIM_DIER_CC2IE | TIM_DIER_UDE); diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index c67d65ff7..b7160cbf9 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -1242,29 +1242,6 @@ #define EXTMODULE_USART_TX_DMA_STREAM DMA2_Stream6 #define EXTMODULE_USART_RX_DMA_CHANNEL DMA_Channel_5 #define EXTMODULE_USART_RX_DMA_STREAM DMA2_Stream1 -#elif defined(RADIO_X9DP2019) - #define EXTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2) - #define EXTMODULE_RCC_APB2Periph (RCC_APB2Periph_TIM8 | RCC_APB2Periph_USART6) - #define EXTMODULE_PWR_GPIO GPIOD - #define EXTMODULE_PWR_GPIO_PIN GPIO_Pin_8 // PD.08 - #define EXTERNAL_MODULE_PWR_ON() GPIO_SetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN) - #define EXTERNAL_MODULE_PWR_OFF() GPIO_ResetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN) - #define IS_EXTERNAL_MODULE_ON() (GPIO_ReadInputDataBit(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN) == Bit_SET) - #define EXTMODULE_TX_GPIO GPIOC - #define EXTMODULE_TX_GPIO_PIN GPIO_Pin_7 // PC.07 - #define EXTMODULE_TX_GPIO_PinSource GPIO_PinSource7 - #define EXTMODULE_TIMER TIM8 - #define EXTMODULE_TIMER_TX_GPIO_AF GPIO_AF_TIM8 // TIM8_CH2 - #define EXTMODULE_TIMER_CC_IRQn TIM8_CC_IRQn - #define EXTMODULE_TIMER_CC_IRQHandler TIM8_CC_IRQHandler - #define EXTMODULE_TIMER_DMA_CHANNEL DMA_Channel_7 // TIM8_UP - #define EXTMODULE_TIMER_DMA_STREAM DMA2_Stream1 // TIM8_UP - #define EXTMODULE_TIMER_DMA_STREAM_IRQn DMA2_Stream1_IRQn - #define EXTMODULE_TIMER_DMA_STREAM_IRQHandler DMA2_Stream1_IRQHandler - #define EXTMODULE_TIMER_DMA_FLAG_TC DMA_IT_TCIF1 - #define EXTMODULE_TIMER_OUTPUT_ENABLE TIM_CCER_CC2E - #define EXTMODULE_TIMER_OUTPUT_POLARITY TIM_CCER_CC2NP - #define EXTMODULE_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2) #else #define EXTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2) #define EXTMODULE_RCC_APB2Periph RCC_APB2Periph_TIM8 diff --git a/radio/src/telemetry/ghost.cpp b/radio/src/telemetry/ghost.cpp index 10928da21..7a9653bb4 100755 --- a/radio/src/telemetry/ghost.cpp +++ b/radio/src/telemetry/ghost.cpp @@ -46,6 +46,9 @@ enum GHOST_ID_VTX_CHAN = 0x000a, // Vtx Channel GHOST_ID_VTX_BAND = 0x000b, // Vtx Band + GHOST_ID_PACK_VOLTS = 0x000c, // Battery Pack Voltage + GHOST_ID_PACK_AMPS = 0x000d, // Battery Pack Current + GHOST_ID_PACK_MAH = 0x000e, // Battery Pack mAh consumed }; const GhostSensor ghostSensors[] = { @@ -63,6 +66,10 @@ const GhostSensor ghostSensors[] = { {GHOST_ID_VTX_CHAN, ZSTR_VTX_CHAN, UNIT_RAW, 0}, {GHOST_ID_VTX_BAND, ZSTR_VTX_BAND, UNIT_TEXT, 0}, + {GHOST_ID_PACK_VOLTS, ZSTR_BATT, UNIT_VOLTS, 2}, + {GHOST_ID_PACK_AMPS, ZSTR_CURR, UNIT_AMPS, 2}, + {GHOST_ID_PACK_MAH, ZSTR_CAPACITY, UNIT_MAH, 0}, + {0x00, NULL, UNIT_RAW, 0}, }; @@ -103,6 +110,11 @@ uint16_t getTelemetryValue_u16(uint8_t index) return (telemetryRxBuffer[index] << 8) | telemetryRxBuffer[index + 1]; } +uint16_t getTelemetryValue_u16le(uint8_t index) +{ + return (telemetryRxBuffer[index + 1] << 8) | telemetryRxBuffer[index]; +} + uint32_t getTelemetryValue_s32(uint8_t index) { uint32_t val = 0; @@ -180,11 +192,10 @@ void processGhostTelemetryFrame() { GhostMenuFrame * packet; GhostMenuData * lineData; - packet = (GhostMenuFrame * ) telemetryRxBuffer; lineData = (GhostMenuData *) &reusableBuffer.ghostMenu.line[packet->lineIndex]; lineData->splitLine = 0; - reusableBuffer.ghostMenu.menuAction = packet->menuFlags; + reusableBuffer.ghostMenu.menuFlags = packet->menuFlags; lineData->lineFlags = packet->lineFlags; for (uint8_t i = 0; i < GHST_MENU_CHARS; i++) { if (packet->menuText[i] == 0x7C) { @@ -198,6 +209,19 @@ void processGhostTelemetryFrame() lineData->menuText[GHST_MENU_CHARS] = '\0'; break; } + + case GHST_DL_PACK_STAT: { +#if defined(BLUETOOTH) + if (g_eeGeneral.bluetoothMode == BLUETOOTH_TELEMETRY && bluetooth.state == BLUETOOTH_STATE_CONNECTED) { + bluetooth.write(telemetryRxBuffer, telemetryRxBufferCount); + } +#endif + processGhostTelemetryValue(GHOST_ID_PACK_VOLTS, getTelemetryValue_u16le(3)); + processGhostTelemetryValue(GHOST_ID_PACK_AMPS, getTelemetryValue_u16le(5)); + processGhostTelemetryValue(GHOST_ID_PACK_MAH, getTelemetryValue_u16le(7) * 10); + + break; + } } } diff --git a/radio/src/telemetry/ghost.h b/radio/src/telemetry/ghost.h index 77ced179f..ae8c63465 100755 --- a/radio/src/telemetry/ghost.h +++ b/radio/src/telemetry/ghost.h @@ -43,6 +43,7 @@ #define GHST_DL_OPENTX_SYNC 0x20 #define GHST_DL_LINK_STAT 0x21 #define GHST_DL_VTX_STAT 0x22 +#define GHST_DL_PACK_STAT 0x23 #define GHST_DL_MENU_DESC 0x24 #define GHST_RC_CTR_VAL_12BIT 0x7C0 // 0x3e0 << 1