Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion radio/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include(CMakeForceCompiler)
include(Bitmaps)

set(PCB_TYPES X9LITE X9LITES X7 XLITE XLITES X9D X9D+ X9E X10 X12S PL18 T15PRO ST16 PA01 TX15 TX16SMK3)
set(PCB_TYPES X9LITE X9LITES X7 XLITE XLITES X9D X9D+ X9E X10 X12S PL18 T15PRO ST16 PA01 TX15 TX16SMK3 V12)
set(RADIO_LANGUAGES CN CZ DA DE EN ES FI FR HE HU IT JP KO NL PL PT RU SE SK TW UA)
set(TTS_LANGUAGES CN CZ DA DE EN ES FI FR HE HU IT JP KO NL PL PT RU SE SK TW UA)

Expand Down Expand Up @@ -97,6 +97,8 @@ elseif(PCB STREQUAL ST16)
include(targets/st16/CMakeLists.txt)
elseif(PCB STREQUAL PA01)
include(targets/pa01/CMakeLists.txt)
elseif(PCB STREQUAL V12)
include(targets/v12/CMakeLists.txt)
elseif(PCB STREQUAL TX15)
include(targets/tx15/CMakeLists.txt)
elseif(PCB STREQUAL TX16SMK3)
Expand Down
22 changes: 22 additions & 0 deletions radio/src/boards/generic_stm32/i2c_bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ static const stm32_i2c_hw_def_t _i2c2 = {
};
#endif

#if defined(I2C_B4)
static const stm32_i2c_hw_def_t _i2c4 = {
.I2Cx = I2C_B4,
.SCL_GPIO = (gpio_t)I2C_B4_SCL_GPIO,
.SDA_GPIO = (gpio_t)I2C_B4_SDA_GPIO,
.GPIO_AF = I2C_B4_GPIO_AF,
.set_pwr = nullptr,
};
#endif

int i2c_init(etx_i2c_bus_t bus)
{
#if defined(I2C_B1)
Expand All @@ -72,6 +82,12 @@ int i2c_init(etx_i2c_bus_t bus)
}
#endif

#if defined(I2C_B4)
if (bus == I2C_Bus_4) {
return stm32_i2c_init(I2C_Bus_4, I2C_B4_CLK_RATE, &_i2c4);
}
#endif

return -1;
}

Expand All @@ -89,6 +105,12 @@ int i2c_deinit(etx_i2c_bus_t bus)
}
#endif

#if defined(I2C_B4)
if (bus == I2C_Bus_4) {
return stm32_i2c_deinit(I2C_Bus_4);
}
#endif

return -1;
}

Expand Down
94 changes: 94 additions & 0 deletions radio/src/boards/helloradio-h750/backlight_driver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* 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 "hal/gpio.h"
#include "stm32_gpio.h"
#include "stm32_timer.h"
#include "stm32_pulse_driver.h"

#include "edgetx_types.h"
#include "board.h"

#include "globals.h"

static const stm32_pulse_timer_t _bl_timer = {
.GPIO = (gpio_t)BACKLIGHT_GPIO,
.GPIO_Alternate = BACKLIGHT_GPIO_AF,
.TIMx = BACKLIGHT_TIMER,
.TIM_Freq = BACKLIGHT_TIMER_FREQ,
.TIM_Channel = BACKLIGHT_TIMER_CHANNEL,
.TIM_IRQn = (IRQn_Type)-1,
.DMAx = nullptr,
.DMA_Stream = 0,
.DMA_Channel = 0,
.DMA_IRQn = (IRQn_Type)-1,
.DMA_TC_CallbackPtr = nullptr,
};

void backlightLowInit()
{
gpio_init(BACKLIGHT_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
gpio_clear(BACKLIGHT_GPIO);
}

void backlightInit()
{
stm32_pulse_init(&_bl_timer, 10000);
stm32_pulse_config_output(&_bl_timer, true, LL_TIM_OCMODE_PWM1, 100);
LL_TIM_SetAutoReload(_bl_timer.TIMx, 100);
LL_TIM_EnableCounter(_bl_timer.TIMx);
}

uint8_t lastDutyCycle = 0;

void backlightEnable(uint8_t dutyCycle)
{
stm32_pulse_set_cmp_val(&_bl_timer, dutyCycle);

// TODO: removed until QSPI & LCD SPI are split
// if(!dutyCycle) {
// //experimental to turn off LCD when no backlight
// // if(lcdOffFunction) lcdOffFunction();
// }
// else if(!lastDutyCycle) {
// // if(lcdOnFunction) lcdOnFunction();
// // else lcdInit();
// }

// lastDutyCycle = dutyCycle;
}

void lcdOff() {
backlightEnable(0);
}

void lcdOn(){
// if(lcdOnFunction) lcdOnFunction();
// else lcdInit();
backlightEnable(BACKLIGHT_LEVEL_MAX);
}

bool boardBacklightOn;

bool isBacklightEnabled()
{
return boardBacklightOn;
}
Loading