Fix GD77 display driver
This commit is contained in:
parent
8762a9e3a8
commit
5d9ac78548
12
meson.build
12
meson.build
|
|
@ -12,10 +12,10 @@ project('OpenRTX', 'c',
|
||||||
## OpenRTX
|
## OpenRTX
|
||||||
|
|
||||||
|
|
||||||
openrtx_src = ['openrtx/src/bootstrap.c']
|
openrtx_src = ['openrtx/src/bootstrap.c',
|
||||||
#'openrtx/src/state.c',
|
'openrtx/src/state.c',
|
||||||
#'openrtx/src/ui.c',
|
'openrtx/src/ui.c',
|
||||||
#'openrtx/src/threads.c']
|
'openrtx/src/threads.c']
|
||||||
|
|
||||||
|
|
||||||
## Replace main executable with platform test
|
## Replace main executable with platform test
|
||||||
|
|
@ -204,7 +204,9 @@ mduv380_def = def + stm32f405_def + {'PLATFORM_MDUV380': ''}
|
||||||
|
|
||||||
|
|
||||||
## Radioddity GD77
|
## 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_inc = inc + mk22fn512_inc + ['platform/targets/GD77']
|
||||||
gd77_def = def + mk22fn512_def + {'PLATFORM_GD77': ''}
|
gd77_def = def + mk22fn512_def + {'PLATFORM_GD77': ''}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
|
#include "hwconfig.h"
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -91,10 +91,11 @@ void display_init()
|
||||||
gpio_clearPin(LCD_CS);
|
gpio_clearPin(LCD_CS);
|
||||||
|
|
||||||
gpio_clearPin(LCD_RS); /* RS low -> command mode */
|
gpio_clearPin(LCD_RS); /* RS low -> command mode */
|
||||||
// sendByteToController(0xE2); /* System Reset */
|
// sendByteToController(0xE2); /* System Reset */
|
||||||
sendByteToController(0x2F); /* Voltage Follower On */
|
sendByteToController(0x2F); /* Voltage Follower On */
|
||||||
sendByteToController(0x81); /* Set Electronic Volume = 15 */
|
sendByteToController(0x81); /* Set Electronic Volume = 15 */
|
||||||
sendByteToController(0x3F); /* Full contrast */
|
/* TODO variable contrast */
|
||||||
|
sendByteToController(0x15); /* Contrast */
|
||||||
sendByteToController(0xA2); /* Set Bias = 1/9 */
|
sendByteToController(0xA2); /* Set Bias = 1/9 */
|
||||||
sendByteToController(0xA1); /* A0 Set SEG Direction */
|
sendByteToController(0xA1); /* A0 Set SEG Direction */
|
||||||
sendByteToController(0xC0); /* Set COM 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)
|
void display_renderRows(uint8_t startRow, uint8_t endRow)
|
||||||
{
|
{
|
||||||
if(frameBuffer == NULL) return;
|
for(uint8_t row = startRow; row < endRow; row++)
|
||||||
|
|
||||||
uint8_t *rowPos = (frameBuffer + startRow * SCREEN_WIDTH);
|
|
||||||
|
|
||||||
for(uint8_t row = startRow; row < endRow; row++)
|
|
||||||
{
|
{
|
||||||
gpio_clearPin(LCD_RS); /* RS low -> command mode */
|
gpio_clearPin(LCD_RS); /* RS low -> command mode */
|
||||||
sendByteToController(0xB0 | row); /* Set Y position */
|
sendByteToController(0xB0 | row); /* Set Y position */
|
||||||
sendByteToController(0x10); /* Set X position */
|
sendByteToController(0x10); /* Set X position */
|
||||||
sendByteToController(0x04);
|
sendByteToController(0x04);
|
||||||
|
|
||||||
gpio_setPin(LCD_RS); /* RS high -> data mode */
|
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()
|
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()
|
bool display_renderingInProgress()
|
||||||
{
|
{
|
||||||
/*
|
return (gpio_readPin(LCD_CS) == 0);
|
||||||
* Rendering is in progress if display's chip select is low or a DMA
|
|
||||||
* transfer is in progress.
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *display_getFrameBuffer()
|
void *display_getFrameBuffer()
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,16 @@
|
||||||
#define GREEN_LED GPIOB,18
|
#define GREEN_LED GPIOB,18
|
||||||
#define RED_LED GPIOC,14
|
#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
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,30 @@
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include <gpio.h>
|
#include <gpio.h>
|
||||||
#include "hwconfig.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()
|
void platform_init()
|
||||||
{
|
{
|
||||||
/* Configure GPIOs */
|
/* Configure GPIOs */
|
||||||
gpio_setMode(GREEN_LED, OUTPUT);
|
gpio_setMode(GREEN_LED, OUTPUT);
|
||||||
gpio_setMode(RED_LED, OUTPUT);
|
gpio_setMode(RED_LED, OUTPUT);
|
||||||
|
|
||||||
|
gpio_setMode(LCD_BKLIGHT, OUTPUT);
|
||||||
|
gpio_clearPin(LCD_BKLIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_terminate()
|
void platform_terminate()
|
||||||
|
|
@ -112,4 +130,12 @@ void platform_beepStop()
|
||||||
void platform_setBacklightLevel(uint8_t level)
|
void platform_setBacklightLevel(uint8_t level)
|
||||||
{
|
{
|
||||||
/* TODO */
|
/* TODO */
|
||||||
|
if(level > 1)
|
||||||
|
{
|
||||||
|
gpio_setPin(LCD_BKLIGHT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gpio_clearPin(LCD_BKLIGHT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue