Fixing orientation & colors

This commit is contained in:
Clément Grennerat 2025-09-14 18:00:40 +02:00
parent 73f2ea0ce1
commit 10b9a14a75
7 changed files with 152 additions and 226 deletions

View File

@ -28,8 +28,8 @@
#define SPI1_BASEDR_ADR SPI1_BASE //adresse du reg SPI3 DR pour acces 8 bits (defs std permet accès 16bits seulement) #define SPI1_BASEDR_ADR SPI1_BASE //adresse du reg SPI3 DR pour acces 8 bits (defs std permet accès 16bits seulement)
#define LCD_SCREEN_HEIGHT 282 // ST7365 is 320 (centered, offset = 19) #define LCD_HEIGHT 282 // ST7365 is 320 (centered, offset = 19)
#define LCD_SCREEN_WIDTH 470 // ST7365 is 480 (aligned at the left, offset = 10) #define LCD_WIDTH 470 // ST7365 is 480 (aligned at the left, offset = 10)
//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)

21
Core/Inc/dashboard.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef __DASHBOARD_H
#define __DASHBOARD_H
#endif
void run_dashboard_loop();
void init();
void update_values();
void update_values_setup();
void update_adc();
void draw_init();
void draw_battery();
void draw_distances();
void draw_power_bars();
void draw_speed();
void draw_power();
void draw_adc();
void draw_temps();

View File

