Fix GD77 display driver

replace/476ef1d408236d3b5a3567c4038e4b39c15bf5db
Fred 2020-12-04 10:22:57 +01:00
rodzic 8762a9e3a8
commit 5d9ac78548
5 zmienionych plików z 81 dodań i 24 usunięć

Wyświetl plik

@ -12,10 +12,10 @@ project('OpenRTX', 'c',
## OpenRTX
openrtx_src = ['openrtx/src/bootstrap.c']
#'openrtx/src/state.c',
#'openrtx/src/ui.c',
#'openrtx/src/threads.c']
openrtx_src = ['openrtx/src/bootstrap.c',
'openrtx/src/state.c',
'openrtx/src/ui.c',
'openrtx/src/threads.c']
## Replace main executable with platform test
@ -204,7 +204,9 @@ mduv380_def = def + stm32f405_def + {'PLATFORM_MDUV380': ''}
## Radioddity GD77
gd77_src = src + mk22fn512_src + ['platform/targets/GD77/platform.c']
gd77_src = src + mk22fn512_src + ['platform/targets/GD77/platform.c',
'platform/drivers/display/UC1701_GD77.c',
'openrtx/src/graphics/graphics_bw.c']
gd77_inc = inc + mk22fn512_inc + ['platform/targets/GD77']
gd77_def = def + mk22fn512_def + {'PLATFORM_GD77': ''}

Wyświetl plik

@ -27,6 +27,7 @@
#include <stdio.h>
#include "display.h"
#include "graphics.h"
#include "hwconfig.h"
typedef enum
{

Wyświetl plik

@ -94,7 +94,8 @@ void display_init()
// sendByteToController(0xE2); /* System Reset */
sendByteToController(0x2F); /* Voltage Follower On */
sendByteToController(0x81); /* Set Electronic Volume = 15 */
sendByteToController(0x3F); /* Full contrast */
/* TODO variable contrast */
sendByteToController(0x15); /* Contrast */
sendByteToController(0xA2); /* Set Bias = 1/9 */
sendByteToController(0xA1); /* A0 Set SEG Direction */
sendByteToController(0xC0); /* Set COM Direction */
@ -110,40 +111,55 @@ void display_terminate()
}
}
void display_renderRow(uint8_t row)
{
/* magic stuff */
uint8_t *buf = (frameBuffer + 128 * row);
for (uint8_t i = 0; i<16; i++)
{
uint8_t tmp[8] = {0};
for (uint8_t j = 0; j < 8; j++)
{
uint8_t tmp_buf = buf[j*16 + i];
int count = __builtin_popcount(tmp_buf);
while (count > 0)
{
int pos = __builtin_ctz(tmp_buf);
tmp[pos] |= 1UL << j;
tmp_buf &= ~(1 << pos);
count--;
}
}
for (uint8_t s = 0; s < 8; s++){
sendByteToController(tmp[s]);
}
}
}
void display_renderRows(uint8_t startRow, uint8_t endRow)
{
if(frameBuffer == NULL) return;
uint8_t *rowPos = (frameBuffer + startRow * SCREEN_WIDTH);
for(uint8_t row = startRow; row < endRow; row++)
{
gpio_clearPin(LCD_RS); /* RS low -> command mode */
sendByteToController(0xB0 | row); /* Set Y position */
sendByteToController(0x10); /* Set X position */
sendByteToController(0x04);
gpio_setPin(LCD_RS); /* RS high -> data mode */
display_renderRow(row);
}
for(size_t x = 0; x < SCREEN_WIDTH; x++)
{
sendByteToController(*rowPos);
rowPos++;
}
}
}
void display_render()
{
display_renderRows(0, SCREEN_HEIGHT);
gpio_clearPin(LCD_CS);
display_renderRows(0, SCREEN_HEIGHT / 8);
gpio_setPin(LCD_CS);
}
bool display_renderingInProgress()
{
/*
* Rendering is in progress if display's chip select is low or a DMA
* transfer is in progress.
*/
return (gpio_readPin(LCD_CS) == 0);
}
void *display_getFrameBuffer()

Wyświetl plik

@ -27,4 +27,16 @@
#define GREEN_LED GPIOB,18
#define RED_LED GPIOC,14
/* Screen dimensions */
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
/* Display */
#define LCD_BKLIGHT GPIOC,4
#define LCD_CS GPIOC,8
#define LCD_RST GPIOC,9
#define LCD_RS GPIOC,10
#define LCD_CLK GPIOC,11
#define LCD_DAT GPIOC,12
#endif

Wyświetl plik

@ -21,12 +21,30 @@
#include <platform.h>
#include <gpio.h>
#include "hwconfig.h"
#include "rtc.h"
curTime_t rtc_getTime()
{
/* TODO */
curTime_t t;
t.hour = 12;
t.minute = 12;
t.second = 12;
t.year = 2020;
t.day = 4;
t.month = 12;
t.date = 12;
return t;
}
void platform_init()
{
/* Configure GPIOs */
gpio_setMode(GREEN_LED, OUTPUT);
gpio_setMode(RED_LED, OUTPUT);
gpio_setMode(LCD_BKLIGHT, OUTPUT);
gpio_clearPin(LCD_BKLIGHT);
}
void platform_terminate()
@ -112,4 +130,12 @@ void platform_beepStop()
void platform_setBacklightLevel(uint8_t level)
{
/* TODO */
if(level > 1)
{
gpio_setPin(LCD_BKLIGHT);
}
else
{
gpio_clearPin(LCD_BKLIGHT);
}
}