Linting & bringing the config closer to the ST7365

This commit is contained in:
Clément Grennerat 2025-08-18 23:08:08 +02:00
parent 6e6abff60c
commit 3bd65d37a5
11 changed files with 671 additions and 765 deletions

8
.idea/.gitignore generated vendored
View File

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

102
.idea/editor.xml generated
View File

@ -1,102 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BackendCodeEditorSettings">
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXPRESSION/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_FOR_STMT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_PARAMETER/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_ARGUMENT/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_PARAMETER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTIPLE_DECLARATION/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_TERNARY/@EntryValue" value="ALIGN_ALL" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_CLASS_DEFINITION/@EntryValue" value="1" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_DECLARATIONS/@EntryValue" value="0" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DECLARATION/@EntryValue" value="1" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DEFINITION/@EntryValue" value="1" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BREAK_TEMPLATE_DECLARATION/@EntryValue" value="LINE_BREAK" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Double" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/FREE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_COMMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_SIZE/@EntryValue" value="4" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_STYLE/@EntryValue" value="Space" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INITIALIZER_BRACES/@EntryValue" value="END_OF_LINE_NO_SPACE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INT_ALIGN_EQ/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INVOCABLE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_CODE/@EntryValue" value="2" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue" value="2" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_USER_LINEBREAKS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_COLON_IN_MEMBER_INITIALIZER_LISTS/@EntryValue" value="ON_SINGLE_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/MEMBER_INITIALIZER_LIST_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_INDENTATION/@EntryValue" value="All" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/OTHER_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_CATCH_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_ELSE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_NAMESPACE_DEFINITIONS_ON_SAME_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_WHILE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_BLOCK_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_COLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_SEMICOLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_METHOD/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_NESTED_DECLARATOR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_METHOD/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_UNARY_OPERATOR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_COLON/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_SEMICOLON/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_METHOD/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_METHOD/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BETWEEN_CLOSING_ANGLE_BRACKETS_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_ARRAY_ACCESS_BRACKETS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_DECLARATION_PARENTHESES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_BLOCKS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_METHOD_PARENTHESES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPECIAL_ELSE_IF_TREATMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TAB_WIDTH/@EntryValue" value="4" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_BINARY_OPSIGN/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_DECLARATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_INVOCATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ARGUMENTS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_RPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_RPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_TERNARY_OPSIGNS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_PARAMETERS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
<option name="/Default/CodeStyle/EditorConfig/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
</component>
</project>

View File

@ -1,12 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredIdentifiers">
<list>
<option value="src.*" />
</list>
</option>
</inspection_tool>
</profile>
</component>

7
.idea/misc.xml generated
View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakePythonSetting">
<option name="pythonIntegrationState" value="YES" />
</component>
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>

8
.idea/modules.xml generated
View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ow-dash-cube.iml" filepath="$PROJECT_DIR$/.idea/ow-dash-cube.iml" />
</modules>
</component>
</project>

View File

@ -1,2 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />

4
.idea/vcs.xml generated
View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings" defaultProject="true" />
</project>

View File

@ -31,7 +31,6 @@
#define LCD_SCREEN_HEIGHT 320 #define LCD_SCREEN_HEIGHT 320
#define LCD_SCREEN_WIDTH 480 #define LCD_SCREEN_WIDTH 480
//CHIP SELECT PIN AND PORT, STANDARD GPIO //CHIP SELECT PIN AND PORT, STANDARD GPIO
#define LCD_CS_PIN (1<<8) #define LCD_CS_PIN (1<<8)
#define LCD_DC_PIN (1<<11) #define LCD_DC_PIN (1<<11)
@ -45,7 +44,6 @@
//#define LCD_RST_PORT GPIOC //#define LCD_RST_PORT GPIOC
//#define LCD_RST_PIN RST_Pin //#define LCD_RST_PIN RST_Pin
#define BURST_MAX_SIZE 100 //buffer burst stocké sur pile. Par défaut stackSiZE=256 dans FreeRTOS. #define BURST_MAX_SIZE 100 //buffer burst stocké sur pile. Par défaut stackSiZE=256 dans FreeRTOS.
#define BLACK 0x0000 #define BLACK 0x0000
@ -94,17 +92,29 @@ void LCD_Fill_Screen(uint16_t Colour);
void LCD_Draw_Colour(uint16_t Colour); void LCD_Draw_Colour(uint16_t Colour);
// @param Colour : voir #define de quelques couleurs 16 bits standard ci-dessus // @param Colour : voir #define de quelques couleurs 16 bits standard ci-dessus
void LCD_Draw_Pixel(uint16_t X,uint16_t Y,uint16_t Colour); void LCD_Draw_Pixel(uint16_t X, uint16_t Y, uint16_t Colour);
//@param X : coordonnee x //@param X : coordonnee x
//@param Y : coordonnee y //@param Y : coordonnee y
//@param Colour : voir #define de quelques couleurs 16 bits standard ci-dessus //@param Colour : voir #define de quelques couleurs 16 bits standard ci-dessus
void LCD_Draw_Horizontal_Line(uint16_t X, uint16_t Y, uint16_t Width, uint16_t Colour); void LCD_Draw_Horizontal_Line(
void LCD_Draw_Vertical_Line(uint16_t X, uint16_t Y, uint16_t Height, uint16_t Colour); uint16_t X,
void LCD_Draw_Rectangle(uint16_t X, uint16_t Y, uint16_t Width, uint16_t Height, uint16_t Colour); uint16_t Y,
uint16_t Width,
uint16_t Colour);
void LCD_Draw_Vertical_Line(
uint16_t X,
uint16_t Y,
uint16_t Height,
uint16_t Colour);
void LCD_Draw_Rectangle(
uint16_t X,
uint16_t Y,
uint16_t Width,
uint16_t Height,
uint16_t Colour);
void LCD_Draw_Colour_Burst(uint16_t Colour, uint32_t Size); void LCD_Draw_Colour_Burst(uint16_t Colour, uint32_t Size);
#endif #endif
/*******************PARTIE ISSUE DE LA LIB ILI9193_GFX.h***************************/ /*******************PARTIE ISSUE DE LA LIB ILI9193_GFX.h***************************/
@ -115,22 +125,60 @@ void LCD_Draw_Colour_Burst(uint16_t Colour, uint32_t Size);
#define HORIZONTAL_IMAGE 0 #define HORIZONTAL_IMAGE 0
#define VERTICAL_IMAGE 1 #define VERTICAL_IMAGE 1
void LCD_Draw_Hollow_Circle(uint16_t X, uint16_t Y, uint16_t Radius, uint16_t Colour); void LCD_Draw_Hollow_Circle(
void LCD_Draw_Filled_Circle(uint16_t X, uint16_t Y, uint16_t Radius, uint16_t Colour); uint16_t X,
void LCD_Draw_Hollow_Rectangle_Coord(uint16_t X0, uint16_t Y0, uint16_t X1, uint16_t Y1, uint16_t Colour); uint16_t Y,
void LCD_Draw_Filled_Rectangle_Coord(uint16_t X0, uint16_t Y0, uint16_t X1, uint16_t Y1, uint16_t Colour); uint16_t Radius,
void LCD_Draw_Char(char Character, uint16_t X, uint16_t Y, uint16_t Colour, uint16_t Size, uint16_t Background_Colour); uint16_t Colour);
void LCD_Draw_Filled_Circle(
uint16_t X,
uint16_t Y,
uint16_t Radius,
uint16_t Colour);
void LCD_Draw_Hollow_Rectangle_Coord(
uint16_t X0,
uint16_t Y0,
uint16_t X1,
uint16_t Y1,
uint16_t Colour);
void LCD_Draw_Filled_Rectangle_Coord(
uint16_t X0,
uint16_t Y0,
uint16_t X1,
uint16_t Y1,
uint16_t Colour);
void LCD_Draw_Char(
char Character,
uint16_t X,
uint16_t Y,
uint16_t Colour,
uint16_t Size,
uint16_t Background_Colour);
void LCD_Draw_Text(const char* Text, uint16_t X, uint16_t Y, uint16_t Colour, uint16_t Size, uint16_t Background_Colour); void LCD_Draw_Text(
const char *Text,
uint16_t X,
uint16_t Y,
uint16_t Colour,
uint16_t Size,
uint16_t Background_Colour);
/*Draws a character (fonts imported from fonts.h) at X,Y location with specified font colour, size and Background colour*/ /*Draws a character (fonts imported from fonts.h) at X,Y location with specified font colour, size and Background colour*/
void LCD_Draw_Filled_Rectangle_Size_Text(uint16_t X0, uint16_t Y0, uint16_t Size_X, uint16_t Size_Y, uint16_t Colour); void LCD_Draw_Filled_Rectangle_Size_Text(
uint16_t X0,
uint16_t Y0,
uint16_t Size_X,
uint16_t Size_Y,
uint16_t Colour);
void LCD_Draw_Image_XY(
void LCD_Draw_Image_XY(const char* Image_Array, uint16_t X, uint16_t Y, uint16_t Width, uint16_t Height); const char *Image_Array,
uint16_t X,
uint16_t Y,
uint16_t Width,
uint16_t Height);
/*Dessine une image 65K couleurs (2Bytes / Pixel) dans une zone de l'ecran, aux coordonnées X et Y*/ /*Dessine une image 65K couleurs (2Bytes / Pixel) dans une zone de l'ecran, aux coordonnées X et Y*/
//CONVERTISSEUR: http://www.digole.com/tools/PicturetoC_Hex_converter.php //CONVERTISSEUR: http://www.digole.com/tools/PicturetoC_Hex_converter.php
void LCD_Draw_Image_Full(const char *Image_Array, uint8_t Orientation);
void LCD_Draw_Image_Full(const char* Image_Array, uint8_t Orientation);
#endif #endif

