Battery level displaying
This commit is contained in:
parent
13c4e50264
commit
7291a9eef3
33
.cproject
33
.cproject
@ -22,7 +22,8 @@
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.565286878" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.37600117" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1822215885" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F103CBTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | /Users/clement/STM32Cube/Repository/STM32Cube_FW_F1_V1.8.6/Drivers/STM32F1xx_HAL_Driver/Inc | /Users/clement/STM32Cube/Repository/STM32Cube_FW_F1_V1.8.6/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy | /Users/clement/STM32Cube/Repository/STM32Cube_FW_F1_V1.8.6/Drivers/CMSIS/Device/ST/STM32F1xx/Include | /Users/clement/STM32Cube/Repository/STM32Cube_FW_F1_V1.8.6/Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32F103xB || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F103CBTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.1725797747" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="64" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.1725797747" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="64" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat.144424741" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat" value="true" valueType="boolean"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.2106904101" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||
<builder buildPath="${workspace_loc:/ow-dash-cube}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1958807577" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.909874354" name="MCU/MPU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
||||
@ -95,26 +96,26 @@
|
||||
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.2010124864" name="Release" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release">
|
||||
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.2010124864." name="/" resourcePath="">
|
||||
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release.1996682977" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release">
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.1015202491" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="true" value="STM32F103CBTx" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.1177527638" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" useByScannerDiscovery="false" value="0" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.41017139" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.346353224" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.204008112" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F103CBTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | /Users/clement/STM32Cube/Repository/STM32Cube_FW_F1_V1.8.6/Drivers/STM32F1xx_HAL_Driver/Inc | /Users/clement/STM32Cube/Repository/STM32Cube_FW_F1_V1.8.6/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy | /Users/clement/STM32Cube/Repository/STM32Cube_FW_F1_V1.8.6/Drivers/CMSIS/Device/ST/STM32F1xx/Include | /Users/clement/STM32Cube/Repository/STM32Cube_FW_F1_V1.8.6/Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32F103xB || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F103CBTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.1851993780" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="64" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.1015202491" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="true" value="STM32F103CBTx" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.1177527638" name="CPU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" useByScannerDiscovery="false" value="0" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.41017139" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.346353224" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.204008112" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F103CBTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | /Users/clement/STM32Cube/Repository/STM32Cube_FW_F1_V1.8.6/Drivers/STM32F1xx_HAL_Driver/Inc | /Users/clement/STM32Cube/Repository/STM32Cube_FW_F1_V1.8.6/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy | /Users/clement/STM32Cube/Repository/STM32Cube_FW_F1_V1.8.6/Drivers/CMSIS/Device/ST/STM32F1xx/Include | /Users/clement/STM32Cube/Repository/STM32Cube_FW_F1_V1.8.6/Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32F103xB || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F103CBTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.1851993780" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="64" valueType="string"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.423977139" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||
<builder buildPath="${workspace_loc:/ow-dash-cube}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.12974942" managedBuildOn="true" name="Gnu Make Builder.Release" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
||||
<builder buildPath="${workspace_loc:/ow-dash-cube}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.12974942" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.147359294" name="MCU/MPU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.184360309" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g0" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.184360309" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g0" valueType="enumerated"/>
|
||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.1802112648" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1995662216" name="MCU/MPU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.1591594808" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.5550489" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.os" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.729264445" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.1591594808" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.5550489" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.os" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.729264445" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||
<listOptionValue builtIn="false" value="STM32F103xB"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.877492354" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.877492354" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="../Core/Inc"/>
|
||||
<listOptionValue builtIn="false" value="/Users/clement/STM32Cube/Repository/STM32Cube_FW_F1_V1.8.6/Drivers/STM32F1xx_HAL_Driver/Inc"/>
|
||||
<listOptionValue builtIn="false" value="/Users/clement/STM32Cube/Repository/STM32Cube_FW_F1_V1.8.6/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy"/>
|
||||
@ -124,11 +125,11 @@
|
||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.648640408" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
||||
</tool>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.30520216" name="MCU/MPU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler">
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.94668465" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.1491875658" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.value.os" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.94668465" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.1491875658" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.value.os" valueType="enumerated"/>
|
||||
</tool>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.69987060" name="MCU/MPU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker">
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.1678081859" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="${workspace_loc:/${ProjName}/STM32F103CBTX_FLASH.ld}" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.1678081859" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="${workspace_loc:/${ProjName}/STM32F103CBTX_FLASH.ld}" valueType="string"/>
|
||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.1983013067" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
#define COLOR_SECONDARY 0x667f
|
||||
#define COLOR_SUCCESS 0x3766
|
||||
#define COLOR_ERROR 0xf226
|
||||
#define COLOR_BG 0xFFFF
|
||||
#define COLOR_FG 0x0000
|
||||
#define COLOR_FG 0xFFFF
|
||||
#define COLOR_BG 0x0000
|
||||
#define COLOR_OFF 0x0000
|
||||
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ void GFX_DrawChar(
|
||||
uint16_t GFX_GetTextWidth(const char *text, const GFXfont *font, int8_t letter_spacing);
|
||||
|
||||
// Alignment: 0 => Left, 1 => Center, 2 => Right
|
||||
void GFX_DrawText(
|
||||
uint16_t GFX_DrawText(
|
||||
uint16_t x,
|
||||
uint16_t y,
|
||||
const char *text,
|
||||
|
||||
@ -96,7 +96,6 @@ void LCD_Init(void) {
|
||||
LCD_Write_Command(0x36);
|
||||
LCD_Write_Data(0b00111100);
|
||||
|
||||
|
||||
// Exit sleep
|
||||
LCD_Write_Command(0x11);
|
||||
HAL_Delay(150);
|
||||
@ -375,7 +374,6 @@ void LCD_Draw_Filled_Rectangle_Coord(
|
||||
// while ((SPI3->SR & SPI_SR_BSY) != 0);//Attendre fin envoi trame
|
||||
// CS_OFF;
|
||||
//}
|
||||
|
||||
void LCD_DrawHollowRoundRect(
|
||||
uint16_t x,
|
||||
uint16_t y,
|
||||
@ -388,247 +386,260 @@ void LCD_DrawHollowRoundRect(
|
||||
uint16_t fill_color,
|
||||
uint8_t do_fill) {
|
||||
|
||||
uint8_t radius_top_lines = radius_top ? radius_top - 1 : 0;
|
||||
uint8_t radius_bottom_lines = radius_bottom ? radius_bottom - 1 : 0;
|
||||
uint8_t radius_top_lines = radius_top ? radius_top - 1 : 0;
|
||||
uint8_t radius_bottom_lines = radius_bottom ? radius_bottom - 1 : 0;
|
||||
|
||||
// Fill interior if requested
|
||||
if (do_fill) {
|
||||
uint16_t x_inner, y_inner, w_inner, h_inner;
|
||||
uint8_t radius_top_fill, radius_bottom_fill;
|
||||
// Fill interior if requested
|
||||
if (do_fill) {
|
||||
uint16_t x_inner, y_inner, w_inner, h_inner;
|
||||
uint8_t radius_top_fill, radius_bottom_fill;
|
||||
|
||||
if (border_width == 0) {
|
||||
// Full area fill (no border)
|
||||
x_inner = x;
|
||||
y_inner = y;
|
||||
w_inner = w;
|
||||
h_inner = h;
|
||||
radius_top_fill = radius_top;
|
||||
radius_bottom_fill = radius_bottom;
|
||||
} else {
|
||||
// Interior area (inside border)
|
||||
x_inner = x + border_width;
|
||||
y_inner = y + border_width;
|
||||
w_inner = (w > 2 * border_width) ? w - 2 * border_width : 0;
|
||||
h_inner = (h > 2 * border_width) ? h - 2 * border_width : 0;
|
||||
if (border_width == 0) {
|
||||
// Full area fill (no border)
|
||||
x_inner = x;
|
||||
y_inner = y;
|
||||
w_inner = w;
|
||||
h_inner = h;
|
||||
radius_top_fill = radius_top;
|
||||
radius_bottom_fill = radius_bottom;
|
||||
} else {
|
||||
// Interior area (inside border)
|
||||
x_inner = x + border_width;
|
||||
y_inner = y + border_width;
|
||||
w_inner = (w > 2 * border_width) ? w - 2 * border_width : 0;
|
||||
h_inner = (h > 2 * border_width) ? h - 2 * border_width : 0;
|
||||
|
||||
radius_top_fill = (radius_top > border_width) ? radius_top - border_width : 0;
|
||||
radius_bottom_fill = (radius_bottom > border_width) ? radius_bottom - border_width : 0;
|
||||
}
|
||||
radius_top_fill =
|
||||
(radius_top > border_width) ? radius_top - border_width : 0;
|
||||
radius_bottom_fill =
|
||||
(radius_bottom > border_width) ? radius_bottom - border_width : 0;
|
||||
}
|
||||
|
||||
// Draw filled interior (only if dimensions are valid)
|
||||
if (w_inner > 0 && h_inner > 0) {
|
||||
uint16_t x_central = x_inner + radius_top_fill;
|
||||
uint16_t y_central = y;
|
||||
uint16_t w_central = w_inner - 2*radius_top_fill;
|
||||
uint16_t h_central = h;
|
||||
LCD_Draw_Rectangle(x_central, y_central, w_central, h_central, fill_color);
|
||||
|
||||
uint16_t x_left = x;
|
||||
uint16_t y_left = y_inner + radius_top_fill;
|
||||
uint16_t w_left = x_inner + radius_top_fill + 1 - x;
|
||||
uint16_t h_left = h_inner - radius_bottom_fill - radius_top_fill;
|
||||
LCD_Draw_Rectangle(x_left, y_left, w_left, h_left, fill_color);
|
||||
// Draw filled interior (only if dimensions are valid)
|
||||
if (w_inner > 0 && h_inner > 0) {
|
||||
uint16_t x_central = x_inner + radius_top_fill;
|
||||
uint16_t y_central = y;
|
||||
if (w_inner > 2 * radius_top_fill) {
|
||||
uint16_t w_central = w_inner - 2 * radius_top_fill;
|
||||
uint16_t h_central = h;
|
||||
LCD_Draw_Rectangle(x_central, y_central, w_central, h_central,
|
||||
fill_color);
|
||||
}
|
||||
|
||||
uint16_t x_left = x;
|
||||
uint16_t y_left = y_inner + radius_top_fill;
|
||||
if (x_inner + radius_top_fill + 1 > x) {
|
||||
uint16_t w_left = x_inner + radius_top_fill + 1 - x;
|
||||
if (h_inner > radius_bottom_fill + radius_top_fill) {
|
||||
uint16_t h_left = h_inner - radius_bottom_fill - radius_top_fill;
|
||||
LCD_Draw_Rectangle(x_left, y_left, w_left, h_left, fill_color);
|
||||
if (x + w > w_left) {
|
||||
uint16_t x_right = x + w - w_left;
|
||||
LCD_Draw_Rectangle(x_right, y_left, w_left, h_left, fill_color);
|
||||
|
||||
|
||||
// Top-left rounded corner
|
||||
if (radius_top_fill > 0) {
|
||||
uint32_t r_sq = (uint32_t)radius_top_fill * radius_top_fill;
|
||||
int16_t center_x = x_inner + radius_top_fill - 1;
|
||||
int16_t center_y = y_inner + radius_top_fill - 1;
|
||||
|
||||
for (int16_t i = x_inner; i < x_inner + radius_top_fill; i++) {
|
||||
for (int16_t j = y_inner; j < y_inner + radius_top_fill; j++) {
|
||||
int16_t dx = center_x - i;
|
||||
int16_t dy = center_y - j;
|
||||
uint32_t dist_sq = (uint32_t)dx * dx + (uint32_t)dy * dy;
|
||||
if (dist_sq <= r_sq) {
|
||||
LCD_Draw_Pixel(i, j, fill_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Top-right rounded corner
|
||||
if (radius_top_fill > 0) {
|
||||
uint32_t r_sq = (uint32_t)radius_top_fill * radius_top_fill;
|
||||
int16_t center_x = x_inner + w_inner - radius_top_fill;
|
||||
int16_t center_y = y_inner + radius_top_fill - 1;
|
||||
|
||||
for (int16_t i = x_inner + w_inner - radius_top_fill; i < x_inner + w_inner; i++) {
|
||||
for (int16_t j = y_inner; j < y_inner + radius_top_fill; j++) {
|
||||
int16_t dx = i - center_x;
|
||||
int16_t dy = center_y - j;
|
||||
uint32_t dist_sq = (uint32_t)dx * dx + (uint32_t)dy * dy;
|
||||
if (dist_sq <= r_sq) {
|
||||
LCD_Draw_Pixel(i, j, fill_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bottom-left rounded corner
|
||||
if (radius_bottom_fill > 0) {
|
||||
uint32_t r_sq = (uint32_t)radius_bottom_fill * radius_bottom_fill;
|
||||
int16_t center_x = x_inner + radius_bottom_fill - 1;
|
||||
int16_t center_y = y_inner + h_inner - radius_bottom_fill;
|
||||
|
||||
for (int16_t i = x_inner; i < x_inner + radius_bottom_fill; i++) {
|
||||
for (int16_t j = y_inner + h_inner - radius_bottom_fill; j < y_inner + h_inner; j++) {
|
||||
int16_t dx = center_x - i;
|
||||
int16_t dy = j - center_y;
|
||||
uint32_t dist_sq = (uint32_t)dx * dx + (uint32_t)dy * dy;
|
||||
if (dist_sq <= r_sq) {
|
||||
LCD_Draw_Pixel(i, j, fill_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bottom-right rounded corner
|
||||
if (radius_bottom_fill > 0) {
|
||||
uint32_t r_sq = (uint32_t)radius_bottom_fill * radius_bottom_fill;
|
||||
int16_t center_x = x_inner + w_inner - radius_bottom_fill;
|
||||
int16_t center_y = y_inner + h_inner - radius_bottom_fill;
|
||||
|
||||
for (int16_t i = x_inner + w_inner - radius_bottom_fill; i < x_inner + w_inner; i++) {
|
||||
for (int16_t j = y_inner + h_inner - radius_bottom_fill; j < y_inner + h_inner; j++) {
|
||||
int16_t dx = i - center_x;
|
||||
int16_t dy = j - center_y;
|
||||
uint32_t dist_sq = (uint32_t)dx * dx + (uint32_t)dy * dy;
|
||||
if (dist_sq <= r_sq) {
|
||||
LCD_Draw_Pixel(i, j, fill_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Top-left rounded corner
|
||||
if (radius_top_fill > 0) {
|
||||
uint32_t r_sq = (uint32_t) radius_top_fill * radius_top_fill;
|
||||
int16_t center_x = x_inner + radius_top_fill - 1;
|
||||
int16_t center_y = y_inner + radius_top_fill - 1;
|
||||
|
||||
for (int16_t i = x_inner; i < x_inner + radius_top_fill; i++) {
|
||||
for (int16_t j = y_inner; j < y_inner + radius_top_fill; j++) {
|
||||
int16_t dx = center_x - i;
|
||||
int16_t dy = center_y - j;
|
||||
uint32_t dist_sq = (uint32_t) dx * dx + (uint32_t) dy * dy;
|
||||
if (dist_sq <= r_sq) {
|
||||
LCD_Draw_Pixel(i, j, fill_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Top-right rounded corner
|
||||
if (radius_top_fill > 0) {
|
||||
uint32_t r_sq = (uint32_t) radius_top_fill * radius_top_fill;
|
||||
int16_t center_x = x_inner + w_inner - radius_top_fill;
|
||||
int16_t center_y = y_inner + radius_top_fill - 1;
|
||||
|
||||
for (int16_t i = x_inner + w_inner - radius_top_fill;
|
||||
i < x_inner + w_inner; i++) {
|
||||
for (int16_t j = y_inner; j < y_inner + radius_top_fill; j++) {
|
||||
int16_t dx = i - center_x;
|
||||
int16_t dy = center_y - j;
|
||||
uint32_t dist_sq = (uint32_t) dx * dx + (uint32_t) dy * dy;
|
||||
if (dist_sq <= r_sq) {
|
||||
LCD_Draw_Pixel(i, j, fill_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bottom-left rounded corner
|
||||
if (radius_bottom_fill > 0) {
|
||||
uint32_t r_sq = (uint32_t) radius_bottom_fill * radius_bottom_fill;
|
||||
int16_t center_x = x_inner + radius_bottom_fill - 1;
|
||||
int16_t center_y = y_inner + h_inner - radius_bottom_fill;
|
||||
|
||||
for (int16_t i = x_inner; i < x_inner + radius_bottom_fill; i++) {
|
||||
for (int16_t j = y_inner + h_inner - radius_bottom_fill;
|
||||
j < y_inner + h_inner; j++) {
|
||||
int16_t dx = center_x - i;
|
||||
int16_t dy = j - center_y;
|
||||
uint32_t dist_sq = (uint32_t) dx * dx + (uint32_t) dy * dy;
|
||||
if (dist_sq <= r_sq) {
|
||||
LCD_Draw_Pixel(i, j, fill_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bottom-right rounded corner
|
||||
if (radius_bottom_fill > 0) {
|
||||
uint32_t r_sq = (uint32_t) radius_bottom_fill * radius_bottom_fill;
|
||||
int16_t center_x = x_inner + w_inner - radius_bottom_fill;
|
||||
int16_t center_y = y_inner + h_inner - radius_bottom_fill;
|
||||
|
||||
for (int16_t i = x_inner + w_inner - radius_bottom_fill;
|
||||
i < x_inner + w_inner; i++) {
|
||||
for (int16_t j = y_inner + h_inner - radius_bottom_fill;
|
||||
j < y_inner + h_inner; j++) {
|
||||
int16_t dx = i - center_x;
|
||||
int16_t dy = j - center_y;
|
||||
uint32_t dist_sq = (uint32_t) dx * dx + (uint32_t) dy * dy;
|
||||
if (dist_sq <= r_sq) {
|
||||
LCD_Draw_Pixel(i, j, fill_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw border only if requested (border_width > 0)
|
||||
if (border_width > 0) {
|
||||
// Top horizontal border segment
|
||||
if (w > 2 * radius_top_lines) {
|
||||
uint16_t x_top = x + radius_top_lines;
|
||||
uint16_t y_top = y;
|
||||
uint16_t w_top = w - 2 * radius_top_lines;
|
||||
uint16_t h_top = border_width;
|
||||
LCD_Draw_Rectangle(x_top, y_top, w_top, h_top, color);
|
||||
}
|
||||
|
||||
// Draw border only if requested (border_width > 0)
|
||||
if (border_width > 0) {
|
||||
// Top horizontal border segment
|
||||
if (w > 2 * radius_top_lines) {
|
||||
uint16_t x_top = x + radius_top_lines;
|
||||
uint16_t y_top = y;
|
||||
uint16_t w_top = w - 2 * radius_top_lines;
|
||||
uint16_t h_top = border_width;
|
||||
LCD_Draw_Rectangle(x_top, y_top, w_top, h_top, color);
|
||||
}
|
||||
|
||||
// Bottom horizontal border segment
|
||||
if (w > 2 * radius_bottom_lines) {
|
||||
uint16_t x_bottom = x + radius_bottom_lines;
|
||||
uint16_t y_bottom = y + h - border_width;
|
||||
uint16_t w_bottom = w - 2 * radius_bottom_lines;
|
||||
uint16_t h_bottom = border_width;
|
||||
LCD_Draw_Rectangle(x_bottom, y_bottom, w_bottom, h_bottom, color);
|
||||
}
|
||||
|
||||
// Left vertical border segment
|
||||
if (h > radius_top_lines + radius_bottom_lines) {
|
||||
uint16_t x_left = x;
|
||||
uint16_t y_left = y + radius_top_lines;
|
||||
uint16_t w_left = border_width;
|
||||
uint16_t h_left = h - radius_top_lines - radius_bottom_lines;
|
||||
LCD_Draw_Rectangle(x_left, y_left, w_left, h_left, color);
|
||||
}
|
||||
|
||||
// Right vertical border segment
|
||||
if (h > radius_top_lines + radius_bottom_lines) {
|
||||
uint16_t x_right = x + w - border_width;
|
||||
uint16_t y_right = y + radius_top_lines;
|
||||
uint16_t w_right = border_width;
|
||||
uint16_t h_right = h - radius_top_lines - radius_bottom_lines;
|
||||
LCD_Draw_Rectangle(x_right, y_right, w_right, h_right, color);
|
||||
}
|
||||
|
||||
// Top-left rounded corner
|
||||
if (radius_top > 0) {
|
||||
int16_t inner_radius = radius_top - border_width;
|
||||
if (inner_radius < 0) inner_radius = 0;
|
||||
uint32_t inner_sq = (uint32_t)inner_radius * inner_radius;
|
||||
uint32_t outer_sq = (uint32_t)radius_top * radius_top;
|
||||
int16_t center_x = x + radius_top - 1;
|
||||
int16_t center_y = y + radius_top - 1;
|
||||
|
||||
for (int16_t i = x; i < x + radius_top; i++) {
|
||||
for (int16_t j = y; j < y + radius_top; j++) {
|
||||
int16_t dx = center_x - i;
|
||||
int16_t dy = center_y - j;
|
||||
uint32_t dist_sq = (uint32_t)dx * dx + (uint32_t)dy * dy;
|
||||
if (dist_sq <= outer_sq && dist_sq > inner_sq) {
|
||||
LCD_Draw_Pixel(i, j, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Top-right rounded corner
|
||||
if (radius_top > 0) {
|
||||
int16_t inner_radius = radius_top - border_width;
|
||||
if (inner_radius < 0) inner_radius = 0;
|
||||
uint32_t inner_sq = (uint32_t)inner_radius * inner_radius;
|
||||
uint32_t outer_sq = (uint32_t)radius_top * radius_top;
|
||||
int16_t center_x = x + w - radius_top;
|
||||
int16_t center_y = y + radius_top - 1;
|
||||
|
||||
for (int16_t i = x + w - radius_top; i < x + w; i++) {
|
||||
for (int16_t j = y; j < y + radius_top; j++) {
|
||||
int16_t dx = i - center_x;
|
||||
int16_t dy = center_y - j;
|
||||
uint32_t dist_sq = (uint32_t)dx * dx + (uint32_t)dy * dy;
|
||||
if (dist_sq <= outer_sq && dist_sq > inner_sq) {
|
||||
LCD_Draw_Pixel(i, j, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bottom-left rounded corner
|
||||
if (radius_bottom > 0) {
|
||||
int16_t inner_radius = radius_bottom - border_width;
|
||||
if (inner_radius < 0) inner_radius = 0;
|
||||
uint32_t inner_sq = (uint32_t)inner_radius * inner_radius;
|
||||
uint32_t outer_sq = (uint32_t)radius_bottom * radius_bottom;
|
||||
int16_t center_x = x + radius_bottom - 1;
|
||||
int16_t center_y = y + h - radius_bottom;
|
||||
|
||||
for (int16_t i = x; i < x + radius_bottom; i++) {
|
||||
for (int16_t j = y + h - radius_bottom; j < y + h; j++) {
|
||||
int16_t dx = center_x - i;
|
||||
int16_t dy = j - center_y;
|
||||
uint32_t dist_sq = (uint32_t)dx * dx + (uint32_t)dy * dy;
|
||||
if (dist_sq <= outer_sq && dist_sq > inner_sq) {
|
||||
LCD_Draw_Pixel(i, j, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bottom-right rounded corner
|
||||
if (radius_bottom > 0) {
|
||||
int16_t inner_radius = radius_bottom - border_width;
|
||||
if (inner_radius < 0) inner_radius = 0;
|
||||
uint32_t inner_sq = (uint32_t)inner_radius * inner_radius;
|
||||
uint32_t outer_sq = (uint32_t)radius_bottom * radius_bottom;
|
||||
int16_t center_x = x + w - radius_bottom;
|
||||
int16_t center_y = y + h - radius_bottom;
|
||||
|
||||
for (int16_t i = x + w - radius_bottom; i < x + w; i++) {
|
||||
for (int16_t j = y + h - radius_bottom; j < y + h; j++) {
|
||||
int16_t dx = i - center_x;
|
||||
int16_t dy = j - center_y;
|
||||
uint32_t dist_sq = (uint32_t)dx * dx + (uint32_t)dy * dy;
|
||||
if (dist_sq <= outer_sq && dist_sq > inner_sq) {
|
||||
LCD_Draw_Pixel(i, j, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Bottom horizontal border segment
|
||||
if (w > 2 * radius_bottom_lines) {
|
||||
uint16_t x_bottom = x + radius_bottom_lines;
|
||||
uint16_t y_bottom = y + h - border_width;
|
||||
uint16_t w_bottom = w - 2 * radius_bottom_lines;
|
||||
uint16_t h_bottom = border_width;
|
||||
LCD_Draw_Rectangle(x_bottom, y_bottom, w_bottom, h_bottom, color);
|
||||
}
|
||||
|
||||
// Left vertical border segment
|
||||
if (h > radius_top_lines + radius_bottom_lines) {
|
||||
uint16_t x_left = x;
|
||||
uint16_t y_left = y + radius_top_lines;
|
||||
uint16_t w_left = border_width;
|
||||
uint16_t h_left = h - radius_top_lines - radius_bottom_lines;
|
||||
LCD_Draw_Rectangle(x_left, y_left, w_left, h_left, color);
|
||||
}
|
||||
|
||||
// Right vertical border segment
|
||||
if (h > radius_top_lines + radius_bottom_lines) {
|
||||
uint16_t x_right = x + w - border_width;
|
||||
uint16_t y_right = y + radius_top_lines;
|
||||
uint16_t w_right = border_width;
|
||||
uint16_t h_right = h - radius_top_lines - radius_bottom_lines;
|
||||
LCD_Draw_Rectangle(x_right, y_right, w_right, h_right, color);
|
||||
}
|
||||
|
||||
// Top-left rounded corner
|
||||
if (radius_top > 0) {
|
||||
int16_t inner_radius = radius_top - border_width;
|
||||
if (inner_radius < 0) inner_radius = 0;
|
||||
uint32_t inner_sq = (uint32_t) inner_radius * inner_radius;
|
||||
uint32_t outer_sq = (uint32_t) radius_top * radius_top;
|
||||
int16_t center_x = x + radius_top - 1;
|
||||
int16_t center_y = y + radius_top - 1;
|
||||
|
||||
for (int16_t i = x; i < x + radius_top; i++) {
|
||||
for (int16_t j = y; j < y + radius_top; j++) {
|
||||
int16_t dx = center_x - i;
|
||||
int16_t dy = center_y - j;
|
||||
uint32_t dist_sq = (uint32_t) dx * dx + (uint32_t) dy * dy;
|
||||
if (dist_sq <= outer_sq && dist_sq > inner_sq) {
|
||||
LCD_Draw_Pixel(i, j, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Top-right rounded corner
|
||||
if (radius_top > 0) {
|
||||
int16_t inner_radius = radius_top - border_width;
|
||||
if (inner_radius < 0) inner_radius = 0;
|
||||
uint32_t inner_sq = (uint32_t) inner_radius * inner_radius;
|
||||
uint32_t outer_sq = (uint32_t) radius_top * radius_top;
|
||||
int16_t center_x = x + w - radius_top;
|
||||
int16_t center_y = y + radius_top - 1;
|
||||
|
||||
for (int16_t i = x + w - radius_top; i < x + w; i++) {
|
||||
for (int16_t j = y; j < y + radius_top; j++) {
|
||||
int16_t dx = i - center_x;
|
||||
int16_t dy = center_y - j;
|
||||
uint32_t dist_sq = (uint32_t) dx * dx + (uint32_t) dy * dy;
|
||||
if (dist_sq <= outer_sq && dist_sq > inner_sq) {
|
||||
LCD_Draw_Pixel(i, j, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bottom-left rounded corner
|
||||
if (radius_bottom > 0) {
|
||||
int16_t inner_radius = radius_bottom - border_width;
|
||||
if (inner_radius < 0) inner_radius = 0;
|
||||
uint32_t inner_sq = (uint32_t) inner_radius * inner_radius;
|
||||
uint32_t outer_sq = (uint32_t) radius_bottom * radius_bottom;
|
||||
int16_t center_x = x + radius_bottom - 1;
|
||||
int16_t center_y = y + h - radius_bottom;
|
||||
|
||||
for (int16_t i = x; i < x + radius_bottom; i++) {
|
||||
for (int16_t j = y + h - radius_bottom; j < y + h; j++) {
|
||||
int16_t dx = center_x - i;
|
||||
int16_t dy = j - center_y;
|
||||
uint32_t dist_sq = (uint32_t) dx * dx + (uint32_t) dy * dy;
|
||||
if (dist_sq <= outer_sq && dist_sq > inner_sq) {
|
||||
LCD_Draw_Pixel(i, j, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bottom-right rounded corner
|
||||
if (radius_bottom > 0) {
|
||||
int16_t inner_radius = radius_bottom - border_width;
|
||||
if (inner_radius < 0) inner_radius = 0;
|
||||
uint32_t inner_sq = (uint32_t) inner_radius * inner_radius;
|
||||
uint32_t outer_sq = (uint32_t) radius_bottom * radius_bottom;
|
||||
int16_t center_x = x + w - radius_bottom;
|
||||
int16_t center_y = y + h - radius_bottom;
|
||||
|
||||
for (int16_t i = x + w - radius_bottom; i < x + w; i++) {
|
||||
for (int16_t j = y + h - radius_bottom; j < y + h; j++) {
|
||||
int16_t dx = i - center_x;
|
||||
int16_t dy = j - center_y;
|
||||
uint32_t dist_sq = (uint32_t) dx * dx + (uint32_t) dy * dy;
|
||||
if (dist_sq <= outer_sq && dist_sq > inner_sq) {
|
||||
LCD_Draw_Pixel(i, j, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -4,12 +4,22 @@
|
||||
#include "monomaniacone14pt.h"
|
||||
#include "monomaniacone20pt.h"
|
||||
#include "monomaniacone72pt.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void run_dashboard_loop() {
|
||||
|
||||
init();
|
||||
uint32_t i = 0;
|
||||
while (1) {
|
||||
|
||||
draw_battery(654, i * 100, 1321, 343);
|
||||
|
||||
HAL_Delay(100);
|
||||
if (i == 100) {
|
||||
i = 0;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -51,12 +61,13 @@ void draw_init() {
|
||||
GFX_DrawChar(120, 40, '5', &monomaniacone20pt, COLOR_ERROR, COLOR_BG);
|
||||
|
||||
GFX_DrawText(LCD_WIDTH / 2, 50, "Bonjour Monsieur !", &monomaniacone12pt,
|
||||
COLOR_SECONDARY, COLOR_BG, 1, -2);
|
||||
COLOR_SECONDARY, COLOR_BG, 1, -2);
|
||||
GFX_DrawText(LCD_WIDTH / 2, 70, "Bonjour Monsieur !", &monomaniacone14pt,
|
||||
COLOR_SECONDARY, COLOR_BG, 1, -2);
|
||||
COLOR_SECONDARY, COLOR_BG, 1, -2);
|
||||
GFX_DrawText(LCD_WIDTH / 2, 100, "Bonjour MONSieur !", &monomaniacone20pt,
|
||||
COLOR_SUCCESS, COLOR_BG, 1, -2);
|
||||
GFX_DrawText(LCD_WIDTH / 2, 26+95, "12", &monomaniacone72pt, COLOR_FG, COLOR_BG, 1, -5);
|
||||
COLOR_SUCCESS, COLOR_BG, 1, -2);
|
||||
GFX_DrawText(LCD_WIDTH / 2, 26 + 95, "12", &monomaniacone72pt, COLOR_FG,
|
||||
COLOR_BG, 1, -5);
|
||||
|
||||
// Draw a rectangle with different top/bottom radii
|
||||
LCD_DrawHollowRoundRect(10, 10, 100, 50, 10, 0, 4, BLACK, COLOR_PRIMARY, 1);
|
||||
@ -67,10 +78,116 @@ void draw_init() {
|
||||
LCD_DrawHollowRoundRect(130, 100, 60, 60, 10, 10, 0, 0, COLOR_ERROR, 1);
|
||||
LCD_DrawHollowRoundRect(136, 106, 48, 48, 4, 4, 0, 0, COLOR_PRIMARY, 1);
|
||||
|
||||
uint16_t bar_width = LCD_WIDTH - 12;
|
||||
LCD_DrawHollowRoundRect(4, LCD_HEIGHT - 30, bar_width+4, 26, 8, 8, 2,
|
||||
COLOR_FG, COLOR_SUCCESS, 0);
|
||||
LCD_DrawHollowRoundRect(4+2, LCD_HEIGHT - 30 + 2, 0.75 * bar_width, 22, 6, 6, 0,
|
||||
COLOR_FG, COLOR_SUCCESS, 1);
|
||||
LCD_DrawHollowRoundRect(200, 100, 4, 20, 6, 6, 0, 0, COLOR_PRIMARY, 1);
|
||||
LCD_DrawHollowRoundRect(200, 125, 6, 20, 6, 6, 0, 0, COLOR_PRIMARY, 1);
|
||||
LCD_DrawHollowRoundRect(200, 150, 8, 20, 6, 6, 0, 0, COLOR_PRIMARY, 1);
|
||||
}
|
||||
|
||||
// Displays the battery voltage and percent, with the trip and life distances
|
||||
// Input voltage from COMM_GET_VALUES, scale 10
|
||||
// battery percent (level) from COMM_GET_VALUES_SETUP, scale 100
|
||||
// trip distance from COMM_GET_VALUES_SETUP, scale 100
|
||||
// life distance (odometer) from COMM_GET_VALUES_SETUP
|
||||
void draw_battery(
|
||||
int16_t voltage,
|
||||
int32_t percent,
|
||||
int32_t trip_dist,
|
||||
uint32_t life_dist) {
|
||||
|
||||
uint16_t bar_width = LCD_WIDTH - 12;
|
||||
uint16_t bar_height = 22;
|
||||
uint16_t filled_bar_width = (((float) (percent / 100)) / 100.0) * bar_width;
|
||||
if(filled_bar_width < 6) {
|
||||
filled_bar_width = 6; // Must be at least the size of the border radius.
|
||||
}
|
||||
uint16_t filled_bar_end_x = 4 + 2 + filled_bar_width;
|
||||
uint16_t text_y_12 = LCD_HEIGHT - 6 - (22 - 16) / 2;
|
||||
uint16_t text_y_14 = LCD_HEIGHT - 6 - (22 - 18) / 2;
|
||||
|
||||
char voltage_text[8];
|
||||
sprintf(voltage_text, "%.1fV", ((float) voltage) / 10.0);
|
||||
char percent_text[6];
|
||||
sprintf(percent_text, "%lu%%", percent / 100);
|
||||
char distances_text[20];
|
||||
sprintf(distances_text, "%.1fKm / %luKm", ((float) trip_dist) / 100.0,
|
||||
life_dist);
|
||||
|
||||
// Drawing the bars
|
||||
LCD_DrawHollowRoundRect(4, LCD_HEIGHT - (bar_height + 4) - 4, bar_width + 4,
|
||||
bar_height + 4, 8, 8, 2, COLOR_FG, COLOR_BG, 1);
|
||||
if (filled_bar_width > 0) {
|
||||
LCD_DrawHollowRoundRect(4 + 2, LCD_HEIGHT - (bar_height + 2) - 4,
|
||||
filled_bar_width, bar_height, 6, 6, 0, 0, COLOR_SUCCESS, 1);
|
||||
}
|
||||
|
||||
// Drawing the values
|
||||
uint16_t left_x = 10;
|
||||
uint16_t right_x = LCD_WIDTH - 10;
|
||||
|
||||
if (percent > 20 * 100) {
|
||||
// Drawing the voltage to the left
|
||||
left_x = 12
|
||||
+ GFX_DrawText(left_x, text_y_14, voltage_text, &monomaniacone14pt,
|
||||
COLOR_BG, COLOR_SUCCESS, 0, -2);
|
||||
} else {
|
||||
// Drawing the voltage to the right
|
||||
right_x = -12
|
||||
+ GFX_DrawText(right_x, text_y_14, voltage_text, &monomaniacone14pt,
|
||||
COLOR_FG, COLOR_BG, 2, -2);
|
||||
}
|
||||
|
||||
if (percent > 50 * 100) {
|
||||
// Drawing the distances on the left
|
||||
GFX_DrawText(left_x, text_y_14, distances_text, &monomaniacone14pt,
|
||||
COLOR_BG, COLOR_SUCCESS, 0, -4);
|
||||
} else {
|
||||
// Drawing the distances on the right
|
||||
GFX_DrawText(right_x, text_y_14, distances_text, &monomaniacone14pt,
|
||||
COLOR_FG, COLOR_BG, 2, -4);
|
||||
}
|
||||
|
||||
if (percent > 80 * 100) {
|
||||
// Drawing the distances on the left
|
||||
GFX_DrawText(filled_bar_end_x - 4, text_y_14, percent_text,
|
||||
&monomaniacone14pt,
|
||||
COLOR_BG, COLOR_SUCCESS, 2, 0);
|
||||
} else {
|
||||
// Drawing the distances on the right
|
||||
GFX_DrawText(filled_bar_end_x + 4, text_y_14, percent_text,
|
||||
&monomaniacone14pt,
|
||||
COLOR_FG, COLOR_BG, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Displays the power bars at the top
|
||||
// Duty from COMM_GET_VALUES, scale 1000
|
||||
void draw_power_bars(int16_t duty) {
|
||||
|
||||
}
|
||||
|
||||
// Displays the huge speed counter with avg and max values.
|
||||
// Speed from COMM_GET_VALUES_SETUP, scale 1000
|
||||
void draw_speed(int32_t speed) {
|
||||
|
||||
}
|
||||
|
||||
// Displays Current, Duty, Watts
|
||||
// Current from COMM_GET_VALUES, scale 100
|
||||
// Duty from COMM_GET_VALUES, scale 1000
|
||||
// Input voltage from COMM_GET_VALUES, scale 10
|
||||
void draw_power(int32_t amps, int16_t duty, int16_t voltage) {
|
||||
|
||||
}
|
||||
|
||||
// Displays the two ADS voltages
|
||||
// 2 voltages from COMM_GET_DECODED_ADC, scale 1 000 000
|
||||
void draw_adc(int32_t adc1, int32_t adc2) {
|
||||
|
||||
}
|
||||
|
||||
// Displays the controller and motor temperatures
|
||||
// 2 temperatures from COMM_GET_VALUES_SETUP, scale 10
|
||||
void draw_temps(int16_t temp_fet, int16_t temp_motor) {
|
||||
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ uint16_t GFX_GetTextWidth(const char *text, const GFXfont *font, int8_t letter_s
|
||||
return width;
|
||||
}
|
||||
|
||||
void GFX_DrawText(
|
||||
uint16_t GFX_DrawText(
|
||||
uint16_t x,
|
||||
uint16_t y,
|
||||
const char *text,
|
||||
@ -122,4 +122,8 @@ void GFX_DrawText(
|
||||
|
||||
text++;
|
||||
}
|
||||
if(alignment == 2) {
|
||||
return x;
|
||||
}
|
||||
return cursorX;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user