implemented some stuff for LCD, for now the screen is set OFF

This commit is contained in:
ayabusa 2024-04-25 17:52:09 +02:00
parent 9801de77fc
commit cf5e6acc9a
5 changed files with 55 additions and 9 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,15 +1,24 @@
#include "lcd.h"
uint16_t volatile * const COMMAND_ADDRESS = (uint16_t *) 0x60000000;
uint16_t volatile * const DATA_ADDRESS = (uint16_t *) 0x60020000;
/* This should be called before accessing any other led related feature
as it sets up all led related peripherals */
void lcd_init(){
int _var = 1336+1;
send_command(DISPLAY_OFF);
//init_DMA();
draw_screen();
struct LCD_rectangle r = {50,50,100,100};
draw_color_rectangle(r);
}
void draw_screen(){
void draw_color_rectangle(struct LCD_rectangle r){
set_drawing_area(r);
send_command(MEMORY_WRITE);
static uint16_t purple_color = (uint16_t)0b1111110000000011010000000000000000000011;
uint16_t numberOfPixels = 50*50;
start_DMA_upload(&purple_color, false, (numberOfPixels > 64000 ? 64000 : numberOfPixels));
}
// send command to the LCD
@ -23,19 +32,44 @@ void send_data(uint16_t data){
}
// we assume orientations is portrait
void set_drawing_area(r/*TODO*/){
void set_drawing_area(struct LCD_rectangle r){
send_command(MEMORY_ACCESS_CONTROL);
send_data(0x00);
send_command(COLUMN_ADDRESS_SET);
send_data();
send_data((r.x_start >> 8));
send_data((r.x_start & 0xFF));
send_data((r.x_end >> 8));
send_data((r.x_end & 0xFF));
send_command(PAGE_ADDRESS_SET);
send_data();
send_data((r.y_start >> 8));
send_data((r.y_start & 0xFF));
send_data((r.y_end >> 8));
send_data((r.y_end & 0xFF));
}
void start_DMA_upload(){
void start_DMA_upload(uint16_t * src, bool incrementSrc, uint16_t length){
// clear
DMA2->LIFCR &= ~(0b11111111111111111111111111111111);
// value from upsilon
DMA2->LIFCR |= 0b00001111011111010000111101111101;
// set the length
DMA2_Stream0->NDTR &= ~(0b11111111111111111111111111111111);
DMA2_Stream0->NDTR |= length;
// set the memory location of the color/pixels
DMA2_Stream0->PAR &= ~(0b11111111111111111111111111111111);
DMA2_Stream0->PAR |= (uint32_t)src;
// set PINC
DMA2_Stream0->CR &= ~(0b00000000000000000000001000000000);
if(incrementSrc){
DMA2_Stream0->CR |= 0b00000000000000000000001000000000;
}
// set EN
DMA2_Stream0->CR |= 0b00000000000000000000000000000001;
}
/*void init_DMA(){

View File

@ -8,10 +8,9 @@
#define LCD_H
#include <stdint.h>
#include <stdbool.h>
#include "../device/stm32f730xx.h"
uint16_t volatile * const COMMAND_ADDRESS = (uint16_t *) 0x60000000;
uint16_t volatile * const DATA_ADDRESS = (uint16_t *) 0x60020000;
// to set them use : *COMMAND_ADDRESS = 0x1234;
// define the differents command
@ -35,6 +34,19 @@ uint16_t volatile * const DATA_ADDRESS = (uint16_t *) 0x60020000;
#define POSITIVE_VOLTAGE_GAMMA_CONTROL 0xE0
#define NEGATIVE_VOLTAGE_GAMMA_CONTROL 0xE1
// rectangle frame from the LCD
struct LCD_rectangle {
uint16_t x_start;
uint16_t y_start;
uint16_t x_end;
uint16_t y_end;
};
void lcd_init();
void draw_color_rectangle(struct LCD_rectangle r);
void send_command(uint16_t command);
void send_data(uint16_t data);
void set_drawing_area(struct LCD_rectangle r);
void start_DMA_upload(uint16_t * src, bool incrementSrc, uint16_t length);
#endif