diff --git a/docs/releases.txt b/docs/releases.txt index 11d2549c..ad093d46 100644 --- a/docs/releases.txt +++ b/docs/releases.txt @@ -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 *** diff --git a/drivers/gdisp/QImage/driver.mk b/drivers/gdisp/QImage/driver.mk new file mode 100644 index 00000000..dbf3a2b3 --- /dev/null +++ b/drivers/gdisp/QImage/driver.mk @@ -0,0 +1,2 @@ +GFXINC += $(GFXLIB)/drivers/gdisp/QImage +GFXSRC += $(GFXLIB)/drivers/gdisp/QImage/gdisp_lld_QImage.c diff --git a/drivers/gdisp/QImage/gdisp_lld_config.h b/drivers/gdisp/QImage/gdisp_lld_config.h new file mode 100644 index 00000000..ae97cfcb --- /dev/null +++ b/drivers/gdisp/QImage/gdisp_lld_config.h @@ -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 */ diff --git a/drivers/gdisp/QImage/gdisp_lld_driver.c b/drivers/gdisp/QImage/gdisp_lld_driver.c new file mode 100644 index 00000000..dbd7c279 --- /dev/null +++ b/drivers/gdisp/QImage/gdisp_lld_driver.c @@ -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 */ diff --git a/drivers/gdisp/QImage/gdisp_lld_qimage.cpp b/drivers/gdisp/QImage/gdisp_lld_qimage.cpp new file mode 100644 index 00000000..a133dfb4 --- /dev/null +++ b/drivers/gdisp/QImage/gdisp_lld_qimage.cpp @@ -0,0 +1,38 @@ +#include +#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(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(g->priv); + if (!qimage) { + return 0; + } + + return static_cast(qimage->pixel(g->p.x, g->p.y)); +} diff --git a/drivers/gdisp/QImage/gdisp_lld_qimage.h b/drivers/gdisp/QImage/gdisp_lld_qimage.h new file mode 100644 index 00000000..9e855f08 --- /dev/null +++ b/drivers/gdisp/QImage/gdisp_lld_qimage.h @@ -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 diff --git a/drivers/gdisp/readme.txt b/drivers/gdisp/readme.txt index c7c8b137..a898066b 100644 --- a/drivers/gdisp/readme.txt +++ b/drivers/gdisp/readme.txt @@ -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)