]> git.ayabusa.dev Git - numworks-zeta-os.git/commitdiff
implemented some stuff for LCD, for now the screen is set OFF main
authorayabusa <lebgpub@gmail.com>
Thu, 25 Apr 2024 15:52:09 +0000 (17:52 +0200)
committerayabusa <lebgpub@gmail.com>
Thu, 25 Apr 2024 15:52:09 +0000 (17:52 +0200)
build/Laplace/lcd.o
build/main.bin
build/main.elf
src/Laplace/lcd.c
src/Laplace/lcd.h

index f583644228b579c43d8d00757e53ca7afed7529b..edcc1e9be6be349908b6fa10d8dc5ec1598ffca5 100644 (file)
Binary files a/build/Laplace/lcd.o and b/build/Laplace/lcd.o differ
index 9fc84eefe8395cef042f7847738d816dc3c33391..11045f6f0d98f23382ddc2e14713452ee0e7f573 100755 (executable)
Binary files a/build/main.bin and b/build/main.bin differ
index 9187d1d37c1235f1c2f3fc6b97394340755b3bd7..cd40a0a01717ccb42aa94593a91c228939ed40bf 100755 (executable)
Binary files a/build/main.elf and b/build/main.elf differ
index dfa300d498dd55dcea5d9ea6a7816ec3b0712386..831b889cb033170e97c803d06c6e4b16592fe5cc 100644 (file)
@@ -1,15 +1,24 @@
 #include "lcd.h"
 
 #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;
 /* 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();
     //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
 }
 
 // send command to the LCD
@@ -23,19 +32,44 @@ void send_data(uint16_t data){
 }
 
 // we assume orientations is portrait
 }
 
 // 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_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_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(){
 }
 
 /*void init_DMA(){
index d148df7776ec33263047c71dd22ec386d2190f27..c117c51cba520877c80095a9b0dcda571728b389 100644 (file)
@@ -8,10 +8,9 @@
 #define LCD_H
 
 #include <stdint.h>
 #define LCD_H
 
 #include <stdint.h>
+#include <stdbool.h>
 #include "../device/stm32f730xx.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
 // 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
 
 #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 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
\ No newline at end of file
 
 #endif
\ No newline at end of file