View File

@ -16,6 +16,7 @@
* *
****************************************************************************** ******************************************************************************
*/ */
//@formatter:off
/* USER CODE END Header */ /* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/ /* Define to prevent recursive inclusion -------------------------------------*/
@ -31,29 +32,34 @@ extern "C" {
/* Private includes ----------------------------------------------------------*/ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
//@formatter:on
//@formatter:off
/* USER CODE END Includes */ /* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */ /* USER CODE BEGIN ET */
//@formatter:on
//@formatter:off
/* USER CODE END ET */ /* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */ /* USER CODE BEGIN EC */
//@formatter:on
//@formatter:off
/* USER CODE END EC */ /* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */ /* USER CODE BEGIN EM */
//@formatter:on
//@formatter:off
/* USER CODE END EM */ /* USER CODE END EM */
/* Exported functions prototypes ---------------------------------------------*/ /* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void); void Error_Handler(void);
/* USER CODE BEGIN EFP */ /* USER CODE BEGIN EFP */
//@formatter:on
//@formatter:off
/* USER CODE END EFP */ /* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/ /* Private defines -----------------------------------------------------------*/
@ -105,7 +111,8 @@ void Error_Handler(void);
#define DB12_GPIO_Port GPIOB #define DB12_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */ /* USER CODE BEGIN Private defines */
//@formatter:on
//@formatter:off
/* USER CODE END Private defines */ /* USER CODE END Private defines */
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -32,81 +32,77 @@
volatile uint16_t LCD_HEIGHT = LCD_SCREEN_HEIGHT; volatile uint16_t LCD_HEIGHT = LCD_SCREEN_HEIGHT;
volatile uint16_t LCD_WIDTH = LCD_SCREEN_WIDTH; volatile uint16_t LCD_WIDTH = LCD_SCREEN_WIDTH;
/* SPI3 & GPIOs init function */ /* SPI3 & GPIOs init function */
void LCD_SPI_Init(void) void LCD_SPI_Init(void) {
{ //__HAL_RCC_SPI3_CLK_ENABLE();
//__HAL_RCC_SPI3_CLK_ENABLE(); RCC->APB1ENR1 |= RCC_APB1ENR1_SPI3EN;// SPI3 clock enable
RCC->APB1ENR1 |= RCC_APB1ENR1_SPI3EN; // SPI3 clock enable RCC->AHB2ENR |= RCC_AHB2ENR_GPIOCEN;// GPIOC clock enable
RCC->AHB2ENR |= RCC_AHB2ENR_GPIOCEN; // GPIOC clock enable
/** CS & DC GPIO signals configuration /** CS & DC GPIO signals configuration
PC8 ------> LCD_CS_PIN PC8 ------> LCD_CS_PIN
PC11 ------> LCD_DC_PIN PC11 ------> LCD_DC_PIN
*/ */
GPIOC->BSRR = LCD_CS_PIN | (LCD_DC_PIN <<16); //CS à 1 et DC à 0 GPIOC->BSRR = LCD_CS_PIN | (LCD_DC_PIN << 16);//CS à 1 et DC à 0
GPIOC->MODER |= (1<<16)|(1<<22); //GPIO out GPIOC->MODER |= (1 << 16) | (1 << 22);//GPIO out
GPIOC->MODER &= ~((1<<17)|(1<<23)); //mise à 0 GPIOC->MODER &= ~((1 << 17) | (1 << 23));//mise à 0
GPIOC->OTYPER &= (GPIO_OTYPER_OT8 | GPIO_OTYPER_OT11); //PC8 & 11 en PP GPIOC->OTYPER &= (GPIO_OTYPER_OT8 | GPIO_OTYPER_OT11);//PC8 & 11 en PP
GPIOC->OSPEEDR |= (3<<16) | (3<<22); //High speed GPIOC->OSPEEDR |= (3 << 16) | (3 << 22);//High speed
/**SPI3 GPIO Configuration /**SPI3 GPIO Configuration
PC10 ------> SPI3_SCK PC10 ------> SPI3_SCK
PC12 ------> SPI3_MOSI */ PC12 ------> SPI3_MOSI */
GPIOC->AFR[1] |= (6 << 8)|(6 << 16); //PC10 en AF6 : SPI3_SCK, PC12 en AF6 : SPI3_MOSI GPIOC->AFR[1] |= (6 << 8) | (6 << 16);//PC10 en AF6 : SPI3_SCK, PC12 en AF6 : SPI3_MOSI
GPIOC->AFR[1] &= 0xFFF6F6FF; //Mise à 0 GPIOC->AFR[1] &= 0xFFF6F6FF;//Mise à 0
GPIOC->MODER |= (2<<20)|(2<<24); //MODE AF GPIOC->MODER |= (2 << 20) | (2 << 24);//MODE AF
GPIOC->MODER &= 0xFEEFFFFF; //Mise à 0 GPIOC->MODER &= 0xFEEFFFFF;//Mise à 0
GPIOC->OTYPER &= (GPIO_OTYPER_OT10 | GPIO_OTYPER_OT12); //PC10 & 12 en PP GPIOC->OTYPER &= (GPIO_OTYPER_OT10 | GPIO_OTYPER_OT12);//PC10 & 12 en PP
GPIOC->OSPEEDR |= (3<<24) | (3<<20); //High speed GPIOC->OSPEEDR |= (3 << 24) | (3 << 20);//High speed
/*Configure module SPI3*/ /*Configure module SPI3*/
SPI3->CR1=SPI_CR1_SSM | SPI_CR1_SSI; //CS soft, SSI à 1 sinon decl. mode fault SPI3->CR1 = SPI_CR1_SSM | SPI_CR1_SSI;//CS soft, SSI à 1 sinon decl. mode fault
SPI3->CR1|=SPI_CR1_MSTR; // 0 sauf SPE et mode Master, BR = 0 => /2=> Fsck=40M SPI3->CR1 |= SPI_CR1_MSTR;// 0 sauf SPE et mode Master, BR = 0 => /2=> Fsck=40M
SPI3->CR2=0x0700 | SPI_CR2_FRXTH;// | SPI_CR2_NSSP; //mode 8 bits, ITs disabled, no DMA, FRXTH doit être à 1 en 8 bits SPI3->CR2 = 0x0700 | SPI_CR2_FRXTH;// | SPI_CR2_NSSP; //mode 8 bits, ITs disabled, no DMA, FRXTH doit être à 1 en 8 bits
SPI3->CR1|=SPI_CR1_SPE; SPI3->CR1 |= SPI_CR1_SPE;
} }
/* Send command (char) to LCD via SPI bus */ /* Send command (char) to LCD via SPI bus */
void LCD_Write_Command(uint8_t Command) void LCD_Write_Command(uint8_t Command) {
{ CMD
// principe : on attend toujours la fin du transfert, à cause du CS_OFF soft qui arrive après. ;
// donc à priori pas besoin de tester l'état du buffer TX avant l'envoi : //CS_ON;
// le buffer devrait toujours vide while ((SPI1->SR & SPI_SR_TXE) != 0);// Waiting for TX register to be available.
CMD; //Ligne de commande a '1' *(uint8_t*) (SPI1_DR_ADR) = Command;// Cast sur pointeur, pour ecriture 8 bits. Sinon l'acces 16 bits provoque un tfert 16 bits
//CS_ON; //while ((SPI1->SR & SPI_SR_BSY) != 0); //Attendre fin envoi trame (cf RM P1289)
while ((SPI1->SR & SPI_SR_TXE) != 0); // SPI_SR_BSY si besoin dattendre la fin complète de lenvoi des trames SPI. //CS_OFF;
*(uint8_t *)(SPI1_DR_ADR) = Command; //Cast sur pointeur, pour ecriture 8 bits. Sinon l'acces 16 bits provoque un tfert 16 bits
//CS_OFF;
} }
/* Send Data (char) to LCD via SPI bus */ /* Send Data (char) to LCD via SPI bus */
void LCD_Write_Data(uint8_t Data) void LCD_Write_Data(uint8_t Data) {
{ DATA
DATA; //Ligne de data a '1' ;
CS_ON; //CS_ON;
*(uint8_t *)(SPI1_DR_ADR) = Data; while ((SPI1->SR & SPI_SR_TXE) != 0);// Waiting for TX register to be available.
while ((SPI1->SR & SPI_SR_BSY) != 0); //Attendre fin envoi trame (cf RM P1289) *(uint8_t*) (SPI1_DR_ADR) = Data;
CS_OFF; //while ((SPI1->SR & SPI_SR_BSY) != 0); //Attendre fin envoi trame (cf RM P1289)
//CS_OFF;
} }
/* Set Address - Location block - to draw into */ /* Set the frame to draw into and sends a write into frame command */
void LCD_Set_Address(uint16_t X1, uint16_t Y1, uint16_t X2, uint16_t Y2) void LCD_Set_Address(uint16_t X1, uint16_t Y1, uint16_t X2, uint16_t Y2) {
{ LCD_Write_Command(0x2A);
LCD_Write_Command(0x2A); LCD_Write_Data(X1 >> 8);
LCD_Write_Data(X1>>8); LCD_Write_Data(X1);
LCD_Write_Data(X1); LCD_Write_Data(X2 >> 8);
LCD_Write_Data(X2>>8); LCD_Write_Data(X2);
LCD_Write_Data(X2);
LCD_Write_Command(0x2B); LCD_Write_Command(0x2B);
LCD_Write_Data(Y1>>8); LCD_Write_Data(Y1 >> 8);
LCD_Write_Data(Y1); LCD_Write_Data(Y1);
LCD_Write_Data(Y2>>8); LCD_Write_Data(Y2 >> 8);
LCD_Write_Data(Y2); LCD_Write_Data(Y2);
LCD_Write_Command(0x2C); LCD_Write_Command(0x2C);
} }
/*HARDWARE RESET*/ /*HARDWARE RESET*/
@ -119,147 +115,141 @@ LCD_Write_Command(0x2C);
// HAL_Delay(200); // HAL_Delay(200);
// HAL_GPIO_WritePin(LCD_RST_PORT, LCD_RST_PIN, GPIO_PIN_SET); // HAL_GPIO_WritePin(LCD_RST_PORT, LCD_RST_PIN, GPIO_PIN_SET);
// } // }
/*Ser rotation of the screen - changes x0 and y0*/ /*Ser rotation of the screen - changes x0 and y0*/
void LCD_Set_Rotation(uint8_t Rotation) void LCD_Set_Rotation(uint8_t Rotation) {
{
uint8_t screen_rotation = Rotation; uint8_t screen_rotation = Rotation;
LCD_Write_Command(0x36); LCD_Write_Command(0x36);
for(volatile uint32_t i=0;i<TEMPO1MS_80M;i++); //~1ms attente for (volatile uint32_t i = 0; i < TEMPO1MS_80M; i++);//~1ms attente
switch(screen_rotation) switch (screen_rotation) {
{
case SCREEN_VERTICAL_1: case SCREEN_VERTICAL_1:
LCD_Write_Data(0x40|0x08); LCD_Write_Data(0x40 | 0x08);
LCD_WIDTH = 240; LCD_WIDTH = 240;
LCD_HEIGHT = 320; LCD_HEIGHT = 320;
break; break;
case SCREEN_HORIZONTAL_1: case SCREEN_HORIZONTAL_1:
LCD_Write_Data(0x20|0x08); LCD_Write_Data(0x20 | 0x08);
LCD_WIDTH = 320; LCD_WIDTH = 320;
LCD_HEIGHT = 240; LCD_HEIGHT = 240;
break; break;
case SCREEN_VERTICAL_2: case SCREEN_VERTICAL_2:
LCD_Write_Data(0x80|0x08); LCD_Write_Data(0x80 | 0x08);
LCD_WIDTH = 240; LCD_WIDTH = 240;
LCD_HEIGHT = 320; LCD_HEIGHT = 320;
break; break;
case SCREEN_HORIZONTAL_2: case SCREEN_HORIZONTAL_2:
LCD_Write_Data(0x40|0x80|0x20|0x08); LCD_Write_Data(0x40 | 0x80 | 0x20 | 0x08);
LCD_WIDTH = 320; LCD_WIDTH = 320;
LCD_HEIGHT = 240; LCD_HEIGHT = 240;
break; break;
default: default:
//EXIT IF SCREEN ROTATION NOT VALID! //EXIT IF SCREEN ROTATION NOT VALID!
break; break;
} }
} }
/*Enable LCD display*/ /*Enable LCD display*/
//Reset n'est pas cable sur aff ADA1983 //Reset n'est pas cable sur aff ADA1983
// void LCD_Enable(void) // void LCD_Enable(void)
// { // {
// HAL_GPIO_WritePin(LCD_RST_PORT, LCD_RST_PIN, GPIO_PIN_SET); // HAL_GPIO_WritePin(LCD_RST_PORT, LCD_RST_PIN, GPIO_PIN_SET);
// } // }
/*Initialize LCD display*/ /*Initialize LCD display*/
void LCD_Init(void) void LCD_Init(void) {
{ volatile uint32_t i;//Boucle att
volatile uint32_t i; //Boucle att
//Reset n'est pas cable sur aff ADA1983 //Reset n'est pas cable sur aff ADA1983
//LCD_Enable(); //LCD_Enable();
LCD_SPI_Init(); LCD_SPI_Init();
//LCD_Reset(); //LCD_Reset();
//SOFTWARE RESET //SOFTWARE RESET
LCD_Write_Command(0x01); LCD_Write_Command(0x01);
for(i=0; i<(1000*TEMPO1MS_80M); i++); //~1s attente @80M for (i = 0; i < (1000 * TEMPO1MS_80M); i++);// ~1s sleep @80M
//POWER CONTROL A //POWER CONTROL A -- command not existing
LCD_Write_Command(0xCB); // LCD_Write_Command(0xCB);
LCD_Write_Data(0x39); // LCD_Write_Data(0x39);
LCD_Write_Data(0x2C); // LCD_Write_Data(0x2C);
LCD_Write_Data(0x00); // LCD_Write_Data(0x00);
LCD_Write_Data(0x34); // LCD_Write_Data(0x34);
LCD_Write_Data(0x02); // LCD_Write_Data(0x02);
//POWER CONTROL B //POWER CONTROL B -- command not existing
LCD_Write_Command(0xCF); // LCD_Write_Command(0xCF);
LCD_Write_Data(0x00); // LCD_Write_Data(0x00);
LCD_Write_Data(0xC1); // LCD_Write_Data(0xC1);
LCD_Write_Data(0x30); // LCD_Write_Data(0x30);
//DRIVER TIMING CONTROL A //DRIVER TIMING CONTROL A -- Display Output Ctrl Adjust
LCD_Write_Command(0xE8); LCD_Write_Command(0xE8);
LCD_Write_Data(0x85); LCD_Write_Data(0x85);
LCD_Write_Data(0x00); LCD_Write_Data(0x00);
LCD_Write_Data(0x78); LCD_Write_Data(0x78);
//DRIVER TIMING CONTROL B //DRIVER TIMING CONTROL B -- command not existing
LCD_Write_Command(0xEA); // LCD_Write_Command(0xEA);
LCD_Write_Data(0x00); // LCD_Write_Data(0x00);
LCD_Write_Data(0x00); // LCD_Write_Data(0x00);
//POWER ON SEQUENCE CONTROL //POWER ON SEQUENCE CONTROL -- command not existing
LCD_Write_Command(0xED); // LCD_Write_Command(0xED);
LCD_Write_Data(0x64); // LCD_Write_Data(0x64);
LCD_Write_Data(0x03); // LCD_Write_Data(0x03);
LCD_Write_Data(0x12); // LCD_Write_Data(0x12);
LCD_Write_Data(0x81); // LCD_Write_Data(0x81);
//PUMP RATIO CONTROL //PUMP RATIO CONTROL -- command not existing
LCD_Write_Command(0xF7); // LCD_Write_Command(0xF7);
LCD_Write_Data(0x20); // LCD_Write_Data(0x20);
//POWER CONTROL,VRH[5:0] //POWER CONTROL,VRH[5:0] -- Power Control 1
LCD_Write_Command(0xC0); LCD_Write_Command(0xC0);
LCD_Write_Data(0x23); LCD_Write_Data(0x23);
//POWER CONTROL,SAP[2:0];BT[3:0] //POWER CONTROL,SAP[2:0];BT[3:0] -- Power Control 2
LCD_Write_Command(0xC1); LCD_Write_Command(0xC1);
LCD_Write_Data(0x10); LCD_Write_Data(0x10);
//VCM CONTROL //VCM CONTROL -- VCOM Control
LCD_Write_Command(0xC5); LCD_Write_Command(0xC5);
LCD_Write_Data(0x3E); LCD_Write_Data(0x3E);
LCD_Write_Data(0x28); LCD_Write_Data(0x28);
//VCM CONTROL 2 //VCM CONTROL 2
LCD_Write_Command(0xC7); LCD_Write_Command(0xC7);
LCD_Write_Data(0x86); LCD_Write_Data(0x86);
//MEMORY ACCESS CONTROL //MEMORY ACCESS CONTROL
LCD_Write_Command(0x36); LCD_Write_Command(0x36);
LCD_Write_Data(0x48); LCD_Write_Data(0x48);
//PIXEL FORMAT //PIXEL FORMAT
LCD_Write_Command(0x3A); LCD_Write_Command(0x3A);
LCD_Write_Data(0x55); LCD_Write_Data(0x55);
//FRAME RATIO CONTROL, STANDARD RGB COLOR //FRAME RATIO CONTROL, STANDARD RGB COLOR
LCD_Write_Command(0xB1); LCD_Write_Command(0xB1);
LCD_Write_Data(0x00); LCD_Write_Data(0x00);
LCD_Write_Data(0x18); LCD_Write_Data(0x18);
//DISPLAY FUNCTION CONTROL //DISPLAY FUNCTION CONTROL
LCD_Write_Command(0xB6); LCD_Write_Command(0xB6);
LCD_Write_Data(0x08); LCD_Write_Data(0x08);
LCD_Write_Data(0x82); LCD_Write_Data(0x82);
LCD_Write_Data(0x27); LCD_Write_Data(0x27);
//3GAMMA FUNCTION DISABLE //3GAMMA FUNCTION DISABLE
LCD_Write_Command(0xF2); LCD_Write_Command(0xF2);
LCD_Write_Data(0x00); LCD_Write_Data(0x00);
//GAMMA CURVE SELECTED //GAMMA CURVE SELECTED
LCD_Write_Command(0x26); LCD_Write_Command(0x26);
LCD_Write_Data(0x01); LCD_Write_Data(0x01);
//POSITIVE GAMMA CORRECTION //POSITIVE GAMMA CORRECTION
LCD_Write_Command(0xE0); LCD_Write_Command(0xE0);
LCD_Write_Data(0x0F); LCD_Write_Data(0x0F);
LCD_Write_Data(0x31); LCD_Write_Data(0x31);
@ -277,7 +267,7 @@ void LCD_Init(void)
LCD_Write_Data(0x09); LCD_Write_Data(0x09);
LCD_Write_Data(0x00); LCD_Write_Data(0x00);
//NEGATIVE GAMMA CORRECTION //NEGATIVE GAMMA CORRECTION
LCD_Write_Command(0xE1); LCD_Write_Command(0xE1);
LCD_Write_Data(0x00); LCD_Write_Data(0x00);
LCD_Write_Data(0x0E); LCD_Write_Data(0x0E);
@ -295,41 +285,40 @@ void LCD_Init(void)
LCD_Write_Data(0x36); LCD_Write_Data(0x36);
LCD_Write_Data(0x0F); LCD_Write_Data(0x0F);
//EXIT SLEEP //EXIT SLEEP
LCD_Write_Command(0x11); LCD_Write_Command(0x11);
for(i=0; i<(120/TEMPO1MS_80M); i++); //~120ms attente for (i = 0; i < (120 / TEMPO1MS_80M); i++); // ~120ms sleep
//TURN ON DISPLAY //TURN ON DISPLAY
LCD_Write_Command(0x29); LCD_Write_Command(0x29);
//STARTING ROTATION //STARTING ROTATION
LCD_Set_Rotation(SCREEN_HORIZONTAL_1); LCD_Set_Rotation(SCREEN_HORIZONTAL_1);
} }
//INTERNAL FUNCTION OF LIBRARY //INTERNAL FUNCTION OF LIBRARY
/*Sends block colour information to LCD*/ /*Sends block colour information to LCD*/
void LCD_Draw_Colour_Burst(uint16_t Colour, uint32_t Size) void LCD_Draw_Colour_Burst(uint16_t Colour, uint32_t Size) {
{
short bufColour; short bufColour;
// On envoie la même couleur sur Size pixels // On envoie la même couleur sur Size pixels
bufColour = Colour>>8; // pour le tfert dans DR en 1 seul write mais bufColour = Colour >> 8;// pour le tfert dans DR en 1 seul write mais
bufColour |= Colour<<8; // en mode 8 bits, il faut inverser les octets MSB/LSB bufColour |= Colour << 8;// en mode 8 bits, il faut inverser les octets MSB/LSB
DATA; DATA
;
CS_ON; CS_ON;
for(uint32_t j=0;j<Size;j++){ for (uint32_t j = 0; j < Size; j++) {
while((SPI3->SR & SPI_SR_TXE) == 0); //Si FIFO full (TX buffer Empty=0), on attend while ((SPI3->SR & SPI_SR_TXE) == 0);//Si FIFO full (TX buffer Empty=0), on attend
SPI3->DR = bufColour; SPI3->DR = bufColour;
} }
while ((SPI3->SR & SPI_SR_BSY) != 0); //Attendre fin envoi trame while ((SPI3->SR & SPI_SR_BSY) != 0);//Attendre fin envoi trame
CS_OFF; CS_OFF;
} }
//FILL THE ENTIRE SCREEN WITH SELECTED COLOUR (either #define-d ones or custom 16bit) //FILL THE ENTIRE SCREEN WITH SELECTED COLOUR (either #define-d ones or custom 16bit)
/*Sets address (entire screen) and Sends Height*Width ammount of colour information to LCD*/ /*Sets address (entire screen) and Sends Height*Width ammount of colour information to LCD*/
void LCD_Fill_Screen(uint16_t Colour) void LCD_Fill_Screen(uint16_t Colour) {
{ LCD_Set_Address(0, 0, LCD_WIDTH, LCD_HEIGHT);
LCD_Set_Address(0,0,LCD_WIDTH,LCD_HEIGHT); LCD_Draw_Colour_Burst(Colour, LCD_WIDTH * LCD_HEIGHT);
LCD_Draw_Colour_Burst(Colour, LCD_WIDTH*LCD_HEIGHT);
} }
//DRAW PIXEL AT XY POSITION WITH SELECTED COLOUR //DRAW PIXEL AT XY POSITION WITH SELECTED COLOUR
@ -338,44 +327,43 @@ void LCD_Fill_Screen(uint16_t Colour)
//Using pixels to draw big simple structures is not recommended as it is really slow //Using pixels to draw big simple structures is not recommended as it is really slow
//Try using either rectangles or lines if possible //Try using either rectangles or lines if possible
// //
void LCD_Draw_Pixel(uint16_t X,uint16_t Y,uint16_t Colour) void LCD_Draw_Pixel(uint16_t X, uint16_t Y, uint16_t Colour) {
{ if ((X >= LCD_WIDTH) || (Y >= LCD_HEIGHT)) return;//OUT OF BOUNDS!
if((X >=LCD_WIDTH) || (Y >=LCD_HEIGHT)) return; //OUT OF BOUNDS!
//ADDRESS //ADDRESS
LCD_Write_Command(0x2A); LCD_Write_Command(0x2A);
//XDATA //XDATA
DATA; DATA
;
CS_ON; CS_ON;
SPI3->DR = (X>>8) | (X<<8); //inversion MSB / LSB pour envoi des 2 mots 8 bits en 1W 16bits SPI3->DR = (X >> 8) | (X << 8);//inversion MSB / LSB pour envoi des 2 mots 8 bits en 1W 16bits
//Pas d'att si FIFO full (TX buffer Empty=0) car juste 2 écriture 16 bits tiennent dans FIFO //Pas d'att si FIFO full (TX buffer Empty=0) car juste 2 écriture 16 bits tiennent dans FIFO
SPI3->DR = ((X+1)>>8) | ((X+1)<<8); SPI3->DR = ((X + 1) >> 8) | ((X + 1) << 8);
while ((SPI3->SR & SPI_SR_BSY) != 0); //Attendre fin envoi trame while ((SPI3->SR & SPI_SR_BSY) != 0);//Attendre fin envoi trame
CS_OFF; CS_OFF;
//ADDRESS
//ADDRESS
LCD_Write_Command(0x2B); LCD_Write_Command(0x2B);
//YDATA //YDATA
DATA; DATA
;
CS_ON; CS_ON;
SPI3->DR = (Y>>8) | (Y<<8); SPI3->DR = (Y >> 8) | (Y << 8);
SPI3->DR = ((Y+1)>>8) | ((Y+1)<<8); SPI3->DR = ((Y + 1) >> 8) | ((Y + 1) << 8);
while ((SPI3->SR & SPI_SR_BSY) != 0); //Attendre fin envoi trame while ((SPI3->SR & SPI_SR_BSY) != 0);//Attendre fin envoi trame
CS_OFF; CS_OFF;
//ADDRESS
//ADDRESS
LCD_Write_Command(0x2C); LCD_Write_Command(0x2C);
//COLOUR //COLOUR
DATA; DATA
;
CS_ON; CS_ON;
SPI3->DR = (Colour>>8) | (Colour<<8); SPI3->DR = (Colour >> 8) | (Colour << 8);
while ((SPI3->SR & SPI_SR_BSY) != 0); //Attendre fin envoi trame while ((SPI3->SR & SPI_SR_BSY) != 0);//Attendre fin envoi trame
CS_OFF; CS_OFF;
} }
@ -385,58 +373,66 @@ void LCD_Draw_Pixel(uint16_t X,uint16_t Y,uint16_t Colour)
//As with all other draw calls x0 and y0 locations dependant on screen orientation //As with all other draw calls x0 and y0 locations dependant on screen orientation
// //
void LCD_Draw_Rectangle(uint16_t X, uint16_t Y, uint16_t Width, uint16_t Height, uint16_t Colour) void LCD_Draw_Rectangle(
{ uint16_t X,
if((X >=LCD_WIDTH) || (Y >=LCD_HEIGHT)) return; uint16_t Y,
if((X+Width-1)>=LCD_WIDTH) uint16_t Width,
{ uint16_t Height,
Width=LCD_WIDTH-X; uint16_t Colour) {
if ((X >= LCD_WIDTH) || (Y >= LCD_HEIGHT)) return;
if ((X + Width - 1) >= LCD_WIDTH) {
Width = LCD_WIDTH - X;
} }
if((Y+Height-1)>=LCD_HEIGHT) if ((Y + Height - 1) >= LCD_HEIGHT) {
{ Height = LCD_HEIGHT - Y;
Height=LCD_HEIGHT-Y;
} }
LCD_Set_Address(X, Y, X+Width-1, Y+Height-1); LCD_Set_Address(X, Y, X + Width - 1, Y + Height - 1);
LCD_Draw_Colour_Burst(Colour, Height*Width); LCD_Draw_Colour_Burst(Colour, Height * Width);
} }
//DRAW LINE FROM X,Y LOCATION to X+Width,Y LOCATION //DRAW LINE FROM X,Y LOCATION to X+Width,Y LOCATION
void LCD_Draw_Horizontal_Line(uint16_t X, uint16_t Y, uint16_t Width, uint16_t Colour) void LCD_Draw_Horizontal_Line(
{ uint16_t X,
if((X >=LCD_WIDTH) || (Y >=LCD_HEIGHT)) return; uint16_t Y,
if((X+Width-1)>=LCD_WIDTH) uint16_t Width,
{ uint16_t Colour) {
Width=LCD_WIDTH-X; if ((X >= LCD_WIDTH) || (Y >= LCD_HEIGHT)) return;
if ((X + Width - 1) >= LCD_WIDTH) {
Width = LCD_WIDTH - X;
} }
LCD_Set_Address(X, Y, X+Width-1, Y); LCD_Set_Address(X, Y, X + Width - 1, Y);
LCD_Draw_Colour_Burst(Colour, Width); LCD_Draw_Colour_Burst(Colour, Width);
} }
//DRAW LINE FROM X,Y LOCATION to X,Y+Height LOCATION //DRAW LINE FROM X,Y LOCATION to X,Y+Height LOCATION
void LCD_Draw_Vertical_Line(uint16_t X, uint16_t Y, uint16_t Height, uint16_t Colour) void LCD_Draw_Vertical_Line(
{ uint16_t X,
if((X >=LCD_WIDTH) || (Y >=LCD_HEIGHT)) return; uint16_t Y,
if((Y+Height-1)>=LCD_HEIGHT) uint16_t Height,
{ uint16_t Colour) {
Height=LCD_HEIGHT-Y; if ((X >= LCD_WIDTH) || (Y >= LCD_HEIGHT)) return;
if ((Y + Height - 1) >= LCD_HEIGHT) {
Height = LCD_HEIGHT - Y;
} }
LCD_Set_Address(X, Y, X, Y+Height-1); LCD_Set_Address(X, Y, X, Y + Height - 1);
LCD_Draw_Colour_Burst(Colour, Height); LCD_Draw_Colour_Burst(Colour, Height);
} }
/*********************Partie de la Lib issue de LCD_GFX**************************/ /*********************Partie de la Lib issue de LCD_GFX**************************/
/*Draw hollow circle at X,Y location with specified radius and colour. X and Y represent circles center */ /*Draw hollow circle at X,Y location with specified radius and colour. X and Y represent circles center */
void LCD_Draw_Hollow_Circle(uint16_t X, uint16_t Y, uint16_t Radius, uint16_t Colour) void LCD_Draw_Hollow_Circle(
{ uint16_t X,
int x = Radius-1; uint16_t Y,
uint16_t Radius,
uint16_t Colour) {
int x = Radius - 1;
int y = 0; int y = 0;
int dx = 1; int dx = 1;
int dy = 1; int dy = 1;
int err = dx - (Radius << 1); int err = dx - (Radius << 1);
while (x >= y) while (x >= y) {
{
LCD_Draw_Pixel(X + x, Y + y, Colour); LCD_Draw_Pixel(X + x, Y + y, Colour);
LCD_Draw_Pixel(X + y, Y + x, Colour); LCD_Draw_Pixel(X + y, Y + x, Colour);
LCD_Draw_Pixel(X - y, Y + x, Colour); LCD_Draw_Pixel(X - y, Y + x, Colour);
@ -446,14 +442,12 @@ void LCD_Draw_Hollow_Circle(uint16_t X, uint16_t Y, uint16_t Radius, uint16_t Co
LCD_Draw_Pixel(X + y, Y - x, Colour); LCD_Draw_Pixel(X + y, Y - x, Colour);
LCD_Draw_Pixel(X + x, Y - y, Colour); LCD_Draw_Pixel(X + x, Y - y, Colour);
if (err <= 0) if (err <= 0) {
{
y++; y++;
err += dy; err += dy;
dy += 2; dy += 2;
} }
if (err > 0) if (err > 0) {
{
x--; x--;
dx += 2; dx += 2;
err += (-Radius << 1) + dx; err += (-Radius << 1) + dx;
@ -462,8 +456,11 @@ void LCD_Draw_Hollow_Circle(uint16_t X, uint16_t Y, uint16_t Radius, uint16_t Co
} }
/*Draw filled circle at X,Y location with specified radius and colour. X and Y represent circles center */ /*Draw filled circle at X,Y location with specified radius and colour. X and Y represent circles center */
void LCD_Draw_Filled_Circle(uint16_t X, uint16_t Y, uint16_t Radius, uint16_t Colour) void LCD_Draw_Filled_Circle(
{ uint16_t X,
uint16_t Y,
uint16_t Radius,
uint16_t Colour) {
int x = Radius; int x = Radius;
int y = 0; int y = 0;
@ -471,36 +468,36 @@ void LCD_Draw_Filled_Circle(uint16_t X, uint16_t Y, uint16_t Radius, uint16_t Co
int yChange = 0; int yChange = 0;
int radiusError = 0; int radiusError = 0;
while (x >= y) while (x >= y) {
{ for (int i = X - x; i <= X + x; i++) {
for (int i = X - x; i <= X + x; i++) LCD_Draw_Pixel(i, Y + y, Colour);
{ LCD_Draw_Pixel(i, Y - y, Colour);
LCD_Draw_Pixel(i, Y + y,Colour);
LCD_Draw_Pixel(i, Y - y,Colour);
} }
for (int i = X - y; i <= X + y; i++) for (int i = X - y; i <= X + y; i++) {
{ LCD_Draw_Pixel(i, Y + x, Colour);
LCD_Draw_Pixel(i, Y + x,Colour); LCD_Draw_Pixel(i, Y - x, Colour);
LCD_Draw_Pixel(i, Y - x,Colour);
} }
y++; y++;
radiusError += yChange; radiusError += yChange;
yChange += 2; yChange += 2;
if (((radiusError << 1) + xChange) > 0) if (((radiusError << 1) + xChange) > 0) {
{
x--; x--;
radiusError += xChange; radiusError += xChange;
xChange += 2; xChange += 2;
} }
} }
//Really slow implementation, will require future overhaul //Really slow implementation, will require future overhaul
//TODO: https://stackoverflow.com/questions/1201200/fast-algorithm-for-drawing-filled-circles //TODO: https://stackoverflow.com/questions/1201200/fast-algorithm-for-drawing-filled-circles
} }
/*Draw a hollow rectangle between positions X0,Y0 and X1,Y1 with specified colour*/ /*Draw a hollow rectangle between positions X0,Y0 and X1,Y1 with specified colour*/
void LCD_Draw_Hollow_Rectangle_Coord(uint16_t X0, uint16_t Y0, uint16_t X1, uint16_t Y1, uint16_t Colour) void LCD_Draw_Hollow_Rectangle_Coord(
{ uint16_t X0,
uint16_t Y0,
uint16_t X1,
uint16_t Y1,
uint16_t Colour) {
uint16_t X_length = 0; uint16_t X_length = 0;
uint16_t Y_length = 0; uint16_t Y_length = 0;
uint8_t Negative_X = 0; uint8_t Negative_X = 0;
@ -508,49 +505,43 @@ void LCD_Draw_Hollow_Rectangle_Coord(uint16_t X0, uint16_t Y0, uint16_t X1, uint
float Calc_Negative = 0; float Calc_Negative = 0;
Calc_Negative = X1 - X0; Calc_Negative = X1 - X0;
if(Calc_Negative < 0) Negative_X = 1; if (Calc_Negative < 0) Negative_X = 1;
Calc_Negative = 0; Calc_Negative = 0;
Calc_Negative = Y1 - Y0; Calc_Negative = Y1 - Y0;
if(Calc_Negative < 0) Negative_Y = 1; if (Calc_Negative < 0) Negative_Y = 1;
//DRAW HORIZONTAL!
//DRAW HORIZONTAL! if (!Negative_X) {
if(!Negative_X)
{
X_length = X1 - X0; X_length = X1 - X0;
} } else {
else
{
X_length = X0 - X1; X_length = X0 - X1;
} }
LCD_Draw_Horizontal_Line(X0, Y0, X_length, Colour); LCD_Draw_Horizontal_Line(X0, Y0, X_length, Colour);
LCD_Draw_Horizontal_Line(X0, Y1, X_length, Colour); LCD_Draw_Horizontal_Line(X0, Y1, X_length, Colour);
//DRAW VERTICAL!
if (!Negative_Y) {
//DRAW VERTICAL!
if(!Negative_Y)
{
Y_length = Y1 - Y0; Y_length = Y1 - Y0;
} } else {
else
{
Y_length = Y0 - Y1; Y_length = Y0 - Y1;
} }
LCD_Draw_Vertical_Line(X0, Y0, Y_length, Colour); LCD_Draw_Vertical_Line(X0, Y0, Y_length, Colour);
LCD_Draw_Vertical_Line(X1, Y0, Y_length, Colour); LCD_Draw_Vertical_Line(X1, Y0, Y_length, Colour);
if((X_length > 0)||(Y_length > 0)) if ((X_length > 0) || (Y_length > 0)) {
{
LCD_Draw_Pixel(X1, Y1, Colour); LCD_Draw_Pixel(X1, Y1, Colour);
} }
} }
/*Draw a filled rectangle between positions X0,Y0 and X1,Y1 with specified colour*/ /*Draw a filled rectangle between positions X0,Y0 and X1,Y1 with specified colour*/
void LCD_Draw_Filled_Rectangle_Coord(uint16_t X0, uint16_t Y0, uint16_t X1, uint16_t Y1, uint16_t Colour) void LCD_Draw_Filled_Rectangle_Coord(
{ uint16_t X0,
uint16_t Y0,
uint16_t X1,
uint16_t Y1,
uint16_t Colour) {
uint16_t X_length = 0; uint16_t X_length = 0;
uint16_t Y_length = 0; uint16_t Y_length = 0;
uint8_t Negative_X = 0; uint8_t Negative_X = 0;
@ -561,33 +552,26 @@ void LCD_Draw_Filled_Rectangle_Coord(uint16_t X0, uint16_t Y0, uint16_t X1, uint
uint16_t Y0_true = 0; uint16_t Y0_true = 0;
Calc_Negative = X1 - X0; Calc_Negative = X1 - X0;
if(Calc_Negative < 0) Negative_X = 1; if (Calc_Negative < 0) Negative_X = 1;
Calc_Negative = 0; Calc_Negative = 0;
Calc_Negative = Y1 - Y0; Calc_Negative = Y1 - Y0;
if(Calc_Negative < 0) Negative_Y = 1; if (Calc_Negative < 0) Negative_Y = 1;
//DRAW HORIZONTAL!
//DRAW HORIZONTAL! if (!Negative_X) {
if(!Negative_X)
{
X_length = X1 - X0; X_length = X1 - X0;
X0_true = X0; X0_true = X0;
} } else {
else
{
X_length = X0 - X1; X_length = X0 - X1;
X0_true = X1; X0_true = X1;
} }
//DRAW VERTICAL! //DRAW VERTICAL!
if(!Negative_Y) if (!Negative_Y) {
{
Y_length = Y1 - Y0; Y_length = Y1 - Y0;
Y0_true = Y0; Y0_true = Y0;
} } else {
else
{
Y_length = Y0 - Y1; Y_length = Y0 - Y1;
Y0_true = Y1; Y0_true = Y1;
} }
@ -597,10 +581,15 @@ void LCD_Draw_Filled_Rectangle_Coord(uint16_t X0, uint16_t Y0, uint16_t X1, uint
/*Draws a character (fonts imported from fonts.h) at X,Y location with specified font colour, size and Background colour*/ /*Draws a character (fonts imported from fonts.h) at X,Y location with specified font colour, size and Background colour*/
/*See fonts.h implementation of font on what is required for changing to a different font when switching fonts libraries*/ /*See fonts.h implementation of font on what is required for changing to a different font when switching fonts libraries*/
void LCD_Draw_Char(char Character, uint16_t X, uint16_t Y, uint16_t Colour, uint16_t Size, uint16_t Background_Colour) void LCD_Draw_Char(
{ char Character,
uint16_t X,
uint16_t Y,
uint16_t Colour,
uint16_t Size,
uint16_t Background_Colour) {
uint8_t function_char; uint8_t function_char;
uint8_t i,j; uint8_t i, j;
function_char = Character; function_char = Character;
@ -611,23 +600,21 @@ void LCD_Draw_Char(char Character, uint16_t X, uint16_t Y, uint16_t Colour, uint
} }
char temp[CHAR_WIDTH]; char temp[CHAR_WIDTH];
for(uint8_t k = 0; k<CHAR_WIDTH; k++) for (uint8_t k = 0; k < CHAR_WIDTH; k++) {
{
temp[k] = font[function_char][k]; temp[k] = font[function_char][k];
} }
// Draw pixels // Draw pixels
LCD_Draw_Rectangle(X, Y, CHAR_WIDTH*Size, CHAR_HEIGHT*Size, Background_Colour); LCD_Draw_Rectangle(X, Y, CHAR_WIDTH * Size, CHAR_HEIGHT * Size,
for (j=0; j<CHAR_WIDTH; j++) { Background_Colour);
for (i=0; i<CHAR_HEIGHT; i++) { for (j = 0; j < CHAR_WIDTH; j++) {
if (temp[j] & (1<<i)) { for (i = 0; i < CHAR_HEIGHT; i++) {
if(Size == 1) if (temp[j] & (1 << i)) {
{ if (Size == 1) {
LCD_Draw_Pixel(X+j, Y+i, Colour); LCD_Draw_Pixel(X + j, Y + i, Colour);
} } else {
else LCD_Draw_Rectangle(X + (j * Size), Y + (i * Size), Size, Size,
{ Colour);
LCD_Draw_Rectangle(X+(j*Size), Y+(i*Size), Size, Size, Colour);
} }
} }
} }
@ -636,76 +623,83 @@ void LCD_Draw_Char(char Character, uint16_t X, uint16_t Y, uint16_t Colour, uint
/*Draws an array of characters (fonts imported from fonts.h) at X,Y location with specified font colour, size and Background colour*/ /*Draws an array of characters (fonts imported from fonts.h) at X,Y location with specified font colour, size and Background colour*/
/*See fonts.h implementation of font on what is required for changing to a different font when switching fonts libraries*/ /*See fonts.h implementation of font on what is required for changing to a different font when switching fonts libraries*/
void LCD_Draw_Text(const char* Text, uint16_t X, uint16_t Y, uint16_t Colour, uint16_t Size, uint16_t Background_Colour) void LCD_Draw_Text(
{ const char *Text,
uint16_t X,
uint16_t Y,
uint16_t Colour,
uint16_t Size,
uint16_t Background_Colour) {
while (*Text) { while (*Text) {
LCD_Draw_Char(*Text++, X, Y, Colour, Size, Background_Colour); LCD_Draw_Char(*Text++, X, Y, Colour, Size, Background_Colour);
X += CHAR_WIDTH*Size; X += CHAR_WIDTH * Size;
} }
} }
/*Dessine une image dans une zone de l'ecran, aux coordonnées X et Y*/ /*Dessine une image dans une zone de l'ecran, aux coordonnées X et Y*/
//CONVERTISSEUR: http://www.digole.com/tools/PicturetoC_Hex_converter.php //CONVERTISSEUR: http://www.digole.com/tools/PicturetoC_Hex_converter.php
//65K colour (2Bytes / Pixel) //65K colour (2Bytes / Pixel)
void LCD_Draw_Image_XY(const char* Image_Array, uint16_t X, uint16_t Y, uint16_t Width, uint16_t Height) void LCD_Draw_Image_XY(
{ const char *Image_Array,
LCD_Set_Address(X,Y,X+Width-1,Y+Height-1); uint16_t X,
uint16_t Y,
uint16_t Width,
uint16_t Height) {
LCD_Set_Address(X, Y, X + Width - 1, Y + Height - 1);
DATA; DATA
;
CS_ON; CS_ON;
for(uint32_t i = 0; i < Width*Height*2; i+=2) for (uint32_t i = 0; i < Width * Height * 2; i += 2) {
{ while ((SPI3->SR & SPI_SR_TXE) == 0);//Si FIFO full (TX buffer Empty=0), on attend
while((SPI3->SR & SPI_SR_TXE) == 0); //Si FIFO full (TX buffer Empty=0), on attend // on utilise l'ecriture 16 bits dans DR, pour des envois 8 bits
// on utilise l'ecriture 16 bits dans DR, pour des envois 8 bits // Le LSB doit etre place ds le MSB :
// Le LSB doit etre place ds le MSB : SPI3->DR = ((short) Image_Array[i + 1]) << 8 | Image_Array[i];
SPI3->DR = ((short)Image_Array[i+1])<<8 | Image_Array[i];
} }
while ((SPI3->SR & SPI_SR_BSY) != 0); //Attendre fin envoi trame while ((SPI3->SR & SPI_SR_BSY) != 0);//Attendre fin envoi trame
CS_OFF; CS_OFF;
} }
/*Draws a full screen picture from flash. Image converted from RGB .jpeg/other to C array using online converter*/ /*Draws a full screen picture from flash. Image converted from RGB .jpeg/other to C array using online converter*/
//USING CONVERTER: http://www.digole.com/tools/PicturetoC_Hex_converter.php //USING CONVERTER: http://www.digole.com/tools/PicturetoC_Hex_converter.php
//65K colour (2Bytes / Pixel) //65K colour (2Bytes / Pixel)
void LCD_Draw_Image_Full(const char* Image_Array, uint8_t Orientation) void LCD_Draw_Image_Full(const char *Image_Array, uint8_t Orientation) {
{ switch (Orientation) {
switch(Orientation) case SCREEN_HORIZONTAL_1:
{
case SCREEN_HORIZONTAL_1 :
LCD_Set_Rotation(SCREEN_HORIZONTAL_1); LCD_Set_Rotation(SCREEN_HORIZONTAL_1);
LCD_Set_Address(0,0,LCD_SCREEN_WIDTH,LCD_SCREEN_HEIGHT); LCD_Set_Address(0, 0, LCD_SCREEN_WIDTH, LCD_SCREEN_HEIGHT);
break; break;
case SCREEN_HORIZONTAL_2 : case SCREEN_HORIZONTAL_2:
LCD_Set_Rotation(SCREEN_HORIZONTAL_2); LCD_Set_Rotation(SCREEN_HORIZONTAL_2);
LCD_Set_Address(0,0,LCD_SCREEN_WIDTH,LCD_SCREEN_HEIGHT); LCD_Set_Address(0, 0, LCD_SCREEN_WIDTH, LCD_SCREEN_HEIGHT);
break; break;
case SCREEN_VERTICAL_1 : case SCREEN_VERTICAL_1:
LCD_Set_Rotation(SCREEN_VERTICAL_1); LCD_Set_Rotation(SCREEN_VERTICAL_1);
LCD_Set_Address(0,0,LCD_SCREEN_HEIGHT,LCD_SCREEN_WIDTH); LCD_Set_Address(0, 0, LCD_SCREEN_HEIGHT, LCD_SCREEN_WIDTH);
break; break;
case SCREEN_VERTICAL_2 : case SCREEN_VERTICAL_2:
LCD_Set_Rotation(SCREEN_VERTICAL_2); LCD_Set_Rotation(SCREEN_VERTICAL_2);
LCD_Set_Address(0,0,LCD_SCREEN_HEIGHT,LCD_SCREEN_WIDTH); LCD_Set_Address(0, 0, LCD_SCREEN_HEIGHT, LCD_SCREEN_WIDTH);
break; break;
} }
DATA; DATA
;
CS_ON; CS_ON;
for(uint32_t i = 0; i < LCD_SCREEN_WIDTH*LCD_SCREEN_HEIGHT*2; i+=2) for (uint32_t i = 0; i < LCD_SCREEN_WIDTH * LCD_SCREEN_HEIGHT * 2; i += 2) {
{ while ((SPI3->SR & SPI_SR_TXE) == 0);//Si FIFO full (TX buffer Empty=0), on attend
while((SPI3->SR & SPI_SR_TXE) == 0); //Si FIFO full (TX buffer Empty=0), on attend // on utilise l'ecriture 16 bits dans DR, pour des envois 8 bits
// on utilise l'ecriture 16 bits dans DR, pour des envois 8 bits // Le LSB doit etre place ds le MSB :
// Le LSB doit etre place ds le MSB : SPI3->DR = ((short) Image_Array[i + 1]) << 8 | Image_Array[i];
SPI3->DR = ((short)Image_Array[i+1])<<8 | Image_Array[i];
} }
while ((SPI3->SR & SPI_SR_BSY) != 0); //Attendre fin envoi trame while ((SPI3->SR & SPI_SR_BSY) != 0);//Attendre fin envoi trame
CS_OFF; CS_OFF;
} }

View File

@ -1,4 +1,4 @@
/* USER CODE BEGIN Header */ /* USER CODE BEGIN */
/** /**
****************************************************************************** ******************************************************************************
* @file : main.c * @file : main.c
@ -15,7 +15,7 @@
* *
****************************************************************************** ******************************************************************************
*/ */
/* USER CODE END Header */ /* USER CODE END */
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "main.h" #include "main.h"
#include "LCD_driver.h" #include "LCD_driver.h"
@ -23,47 +23,47 @@
#include "LogoIUT.h" #include "LogoIUT.h"
/* Private includes ----------------------------------------------------------*/ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN */
/* USER CODE END Includes */ /* USER CODE END */
/* Private typedef -----------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */ /* USER CODE BEGIN */
/* USER CODE END PTD */ /* USER CODE END */
/* Private define ------------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */ /* USER CODE BEGIN */
/* USER CODE END PD */ /* USER CODE END */
/* Private macro -------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */ /* USER CODE BEGIN */
/* USER CODE END PM */ /* USER CODE END */
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
SPI_HandleTypeDef hspi1; SPI_HandleTypeDef hspi1;
UART_HandleTypeDef huart1; UART_HandleTypeDef huart1;
/* USER CODE BEGIN PV */ /* USER CODE BEGIN */
/* USER CODE END PV */ /* USER CODE END */
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void); void SystemClock_Config(void);
static void MX_GPIO_Init(void); static void MX_GPIO_Init(void);
static void MX_SPI1_Init(void); static void MX_SPI1_Init(void);
static void MX_USART1_UART_Init(void); static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN PFP */ /* USER CODE BEGIN */
/* USER CODE END PFP */ /* USER CODE END */
/* Private user code ---------------------------------------------------------*/ /* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */ /* USER CODE BEGIN */
/* USER CODE END 0 */ /* USER CODE END */
/** /**
* @brief The application entry point. * @brief The application entry point.
@ -72,47 +72,48 @@ static void MX_USART1_UART_Init(void);
int main(void) int main(void)
{ {
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN */
/* USER CODE END 1 */ /* USER CODE END */
/* MCU Configuration--------------------------------------------------------*/ /* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init(); HAL_Init();
/* USER CODE BEGIN Init */ /* USER CODE BEGIN */
/* USER CODE END Init */ /* USER CODE END */
/* Configure the system clock */ /* Configure the system clock */
SystemClock_Config(); SystemClock_Config();
/* USER CODE BEGIN SysInit */ /* USER CODE BEGIN */
/* USER CODE END */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */ /* Initialize all configured peripherals */
MX_GPIO_Init(); MX_GPIO_Init();
MX_SPI1_Init(); MX_SPI1_Init();
MX_USART1_UART_Init(); MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN */
/* USER CODE END 2 */ LCD_Init();
LCD_Fill_Screen(PURPLE);
/* USER CODE END */
/* Infinite loop */ /* Infinite loop */
/* USER CODE BEGIN WHILE */ /* USER CODE BEGIN */
while (1) while (1) {
{
/* USER CODE END WHILE */ /* USER CODE END */
/* USER CODE BEGIN 3 */ /* USER CODE BEGIN */
} }
/* USER CODE END 3 */ /* USER CODE END */
} }
/** /**
@ -161,13 +162,13 @@ void SystemClock_Config(void)
static void MX_SPI1_Init(void) static void MX_SPI1_Init(void)
{ {
/* USER CODE BEGIN SPI1_Init 0 */ /* USER CODE BEGIN */
/* USER CODE END SPI1_Init 0 */ /* USER CODE END */
/* USER CODE BEGIN SPI1_Init 1 */ /* USER CODE BEGIN */
/* USER CODE END SPI1_Init 1 */ /* USER CODE END */
/* SPI1 parameter configuration*/ /* SPI1 parameter configuration*/
hspi1.Instance = SPI1; hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER; hspi1.Init.Mode = SPI_MODE_MASTER;
@ -185,9 +186,9 @@ static void MX_SPI1_Init(void)
{ {
Error_Handler(); Error_Handler();
} }
/* USER CODE BEGIN SPI1_Init 2 */ /* USER CODE BEGIN */
/* USER CODE END SPI1_Init 2 */ /* USER CODE END */
} }
@ -199,13 +200,13 @@ static void MX_SPI1_Init(void)
static void MX_USART1_UART_Init(void) static void MX_USART1_UART_Init(void)
{ {
/* USER CODE BEGIN USART1_Init 0 */ /* USER CODE BEGIN */
/* USER CODE END USART1_Init 0 */ /* USER CODE END */
/* USER CODE BEGIN USART1_Init 1 */ /* USER CODE BEGIN */
/* USER CODE END USART1_Init 1 */ /* USER CODE END */
huart1.Instance = USART1; huart1.Instance = USART1;
huart1.Init.BaudRate = 115200; huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B; huart1.Init.WordLength = UART_WORDLENGTH_8B;
@ -218,9 +219,9 @@ static void MX_USART1_UART_Init(void)
{ {
Error_Handler(); Error_Handler();
} }
/* USER CODE BEGIN USART1_Init 2 */ /* USER CODE BEGIN */
/* USER CODE END USART1_Init 2 */ /* USER CODE END */
} }
@ -232,9 +233,9 @@ static void MX_USART1_UART_Init(void)
static void MX_GPIO_Init(void) static void MX_GPIO_Init(void)
{ {
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
/* USER CODE BEGIN MX_GPIO_Init_1 */ /* USER CODE BEGIN */
/* USER CODE END MX_GPIO_Init_1 */ /* USER CODE END */
/* GPIO Ports Clock Enable */ /* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE();
@ -319,14 +320,14 @@ static void MX_GPIO_Init(void)
/*Configure peripheral I/O remapping */ /*Configure peripheral I/O remapping */
__HAL_AFIO_REMAP_PD01_ENABLE(); __HAL_AFIO_REMAP_PD01_ENABLE();
/* USER CODE BEGIN MX_GPIO_Init_2 */ /* USER CODE BEGIN */
/* USER CODE END MX_GPIO_Init_2 */ /* USER CODE END */
} }
/* USER CODE BEGIN 4 */ /* USER CODE BEGIN */
/* USER CODE END 4 */ /* USER CODE END */
/** /**
* @brief This function is executed in case of error occurrence. * @brief This function is executed in case of error occurrence.
@ -334,13 +335,12 @@ static void MX_GPIO_Init(void)
*/ */
void Error_Handler(void) void Error_Handler(void)
{ {
/* USER CODE BEGIN Error_Handler_Debug */ /* USER CODE BEGIN */
/* User can add his own implementation to report the HAL error return state */ /* User can add his own implementation to report the HAL error return state */
__disable_irq(); __disable_irq();
while (1) while (1) {
{
} }
/* USER CODE END Error_Handler_Debug */ /* USER CODE END */
} }
#ifdef USE_FULL_ASSERT #ifdef USE_FULL_ASSERT
/** /**
@ -350,11 +350,11 @@ void Error_Handler(void)
* @param line: assert_param error line source number * @param line: assert_param error line source number
* @retval None * @retval None
*/ */
void assert_failed(uint8_t *file, uint32_t line) void assert_failed( uint8_t * file , uint32_t line)
{ {
/* USER CODE BEGIN 6 */ /* USER CODE BEGIN */
/* User can add his own implementation to report the file name and line number, /* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */ /* USER CODE END */
} }
#endif /* USE_FULL_ASSERT */ #endif /* USE_FULL_ASSERT */