This commit is contained in:
2025-08-09 15:01:26 +02:00
parent 046f4b61dc
commit 6c75619957
16 changed files with 10760 additions and 22164 deletions
+56 -51
View File
@@ -1,38 +1,48 @@
/*
* gc9a01.h
*
* Created on: Jul 24, 2025
* Author: loren
/**
* @file gc9a01.h
* @brief Driver GC9A01 pour STM32 (HAL)
* @date 09 août 2025
* @author Lorent
*/
#ifndef INC_GC9A01_H_
#define INC_GC9A01_H_
#include "main.h"
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PIX_BUF 512
//==============================================================================
// Configuration des pins (à adapter selon votre câblage)
// 📌 Configuration matérielle
//==============================================================================
// Chip Select (CS)
#define GC9A01_CS_GPIO_Port GPIOB
#define GC9A01_CS_Pin GPIO_PIN_0
// Data/Command (DC)
#define GC9A01_DC_GPIO_Port GPIOB
#define GC9A01_DC_Pin GPIO_PIN_1
// Reset (RST)
#define GC9A01_RST_GPIO_Port GPIOB
#define GC9A01_RST_Pin GPIO_PIN_2
// SCK et MOSI sont sur SPI1 par défaut
//==============================================================================
// Constantes de l'écran
//==============================================================================
// Dimensions écran
#define GC9A01_WIDTH 240
#define GC9A01_HEIGHT 240
#define GC9A01_RADIUS 120
#define GC9A01_RADIUS (GC9A01_WIDTH / 2)
//==============================================================================
// Couleurs 16-bit (RGB565)
// 🎨 Couleurs (format RGB565)
//==============================================================================
#define GC9A01_BLACK 0x0000
#define GC9A01_WHITE 0xFFFF
@@ -49,14 +59,13 @@
#define GC9A01_LIGHTGRAY 0xC618
//==============================================================================
// Commandes du contrôleur GC9A01
// 📜 Commandes GC9A01
//==============================================================================
#define GC9A01_SWRESET 0x01
#define GC9A01_RDDID 0x04
#define GC9A01_RDDST 0x09
#define GC9A01_SLPIN 0x10
#define GC9A01_SLPOUT 0x11
#define GC9A01_PTLON 0x12
#define GC9A01_NORON 0x13
#define GC9A01_INVOFF 0x20
#define GC9A01_INVON 0x21
@@ -66,29 +75,21 @@
#define GC9A01_RASET 0x2B
#define GC9A01_RAMWR 0x2C
#define GC9A01_RAMRD 0x2E
#define GC9A01_PTLAR 0x30
#define GC9A01_COLMOD 0x3A
#define GC9A01_MADCTL 0x36
#define GC9A01_DFUNCTR 0xB6
#define GC9A01_PWCTR1 0xC1
#define GC9A01_PWCTR2 0xC3
#define GC9A01_PWCTR3 0xC4
#define GC9A01_PWCTR4 0xC9
#define GC9A01_RDID1 0xDA
#define GC9A01_RDID2 0xDB
#define GC9A01_RDID3 0xDC
#define GC9A01_FRAMERATE 0xE8
#define GC9A01_SPI2DATA 0xE9
#define GC9A01_INREGEN2 0xEF
#define GC9A01_GAMMA1 0xF0
#define GC9A01_GAMMA2 0xF1
#define GC9A01_GAMMA3 0xF2
#define GC9A01_GAMMA4 0xF3
//==============================================================================
// Structures
// 📦 Structures
//==============================================================================
typedef struct {
uint16_t x;
uint16_t y;
@@ -109,38 +110,42 @@ typedef struct {
} GC9A01_Circle_t;
//==============================================================================
// Fonctions publiques
// 🔹 Fonctions publiques
//==============================================================================
// Initialisation et contrôle de base
bool GC9A01_Init(SPI_HandleTypeDef *hspi);
void GC9A01_Reset(void);
void GC9A01_DisplayOn(void);
void GC9A01_DisplayOff(void);
void GC9A01_SetRotation(uint8_t rotation);
// Initialisation
void GC9A01_Init(SPI_HandleTypeDef *hspi);
void GC9A01_Reset(void);
void GC9A01_DisplayOn(void);
void GC9A01_DisplayOff(void);
void GC9A01_SetRotation(uint8_t rotation);
// Fonctions de dessin de base
void GC9A01_FillScreen(uint16_t color);
void GC9A01_SetPixel(uint16_t x, uint16_t y, uint16_t color);
void GC9A01_DrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
void GC9A01_DrawRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
void GC9A01_FillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
void GC9A01_DrawCircle(uint16_t x, uint16_t y, uint8_t radius, uint16_t color);
void GC9A01_FillCircle(uint16_t x, uint16_t y, uint8_t radius, uint16_t color);
// Dessin basique
void GC9A01_FillScreen(uint16_t color);
void GC9A01_SetPixel(uint16_t x, uint16_t y, uint16_t color);
void GC9A01_DrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
void GC9A01_DrawRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
void GC9A01_FillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
void GC9A01_DrawCircle(uint16_t x, uint16_t y, uint8_t radius, uint16_t color);
void GC9A01_FillCircle(uint16_t x, uint16_t y, uint8_t radius, uint16_t color);
// Fonctions de texte (simple)
void GC9A01_DrawChar(uint16_t x, uint16_t y, char c, uint16_t color, uint16_t bg_color, uint8_t size);
void GC9A01_DrawString(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bg_color, uint8_t size);
// Texte
void GC9A01_DrawChar(uint16_t x, uint16_t y, char c, uint16_t color, uint16_t bg_color, uint8_t size);
void GC9A01_DrawString(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bg_color, uint8_t size);
// Fonctions utilitaires
// Utilitaires
uint16_t GC9A01_RGB565(uint8_t r, uint8_t g, uint8_t b);
bool GC9A01_IsInCircle(uint16_t x, uint16_t y);
bool GC9A01_IsInCircle(uint16_t x, uint16_t y);
// Fonctions spécifiques pour interface moto
void GC9A01_DrawGauge(uint16_t center_x, uint16_t center_y, uint8_t radius,
float value, float min_val, float max_val,
uint16_t color, const char* label);
void GC9A01_DrawAngleIndicator(float roll, float pitch);
void GC9A01_DrawStateIndicator(const char* state, uint16_t color);
// Fonctions spécifiques moto
void GC9A01_DrawGauge(uint16_t center_x, uint16_t center_y, uint8_t radius,
float value, float min_val, float max_val,
uint16_t color, const char* label);
void GC9A01_DrawAngleIndicator(float roll, float pitch);
void GC9A01_DrawStateIndicator(const char* state, uint16_t color);
#endif /* INC_GC9A01_H_ */
#ifdef __cplusplus
}
#endif
#endif // GC9A01_H
+17 -3
View File
@@ -3,7 +3,21 @@
#include "stm32l4xx_hal.h"
void icm20948_init(void);
void icm20948_read_accel(float *ax, float *ay, float *az);
// Adresse I2C par défaut (SA0=1)
#define ICM20948_I2C_ADDR (0x69 << 1)
#endif
// ----- Fonctions de configuration -----
void icm20948_init(void);
void icm20948_mag_init(void);
// ----- Fonctions de lecture -----
void icm20948_read_accel(float *ax, float *ay, float *az);
void icm20948_read_gyro(float *gx, float *gy, float *gz);
void icm20948_read_mag(float *mx, float *my, float *mz);
// ----- Fonctions internes (optionnelles, si besoin hors module) -----
void icm20948_select_bank(uint8_t bank);
uint8_t icm20948_read_register(uint8_t reg);
void icm20948_write_register(uint8_t reg, uint8_t val);
#endif // ICM20948_H