147 lines
5.2 KiB
C
147 lines
5.2 KiB
C
/*
|
|
* gc9a01.h
|
|
*
|
|
* Created on: Jul 24, 2025
|
|
* Author: loren
|
|
*/
|
|
|
|
#ifndef INC_GC9A01_H_
|
|
#define INC_GC9A01_H_
|
|
|
|
|
|
#include "main.h"
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
//==============================================================================
|
|
// Configuration des pins (à adapter selon votre câblage)
|
|
//==============================================================================
|
|
#define GC9A01_CS_GPIO_Port GPIOB
|
|
#define GC9A01_CS_Pin GPIO_PIN_0
|
|
#define GC9A01_DC_GPIO_Port GPIOB
|
|
#define GC9A01_DC_Pin GPIO_PIN_1
|
|
#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
|
|
//==============================================================================
|
|
#define GC9A01_WIDTH 240
|
|
#define GC9A01_HEIGHT 240
|
|
#define GC9A01_RADIUS 120
|
|
|
|
//==============================================================================
|
|
// Couleurs 16-bit (RGB565)
|
|
//==============================================================================
|
|
#define GC9A01_BLACK 0x0000
|
|
#define GC9A01_WHITE 0xFFFF
|
|
#define GC9A01_RED 0xF800
|
|
#define GC9A01_GREEN 0x07E0
|
|
#define GC9A01_BLUE 0x001F
|
|
#define GC9A01_CYAN 0x07FF
|
|
#define GC9A01_MAGENTA 0xF81F
|
|
#define GC9A01_YELLOW 0xFFE0
|
|
#define GC9A01_ORANGE 0xFD20
|
|
#define GC9A01_DARKGREEN 0x03E0
|
|
#define GC9A01_DARKBLUE 0x0010
|
|
#define GC9A01_GRAY 0x8410
|
|
#define GC9A01_LIGHTGRAY 0xC618
|
|
|
|
//==============================================================================
|
|
// Commandes du contrôleur 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
|
|
#define GC9A01_DISPOFF 0x28
|
|
#define GC9A01_DISPON 0x29
|
|
#define GC9A01_CASET 0x2A
|
|
#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
|
|
//==============================================================================
|
|
|
|
typedef struct {
|
|
uint16_t x;
|
|
uint16_t y;
|
|
} GC9A01_Point_t;
|
|
|
|
typedef struct {
|
|
uint16_t x;
|
|
uint16_t y;
|
|
uint16_t width;
|
|
uint16_t height;
|
|
} GC9A01_Rect_t;
|
|
|
|
typedef struct {
|
|
uint16_t x;
|
|
uint16_t y;
|
|
uint8_t radius;
|
|
uint16_t color;
|
|
} GC9A01_Circle_t;
|
|
|
|
//==============================================================================
|
|
// 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);
|
|
|
|
// 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);
|
|
|
|
// 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);
|
|
|
|
// Fonctions utilitaires
|
|
uint16_t GC9A01_RGB565(uint8_t r, uint8_t g, uint8_t b);
|
|
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);
|
|
|
|
#endif /* INC_GC9A01_H_ */
|