@ -1,4 +1,4 @@
/* USER CODE BEGIN Header */ /* USER CODE BEGIN */
/** /**
****************************************************************************** ******************************************************************************
* @file : main.h * @file : main.h
@ -16,7 +16,7 @@
* *
****************************************************************************** ******************************************************************************
*/ */
/* USER CODE END Header */ /* USER CODE END */
/* Define to prevent recursive inclusion -------------------------------------*/ /* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H #ifndef __MAIN_H
@ -30,31 +30,31 @@ extern "C" {
#include "stm32f1xx_hal.h" #include "stm32f1xx_hal.h"
/* Private includes ----------------------------------------------------------*/ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN */
/* USER CODE END Includes */ /* USER CODE END */
/* Exported types ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */ /* USER CODE BEGIN */
/* USER CODE END ET */ /* USER CODE END */
/* Exported constants --------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */ /* USER CODE BEGIN */
/* USER CODE END EC */ /* USER CODE END */
/* Exported macro ------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */ /* USER CODE BEGIN */
/* USER CODE END EM */ /* USER CODE END */
/* Exported functions prototypes ---------------------------------------------*/ /* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void); void Error_Handler(void);
/* USER CODE BEGIN EFP */ /* USER CODE BEGIN */
/* USER CODE END EFP */ /* USER CODE END */
/* Private defines -----------------------------------------------------------*/ /* Private defines -----------------------------------------------------------*/
#define DB10_Pin GPIO_PIN_13 #define DB10_Pin GPIO_PIN_13
@ -108,9 +108,9 @@ void Error_Handler(void);
#define DB12_Pin GPIO_PIN_9 #define DB12_Pin GPIO_PIN_9
#define DB12_GPIO_Port GPIOB #define DB12_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */ /* USER CODE BEGIN */
/* USER CODE END Private defines */ /* USER CODE END */
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,4 +1,4 @@
/* USER CODE BEGIN Header */ /* USER CODE BEGIN */
/** /**
****************************************************************************** ******************************************************************************
* @file stm32f1xx_hal_conf.h * @file stm32f1xx_hal_conf.h
@ -15,7 +15,7 @@
* *
****************************************************************************** ******************************************************************************
*/ */
/* USER CODE END Header */ /* USER CODE END */
/* Define to prevent recursive inclusion -------------------------------------*/ /* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F1xx_HAL_CONF_H #ifndef __STM32F1xx_HAL_CONF_H

View File

@ -23,79 +23,40 @@
// copies or substantial portions of the Software. // copies or substantial portions of the Software.
// //
/* Includes ------------------------------------------------------------------*/
#include "LCD_driver.h" #include "LCD_driver.h"
#include "5x5_font.h" #include "5x5_font.h"
#include "stm32f1xx.h" #include "stm32f1xx.h"
/* Global Variables ------------------------------------------------------------------*/
volatile uint16_t LCD_HEIGHT = LCD_SCREEN_HEIGHT;
volatile uint16_t LCD_WIDTH = LCD_SCREEN_WIDTH;
/* SPI3 & GPIOs init function */
//void LCD_SPI_Init(void) {
////__HAL_RCC_SPI3_CLK_ENABLE();
// RCC->APB1ENR1 |= RCC_APB1ENR1_SPI3EN;// SPI3 clock enable
// RCC->AHB2ENR |= RCC_AHB2ENR_GPIOCEN;// GPIOC clock enable
//
// /** CS & DC GPIO signals configuration
// PC8 ------> LCD_CS_PIN
// PC11 ------> LCD_DC_PIN
// */
// 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 << 17) | (1 << 23));//mise à 0
// GPIOC->OTYPER &= (GPIO_OTYPER_OT8 | GPIO_OTYPER_OT11);//PC8 & 11 en PP
// GPIOC->OSPEEDR |= (3 << 16) | (3 << 22);//High speed
//
// /**SPI3 GPIO Configuration
// PC10 ------> SPI3_SCK
// PC12 ------> 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->MODER |= (2 << 20) | (2 << 24);//MODE AF
// GPIOC->MODER &= 0xFEEFFFFF;//Mise à 0
// GPIOC->OTYPER &= (GPIO_OTYPER_OT10 | GPIO_OTYPER_OT12);//PC10 & 12 en PP
// GPIOC->OSPEEDR |= (3 << 24) | (3 << 20);//High speed
//
// /*Configure module SPI3*/
// 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->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;
//
//}
/* Send command (char) to LCD via SPI bus */
void LCD_Write_Command(uint8_t Command) { void LCD_Write_Command(uint8_t Command) {
while ((SPI1->SR & SPI_SR_BSY) != 0); while ((SPI1->SR & SPI_SR_BSY) != 0); // Wait that everything is sent before changing the RS pin
CMD CMD
; ;
while ((SPI1->SR & SPI_SR_TXE) == 0); while ((SPI1->SR & SPI_SR_TXE) == 0);
SPI1->DR = Command;// Cast sur pointeur, pour ecriture 8 bits. Sinon l'acces 16 bits provoque un tfert 16 bits SPI1->DR = Command;
} }
/* 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) {
while ((SPI1->SR & SPI_SR_BSY) != 0);//Attendre fin envoi trame while ((SPI1->SR & SPI_SR_BSY) != 0); // Wait that everything is sent before changing the RS pin
DATA DATA
; ;
while ((SPI1->SR & SPI_SR_TXE) == 0);// Waiting for TX register to be available. while ((SPI1->SR & SPI_SR_TXE) == 0);
SPI1->DR = Data; SPI1->DR = Data;
} }
void LCD_Write_Data16(uint16_t data) { void LCD_Write_Data16(uint16_t data) {
while ((SPI1->SR & SPI_SR_BSY) != 0);// Wait until SPI is not busy while ((SPI1->SR & SPI_SR_BSY) != 0); // Wait that everything is sent before changing the RS pin
DATA DATA
; ;
while ((SPI1->SR & SPI_SR_TXE) == 0);// Wait for TX buffer empty while ((SPI1->SR & SPI_SR_TXE) == 0);
SPI1->DR = (data >> 8) & 0xFF;// Send MSB SPI1->DR = (data >> 8) & 0xFF;// Send MSB
while ((SPI1->SR & SPI_SR_TXE) == 0);// Wait for TX buffer empty while ((SPI1->SR & SPI_SR_TXE) == 0);
SPI1->DR = data & 0xFF;// Send LSB SPI1->DR = data & 0xFF;// Send LSB
} }
/* Set the frame to draw into and sends a write into frame command */ /* 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_Data16(X1 + 10); LCD_Write_Data16(X1);
LCD_Write_Data16(X2 + 10); LCD_Write_Data16(X2);
LCD_Write_Command(0x2B); LCD_Write_Command(0x2B);
LCD_Write_Data16(Y1 + 19); LCD_Write_Data16(Y1 + 19);
@ -104,37 +65,6 @@ void LCD_Set_Address(uint16_t X1, uint16_t Y1, uint16_t X2, uint16_t Y2) {
LCD_Write_Command(0x2C); LCD_Write_Command(0x2C);
} }
//void LCD_Set_Rotation(uint8_t Rotation) {
//
// uint8_t screen_rotation = Rotation;
//
// LCD_Write_Command(0x36);
//
// switch (screen_rotation)
// case SCREEN_VERTICAL_1:
// LCD_Write_Data(0x40 | 0x08);
// LCD_WIDTH = 240;
// LCD_HEIGHT = 320;
// break;
// case SCREEN_HORIZONTAL_1:
// LCD_Write_Data(0x20 | 0x08);
// LCD_WIDTH = 320;
// LCD_HEIGHT = 240;
// break;
// case SCREEN_VERTICAL_2:
// LCD_Write_Data(0x80 | 0x08);
// LCD_WIDTH = 240;
// LCD_HEIGHT = 320;
// break;
// case SCREEN_HORIZONTAL_2:
// LCD_Write_Data(0x40 | 0x80 | 0x20 | 0x08);
// LCD_WIDTH = 320;
// LCD_HEIGHT = 240;
// break;
// default:
// break;
//}
void LCD_HardwareReset() { void LCD_HardwareReset() {
HAL_GPIO_WritePin(DRESET_GPIO_Port, DRESET_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(DRESET_GPIO_Port, DRESET_Pin, GPIO_PIN_SET);
HAL_Delay(1); HAL_Delay(1);
@ -166,8 +96,7 @@ void LCD_Init(void) {
// Configure orientation stuff // Configure orientation stuff
LCD_Write_Command(0x36); LCD_Write_Command(0x36);
LCD_Write_Data(0b10110100); LCD_Write_Data(0b00111100);
// Exit sleep // Exit sleep
LCD_Write_Command(0x11); LCD_Write_Command(0x11);
@ -181,8 +110,8 @@ void LCD_Init(void) {
LCD_Fill_Screen(WHITE); LCD_Fill_Screen(WHITE);
// Draw colors columns // Draw colors columns
LCD_Set_Address(30, 30, LCD_SCREEN_WIDTH - 30, LCD_SCREEN_HEIGHT - 30); LCD_Set_Address(30, 30, LCD_WIDTH - 30, LCD_HEIGHT - 30);
uint32_t size = (LCD_SCREEN_WIDTH - 59) * 20; uint32_t size = (LCD_WIDTH - 59) * 20;
LCD_Draw_Colour_Burst(BLACK, size); LCD_Draw_Colour_Burst(BLACK, size);
LCD_Draw_Colour_Burst(WHITE, size); LCD_Draw_Colour_Burst(WHITE, size);
LCD_Draw_Colour_Burst(BLUE, size); LCD_Draw_Colour_Burst(BLUE, size);
@ -192,86 +121,41 @@ void LCD_Init(void) {
// Draw rectangles in the angles // Draw rectangles in the angles
LCD_Draw_Rectangle(1, 1, 20, 20, RED); LCD_Draw_Rectangle(1, 1, 20, 20, RED);
LCD_Draw_Rectangle(LCD_SCREEN_WIDTH - 21, 1, 20, 20, GREEN); LCD_Draw_Rectangle(LCD_WIDTH - 21, 1, 20, 20, GREEN);
LCD_Draw_Rectangle(LCD_SCREEN_WIDTH - 21, LCD_SCREEN_HEIGHT - 21, 20, 20, LCD_Draw_Rectangle(LCD_WIDTH - 21, LCD_HEIGHT - 21, 20, 20,
MAGENTA); BLACK);
LCD_Draw_Rectangle(1, LCD_SCREEN_HEIGHT - 21, 20, 20, BLUE); LCD_Draw_Rectangle(1, LCD_HEIGHT - 21, 20, 20, BLUE);
// STARTING ROTATION // Test drawing text
//LCD_Set_Rotation(SCREEN_HORIZONTAL_1); char text[] = "test bro";
LCD_Draw_Text(&text, 30, 100, WHITE, 20, RED);
} }
//INTERNAL FUNCTION OF LIBRARY //INTERNAL FUNCTIONS OF THE LIBRARY
/*Sends block colour information to LCD*/
void LCD_Draw_Colour_Burst(uint16_t color, uint32_t size) { void LCD_Draw_Colour_Burst(uint16_t color, uint32_t size) {
while ((SPI1->SR & SPI_SR_BSY) != 0);// Wait until SPI is not busy while ((SPI1->SR & SPI_SR_BSY) != 0); // Wait that everything is sent before changing the RS pin
DATA DATA
; ;
for (uint32_t j = 0; j < size; j++) { for (uint32_t j = 0; j < size; j++) {
while ((SPI1->SR & SPI_SR_TXE) == 0);// Waiting for TX register to be available. while ((SPI1->SR & SPI_SR_TXE) == 0);
SPI1->DR = (color >> 8) & 0xFF; SPI1->DR = (color >> 8) & 0xFF;
while ((SPI1->SR & SPI_SR_TXE) == 0);// Waiting for TX register to be available. while ((SPI1->SR & SPI_SR_TXE) == 0);
SPI1->DR = color & 0xFF; SPI1->DR = color & 0xFF;
} }
} }
//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*/
void LCD_Fill_Screen(uint16_t color) { void LCD_Fill_Screen(uint16_t color) {
LCD_Draw_Rectangle(0, 0, LCD_WIDTH, LCD_HEIGHT, color); LCD_Draw_Rectangle(0, 0, LCD_WIDTH, LCD_HEIGHT, color);
} }
//DRAW PIXEL AT XY POSITION WITH SELECTED COLOUR
//
//Location is dependant on screen orientation. x0 and y0 locations change with orientations.
//Using pixels to draw big simple structures is not recommended as it is really slow
//Try using either rectangles or lines if possible
//
//void LCD_Draw_Pixel(uint16_t X, uint16_t Y, uint16_t Colour) {
// if ((X >= LCD_WIDTH) || (Y >= LCD_HEIGHT)) return;//OUT OF BOUNDS!
//
////ADDRESS
// LCD_Write_Command(0x2A);
//
////XDATA
// DATA
// ;
// CS_ON;
// 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
// SPI3->DR = ((X + 1) >> 8) | ((X + 1) << 8);
// while ((SPI3->SR & SPI_SR_BSY) != 0);//Attendre fin envoi trame
// CS_OFF;
//
////ADDRESS
// LCD_Write_Command(0x2B);
//
////YDATA
// DATA
// ;
// CS_ON;
// SPI3->DR = (Y >> 8) | (Y << 8);
// SPI3->DR = ((Y + 1) >> 8) | ((Y + 1) << 8);
// while ((SPI3->SR & SPI_SR_BSY) != 0);//Attendre fin envoi trame
// CS_OFF;
//
////ADDRESS
// LCD_Write_Command(0x2C);
//
////COLOUR
// DATA
// ;
// CS_ON;
// SPI3->DR = (Colour >> 8) | (Colour << 8);
// while ((SPI3->SR & SPI_SR_BSY) != 0);//Attendre fin envoi trame
// CS_OFF;
//}
//DRAW RECTANGLE OF SET SIZE AND HEIGTH AT X and Y POSITION WITH CUSTOM COLOUR void LCD_Draw_Pixel(uint16_t x, uint16_t y, uint16_t color) {
// if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)) return;
//Rectangle is hollow. X and Y positions mark the upper left corner of rectangle
//As with all other draw calls x0 and y0 locations dependant on screen orientation LCD_Set_Address(x, y, x, y);
// LCD_Draw_Colour_Burst(color, 1);
}
void LCD_Draw_Rectangle( void LCD_Draw_Rectangle(
uint16_t X, uint16_t X,
@ -290,7 +174,6 @@ void LCD_Draw_Rectangle(
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
void LCD_Draw_Horizontal_Line( void LCD_Draw_Horizontal_Line(
uint16_t X, uint16_t X,
uint16_t Y, uint16_t Y,
@ -304,7 +187,6 @@ void LCD_Draw_Horizontal_Line(
LCD_Draw_Colour_Burst(Colour, Width); LCD_Draw_Colour_Burst(Colour, Width);
} }
//DRAW LINE FROM X,Y LOCATION to X,Y+Height LOCATION
void LCD_Draw_Vertical_Line( void LCD_Draw_Vertical_Line(
uint16_t X, uint16_t X,
uint16_t Y, uint16_t Y,
@ -318,9 +200,6 @@ void LCD_Draw_Vertical_Line(
LCD_Draw_Colour_Burst(Colour, Height); LCD_Draw_Colour_Burst(Colour, Height);
} }
/*********************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 */
void LCD_Draw_Hollow_Circle( void LCD_Draw_Hollow_Circle(
uint16_t X, uint16_t X,
uint16_t Y, uint16_t Y,
@ -355,7 +234,7 @@ void LCD_Draw_Hollow_Circle(
} }
} }
/*Draw filled circle at X,Y location with specified radius and colour. X and Y represent circles center */
void LCD_Draw_Filled_Circle( void LCD_Draw_Filled_Circle(
uint16_t X, uint16_t X,
uint16_t Y, uint16_t Y,
@ -391,7 +270,6 @@ void LCD_Draw_Filled_Circle(
//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*/
void LCD_Draw_Hollow_Rectangle_Coord( void LCD_Draw_Hollow_Rectangle_Coord(
uint16_t X0, uint16_t X0,
uint16_t Y0, uint16_t Y0,
@ -435,7 +313,6 @@ void LCD_Draw_Hollow_Rectangle_Coord(
} }
/*Draw a filled rectangle between positions X0,Y0 and X1,Y1 with specified colour*/
void LCD_Draw_Filled_Rectangle_Coord( void LCD_Draw_Filled_Rectangle_Coord(
uint16_t X0, uint16_t X0,
uint16_t Y0, uint16_t Y0,

26
Core/Src/dashboard.c Normal file
View File

@ -0,0 +1,26 @@
#include "dashboard.h"
#include "LCD_driver.h"
void run_dashboard_loop() {
init();
while(1) {
}
}
void init() {
LCD_Init();
// draw base
}
void update_values() {
// UART send 0201 04 4084 03
}
void update_values_setup() {
// UART send 0201 2F D58D 03
}
void update_adc() {
// UART send 0201 20 2462 03
}

View File

@ -1,4 +1,4 @@
/* USER CODE BEGIN Header */ /* USER CODE BEGIN */
/** /**
****************************************************************************** ******************************************************************************
* @file : main.c * @file : main.c
@ -15,52 +15,55 @@
* *
****************************************************************************** ******************************************************************************
*/ */
/* USER CODE END Header */ /* USER CODE END */
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "main.h" #include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN */
#include "dashboard.h"
#include "LCD_driver.h"
/* 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.
@ -69,47 +72,46 @@ 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 SysInit */ /* USER CODE END */
/* 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 */ run_dashboard_loop();
/* USER CODE END */
/* Infinite loop */ /* Infinite loop */
/* USER CODE BEGIN WHILE */ /* USER CODE BEGIN */
while (1) while (1)
{ {
LCD_Init();
HAL_Delay(10000);
HAL_Delay(10);
/* USER CODE END WHILE */ /* USER CODE END */
/* USER CODE BEGIN 3 */ /* USER CODE BEGIN */
} }
/* USER CODE END 3 */ /* USER CODE END */
} }
/** /**
@ -158,13 +160,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;
@ -182,9 +184,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 */
} }
@ -196,13 +198,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;
@ -215,9 +217,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 */
} }
@ -229,9 +231,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();
@ -302,14 +304,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.
@ -317,13 +319,13 @@ 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
/** /**
@ -335,9 +337,9 @@ void Error_Handler(void)
*/ */
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 */