Adding QImage display driver

This commit is contained in:
Joel Bodenmann 2016-07-19 01:24:05 +02:00
parent 5ad68305a7
commit 038a1f3630
7 changed files with 142 additions and 0 deletions

View File

@ -10,6 +10,7 @@ FIX: Fixing issue in STM32F746G-Discovery board file that resulted in bad color
FEATURE: Added gwinPrintg()
FIX: Fix sprintg and related functions handling of NULL pointers.
FIX: Fixing width calculation of gdispGDrawString() and gdispGFillString().
FEATURE: Added QImage display driver.
*** Release 2.5 ***

View File

@ -0,0 +1,2 @@
GFXINC += $(GFXLIB)/drivers/gdisp/QImage
GFXSRC += $(GFXLIB)/drivers/gdisp/QImage/gdisp_lld_QImage.c

View File

@ -0,0 +1,21 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#pragma once
#if GFX_USE_GDISP
/*===========================================================================*/
/* Driver hardware support. */
/*===========================================================================*/
#define GDISP_HARDWARE_DRAWPIXEL TRUE
#define GDISP_HARDWARE_PIXELREAD TRUE
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
#endif /* GFX_USE_GDISP */

View File

@ -0,0 +1,64 @@
/*b
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#include "../../../gfx.h"
#if GFX_USE_GDISP
#define GDISP_DRIVER_VMT GDISPVMT_QImage
#include "gdisp_lld_config.h"
#include "../../../src/gdisp/gdisp_driver.h"
#include "gdisp_lld_qimage.h"
#ifndef GDISP_SCREEN_HEIGHT
#define GDISP_SCREEN_HEIGHT 512
#endif
#ifndef GDISP_SCREEN_WIDTH
#define GDISP_SCREEN_WIDTH 512
#endif
#ifndef GDISP_INITIAL_CONTRAST
#define GDISP_INITIAL_CONTRAST 50
#endif
#ifndef GDISP_INITIAL_BACKLIGHT
#define GDISP_INITIAL_BACKLIGHT 100
#endif
LLDSPEC bool_t gdisp_lld_init(GDisplay *g)
{
/* No board interface and no private driver area */
g->priv = g->board = 0;
if (!qimage_init(g, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT)) {
return FALSE;
}
/* Initialise the GDISP structure */
g->g.Width = GDISP_SCREEN_WIDTH;
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Orientation = GDISP_ROTATE_0;
g->g.Powermode = powerOn;
g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
g->g.Contrast = GDISP_INITIAL_CONTRAST;
return TRUE;
}
#if GDISP_HARDWARE_DRAWPIXEL
void gdisp_lld_draw_pixel(GDisplay *g)
{
qimage_setPixel(g);
}
#endif
#if GDISP_HARDWARE_PIXELREAD
color_t gdisp_lld_get_pixel_color(GDisplay *g)
{
return qimage_getPixel(g);
}
#endif
#endif /* GFX_USE_GDISP */

View File

@ -0,0 +1,38 @@
#include <QImage>
#include "../../../gfx.h"
#include "../../../src/gdisp/gdisp_driver.h"
#include "gdisp_lld_qimage.h"
bool_t qimage_init(GDisplay* g, coord_t width, coord_t height)
{
QImage* qimage = new QImage(width, height, QImage::Format_RGB888);
if (!qimage) {
return FALSE;
}
qimage->fill(Qt::gray);
g->priv = qimage;
return TRUE;
}
void qimage_setPixel(GDisplay* g)
{
QImage* qimage = static_cast<QImage*>(g->priv);
if (!qimage) {
return;
}
QRgb rgbVal = qRgb(RED_OF(g->p.color), GREEN_OF(g->p.color), BLUE_OF(g->p.color));
qimage->setPixel(g->p.x, g->p.y, rgbVal);
}
color_t qimage_getPixel(GDisplay* g)
{
const QImage* qimage = static_cast<const QImage*>(g->priv);
if (!qimage) {
return 0;
}
return static_cast<color_t>(qimage->pixel(g->p.x, g->p.y));
}

View File

@ -0,0 +1,15 @@
#pragma once
#include "../../../gfx.h"
#ifdef __cplusplus
extern "C" {
#endif
bool_t qimage_init(GDisplay* g, coord_t width, coord_t height);
void qimage_setPixel(GDisplay* g);
color_t qimage_getPixel(GDisplay* g);
#ifdef __cplusplus
}
#endif

View File

@ -29,6 +29,7 @@ ST7565 - Small monochrome LCD
STM32LTDC - STM32 ART graphics STM32F4 and STM32F7 series CPU's
TestStub - NULL driver just to test compile
TLS8204 - Small monochrome LCD
QImage - Driver that allows rendering into a QImage object (of the Qt framework)
uGFXnet - Remote Network display (in drivers/multiple/uGFXnet directory)
Win32 - Microsoft Windows (in drivers/multiple/Win32 directory)
X - X Windows (Xlib) (in drivers/multiple/X directory)