ow-dash-cube/Core/Inc/LCD_driver.h
2025-09-14 17:17:59 +02:00

185 lines
5.5 KiB
C

// Driver afficheur ADA 1983/chip ILI9341 pour Kit STM32L476 IUT1 de Grenoble Dpt GEII
//
// Adaptations L476, et fusion libs : V. GRENNERAT, IUT1 de Grenoble, Dpt GEII
// Correction bug coordonnees X et Y pour Draw_Char et Draw_Text : V. GRENNERAT
// Ajout fonction LCD_Draw_Image_XY : V. GRENNERAT
// Intégration des fonctions de configuration SPI3 et GPIO : V. GRENNERAT
// --------------------------------
// MIT License
//
// Copyright (c) 2017 Matej Artnak
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
/* Includes ------------------------------------------------------------------*/
#ifndef LCD_STM32_DRIVER_H
#define LCD_STM32_DRIVER_H
#include "stm32f1xx.h"
#include "main.h"
#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_SCREEN_WIDTH 470 // ST7365 is 480 (aligned at the left, offset = 10)
//CHIP SELECT PIN AND PORT, STANDARD GPIO
#define LCD_CS_PIN (1<<8)
#define LCD_DC_PIN (1<<11)
#define CMD DCX_GPIO_Port->BRR=DCX_Pin;
#define DATA DCX_GPIO_Port->BSRR=DCX_Pin;
#define TEMPO1MS_80M 4200
//RESET PIN AND PORT, STANDARD GPIO
//Reset n'est pas cable sur aff ADA1983
//#define LCD_RST_PORT GPIOC
//#define LCD_RST_PIN RST_Pin
#define BURST_MAX_SIZE 100 //buffer burst stocké sur pile. Par défaut stackSiZE=256 dans FreeRTOS.
#define BLACK 0x0000
#define NAVY 0x000F
#define DARKGREEN 0x03E0
#define DARKCYAN 0x03EF
#define MAROON 0x7800
#define PURPLE 0x780F
#define OLIVE 0x7BE0
#define LIGHTGREY 0xC618
#define DARKGREY 0x7BEF
#define BLUE 0x001F
#define GREEN 0x07E0
#define CYAN 0x07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define ORANGE 0xFD20
#define GREENYELLOW 0xAFE5
#define PINK 0xF81F
#define SCREEN_VERTICAL_1 0
#define SCREEN_HORIZONTAL_1 1
#define SCREEN_VERTICAL_2 2
#define SCREEN_HORIZONTAL_2 3
void LCD_SPI_Init(void);
void LCD_SPI_Send(unsigned char SPI_Data);
void LCD_Write_Command(uint8_t Command);
void LCD_Write_Data(uint8_t Data);
void LCD_Set_Address(uint16_t X1, uint16_t Y1, uint16_t X2, uint16_t Y2);
//Reset n'est pas cable sur aff ADA1983:
//void LCD_Reset(void);
//void LCD_Enable(void);
void LCD_Set_Rotation(uint8_t Rotation);
// @param Rotation : valeurs= SCREEN_VERTICAL_1, SCREEN_VERTICAL_2, SCREEN_HORIZONTAL_1, SCREEN_HORIZONTAL_2
// Par defaut pour kit L476 IUT1 : SCREEN_HORIZONTAL_1
void LCD_Init(void);
void LCD_Fill_Screen(uint16_t Colour);
// @param Colour : voir #define de quelques couleurs 16 bits standard ci-dessus
void LCD_Draw_Colour(uint16_t Colour);
// @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);
//@param X : coordonnee x
//@param Y : coordonnee y
//@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_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);
#endif
/*******************PARTIE ISSUE DE LA LIB ILI9193_GFX.h***************************/
#ifndef LCD_GFX_H
#define LCD_GFX_H
#define HORIZONTAL_IMAGE 0
#define VERTICAL_IMAGE 1
void LCD_Draw_Hollow_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);
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);
/*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_Image_XY(
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*/
//CONVERTISSEUR: http://www.digole.com/tools/PicturetoC_Hex_converter.php
void LCD_Draw_Image_Full(const char *Image_Array, uint8_t Orientation);
#endif