Merge pull request #8153 from opentx/3djc/tx12-charge
Handles charge indication on TX12
This commit is contained in:
@@ -183,8 +183,13 @@ void displayBattVoltage()
|
||||
lcdDrawSolidFilledRect(VBATT_X - 25, VBATT_Y + 9, 21, 5);
|
||||
lcdDrawSolidVerticalLine(VBATT_X - 4, VBATT_Y + 10, 3);
|
||||
uint8_t count = GET_TXBATT_BARS(20);
|
||||
for (uint8_t i = 0; i < count; i += 2)
|
||||
for (uint8_t i = 0; i < count; i += 2) {
|
||||
#if defined(USB_CHARGER)
|
||||
if ((i >= count - 2) && usbChargerLed() && BLINK_ON_PHASE) // Blink last segment on charge
|
||||
continue;
|
||||
#endif
|
||||
lcdDrawSolidVerticalLine(VBATT_X - 24 + i, VBATT_Y + 10, 3);
|
||||
}
|
||||
if (!IS_TXBATT_WARNING() || BLINK_ON_PHASE)
|
||||
lcdDrawSolidFilledRect(VBATT_X - 26, VBATT_Y, 24, 15);
|
||||
#else
|
||||
|
||||
@@ -140,6 +140,7 @@ elseif(PCB STREQUAL X7)
|
||||
set(ROTARY_ENCODER YES)
|
||||
set(LUA_EXPORT lua_export_tx12)
|
||||
set(BLUETOOTH NO)
|
||||
set(USB_CHARGER YES)
|
||||
add_definitions(-DRADIO_TX12)
|
||||
add_definitions(-DEEPROM_VARIANT=0x4002)
|
||||
add_definitions(-DMANUFACTURER_RADIOMASTER)
|
||||
@@ -333,6 +334,11 @@ if(ROTARY_ENCODER)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(USB_CHARGER)
|
||||
set(TARGET_SRC ${TARGET_SRC} usb_charger_driver.cpp)
|
||||
add_definitions(-DUSB_CHARGER)
|
||||
endif()
|
||||
|
||||
if(BLUETOOTH)
|
||||
add_definitions(-DBLUETOOTH)
|
||||
set(TARGET_SRC
|
||||
|
||||
@@ -92,7 +92,8 @@ void boardInit()
|
||||
TRAINER_RCC_AHB1Periph |
|
||||
TRAINER_MODULE_RCC_AHB1Periph |
|
||||
BT_RCC_AHB1Periph |
|
||||
GYRO_RCC_AHB1Periph,
|
||||
GYRO_RCC_AHB1Periph |
|
||||
USB_CHARGER_RCC_AHB1Periph,
|
||||
ENABLE);
|
||||
|
||||
RCC_APB1PeriphClockCmd(ROTARY_ENCODER_RCC_APB1Periph |
|
||||
@@ -193,6 +194,10 @@ void boardInit()
|
||||
toplcdInit();
|
||||
#endif
|
||||
|
||||
#if defined(USB_CHARGER)
|
||||
usbChargerInit();
|
||||
#endif
|
||||
|
||||
if (HAS_SPORT_UPDATE_CONNECTOR()) {
|
||||
sportUpdateInit();
|
||||
}
|
||||
|
||||
@@ -863,6 +863,10 @@ void bluetoothDisable();
|
||||
#define IS_BLUETOOTH_CHIP_PRESENT() (true)
|
||||
#endif
|
||||
|
||||
// USB Charger
|
||||
void usbChargerInit();
|
||||
bool usbChargerLed();
|
||||
|
||||
// LED driver
|
||||
void ledInit();
|
||||
void ledOff();
|
||||
|
||||
@@ -1424,6 +1424,16 @@
|
||||
#define PCBREV_RCC_AHB1Periph 0
|
||||
#endif
|
||||
|
||||
|
||||
// USB Charger
|
||||
#if defined(USB_CHARGER)
|
||||
#define USB_CHARGER_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
|
||||
#define USB_CHARGER_GPIO GPIOB
|
||||
#define USB_CHARGER_GPIO_PIN GPIO_Pin_5 // PB.05
|
||||
#else
|
||||
#define USB_CHARGER_RCC_AHB1Periph 0
|
||||
#endif
|
||||
|
||||
// S.Port update connector
|
||||
#if defined(PCBXLITE)
|
||||
#define SPORT_MAX_BAUDRATE 250000 // not tested
|
||||
@@ -1439,7 +1449,7 @@
|
||||
#define SPORT_UPDATE_PWR_GPIO_PIN GPIO_Pin_3 // PB.03
|
||||
#define GPIO_SPORT_UPDATE_PWR_GPIO_ON GPIO_SetBits
|
||||
#define GPIO_SPORT_UPDATE_PWR_GPIO_OFF GPIO_ResetBits
|
||||
#elif defined(PCBX7)
|
||||
#elif defined(RADIO_X7)
|
||||
#define SPORT_MAX_BAUDRATE 250000 // < 400000
|
||||
#define SPORT_UPDATE_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
|
||||
#define SPORT_UPDATE_PWR_GPIO GPIOB
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
void usbChargerInit()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = USB_CHARGER_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(USB_CHARGER_GPIO, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
bool usbChargerLed()
|
||||
{
|
||||
return (GPIO_ReadInputDataBit(USB_CHARGER_GPIO, USB_CHARGER_GPIO_PIN) == Bit_RESET && usbPlugged());
|
||||
}
|
||||
Reference in New Issue
Block a user