Compare commits

...

91 Commits
v2.9 ... master

Author SHA1 Message Date
Joel Bodenmann 41eef9dede GDISP: Add CH1115 driver 2023-11-25 17:19:15 +01:00
Joel Bodenmann b40425a0ae SSD1312: Add new GDISP driver 2023-10-31 12:34:10 +01:00
inmarket f1a34c9852 Fix for Win32 keyboard driver key states 2023-07-25 09:44:48 +10:00
inmarket 025cef93cc Use pure ascii encoding to prevent character encoding issues 2023-07-12 12:02:40 +10:00
Joel Bodenmann e028d196f5 gwin: add extern C to make usable from C++ 2023-07-03 16:42:03 +02:00
Joel Bodenmann fa0c779b0c drivers/multiple/SDL2: initialize only required subsystems 2023-06-07 16:09:24 +02:00
Joel Bodenmann 3d543b62bc drivers/multiple/SDL2: rename UGFX_SDL_INIT_FLAGS to GFX_SDL_INIT_FLAGS 2023-06-07 15:49:24 +02:00
Joel Bodenmann d1279f5ef2 drivers/multiple/SDL2: allow overriding SDL_Init() flags 2023-06-07 15:47:50 +02:00
Joel Bodenmann 6b0ce94b15 cmake: improve SDL2 support 2023-06-07 15:24:51 +02:00
Joel Bodenmann ad90707866 cmake: add support for drivers/ginput/touch/Linux-Event 2023-05-30 13:22:30 +02:00
Joel Bodenmann dee588888b cmake: add support for drivers/gdisp/framebuffer 2023-05-30 13:14:19 +02:00
Joel Bodenmann 9e9fc1e824 cmake: add support for drivers/multiple/X 2023-04-21 19:02:34 +02:00
Joel Bodenmann 325a7c8b5f cmake: fix typo 2022-06-10 13:41:34 +00:00
Joel Bodenmann da1c2233e7 drivers/GDISP/LGDP4532: Add gdisp_lld_draw_pixel() and gdisp_lld_fill_area()
Contributed by "Volodymyr Shylov" <shilow@ukr.net>
2022-05-23 16:05:05 +02:00
Joel Bodenmann 168cd27633 update changelog.txt 2022-04-26 01:27:10 +02:00
Joel Bodenmann 143a3a8847 drivers/GDISP/SSD1322: Add missing driver.mk file
Fixes #7
2022-04-26 00:50:49 +02:00
Joel Bodenmann 56a88c440d cmake: provide an IMPORTED target 2021-11-03 20:50:24 +01:00
Joel Bodenmann cc0b175e7f cmake: Improve Findugfx.cmake 2021-11-03 20:23:29 +01:00
Joel Bodenmann ba9b9fb62b cmake: add driver file for drivers/multiple/Win32 2021-11-03 20:23:16 +01:00
Joel Bodenmann 0f11538656 Revert "cmake: Print UGFX_ROOT variable on success"
This reverts commit d66739a349.
2021-11-03 18:47:09 +01:00
Joel Bodenmann d66739a349 cmake: Print UGFX_ROOT variable on success 2021-11-03 18:38:53 +01:00
Joel Bodenmann ebf5033144 cmake: No longer print _SOURCES and _INCLUDE_DIRS variables 2021-11-03 17:26:43 +01:00
Joel Bodenmann 734c5cd421 cmake: Improve SDL driver integration 2021-10-28 16:15:02 +02:00
Joel Bodenmann 831c23e2ac cmake: Add root directory to include directories 2021-10-28 14:56:01 +02:00
Joel Bodenmann 2ae3cf397d CMake: Automatically set UGFX_ROOT 2021-10-27 16:45:20 +02:00
inmarket 33f6fa0eb0 More line ending fixes 2021-10-20 22:21:56 +10:00
inmarket 2c1c87ee1b Fixing line endings 2021-10-20 22:17:27 +10:00
Joel Bodenmann ae6a3bc18b Adding CMake support for gdisp/STM32LTDC driver 2021-10-12 18:37:02 +02:00
Joel Bodenmann 68483139c9 Adding ChibiOS 7 support 2021-10-12 18:36:02 +02:00
Joel Bodenmann 64aa71339c Adding CMake support 2021-10-12 17:44:54 +02:00
Joel Bodenmann a4f225700f Improving FreeBSD integration support 2021-10-12 15:33:35 +02:00
Joel Bodenmann 71a308a01a Update readme 2021-09-24 17:51:55 +02:00
Joel Bodenmann 50be0d6432 Revert "Fix signed/unsigned comparison in gos_linux.c"
This reverts commit aa9e187581.
2021-09-23 17:49:02 +02:00
Joel Bodenmann 7e2decd0cd Update changelog.txt 2021-09-21 18:12:07 +02:00
Joel Bodenmann aa9e187581 Fix signed/unsigned comparison in gos_linux.c 2021-09-21 18:07:54 +02:00
Joel Bodenmann 05b547bbbb Updating changelog.txt 2021-09-21 17:56:46 +02:00
Joel Bodenmann 1d63573408 Adding FreeBSD support 2021-09-21 17:54:35 +02:00
Joel Bodenmann 1c29a88ee1 Fix SDL2 driver arguments to mmap() and sem_open()
Linux & MacOS seem to tolerate the incorrect parameters but they are wrong as per the documentation.
On more pedantic systems such as FreeBSD these calls fails.
2021-09-21 17:44:43 +02:00
Joel Bodenmann 4261a1fb0b Fix missing return values in FSync GQUEUE implementations 2021-08-31 16:06:44 +02:00
inmarket 3d3555ec5a Add Visual Studio Code project config to the .gitignore 2021-08-29 17:29:13 +10:00
Joel Bodenmann 2f82247223 Prevent const qualifier being discarded in vfnprintg() 2021-08-26 17:46:55 +02:00
Joel Bodenmann cbf9c22adf STM32LTDC: Update readme.md 2021-08-26 14:26:59 +02:00
Joel Bodenmann 6d6ce043d0 Whitespaces 2021-08-26 14:26:17 +02:00
Joel Bodenmann 0a55fc94bd Avoid duplicate const specifier compiler warnings
The original code is perfectly valid standard C. However, some compilers (especially GCC) complain about duplicate const specifiers anyway.
At this point we cave in as there doesn't seem to be any efforts to fix this problem by the corresponding compiler vendors.

uGFX v3 will no longer suffer from this problem as the driver interface works differently in this area.
2021-08-26 14:26:04 +02:00
Joel Bodenmann 0dac6b4d0f Fix ChibiOS 6.x kernel support 2021-08-26 02:08:42 +02:00
Joel Bodenmann 14f26ec934 Whitespaces 2021-08-26 00:33:11 +02:00
Joel Bodenmann 7845f44f20 Win32 driver: Fix memory leak / invalid pointer to free() when re-calculating buffer position in a specific situation.
Thanks to @nathanwiebe for reporting this.
2021-08-26 00:22:19 +02:00
Joel Bodenmann 1235a9056c Win32 driver: Fix buffer position calculation in gdisp_lld_blit_area()
Thanks to @nathanwiebe for reporting this.
2021-08-26 00:04:47 +02:00
Joel Bodenmann 3f1f1c6a95 Fix/clean changelog.txt 2021-08-23 23:43:39 +02:00
Joel Bodenmann 8d6b2c4707 GTRANS: Update /demos/modules/gtrans/basic 2021-08-23 15:46:47 +02:00
Joel Bodenmann 317db95c46 GTRANS: Update types 2021-08-23 15:46:22 +02:00
Joel Bodenmann ec257874a7 GDISP: Explicitly handle gOrientation values where applicaple
This addresses a compiler bug in some versions of GCC which warn about unhandled enum values although there is a default handler.
2021-08-23 15:28:06 +02:00
Joel Bodenmann b17cb215f4 STM32LTDC: Handle gOrientationPortrait and gOrientationLandscape explicitly although not supporting it 2021-08-23 15:26:15 +02:00
Joel Bodenmann b3216fa0cc Minor doxygen fixes 2021-08-19 13:48:44 +02:00
Joel Bodenmann 888c7e8640 STM32LTDC: Fix bug in DMA2D blitting
Thanks to @nathanwiebe for reporting this:
https://community.ugfx.io/topic/3159-a-bug-in-the-stm32-ltdc-driver
2021-08-18 20:58:53 +02:00
Joel Bodenmann 853f2cba98 Relocate current benchmark to /demos/benchmarks/rectangles 2021-08-18 20:51:56 +02:00
Joel Bodenmann c713719326 Update /demos/benchmarks configuration file 2021-08-18 19:18:04 +02:00
Joel Bodenmann b98a6c258c Update /demos/benchmarks
This uses GOS functionalities to count ticks instead of hardware specific cycle counters.
2021-08-18 19:17:04 +02:00
Joel Bodenmann c57bd08379 Fix comment 2021-08-18 18:26:41 +02:00
Joel Bodenmann 409b8d4490 Update changelog.txt 2021-08-18 18:09:49 +02:00
Joel Bodenmann 77f10024e0 STM32LTDC: Improve pixel format detection if 2nd layer is used
This is necessary as using double buffering via STM32LTDC_USE_DOUBLEBUFFERING will also result in GDISP_TOTAL_DISPLAYS being larger than 1.
2021-08-18 17:12:12 +02:00
Joel Bodenmann 72200af286 Update changelog.txt 2021-08-18 17:05:29 +02:00
Joel Bodenmann d980418e81 STM32LTDC: Update readme.md 2021-08-18 16:46:04 +02:00
Joel Bodenmann 08c2358542 STM32LTDC: Support double buffering 2021-08-18 16:38:23 +02:00
Joel Bodenmann 5e3159064a Fix typo in readme 2021-08-17 15:56:06 +02:00
Joel Bodenmann 8804f3a381 STM32LTDC: Fix misspelled macro (internally only) 2021-08-17 15:55:02 +02:00
Joel Bodenmann 7f78be1183 STM32LTDC: Rename user config options for consistency & add docs 2021-08-17 14:23:57 +02:00
Joel Bodenmann 91247717a0 STM32LTDC: Expose more options to board file 2021-08-17 13:40:57 +02:00
Joel Bodenmann 2de054b530 STM32LTDC: Remove obsolete LTDC_NO_CLOCK_INIT define 2021-08-17 13:29:49 +02:00
Joel Bodenmann 94fd096fdd STM32LTDC: Rename ALLOW_2ND_LAYER to LTDC_USE_2ND_LAYER 2021-08-17 13:26:54 +02:00
Joel Bodenmann a9cf2bdfe2 STM32LTDC: Enable DMA cache flushing on H7 platforms 2021-08-17 12:32:12 +02:00
Joel Bodenmann b1b264b6a1 Fix legacy string 2021-08-16 16:25:04 +02:00
Joel Bodenmann cf01cb2e7c GDISP: Move extern GDISPVMT declarations outside of function body
This prevents generation of "nested-externs" compiler warnings.
2021-08-13 11:51:47 +02:00
Joel Bodenmann 37450998e1 STM32LTDC: Fix board function signatures 2021-08-12 20:31:49 +02:00
Joel Bodenmann 6fa3520f2a Refactor STM32LTDC driver to outsource hardware specifics such as clock setup to the board file 2021-08-12 20:22:49 +02:00
Joel Bodenmann beb815e109 Board STM32F746-Discovery: Fix rouge-ly replaced types 2021-08-12 20:08:02 +02:00
Joel Bodenmann 346375c001 Add experimental support for ChibiOS 6.x kernel 2021-08-12 12:47:08 +02:00
Joel Bodenmann 85c7b08825 Update changelog.txt 2021-08-12 12:22:54 +02:00
Joel Bodenmann 9c0678a291 Avoid duplicate const specifier compiler warnings
The original code is perfectly valid standard C. However, some compilers (especially GCC) complain about duplicate const specifiers anyway.
At this point we cave in as there doesn't seem to be any efforts to fix this problem by the corresponding compiler vendors.

uGFX v3 will no longer suffer from this problem as the driver interface works differently in this area.
2021-08-12 12:20:07 +02:00
Joel Bodenmann a587942305 Fix changelog.txt whitespace 2021-08-10 20:18:47 +02:00
Joel Bodenmann 47d9826a0a Fix compiler warning due to implicit cast 2021-08-10 15:41:26 +02:00
Joel Bodenmann 13d360b17f Doxygen: Set PROJECT_NAME appropriately. 2021-04-13 18:53:06 +02:00
Joel Bodenmann df7027881a Doxygen improvements 2021-04-13 18:36:22 +02:00
Joel Bodenmann 2d4bbea4a3 Update doxygen file
Updated doxygenfile using $>_ doxygen -u Doxyfile
2021-04-13 18:21:54 +02:00
inmarket ff93884f71 Fix doxygen comment 2020-01-21 12:10:35 +10:00
inmarket 0586fd276d Fix to gImage BMP handling where the system pixel size is less than a byte 2019-05-08 09:25:35 +10:00
inmarket 127a7cd2a2 Fix to GWIN console widget 2019-05-08 09:01:56 +10:00
inmarket 701f697df5 Fix release notes 2019-05-08 08:33:47 +10:00
Joel Bodenmann 39bde23dd9 Merge branch 'develop' 2019-05-01 17:07:43 +02:00
Joel Bodenmann ac4b7fc8b4 Typedef gImage compatibility only when GDISP_NEED_IMAGE is GFXON 2019-05-01 16:54:39 +02:00
Joel Bodenmann 785047b0aa Introduce type gImage to replace v2.x gdispImage 2019-04-10 17:33:15 +02:00
176 changed files with 16718 additions and 14610 deletions

5
.gitignore vendored
View File

@ -3,6 +3,7 @@ build
.dep
.cproject
.project
.vscode
*.sublime*
*.stackdump
*.lst
@ -15,3 +16,7 @@ docs/html
docs/html.zip
docs/*.db
docs/*.tmp
# CLion
.idea/
cmake-build-*/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,92 @@
#pragma once
#include <stm32f4xx_hal.h>
#include <string.h>
// The command byte to put on the front of each page line
#define SSD1312_PAGE_PREFIX 0x40 // Co = 0, D/C = 1
static I2C_HandleTypeDef i2cHandle;
static GFXINLINE void init_board(GDisplay *g)
{
(void) g;
// GPIO
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
__HAL_RCC_GPIOB_CLK_ENABLE();
// I2C SCL
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
// I2C SDA
GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}
// I2C1
{
__HAL_RCC_I2C1_CLK_ENABLE();
i2cHandle.Instance = I2C1;
i2cHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
i2cHandle.Init.ClockSpeed = 400000;
i2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
i2cHandle.Init.DutyCycle = I2C_DUTYCYCLE_2;
i2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
i2cHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&i2cHandle) != HAL_OK)
gfxHalt("I2C HAL init error");
}
}
static GFXINLINE void post_init_board(GDisplay *g)
{
(void) g;
}
static GFXINLINE void setpin_reset(GDisplay *g, gBool state)
{
(void) g;
(void) state;
}
static GFXINLINE void acquire_bus(GDisplay *g)
{
(void) g;
}
static GFXINLINE void release_bus(GDisplay *g)
{
(void) g;
}
static GFXINLINE void write_cmd(GDisplay *g, gU8 *data, gU16 length)
{
(void) g;
gU8 buf[4]; // length is always <= 3
buf[0] = 0x00;
memcpy(buf+1, data, length);
HAL_I2C_Master_Transmit(&i2cHandle, (0x3c << 1), buf, length+1, 10000);
}
static GFXINLINE void write_data(GDisplay *g, gU8 *data, gU16 length)
{
(void) g;
HAL_I2C_Master_Transmit(&i2cHandle, (0x3c << 1), data, length, 10000);
}

View File

@ -0,0 +1,6 @@
GFXINC +=
GFXSRC +=
GFXDEFS += -DGFX_USE_OS_FREEBSD=GFXON
GFXLIBS += rt
include $(GFXLIB)/drivers/multiple/SDL/driver.mk

View File

@ -0,0 +1,52 @@
# Possible Targets: all clean Debug cleanDebug Release cleanRelease
##############################################################################################
# Settings
#
# General settings
# See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables
OPT_OS = freebsd
OPT_LINK_OPTIMIZE = yes
# Change this next setting (or add the explicit compiler flags) if you are not compiling for x86 linux
OPT_CPU = x64
# uGFX settings
# See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables
GFXLIB = ../uGFX
GFXBOARD = FreeBSD-SDL
GFXDEMO = modules/gdisp/basics
# Linux settings
# See $(GFXLIB)/tools/gmake_scripts/os_linux.mk for the list of variables
##############################################################################################
# Set these for your project
#
ARCH =
XCC = gcc10
XAS = gcc10
XLD = gcc10
SRCFLAGS = -ggdb -O0
CFLAGS = `sdl2-config --libs --cflags`
CXXFLAGS =
ASFLAGS =
LDFLAGS =
SRC =
OBJS =
DEFS =
LIBS =
INCPATH =
LIBPATH =
##############################################################################################
# These should be at the end
#
include $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk
include $(GFXLIB)/tools/gmake_scripts/os_$(OPT_OS).mk
include $(GFXLIB)/tools/gmake_scripts/compiler_gcc.mk
# *** EOF ***

View File

@ -0,0 +1,22 @@
This directory contains the interface for FreeBSD using SDL.
As of today, this is simply a wrapper around the Linux drivers/support.
On this board uGFX currently supports:
- GDISP via the SDL driver
- GINPUT-touch via the SDL driver
- GINPUT-keyboard via the SDL driver
The folowing packages are required to run uGFX using this driver on
a 64-bit FreeBSD system using SDL:
+ devel/gcc10
+ devel/sdl2
The following should be added to the CFLAGS of the target makefile:
CFLAGS = `sdl2-config --libs --cflags`
There is an example Makefile and project in the examples directory.

View File

@ -23,8 +23,6 @@ static const SPIConfig spi_cfg = {
((1 << 3) & SPI_CR1_BR) | SPI_CR1_SSM | SPI_CR1_SSI | SPI_CR1_MSTR
};
#define ALLOW_2ND_LAYER GFXON
static const ltdcConfig driverCfg = {
240, 320,
10, 2,
@ -47,7 +45,7 @@ static const ltdcConfig driverCfg = {
0xFF, // alpha
LTDC_LEF_ENABLE // flags
},
#if ALLOW_2ND_LAYER
#if STM32LTDC_USE_LAYER2 || STM32LTDC_USE_DOUBLEBUFFERING
{ // Foreground layer config (if turned on)
(LLDCOLOR_TYPE *)(SDRAM_BANK_ADDR+(240 * 320 * LTDC_PIXELBYTES)), // Frame buffer address
240, 320, // width, height

View File

@ -19,8 +19,6 @@
#include "stm32f4xx_hal.h"
#include "stm324x9i_eval_sdram.h"
#define ALLOW_2ND_LAYER GFXON
// Panel parameters
// This panel is a AMPIRE640480 panel.
@ -48,7 +46,7 @@ static const ltdcConfig driverCfg = {
LTDC_LEF_ENABLE // Layer configuration flags
},
#if ALLOW_2ND_LAYER
#if STM32LTDC_USE_LAYER2 || STM32LTDC_USE_DOUBLEBUFFERING
{ // Foreground layer config (if turned on)
(LLDCOLOR_TYPE *)(SDRAM_DEVICE_ADDR+(640 * 480 * LTDC_PIXELBYTES)), // Frame buffer address
640, 480, // Width, Height (pixels)

View File

@ -36,8 +36,6 @@
#define AFRH AFR[1]
#endif
#define ALLOW_2ND_LAYER GFXON
static const ltdcConfig driverCfg = {
480, 272, // Width, Height (pixels)
41, 10, // Horizontal, Vertical sync (pixels)
@ -62,7 +60,7 @@ static const ltdcConfig driverCfg = {
LTDC_LEF_ENABLE // Layer configuration flags
},
#if ALLOW_2ND_LAYER
#if STM32LTDC_USE_LAYER2 || STM32LTDC_USE_DOUBLEBUFFERING
{ // Foreground layer config (if turned on)
(LLDCOLOR_TYPE *)(SDRAM_DEVICE_ADDR+(480 * 272 * LTDC_PIXELBYTES)), // Frame buffer address
480, 272, // Width, Height (pixels)
@ -393,6 +391,27 @@ static void configureLcdPins(void) {
#endif
}
static GFXINLINE void init_ltdc_clock(void)
{
// Reset the LTDC peripheral
RCC->APB2RSTR |= RCC_APB2RSTR_LTDCRST;
RCC->APB2RSTR = 0;
// Enable the LTDC clock
RCC->DCKCFGR1 = (RCC->DCKCFGR1 & ~RCC_DCKCFGR1_PLLSAIDIVR) | (1 << 16);
// Enable the peripheral
RCC->APB2ENR |= RCC_APB2ENR_LTDCEN;
}
#if STM32LTDC_USE_DMA2D
static GFXINLINE void init_dma2d_clock(void)
{
// Enable DMA2D clock
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2DEN;
}
#endif
static GFXINLINE void init_board(GDisplay *g) {
(void) g;

View File

@ -66,11 +66,11 @@
#include "stm32f7xx.h"
#if !defined (HSE_VALUE)
#define HSE_VALUE ((gU32)25000000) /*!< Default value of the External oscillator in Hz */
#define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */
#endif /* HSE_VALUE */
#if !defined (HSI_VALUE)
#define HSI_VALUE ((gU32)16000000) /*!< Value of the Internal oscillator in Hz*/
#define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
#endif /* HSI_VALUE */
/**
@ -125,9 +125,9 @@
is no need to call the 2 first functions listed above, since SystemCoreClock
variable is updated automatically.
*/
gU32 SystemCoreClock = 16000000;
const gU8 AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
const gU8 APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4};
uint32_t SystemCoreClock = 16000000;
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4};
/**
* @}
@ -163,19 +163,19 @@ void SystemInit(void)
#endif
/* Reset the RCC clock configuration to the default reset state ------------*/
/* Set HSION bit */
RCC->CR |= (gU32)0x00000001;
RCC->CR |= (uint32_t)0x00000001;
/* Reset CFGR register */
RCC->CFGR = 0x00000000;
/* Reset HSEON, CSSON and PLLON bits */
RCC->CR &= (gU32)0xFEF6FFFF;
RCC->CR &= (uint32_t)0xFEF6FFFF;
/* Reset PLLCFGR register */
RCC->PLLCFGR = 0x24003010;
/* Reset HSEBYP bit */
RCC->CR &= (gU32)0xFFFBFFFF;
RCC->CR &= (uint32_t)0xFFFBFFFF;
/* Disable all interrupts */
RCC->CIR = 0x00000000;
@ -230,7 +230,7 @@ void SystemInit(void)
*/
void SystemCoreClockUpdate(void)
{
gU32 tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
/* Get SYSCLK source -------------------------------------------------------*/
tmp = RCC->CFGR & RCC_CFGR_SWS;
@ -287,8 +287,8 @@ void SystemCoreClockUpdate(void)
*/
void SystemInit_ExtMemCtl(void)
{
register gU32 tmpreg = 0, timeout = 0xFFFF;
register __IO gU32 index;
register uint32_t tmpreg = 0, timeout = 0xFFFF;
register __IO uint32_t index;
/* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG and GPIOH interface
clock */

View File

@ -2,6 +2,40 @@
*** Releases ***
*****************************************************************************
*** After Release 2.9 ***
CHANGE: Added type gImage to replace V2.x gdispImage.
FIX: Fixed GWIN console widget scroll.
FIX: A warning and adjustment is made if GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE is less than 40 bytes.
FIX: Prevent compiler warnings on duplicate const specifiers.
FEATURE: Added support for ChibiOS 6.x kernel.
FEATURE: Added support for ChibiOS 7.x kernel.
CHANGE: STM32LTDC driver: Refactor to outsource clock setup for LTDC & DMA2D peripherals to the board file.
CHANGE: STM32LTDC driver: Remove obsolete LTDC_NO_CLOCK_INIT macro as this clock setup is now outsourced to the board file.
CHANGE: STM32LTDC driver: Automatically enable DMA cache flushing on STM32H7 platforms.
CHANGE: STM32LTDC driver: Rename LTDC_USE_DMA2D to STM32LTDC_USE_DMA2D.
CHANGE: STM32LTDC driver: Rename ALLOW_2ND_LAYER to STM32LTDC_USE_LAYER2.
CHANGE: STM32LTDC driver: Rename LTDC_DMA_CACHE_FLUSH to STM32LTDC_DMA_CACHE_FLUSH.
CHANGE: STM32LTDC driver: Rename GDISP_LTDC_USE_RGB565 to STM32LTDC_USE_RGB565.
FEATURE: STM32LTDC driver: Support double buffering. This introduces STM32LTDC_USE_DOUBLEBUFFERING.
FIX: STM32LTDC driver: Fix bug in gdisp_lld_blit_area() which affected blits with source coordinates other than (0, 0).
FIX: Improve /demos/benchmarks/rectangles.
FIX: Win32 driver: Fix buffer position calculation in gdisp_lld_blit_area().
FIX: Win32 driver: Fix memory leak / invalid pointer to free() when re-calculating buffer position in a specific situation.
FIX: Prevent const qualifier being discarded in vfnprintg().
FIX: Fix missing return value in gfxQueueFSyncPut().
FIX: Fix missing return value in gfxQueueFSyncPush().
FIX: Fix missing return value in gfxQueueFSyncInsert().
FEATURE: Adding support for FreeBSD.
FIX: Fix incorrect calls to mmap() and sem_open() in SDL2 driver (lax operating systems such as Linux & MacOS were silently tolerating these).
FIX: Minor code improvements
FEATURE: Add cmake support
FIX: Add missing driver.mk to SSD1322 driver.
FEATURE: LGDP4532 driver improvements.
FIX: Win32 Keyboard driver now retrieves lock key states on window activate
FEATURE: Add SSD1312 GDISP driver
FEATURE: Add CH1115 GDISP driver
*** Release 2.9 ***
FEATURE: Added config vars GINPUT_TOUCH_CALIBRATION_FONT1 and GINPUT_TOUCH_CALIBRATION_FONT2
FEATURE: Added config vars GINPUT_TOUCH_CALIBRATION_TITLE and GINPUT_TOUCH_CALIBRATION_ERROR

View File

@ -0,0 +1,78 @@
# Define UGFX_ROOT
set(UGFX_ROOT ${CMAKE_CURRENT_LIST_DIR}/..)
# Ensure that UGFX_ROOT is set
if(NOT UGFX_ROOT)
message(FATAL_ERROR "No UGFX_ROOT specified")
endif()
# Assemble list of components
list(APPEND ugfx_COMPONENTS_BUILTIN
gadc
gaudio
gdisp
gdriver
gevent
gfile
ginput
gmisc
gos
gqueue
gtimer
gtrans
gwin
)
# Core sources
list(APPEND ugfx_SOURCES
${UGFX_ROOT}/src/gfx.c
)
# Core include directories
list(APPEND ugfx_INCLUDE_DIRS
${UGFX_ROOT}
${UGFX_ROOT}/src
)
# Include each built-in component
foreach(component ${ugfx_COMPONENTS_BUILTIN})
include(${UGFX_ROOT}/src/${component}/${component}.cmake)
endforeach()
# Include each component
foreach(component ${ugfx_FIND_COMPONENTS})
include(${UGFX_ROOT}/${component}/driver.cmake)
endforeach()
# Remove duplicates from non-cached variables
list(REMOVE_DUPLICATES ugfx_SOURCES)
list(REMOVE_DUPLICATES ugfx_INCLUDE_DIRS)
# Outsource heavy-lifting to cmake
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ugfx DEFAULT_MSG UGFX_ROOT ugfx_SOURCES ugfx_INCLUDE_DIRS)
# Create the target
if(NOT TARGET ugfx)
add_library(ugfx INTERFACE IMPORTED)
endif()
target_include_directories(
ugfx
INTERFACE
${ugfx_INCLUDE_DIRS}
)
target_sources(
ugfx
INTERFACE
${ugfx_SOURCES}
)
target_compile_definitions(
ugfx
INTERFACE
${ugfx_DEFS}
)
target_link_libraries(
ugfx
INTERFACE
${ugfx_LIBS}
)

View File

@ -61,7 +61,7 @@ static GButtonObject btnClose;
/* static GButtonObject btnYes, btnNo; // Reserved for future use */
// Image object
static gdispImage toolbarImageFilmstrip;
static gImage toolbarImageFilmstrip;
static gColor myColors[] = { GFX_BLACK, GFX_RED, GFX_GREEN, GFX_BLUE, GFX_CYAN, GFX_MAGENTA, GFX_YELLOW, GFX_WHITE };

View File

@ -86,7 +86,7 @@ static GHandle ghRadioBlack, ghRadioWhite, ghRadioYellow;
static GHandle ghList1, ghList2, ghList3, ghList4;
static GHandle ghImage1;
static GHandle ghProgressbar1;
static gdispImage imgYesNo;
static gImage imgYesNo;
/* Some useful macros */
#define ScrWidth gdispGetWidth()

View File

@ -48,5 +48,10 @@
/* Builtin Fonts */
#define GDISP_INCLUDE_FONT_UI2 GFXON
/* GFILE */
#define GFX_USE_GFILE GFXON
#define GFILE_NEED_PRINTG GFXON
#define GFILE_NEED_STRINGS GFXON
#endif /* _GFXCONF_H */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2012, 2013, Joel Bodenmann aka Tectu <joel@unormal.org>
* Copyright (c) 2012, 2013, Andrew Hannam aka inmarket
* Copyright (c) 2012 - 2021, Joel Bodenmann aka Tectu <joel@ugfx.io>
* Copyright (c) 2012 - 2021, Andrew Hannam aka inmarket <inmarket@ugfx.io>
*
* All rights reserved.
*
@ -31,87 +31,33 @@
#include "string.h"
#include "gfx.h"
#define SCB_DEMCR (*(volatile unsigned *)0xE000EDFC)
#define CPU_RESET_CYCLECOUNTER do { SCB_DEMCR = SCB_DEMCR | 0x01000000; \
DWT_CYCCNT = 0; \
DWT_CTRL = DWT_CTRL | 1 ; } while(0)
#define RESULT_STR_LENGTH 32
static int uitoa(unsigned int value, char * buf, int max) {
int n = 0;
int i = 0;
unsigned int tmp = 0;
if (!buf)
return -3;
if (2 > max)
return -4;
i=1;
tmp = value;
if (0 > tmp) {
tmp *= -1;
i++;
}
for (;;) {
tmp /= 10;
if (0 >= tmp)
break;
i++;
}
if (i >= max) {
buf[0] = '?';
buf[1] = 0x0;
return 2;
}
n = i;
tmp = value;
if (0 > tmp) {
tmp *= -1;
}
buf[i--] = 0x0;
for (;;) {
buf[i--] = (tmp % 10) + '0';
tmp /= 10;
if (0 >= tmp) {
break;
}
}
if (-1 != i) {
buf[i--] = '-';
}
return n;
}
void benchmark(void) {
gU32 i, pixels, ms, pps;
char pps_str[25];
void benchmark(void)
{
gCoord height, width, rx, ry, rcx, rcy;
gColor random_color;
gCoord fontHeight;
gFont font;
gdispSetOrientation(gOrientation90);
// Prepare resources
width = gdispGetWidth();
height = gdispGetHeight();
font = gdispOpenFont("UI2 Double");
font = gdispOpenFont("*");
fontHeight = gdispGetFontMetric(font, gFontHeight);
gdispDrawStringBox(0, 0, width, 30, "ChibiOS/GFX - Benchmark", font, GFX_WHITE, gJustifyCenter);
font = gdispOpenFont("UI2");
// Show intro message
gdispDrawStringBox(0, 0, width, 30, "uGFX - Benchmark", font, GFX_WHITE, gJustifyCenter);
gdispDrawStringBox(0, height/2, width, 30, "5000 random rectangles", font, GFX_WHITE, gJustifyCenter);
gfxSleepMilliseconds(3000);
/* seed for the rand() */
srand(DWT_CYCCNT);
pixels = 0;
// Seed RNG
srand(0);
CPU_RESET_CYCLECOUNTER;
for (i = 0; i < 5000; i++) {
// Render rectangles and count ticks & pixels
gU64 pixels = 0;
const gTicks ticksStart = gfxSystemTicks();
for (gU32 i = 0; i < 5000; i++) {
random_color = (rand() % 65535);
rx = (rand() % (width-10));
ry = (rand() % (height-10));
@ -121,19 +67,33 @@ void benchmark(void) {
gdispFillArea(rx, ry, rcx, rcy, random_color);
pixels += (rcx+1)*(rcy+1);
}
const gTicks ticksEnd = gfxSystemTicks();
ms = DWT_CYCCNT / 168000;
pps = (float)pixels/((float)ms/1000.0f);
// Calculate result
char str_ticks[RESULT_STR_LENGTH];
char str_seconds[RESULT_STR_LENGTH];
char str_pps[RESULT_STR_LENGTH];
{
// Figure out how many ticks are 1 second
const gTicks ticksPerSecond = gfxMillisecondsToTicks(1000);
memset (pps_str, 0, sizeof(pps_str));
uitoa(pps, pps_str, sizeof(pps_str));
strcat(pps_str, " Pixels/s");
const gTicks ticksElapsed = ticksEnd - ticksStart;
const float secondsElapsed = (float)ticksElapsed / (float)ticksPerSecond;
gU32 pps = (float)pixels / secondsElapsed;
font = gdispOpenFont("UI2 Double");
// Produce strings
memset(str_ticks, 0, RESULT_STR_LENGTH);
memset(str_seconds, 0, RESULT_STR_LENGTH);
memset(str_pps, 0, RESULT_STR_LENGTH);
snprintg(str_ticks, RESULT_STR_LENGTH, "%d ticks", ticksElapsed);
snprintg(str_pps, RESULT_STR_LENGTH, "%d pixels/s", pps);
}
// Show result
gdispClear(GFX_BLACK);
gdispDrawStringBox(0, 0, width, 30, "ChibiOS/GFX - Benchmark", font, GFX_WHITE, gJustifyCenter);
gdispDrawStringBox(0, height/2, width, 30, pps_str, font, GFX_WHITE, gJustifyCenter);
//gdispDrawString(20, height/2, pps_str, font, GFX_WHITE);
gdispDrawStringBox(0, 0, width, 30, "uGFX - Benchmark", font, GFX_WHITE, gJustifyCenter);
gdispDrawStringBox(0, height/2+0*(fontHeight+10), width, 30, str_ticks, font, GFX_WHITE, gJustifyCenter);
gdispDrawStringBox(0, height/2+1*(fontHeight+10), width, 30, str_pps, font, GFX_WHITE, gJustifyCenter);
}
int main(void) {
@ -141,9 +101,8 @@ int main(void) {
benchmark();
while(1) {
while (gTrue)
gfxSleepMilliseconds(500);
}
return 0;
}

View File

@ -24,17 +24,17 @@ typedef struct { // Node properties
nodeProps jg10Field[JG10_FIELD_WIDTH][JG10_FIELD_HEIGHT]; // jg10 field array
gBool jg10GameOver = gFalse;
const char *jg10Graph[] = {"background.bmp", "1.bmp","2.bmp","3.bmp","4.bmp","5.bmp","6.bmp","7.bmp","8.bmp", "9.bmp", "10.bmp", "11.bmp", "12.bmp", "13.bmp", "14.bmp", "15.bmp", "16.bmp", "17.bmp", "18.bmp", "19.bmp", "20.bmp"}; // 21 elements (0-20)
gdispImage jg10Image[JG10_MAX_COUNT];
gImage jg10Image[JG10_MAX_COUNT];
#define JG10_ANIM_IMAGES 5
#define JG10_ANIM_DELAY 60
const char *jg10GraphAnim[] = {"a1.bmp","a2.bmp","a3.bmp","a4.bmp","background.bmp"}; // 5 elements (0-4)
gdispImage jg10ImageAnim[JG10_ANIM_IMAGES];
gImage jg10ImageAnim[JG10_ANIM_IMAGES];
gU8 jg10MaxVal=4; // Max value in field...
gFont font;
#if JG10_SHOW_SPLASH
GTimer jg10SplashBlink;
gBool jg10SplashTxtVisible = gFalse;
gdispImage jg10SplashImage;
gImage jg10SplashImage;
#endif

View File

@ -19,7 +19,7 @@ static gI16 minesFlags; // Flag counter
static gI16 minesTime; // Time counter
static GTimer minesTimeCounterTimer;
static const char* minesGraph[] = {"1.bmp","2.bmp","3.bmp","4.bmp","5.bmp","6.bmp","7.bmp","8.bmp", "closed.bmp", "empty.bmp", "explode.bmp", "flag.bmp", "mine.bmp", "wrong.bmp"}; // 14 elements (0-13)
static gdispImage minesImage;
static gImage minesImage;
static gU8 minesStatusIconWidth = 0;
static gU8 minesStatusIconHeight = 0;
static gBool minesFirstGame = gTrue; // Just don't clear field for the first time, as we have black screen already... :/

View File

@ -36,7 +36,7 @@
* The ROMFS uses the file "romfs_files.h" to describe the set of files in the ROMFS.
*/
static gdispImage myImage;
static gImage myImage;
int main(void) {
gCoord swidth, sheight;

View File

@ -39,7 +39,7 @@
#define USE_IMAGE_CACHE GFXOFF // Only if you want to get performance at the expense of RAM
#define MY_BG_COLOR RGB2COLOR(220, 220, 255) // Pale blue so we can see the transparent parts
static gdispImage myImage;
static gImage myImage;
#define SHOW_ERROR(color) gdispFillArea(errx, erry, errcx, errcy, color)

View File

@ -40,7 +40,7 @@
#include "gfx.h"
static gdispImage _imgHome;
static gImage _imgHome;
int main(void)
{

View File

@ -42,7 +42,6 @@
#define GDISP_NEED_VALIDATION GFXON
#define GDISP_NEED_CLIP GFXON
#define GDISP_NEED_TEXT GFXON
#define GDISP_NEED_ANTIALIAS GFXON
#define GDISP_NEED_UTF8 GFXON
#define GDISP_NEED_TEXT_KERNING GFXON

View File

@ -62,7 +62,7 @@ static const char* FrenchStrings[] = {
};
static const transTable FrenchTranslation = { sizeof(FrenchStrings)/sizeof(FrenchStrings[0]), FrenchStrings };
void updateText()
void updateText(void)
{
gCoord width = 400;
gCoord height = 30;

View File

@ -97,7 +97,7 @@ static GHandle ghRadioBlack, ghRadioWhite, ghRadioYellow;
static GHandle ghList1, ghList2, ghList3, ghList4;
static GHandle ghImage1;
static GHandle ghProgressbar1;
static gdispImage imgYesNo;
static gImage imgYesNo;
/* Some useful macros */
#define ScrWidth gdispGetWidth()

View File

@ -0,0 +1,59 @@
/*
* 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.io/license.html
*/
#pragma once
/**
* The command byte to put in front of each page line.
*
* If this is defined, each page line is prefixed with the specified value in the locally
* maintained framebuffer.
*
* This can be omitted and handled inside of write_data() manually instead.
*/
#define CH1115_PAGE_PREFIX 0x40 // Co = 0, D/C = 1
static GFXINLINE void init_board(GDisplay *g)
{
(void) g;
}
static GFXINLINE void post_init_board(GDisplay *g)
{
(void) g;
}
static GFXINLINE void setpin_reset(GDisplay *g, gBool state)
{
(void) g;
(void) state;
}
static GFXINLINE void acquire_bus(GDisplay *g)
{
(void) g;
}
static GFXINLINE void release_bus(GDisplay *g)
{
(void) g;
}
static GFXINLINE void write_cmd(GDisplay *g, gU8 *data, gU16 length)
{
(void) g;
(void) data;
(void) length;
}
static GFXINLINE void write_data(GDisplay *g, gU8 *data, gU16 length)
{
(void) g;
(void) data;
(void) length;
}

View File

@ -0,0 +1,8 @@
list(APPEND ugfx_INCLUDE_DIRS
${CMAKE_CURRENT_LIST_DIR}
)
list(APPEND ugfx_SOURCES
${CMAKE_CURRENT_LIST_DIR}/gdisp_lld_CH1115.c
)

View File

@ -0,0 +1,3 @@
GFXINC += $(GFXLIB)/drivers/gdisp/CH1115
GFXSRC += $(GFXLIB)/drivers/gdisp/CH1115/gdisp_lld_CH1115.c

View File

@ -0,0 +1,391 @@
/*
* 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.io/license.html
*/
#include "gfx.h"
#if GFX_USE_GDISP
#define GDISP_DRIVER_VMT GDISPVMT_CH1115
#include "gdisp_lld_config.h"
#include "../../../src/gdisp/gdisp_driver.h"
#include "board_CH1115.h"
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
#ifndef GDISP_SCREEN_HEIGHT
#define GDISP_SCREEN_HEIGHT 32 // This controller should also support 64 (untested)
#endif
#ifndef GDISP_SCREEN_WIDTH
#define GDISP_SCREEN_WIDTH 128
#endif
#ifndef GDISP_INITIAL_CONTRAST
#define GDISP_INITIAL_CONTRAST 100
#endif
#ifndef GDISP_INITIAL_BACKLIGHT
#define GDISP_INITIAL_BACKLIGHT 100
#endif
#ifdef CH1115_PAGE_PREFIX
#define CH1115_PAGE_WIDTH (GDISP_SCREEN_WIDTH+1)
#define CH1115_PAGE_OFFSET 1
#else
#define CH1115_PAGE_WIDTH GDISP_SCREEN_WIDTH
#define CH1115_PAGE_OFFSET 0
#endif
#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0)
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
// Some common routines and macros
#define RAM(g) ((gU8 *)g->priv)
#define xyaddr(x, y) (CH1115_PAGE_OFFSET + (x) + ((y)>>3)*CH1115_PAGE_WIDTH)
#define xybit(y) (1<<((y)&7))
#define write_cmd_1(g, a) { gU8 cmd[1]; cmd[0] = a; write_cmd(g, cmd, 1); }
#define write_cmd_2(g, a, b) { gU8 cmd[2]; cmd[0] = a; cmd[1] = b; write_cmd(g, cmd, 2); }
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/**
* As this controller can't update on a pixel boundary we need to maintain the
* the entire display surface in memory so that we can do the necessary bit
* operations. Fortunately it is a small monochrome display.
* 64 * 128 / 8 = 1024 bytes.
*/
LLDSPEC gBool gdisp_lld_init(GDisplay *g)
{
// The private area is the display surface.
g->priv = gfxAlloc(GDISP_SCREEN_HEIGHT/8 * CH1115_PAGE_WIDTH);
if (!g->priv)
return gFalse;
// Fill in the prefix command byte on each page line of the display buffer
// We can do this during initialisation as we're being careful that this byte is never overwritten.
#ifdef CH1115_PAGE_PREFIX
for (unsigned i = 0; i < GDISP_SCREEN_HEIGHT/8 * CH1115_PAGE_WIDTH; i += CH1115_PAGE_WIDTH)
RAM(g)[i] = CH1115_PAGE_PREFIX;
#endif
// Initialise the board interface
init_board(g);
// Hardware reset
setpin_reset(g, gTrue);
gfxSleepMilliseconds(20);
setpin_reset(g, gFalse);
gfxSleepMilliseconds(200);
acquire_bus(g);
// Configuration
// This might require display module vendor specific changes
{
// Display off
write_cmd_1(g, 0xAE);
// Clock divider
write_cmd_2(g, 0xD5, 0x80);
// Multiplex ratio
write_cmd_2(g, 0xA8, 0x1F);
// Display offset
write_cmd_2(g, 0xD3, 0x30);
// Display start line
write_cmd_1(g, 0x40);
// Charge pump
write_cmd_2(g, 0x8D, 0x72); // 0x10 if Vcc externally supplied
// Segment re-map
write_cmd_1(g, 0xA1);
// COM output scan direction
write_cmd_1(g, 0xC0);
// COM pin hardware configuration
write_cmd_2(g, 0xDA, 0x10);
// Set internal/external current reference
write_cmd_2(g, 0xAD, 0x50);
// Set contract
write_cmd_2(g, 0x81, 0x17);
// Set pre-charge period
write_cmd_2(g, 0xD9, 0xF1);
// Set VCOMH select level
write_cmd_2(g, 0xDB, 0x30);
// Set entire display on/off
write_cmd_1(g, 0xA4);
// Set normal/inverse display
write_cmd_1(g, 0xA6);
// Page addressing mode
write_cmd_2(g, 0x20, 0x02);
// Display on
write_cmd_1(g, 0xAF);
}
release_bus(g);
// Finish Init
post_init_board(g);
// Initialise the GDISP structure
g->g.Width = GDISP_SCREEN_WIDTH;
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Orientation = gOrientation0;
g->g.Powermode = gPowerOn;
g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
g->g.Contrast = GDISP_INITIAL_CONTRAST;
return gTrue;
}
#if GDISP_HARDWARE_FLUSH
LLDSPEC void gdisp_lld_flush(GDisplay *g)
{
gU8 * ram;
unsigned pages;
// Only flush if necessary
if (!(g->flags & GDISP_FLG_NEEDFLUSH))
return;
ram = RAM(g);
pages = GDISP_SCREEN_HEIGHT/8;
acquire_bus(g);
write_cmd_1(g, 0x40 | 0);
while (pages--) {
write_cmd_1(g, 0xB0 + (((GDISP_SCREEN_HEIGHT/8)-1)-pages));
write_cmd_1(g, 0x00);
write_cmd_1(g, 0x10);
write_data(g, ram, CH1115_PAGE_WIDTH);
ram += CH1115_PAGE_WIDTH;
}
release_bus(g);
g->flags &= ~GDISP_FLG_NEEDFLUSH;
}
#endif
#if GDISP_HARDWARE_DRAWPIXEL
LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g)
{
gCoord x, y;
switch(g->g.Orientation) {
default:
case gOrientation0:
x = g->p.x;
y = g->p.y;
break;
case gOrientation90:
x = g->p.y;
y = GDISP_SCREEN_HEIGHT-1 - g->p.x;
break;
case gOrientation180:
x = GDISP_SCREEN_WIDTH-1 - g->p.x;
y = GDISP_SCREEN_HEIGHT-1 - g->p.y;
break;
case gOrientation270:
x = GDISP_SCREEN_WIDTH-1 - g->p.y;
y = g->p.x;
break;
}
if (gdispColor2Native(g->p.color) != gdispColor2Native(GFX_BLACK))
RAM(g)[xyaddr(x, y)] |= xybit(y);
else
RAM(g)[xyaddr(x, y)] &= ~xybit(y);
g->flags |= GDISP_FLG_NEEDFLUSH;
}
#endif
#if GDISP_HARDWARE_PIXELREAD
LLDSPEC gColor gdisp_lld_get_pixel_color(GDisplay *g)
{
gCoord x, y;
switch(g->g.Orientation) {
default:
case gOrientation0:
x = g->p.x;
y = g->p.y;
break;
case gOrientation90:
x = g->p.y;
y = GDISP_SCREEN_HEIGHT-1 - g->p.x;
break;
case gOrientation180:
x = GDISP_SCREEN_WIDTH-1 - g->p.x;
y = GDISP_SCREEN_HEIGHT-1 - g->p.y;
break;
case gOrientation270:
x = GDISP_SCREEN_WIDTH-1 - g->p.y;
y = g->p.x;
break;
}
return (RAM(g)[xyaddr(x, y)] & xybit(y)) ? GFX_WHITE : GFX_BLACK;
}
#endif
#if GDISP_HARDWARE_FILLS
LLDSPEC void gdisp_lld_fill_area(GDisplay *g)
{
gCoord sy, ey;
gCoord sx, ex;
gCoord col;
unsigned spage, zpages;
gU8 * base;
gU8 mask;
switch(g->g.Orientation) {
default:
case gOrientation0:
sx = g->p.x;
ex = g->p.x + g->p.cx - 1;
sy = g->p.y;
ey = sy + g->p.cy - 1;
break;
case gOrientation90:
sx = g->p.y;
ex = g->p.y + g->p.cy - 1;
sy = GDISP_SCREEN_HEIGHT - g->p.x - g->p.cx;
ey = GDISP_SCREEN_HEIGHT-1 - g->p.x;
break;
case gOrientation180:
sx = GDISP_SCREEN_WIDTH - g->p.x - g->p.cx;
ex = GDISP_SCREEN_WIDTH-1 - g->p.x;
sy = GDISP_SCREEN_HEIGHT - g->p.y - g->p.cy;
ey = GDISP_SCREEN_HEIGHT-1 - g->p.y;
break;
case gOrientation270:
sx = GDISP_SCREEN_WIDTH - g->p.y - g->p.cy;
ex = GDISP_SCREEN_WIDTH-1 - g->p.y;
sy = g->p.x;
ey = g->p.x + g->p.cx - 1;
break;
}
spage = sy / 8;
base = RAM(g) + CH1115_PAGE_OFFSET + CH1115_PAGE_WIDTH * spage;
mask = 0xff << (sy&7);
zpages = (ey / 8) - spage;
if (gdispColor2Native(g->p.color) == gdispColor2Native(GFX_BLACK)) {
while (zpages--) {
for (col = sx; col <= ex; col++)
base[col] &= ~mask;
mask = 0xff;
base += CH1115_PAGE_WIDTH;
}
mask &= (0xff >> (7 - (ey&7)));
for (col = sx; col <= ex; col++)
base[col] &= ~mask;
}
else {
while (zpages--) {
for (col = sx; col <= ex; col++)
base[col] |= mask;
mask = 0xff;
base += CH1115_PAGE_WIDTH;
}
mask &= (0xff >> (7 - (ey&7)));
for (col = sx; col <= ex; col++)
base[col] |= mask;
}
g->flags |= GDISP_FLG_NEEDFLUSH;
}
#endif
#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
LLDSPEC void gdisp_lld_control(GDisplay *g)
{
switch(g->p.x) {
case GDISP_CONTROL_POWER:
if (g->g.Powermode == (gPowermode)g->p.ptr)
return;
switch((gPowermode)g->p.ptr) {
case gPowerOff:
case gPowerSleep:
case gPowerDeepSleep:
acquire_bus(g);
write_cmd_1(g, 0xAE);
release_bus(g);
break;
case gPowerOn:
acquire_bus(g);
write_cmd_1(g, 0xAF);
release_bus(g);
break;
default:
return;
}
g->g.Powermode = (gPowermode)g->p.ptr;
return;
case GDISP_CONTROL_ORIENTATION:
if (g->g.Orientation == (gOrientation)g->p.ptr)
return;
switch((gOrientation)g->p.ptr) {
// Rotation is handled by the drawing routines
case gOrientation0:
case gOrientation180:
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Width = GDISP_SCREEN_WIDTH;
break;
case gOrientation90:
case gOrientation270:
g->g.Height = GDISP_SCREEN_WIDTH;
g->g.Width = GDISP_SCREEN_HEIGHT;
break;
default:
return;
}
g->g.Orientation = (gOrientation)g->p.ptr;
return;
case GDISP_CONTROL_CONTRAST:
if ((unsigned)g->p.ptr > 100)
g->p.ptr = (void *)100;
acquire_bus(g);
write_cmd_2(g, 0x81, (((unsigned)g->p.ptr)<<8)/101);
release_bus(g);
g->g.Contrast = (unsigned)g->p.ptr;
return;
// Our own special controller code to inverse the display
// 0 = normal, 1 = inverse
case GDISP_CONTROL_INVERSE:
acquire_bus(g);
write_cmd_1(g, g->p.ptr ? 0xA7: 0xA6);
release_bus(g);
return;
}
}
#endif // GDISP_NEED_CONTROL
#endif // GFX_USE_GDISP

View File

@ -0,0 +1,31 @@
/*
* 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.io/license.html
*/
#ifndef _GDISP_LLD_CONFIG_H
#define _GDISP_LLD_CONFIG_H
#if GFX_USE_GDISP
/*===========================================================================*/
/* Driver hardware support. */
/*===========================================================================*/
#define GDISP_HARDWARE_FLUSH GFXON // This controller requires flushing
#define GDISP_HARDWARE_DRAWPIXEL GFXON
#define GDISP_HARDWARE_PIXELREAD GFXON
#define GDISP_HARDWARE_CONTROL GFXON
#define GDISP_HARDWARE_FILLS GFXON
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO
// This controller supports a special gdispControl() to inverse the display.
// Pass a parameter of 1 for inverse and 0 for normal.
#define GDISP_CONTROL_INVERSE (GDISP_CONTROL_LLD+0)
#endif // GFX_USE_GDISP
#endif // _GDISP_LLD_CONFIG_H

View File

@ -55,6 +55,12 @@
#define dummy_read(g) { volatile gU16 dummy; dummy = read_data(g); (void) dummy; }
#define write_reg(g, reg, data) { write_index(g, reg); write_data(g, data); }
// Serial write data for fast fill.
#ifndef write_data_repeat
#define write_data_repeat(g, data, count) { int i; for (i = 0; i < count; ++i) write_data (g, data) }
/* TODO: should use DMA mem2mem */
#endif
static void set_cursor(GDisplay *g) {
switch(g->g.Orientation) {
default:
@ -78,18 +84,18 @@ static void set_viewport(GDisplay* g) {
default:
case gOrientation0:
case gOrientation180:
write_reg(g, 0x50, g->p.x);
write_reg(g, 0x51, g->p.x + g->p.cx - 1);
write_reg(g, 0x52, g->p.y);
write_reg(g, 0x53, g->p.y + g->p.cy - 1);
write_reg(g, LGDP4532_HORIZONTAL_WINDOW_ADDR1, g->p.x);
write_reg(g, LGDP4532_HORIZONTAL_WINDOW_ADDR2, g->p.x + g->p.cx - 1);
write_reg(g, LGDP4532_VERTICAL_WINDOW_ADDR1, g->p.y);
write_reg(g, LGDP4532_VERTICAL_WINDOW_ADDR2, g->p.y + g->p.cy - 1);
break;
case gOrientation90:
case gOrientation270:
write_reg(g, 0x50, g->p.y);
write_reg(g, 0x51, g->p.y + g->p.cy - 1);
write_reg(g, 0x52, g->p.x);
write_reg(g, 0x53, g->p.x + g->p.cx - 1);
write_reg(g, LGDP4532_HORIZONTAL_WINDOW_ADDR1, g->p.y);
write_reg(g, LGDP4532_HORIZONTAL_WINDOW_ADDR2, g->p.y + g->p.cy - 1);
write_reg(g, LGDP4532_VERTICAL_WINDOW_ADDR1, g->p.x);
write_reg(g, LGDP4532_VERTICAL_WINDOW_ADDR2, g->p.x + g->p.cx - 1);
break;
}
}
@ -110,8 +116,6 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
acquire_bus(g);
setwritemode(g);
// chinese code starts here
//############# void Power_Set(void) ################//
write_reg(g, 0x00, 0x0001);
gfxSleepMilliseconds(10);
@ -124,25 +128,24 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
write_reg(g, 0x12, 0x0010);
gfxSleepMilliseconds(10);
write_reg(g, 0x10, 0x2620);
write_reg(g, 0x13, 0x344d); //304d
write_reg(g, 0x13, 0x344d);
gfxSleepMilliseconds(10);
write_reg(g, 0x01, 0x0100);
write_reg(g, 0x02, 0x0300);
write_reg(g, 0x03, 0x1038);//0x1030
write_reg(g, 0x03, 0x1030);
write_reg(g, 0x08, 0x0604);
write_reg(g, 0x09, 0x0000);
write_reg(g, 0x0A, 0x0008);
write_reg(g, 0x41, 0x0002);
write_reg(g, 0x60, 0xA700);
write_reg(g, 0x60, 0x2700);
write_reg(g, 0x61, 0x0001);
write_reg(g, 0x90, 0x0182);
write_reg(g, 0x93, 0x0001);
write_reg(g, 0xa3, 0x0010);
gfxSleepMilliseconds(10);
//################# void Gamma_Set(void) ####################//
write_reg(g, 0x30, 0x0000);
write_reg(g, 0x31, 0x0502);
write_reg(g, 0x32, 0x0307);
@ -155,7 +158,6 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
write_reg(g, 0x39, 0x1505);
gfxSleepMilliseconds(10);
//################## void Display_ON(void) ####################//
write_reg(g, 0x07, 0x0001);
gfxSleepMilliseconds(10);
write_reg(g, 0x07, 0x0021);
@ -164,7 +166,6 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
write_reg(g, 0x07, 0x0033);
gfxSleepMilliseconds(10);
write_reg(g, 0x07, 0x0133);
// chinese code ends here
// Finish Init
post_init_board(g);
@ -357,4 +358,36 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
}
#endif
LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
set_cursor(g);
gdisp_lld_write_color (g);
}
#if GDISP_HARDWARE_FILLS
LLDSPEC void gdisp_lld_fill_area(GDisplay *g) {
LLDCOLOR_TYPE c = gdispColor2Native(g->p.color);
acquire_bus(g);
// Set view port if drawing more than 1 line, or write not started
if (g->p.cy != 1 || !ws) {
set_viewport(g);
}
set_cursor(g);
write_data_repeat (g,c,g->p.cx*g->p.cy);
// Restore view port if write started and drawed more than 1 line
if (g->p.cy != 1 && ws)
{
write_reg(g, LGDP4532_HORIZONTAL_WINDOW_ADDR2, svx);
write_reg(g, LGDP4532_HORIZONTAL_WINDOW_ADDR1, svx + svcx - 1);
write_reg(g, LGDP4532_VERTICAL_WINDOW_ADDR2, svy);
write_reg(g, LGDP4532_VERTICAL_WINDOW_ADDR1, svy + svcy - 1);
}
release_bus(g);
}
#endif // GDISP_HARDWARE_FILLS
#endif /* GFX_USE_GDISP */

View File

@ -14,8 +14,18 @@
#define GDISP_HARDWARE_STREAM_READ GFXON
#define GDISP_HARDWARE_STREAM_POS GFXON
#define GDISP_HARDWARE_CONTROL GFXON
#define GDISP_HARDWARE_FILLS GFXON
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
/* Horizontal Address Start Position */
#define LGDP4532_HORIZONTAL_WINDOW_ADDR1 (0x50u)
/* Horizontal Address End Position */
#define LGDP4532_HORIZONTAL_WINDOW_ADDR2 (0x51u)
/* Vertical Address Start Position */
#define LGDP4532_VERTICAL_WINDOW_ADDR1 (0x52u)
/* Vertical Address End Position */
#define LGDP4532_VERTICAL_WINDOW_ADDR2 (0x53u)
#endif /* GFX_USE_GDISP */
#endif /* _GDISP_LLD_CONFIG_H */

View File

@ -1,6 +1,6 @@
Description:
Driver for OLED with 4-wire serial interface and I²C/SPI interface
Driver for OLED with 4-wire serial interface and I2C/SPI interface
Know restictions:
- Driver works only with SSD1306 hooked up over I2C or SPI (include corresponding header)

View File

@ -0,0 +1,58 @@
/*
* 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.io/license.html
*/
#pragma once
/**
* The command byte to put in front of each page line.
*
* If this is defined, each page line is prefixed with the specified value in the locally
* maintained framebuffer.
*
* This can be omitted and handled inside of write_data() manually instead.
*/
#define SSD1312_PAGE_PREFIX 0x40 // Co = 0, D/C = 1
static GFXINLINE void init_board(GDisplay *g)
{
(void) g;
}
static GFXINLINE void post_init_board(GDisplay *g)
{
(void) g;
}
static GFXINLINE void setpin_reset(GDisplay *g, gBool state)
{
(void) g;
(void) state;
}
static GFXINLINE void acquire_bus(GDisplay *g)
{
(void) g;
}
static GFXINLINE void release_bus(GDisplay *g)
{
(void) g;
}
static GFXINLINE void write_cmd(GDisplay *g, gU8 *data, gU16 length)
{
(void) g;
(void) data;
(void) length;
}
static GFXINLINE void write_data(GDisplay *g, gU8 *data, gU16 length)
{
(void) g;
(void) data;
(void) length;
}

View File

@ -0,0 +1,8 @@
list(APPEND ugfx_INCLUDE_DIRS
${CMAKE_CURRENT_LIST_DIR}
)
list(APPEND ugfx_SOURCES
${CMAKE_CURRENT_LIST_DIR}/gdisp_lld_SSD1312.c
)

View File

@ -0,0 +1,3 @@
GFXINC += $(GFXLIB)/drivers/gdisp/SSD1312
GFXSRC += $(GFXLIB)/drivers/gdisp/SSD1312/gdisp_lld_SSD1312.c

View File

@ -0,0 +1,391 @@
/*
* 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.io/license.html
*/
#include "gfx.h"
#if GFX_USE_GDISP
#define GDISP_DRIVER_VMT GDISPVMT_SSD1312
#include "gdisp_lld_config.h"
#include "../../../src/gdisp/gdisp_driver.h"
#include "board_SSD1312.h"
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
#ifndef GDISP_SCREEN_HEIGHT
#define GDISP_SCREEN_HEIGHT 32 // This controller should also support 64 (untested)
#endif
#ifndef GDISP_SCREEN_WIDTH
#define GDISP_SCREEN_WIDTH 128
#endif
#ifndef GDISP_INITIAL_CONTRAST
#define GDISP_INITIAL_CONTRAST 100
#endif
#ifndef GDISP_INITIAL_BACKLIGHT
#define GDISP_INITIAL_BACKLIGHT 100
#endif
#ifdef SSD1312_PAGE_PREFIX
#define SSD1312_PAGE_WIDTH (GDISP_SCREEN_WIDTH+1)
#define SSD1312_PAGE_OFFSET 1
#else
#define SSD1312_PAGE_WIDTH GDISP_SCREEN_WIDTH
#define SSD1312_PAGE_OFFSET 0
#endif
#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0)
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
// Some common routines and macros
#define RAM(g) ((gU8 *)g->priv)
#define xyaddr(x, y) (SSD1312_PAGE_OFFSET + (x) + ((y)>>3)*SSD1312_PAGE_WIDTH)
#define xybit(y) (1<<((y)&7))
#define write_cmd_1(g, a) { gU8 cmd[1]; cmd[0] = a; write_cmd(g, cmd, 1); }
#define write_cmd_2(g, a, b) { gU8 cmd[2]; cmd[0] = a; cmd[1] = b; write_cmd(g, cmd, 2); }
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/**
* As this controller can't update on a pixel boundary we need to maintain the
* the entire display surface in memory so that we can do the necessary bit
* operations. Fortunately it is a small monochrome display.
* 64 * 128 / 8 = 1024 bytes.
*/
LLDSPEC gBool gdisp_lld_init(GDisplay *g)
{
// The private area is the display surface.
g->priv = gfxAlloc(GDISP_SCREEN_HEIGHT/8 * SSD1312_PAGE_WIDTH);
if (!g->priv)
return gFalse;
// Fill in the prefix command byte on each page line of the display buffer
// We can do this during initialisation as we're being careful that this byte is never overwritten.
#ifdef SSD1312_PAGE_PREFIX
for (unsigned i = 0; i < GDISP_SCREEN_HEIGHT/8 * SSD1312_PAGE_WIDTH; i += SSD1312_PAGE_WIDTH)
RAM(g)[i] = SSD1312_PAGE_PREFIX;
#endif
// Initialise the board interface
init_board(g);
// Hardware reset
setpin_reset(g, gTrue);
gfxSleepMilliseconds(20);
setpin_reset(g, gFalse);
gfxSleepMilliseconds(200);
acquire_bus(g);
// Configuration
// This might require display module vendor specific changes
{
// Display off
write_cmd_1(g, 0xAE);
// Clock divider
write_cmd_2(g, 0xD5, 0x80);
// Multiplex ratio
write_cmd_2(g, 0xA8, 0x1F);
// Display offset
write_cmd_2(g, 0xD3, 0x30);
// Display start line
write_cmd_1(g, 0x40);
// Charge pump
write_cmd_2(g, 0x8D, 0x72); // 0x10 if Vcc externally supplied
// Segment re-map
write_cmd_1(g, 0xA1);
// COM output scan direction
write_cmd_1(g, 0xC0);
// COM pin hardware configuration
write_cmd_2(g, 0xDA, 0x10);
// Set internal/external current reference
write_cmd_2(g, 0xAD, 0x50);
// Set contract
write_cmd_2(g, 0x81, 0x17);
// Set pre-charge period
write_cmd_2(g, 0xD9, 0xF1);
// Set VCOMH select level
write_cmd_2(g, 0xDB, 0x30);
// Set entire display on/off
write_cmd_1(g, 0xA4);
// Set normal/inverse display
write_cmd_1(g, 0xA6);
// Page addressing mode
write_cmd_2(g, 0x20, 0x02);
// Display on
write_cmd_1(g, 0xAF);
}
release_bus(g);
// Finish Init
post_init_board(g);
// Initialise the GDISP structure
g->g.Width = GDISP_SCREEN_WIDTH;
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Orientation = gOrientation0;
g->g.Powermode = gPowerOn;
g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
g->g.Contrast = GDISP_INITIAL_CONTRAST;
return gTrue;
}
#if GDISP_HARDWARE_FLUSH
LLDSPEC void gdisp_lld_flush(GDisplay *g)
{
gU8 * ram;
unsigned pages;
// Only flush if necessary
if (!(g->flags & GDISP_FLG_NEEDFLUSH))
return;
ram = RAM(g);
pages = GDISP_SCREEN_HEIGHT/8;
acquire_bus(g);
write_cmd_1(g, 0x40 | 0);
while (pages--) {
write_cmd_1(g, 0xB0 + (((GDISP_SCREEN_HEIGHT/8)-1)-pages));
write_cmd_1(g, 0x00);
write_cmd_1(g, 0x10);
write_data(g, ram, SSD1312_PAGE_WIDTH);
ram += SSD1312_PAGE_WIDTH;
}
release_bus(g);
g->flags &= ~GDISP_FLG_NEEDFLUSH;
}
#endif
#if GDISP_HARDWARE_DRAWPIXEL
LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g)
{
gCoord x, y;
switch(g->g.Orientation) {
default:
case gOrientation0:
x = g->p.x;
y = g->p.y;
break;
case gOrientation90:
x = g->p.y;
y = GDISP_SCREEN_HEIGHT-1 - g->p.x;
break;
case gOrientation180:
x = GDISP_SCREEN_WIDTH-1 - g->p.x;
y = GDISP_SCREEN_HEIGHT-1 - g->p.y;
break;
case gOrientation270:
x = GDISP_SCREEN_WIDTH-1 - g->p.y;
y = g->p.x;
break;
}
if (gdispColor2Native(g->p.color) != gdispColor2Native(GFX_BLACK))
RAM(g)[xyaddr(x, y)] |= xybit(y);
else
RAM(g)[xyaddr(x, y)] &= ~xybit(y);
g->flags |= GDISP_FLG_NEEDFLUSH;
}
#endif
#if GDISP_HARDWARE_PIXELREAD
LLDSPEC gColor gdisp_lld_get_pixel_color(GDisplay *g)
{
gCoord x, y;
switch(g->g.Orientation) {
default:
case gOrientation0:
x = g->p.x;
y = g->p.y;
break;
case gOrientation90:
x = g->p.y;
y = GDISP_SCREEN_HEIGHT-1 - g->p.x;
break;
case gOrientation180:
x = GDISP_SCREEN_WIDTH-1 - g->p.x;
y = GDISP_SCREEN_HEIGHT-1 - g->p.y;
break;
case gOrientation270:
x = GDISP_SCREEN_WIDTH-1 - g->p.y;
y = g->p.x;
break;
}
return (RAM(g)[xyaddr(x, y)] & xybit(y)) ? GFX_WHITE : GFX_BLACK;
}
#endif
#if GDISP_HARDWARE_FILLS
LLDSPEC void gdisp_lld_fill_area(GDisplay *g)
{
gCoord sy, ey;
gCoord sx, ex;
gCoord col;
unsigned spage, zpages;
gU8 * base;
gU8 mask;
switch(g->g.Orientation) {
default:
case gOrientation0:
sx = g->p.x;
ex = g->p.x + g->p.cx - 1;
sy = g->p.y;
ey = sy + g->p.cy - 1;
break;
case gOrientation90:
sx = g->p.y;
ex = g->p.y + g->p.cy - 1;
sy = GDISP_SCREEN_HEIGHT - g->p.x - g->p.cx;
ey = GDISP_SCREEN_HEIGHT-1 - g->p.x;
break;
case gOrientation180:
sx = GDISP_SCREEN_WIDTH - g->p.x - g->p.cx;
ex = GDISP_SCREEN_WIDTH-1 - g->p.x;
sy = GDISP_SCREEN_HEIGHT - g->p.y - g->p.cy;
ey = GDISP_SCREEN_HEIGHT-1 - g->p.y;
break;
case gOrientation270:
sx = GDISP_SCREEN_WIDTH - g->p.y - g->p.cy;
ex = GDISP_SCREEN_WIDTH-1 - g->p.y;
sy = g->p.x;
ey = g->p.x + g->p.cx - 1;
break;
}
spage = sy / 8;
base = RAM(g) + SSD1312_PAGE_OFFSET + SSD1312_PAGE_WIDTH * spage;
mask = 0xff << (sy&7);
zpages = (ey / 8) - spage;
if (gdispColor2Native(g->p.color) == gdispColor2Native(GFX_BLACK)) {
while (zpages--) {
for (col = sx; col <= ex; col++)
base[col] &= ~mask;
mask = 0xff;
base += SSD1312_PAGE_WIDTH;
}
mask &= (0xff >> (7 - (ey&7)));
for (col = sx; col <= ex; col++)
base[col] &= ~mask;
}
else {
while (zpages--) {
for (col = sx; col <= ex; col++)
base[col] |= mask;
mask = 0xff;
base += SSD1312_PAGE_WIDTH;
}
mask &= (0xff >> (7 - (ey&7)));
for (col = sx; col <= ex; col++)
base[col] |= mask;
}
g->flags |= GDISP_FLG_NEEDFLUSH;
}
#endif
#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
LLDSPEC void gdisp_lld_control(GDisplay *g)
{
switch(g->p.x) {
case GDISP_CONTROL_POWER:
if (g->g.Powermode == (gPowermode)g->p.ptr)
return;
switch((gPowermode)g->p.ptr) {
case gPowerOff:
case gPowerSleep:
case gPowerDeepSleep:
acquire_bus(g);
write_cmd_1(g, 0xAE);
release_bus(g);
break;
case gPowerOn:
acquire_bus(g);
write_cmd_1(g, 0xAF);
release_bus(g);
break;
default:
return;
}
g->g.Powermode = (gPowermode)g->p.ptr;
return;
case GDISP_CONTROL_ORIENTATION:
if (g->g.Orientation == (gOrientation)g->p.ptr)
return;
switch((gOrientation)g->p.ptr) {
// Rotation is handled by the drawing routines
case gOrientation0:
case gOrientation180:
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Width = GDISP_SCREEN_WIDTH;
break;
case gOrientation90:
case gOrientation270:
g->g.Height = GDISP_SCREEN_WIDTH;
g->g.Width = GDISP_SCREEN_HEIGHT;
break;
default:
return;
}
g->g.Orientation = (gOrientation)g->p.ptr;
return;
case GDISP_CONTROL_CONTRAST:
if ((unsigned)g->p.ptr > 100)
g->p.ptr = (void *)100;
acquire_bus(g);
write_cmd_2(g, 0x81, (((unsigned)g->p.ptr)<<8)/101);
release_bus(g);
g->g.Contrast = (unsigned)g->p.ptr;
return;
// Our own special controller code to inverse the display
// 0 = normal, 1 = inverse
case GDISP_CONTROL_INVERSE:
acquire_bus(g);
write_cmd_1(g, g->p.ptr ? 0xA7: 0xA6);
release_bus(g);
return;
}
}
#endif // GDISP_NEED_CONTROL
#endif // GFX_USE_GDISP

View File

@ -0,0 +1,31 @@
/*
* 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.io/license.html
*/
#ifndef _GDISP_LLD_CONFIG_H
#define _GDISP_LLD_CONFIG_H
#if GFX_USE_GDISP
/*===========================================================================*/
/* Driver hardware support. */
/*===========================================================================*/
#define GDISP_HARDWARE_FLUSH GFXON // This controller requires flushing
#define GDISP_HARDWARE_DRAWPIXEL GFXON
#define GDISP_HARDWARE_PIXELREAD GFXON
#define GDISP_HARDWARE_CONTROL GFXON
#define GDISP_HARDWARE_FILLS GFXON
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO
// This controller supports a special gdispControl() to inverse the display.
// Pass a parameter of 1 for inverse and 0 for normal.
#define GDISP_CONTROL_INVERSE (GDISP_CONTROL_LLD+0)
#endif // GFX_USE_GDISP
#endif // _GDISP_LLD_CONFIG_H

View File

@ -0,0 +1,3 @@
GFXINC += $(GFXLIB)/drivers/gdisp/SSD1322
GFXSRC += $(GFXLIB)/drivers/gdisp/SSD1322/gdisp_lld_SSD1322.c

View File

@ -8,8 +8,6 @@
#ifndef _GDISP_LLD_BOARD_H
#define _GDISP_LLD_BOARD_H
#define ALLOW_2ND_LAYER GFXON
static const ltdcConfig driverCfg = {
480, 272, // Width, Height (pixels)
41, 10, // Horizontal, Vertical sync (pixels)
@ -34,7 +32,7 @@ static const ltdcConfig driverCfg = {
LTDC_LEF_ENABLE // Layer configuration flags
},
#if ALLOW_2ND_LAYER
#if STM32LTDC_USE_LAYER2 || STM32LTDC_USE_DOUBLEBUFFERING
{ // Foreground layer config (if turned on)
(LLDCOLOR_TYPE *)(SDRAM_DEVICE_ADDR+(480 * 272 * LTDC_PIXELBYTES)), // Frame buffer address
480, 272, // Width, Height (pixels)
@ -55,7 +53,20 @@ static const ltdcConfig driverCfg = {
#endif
};
static GFXINLINE void init_board(GDisplay* g) {
static GFXINLINE void init_ltdc_clock(void)
{
// Setup LTDC clock and enable the peripheral
}
#if STM32LTDC_USE_DMA2D
static GFXINLINE void init_dma2d_clock(void)
{
// Setup DMA2D clock and enable the peripheral
}
#endif
static GFXINLINE void init_board(GDisplay* g)
{
// This is function only called once with the display for the background layer.
(void)g;
}

View File

@ -0,0 +1,7 @@
list(APPEND ugfx_INCLUDE_DIRS
${CMAKE_CURRENT_LIST_DIR}
)
list(APPEND ugfx_SOURCES
${CMAKE_CURRENT_LIST_DIR}/gdisp_lld_STM32LTDC.c
)

View File

@ -12,6 +12,10 @@
#define GDISP_DRIVER_VMT GDISPVMT_STM32LTDC
#include "gdisp_lld_config.h"
#include "../../../src/gdisp/gdisp_driver.h"
#include "stm32_ltdc.h"
#if STM32LTDC_USE_DMA2D
#include "stm32_dma2d.h"
#endif
#if defined(GDISP_SCREEN_HEIGHT) || defined(GDISP_SCREEN_HEIGHT)
#if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
@ -23,27 +27,37 @@
#undef GDISP_SCREEN_HEIGHT
#endif
#ifndef LTDC_USE_DMA2D
#define LTDC_USE_DMA2D GFXOFF
#ifndef STM32LTDC_DMA_CACHE_FLUSH
#define STM32LTDC_DMA_CACHE_FLUSH GFXOFF
#endif
#ifndef LTDC_NO_CLOCK_INIT
#define LTDC_NO_CLOCK_INIT GFXOFF
#ifndef STM32LTDC_USE_DMA2D
#define STM32LTDC_USE_DMA2D GFXOFF
#endif
#ifndef LTDC_DMA_CACHE_FLUSH
#define LTDC_DMA_CACHE_FLUSH GFXOFF
#ifndef STM32LTDC_USE_LAYER2
#define STM32LTDC_USE_LAYER2 GFXOFF
#endif
#ifndef STM32LTDC_USE_RGB565
#define STM32LTDC_USE_RGB565 GFXOFF
#endif
#include "stm32_ltdc.h"
#if LTDC_USE_DMA2D
#include "stm32_dma2d.h"
#if defined(STM32F7) || defined(STM32F746xx)
#undef LTDC_DMA_CACHE_FLUSH
#define LTDC_DMA_CACHE_FLUSH GFXON
#endif
// Prevent usage of 2nd layer and double buffering at the same time.
// See readme.md for more inforamtion.
#if STM32LTDC_USE_LAYER2 && STM32LTDC_USE_DOUBLEBUFFERING
#error "GDISP - STM32LTDC: Cannot use 2nd LTDC layer and double buffering at the same time. See the driver's readme.md for more information."
#endif
// Double buffering requires GDISP_NEED_CONTROL for the buffer swap command
#if STM32LTDC_USE_DOUBLEBUFFERING && !GDISP_NEED_CONTROL
#error "GDISP - STM32LTDC: Double buffering requires GDISP_NEED_CONTROL."
#endif
// Force DMA cache flushing on certain platforms/systems.
#if STM32LTDC_USE_DMA2D
#if defined(STM32F7) || defined(STM32H7) || defined(STM32F746xx)
#undef STM32LTDC_DMA_CACHE_FLUSH
#define STM32LTDC_DMA_CACHE_FLUSH GFXON
#endif
#endif
typedef struct ltdcLayerConfig {
// Frame
@ -108,7 +122,7 @@ typedef struct ltdcConfig {
/* Driver local routines. */
/*===========================================================================*/
#define PIXIL_POS(g, x, y) ((y) * ((ltdcLayerConfig *)g->priv)->pitch + (x) * LTDC_PIXELBYTES)
#define PIXEL_POS(g, x, y) ((y) * ((ltdcLayerConfig *)g->priv)->pitch + (x) * LTDC_PIXELBYTES)
#define PIXEL_ADDR(g, pos) ((LLDCOLOR_TYPE *)((gU8 *)((ltdcLayerConfig *)g->priv)->frame+pos))
/*===========================================================================*/
@ -166,25 +180,8 @@ static void _ltdc_init(void) {
// Set up the display scanning
gU32 hacc, vacc;
// Reset the LTDC peripheral
RCC->APB2RSTR |= RCC_APB2RSTR_LTDCRST;
RCC->APB2RSTR = 0;
// Enable the LTDC clock
#if !LTDC_NO_CLOCK_INIT
#if defined(STM32F469xx)
RCC->DCKCFGR = (RCC->DCKCFGR & ~RCC_DCKCFGR_PLLSAIDIVR);
#elif defined(STM32F4) || defined(STM32F429_439xx) || defined(STM32F429xx)
RCC->DCKCFGR = (RCC->DCKCFGR & ~RCC_DCKCFGR_PLLSAIDIVR) | (1 << 16);
#elif defined(STM32F7) || defined(STM32F746xx)
RCC->DCKCFGR1 = (RCC->DCKCFGR1 & ~RCC_DCKCFGR1_PLLSAIDIVR) | (1 << 16);
#else
#error STM32LTDC driver not implemented for your platform
#endif
#endif
// Enable the peripheral
RCC->APB2ENR |= RCC_APB2ENR_LTDCEN;
// Let the board handle LTDC clock setups
init_ltdc_clock();
// Turn off the controller and its interrupts
LTDC->GCR = 0;
@ -239,7 +236,8 @@ LLDSPEC gBool gdisp_lld_init(GDisplay* g) {
g->board = 0;
switch(g->controllerdisplay) {
case 0: // Display 0 is the background layer
// Display 0 is the background layer
case 0:
// Init the board
init_board(g);
@ -247,7 +245,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay* g) {
_ltdc_init();
// Initialise DMA2D
#if LTDC_USE_DMA2D
#if STM32LTDC_USE_DMA2D
dma2d_init();
#endif
@ -264,8 +262,11 @@ LLDSPEC gBool gdisp_lld_init(GDisplay* g) {
break;
case 1: // Display 1 is the foreground layer
// Display 1 is the foreground layer or the 2nd buffer for double buffering
case 1:
g->priv = (void *)&driverCfg.fglayer;
#if STM32LTDC_USE_LAYER2
if (!(driverCfg.fglayer.layerflags & LTDC_LEF_ENABLE))
return gFalse;
@ -273,14 +274,14 @@ LLDSPEC gBool gdisp_lld_init(GDisplay* g) {
_ltdc_layer_init(LTDC_Layer2, &driverCfg.fglayer);
_ltdc_reload();
g->priv = (void *)&driverCfg.fglayer;
// Finish Init the board
post_init_board(g);
#endif
break;
default: // There is only 1 LTDC in the CPU and only the 2 layers in the LTDC.
// There is only 1 LTDC in the CPU and only the 2 layers in the LTDC.
default:
return gFalse;
}
@ -300,25 +301,27 @@ LLDSPEC void gdisp_lld_draw_pixel(GDisplay* g) {
#if GDISP_NEED_CONTROL
switch(g->g.Orientation) {
case gOrientationPortrait:
case gOrientationLandscape:
case gOrientation0:
default:
pos = PIXIL_POS(g, g->p.x, g->p.y);
pos = PIXEL_POS(g, g->p.x, g->p.y);
break;
case gOrientation90:
pos = PIXIL_POS(g, g->p.y, g->g.Width-g->p.x-1);
pos = PIXEL_POS(g, g->p.y, g->g.Width-g->p.x-1);
break;
case gOrientation180:
pos = PIXIL_POS(g, g->g.Width-g->p.x-1, g->g.Height-g->p.y-1);
pos = PIXEL_POS(g, g->g.Width-g->p.x-1, g->g.Height-g->p.y-1);
break;
case gOrientation270:
pos = PIXIL_POS(g, g->g.Height-g->p.y-1, g->p.x);
pos = PIXEL_POS(g, g->g.Height-g->p.y-1, g->p.x);
break;
}
#else
pos = PIXIL_POS(g, g->p.x, g->p.y);
pos = PIXEL_POS(g, g->p.x, g->p.y);
#endif
#if LTDC_USE_DMA2D
#if STM32LTDC_USE_DMA2D
while(DMA2D->CR & DMA2D_CR_START);
#endif
@ -338,25 +341,27 @@ LLDSPEC gColor gdisp_lld_get_pixel_color(GDisplay* g) {
#if GDISP_NEED_CONTROL
switch(g->g.Orientation) {
case gOrientationPortrait:
case gOrientationLandscape:
case gOrientation0:
default:
pos = PIXIL_POS(g, g->p.x, g->p.y);
pos = PIXEL_POS(g, g->p.x, g->p.y);
break;
case gOrientation90:
pos = PIXIL_POS(g, g->p.y, g->g.Width-g->p.x-1);
pos = PIXEL_POS(g, g->p.y, g->g.Width-g->p.x-1);
break;
case gOrientation180:
pos = PIXIL_POS(g, g->g.Width-g->p.x-1, g->g.Height-g->p.y-1);
pos = PIXEL_POS(g, g->g.Width-g->p.x-1, g->g.Height-g->p.y-1);
break;
case gOrientation270:
pos = PIXIL_POS(g, g->g.Height-g->p.y-1, g->p.x);
pos = PIXEL_POS(g, g->g.Height-g->p.y-1, g->p.x);
break;
}
#else
pos = PIXIL_POS(g, g->p.x, g->p.y);
pos = PIXEL_POS(g, g->p.x, g->p.y);
#endif
#if LTDC_USE_DMA2D
#if STM32LTDC_USE_DMA2D
while(DMA2D->CR & DMA2D_CR_START);
#endif
@ -399,6 +404,8 @@ LLDSPEC gColor gdisp_lld_get_pixel_color(GDisplay* g) {
g->g.Height = tmp;
}
break;
case gOrientationPortrait:
case gOrientationLandscape:
default:
return;
}
@ -410,12 +417,33 @@ LLDSPEC gColor gdisp_lld_get_pixel_color(GDisplay* g) {
set_backlight(g, (unsigned)g->p.ptr);
g->g.Backlight = (unsigned)g->p.ptr;
return;
#if STM32LTDC_USE_DOUBLEBUFFERING
case STM32LTDC_CONTROL_SHOW_BUFFER:
{
// Wait for end-of-line interrupt
// We use simple polling here as end-of-line interrupts are very frequent and usually happen in sub-millisecond intervals.
while (LTDC->ISR & LTDC_ISR_LIF);
// Update framebuffer address in LTDC register
// As we currently only support one layer when doublebuffering is enabled, this change happens only to layer 1.
LTDC_Layer1->CFBAR = (gU32)(((ltdcLayerConfig*)g->priv)->frame) & LTDC_LxCFBAR_CFBADD;
// Reload after LTDC config register modifications
_ltdc_reload();
return;
}
#endif
default:
return;
}
}
#endif
#if LTDC_USE_DMA2D
#if LTDC_DMA_CACHE_FLUSH
#if STM32LTDC_USE_DMA2D
#if STM32LTDC_DMA_CACHE_FLUSH
#if defined(__CC_ARM)
#define __ugfxDSB() __dsb(0xF)
#else // GCC like
@ -425,8 +453,8 @@ LLDSPEC gColor gdisp_lld_get_pixel_color(GDisplay* g) {
static void dma2d_init(void) {
// Enable DMA2D clock
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2DEN;
// Let the board handle the clock setup
init_dma2d_clock();
// Output color format
#if GDISP_LLD_PIXELFORMAT == GDISP_PIXELFORMAT_RGB565
@ -452,35 +480,37 @@ LLDSPEC gColor gdisp_lld_get_pixel_color(GDisplay* g) {
#if GDISP_NEED_CONTROL
switch(g->g.Orientation) {
case gOrientationPortrait:
case gOrientationLandscape:
case gOrientation0:
default:
pos = PIXIL_POS(g, g->p.x, g->p.y);
pos = PIXEL_POS(g, g->p.x, g->p.y);
lineadd = g->g.Width - g->p.cx;
shape = (g->p.cx << 16) | (g->p.cy);
break;
case gOrientation90:
pos = PIXIL_POS(g, g->p.y, g->g.Width-g->p.x-g->p.cx);
pos = PIXEL_POS(g, g->p.y, g->g.Width-g->p.x-g->p.cx);
lineadd = g->g.Height - g->p.cy;
shape = (g->p.cy << 16) | (g->p.cx);
break;
case gOrientation180:
pos = PIXIL_POS(g, g->g.Width-g->p.x-g->p.cx, g->g.Height-g->p.y-g->p.cy);
pos = PIXEL_POS(g, g->g.Width-g->p.x-g->p.cx, g->g.Height-g->p.y-g->p.cy);
lineadd = g->g.Width - g->p.cx;
shape = (g->p.cx << 16) | (g->p.cy);
break;
case gOrientation270:
pos = PIXIL_POS(g, g->g.Height-g->p.y-g->p.cy, g->p.x);
pos = PIXEL_POS(g, g->g.Height-g->p.y-g->p.cy, g->p.x);
lineadd = g->g.Height - g->p.cy;
shape = (g->p.cy << 16) | (g->p.cx);
break;
}
#else
pos = PIXIL_POS(g, g->p.x, g->p.y);
pos = PIXEL_POS(g, g->p.x, g->p.y);
lineadd = g->g.Width - g->p.cx;
shape = (g->p.cx << 16) | (g->p.cy);
#endif
#if LTDC_DMA_CACHE_FLUSH
#if STM32LTDC_DMA_CACHE_FLUSH
{
// This is slightly less than optimal as we flush the whole line in the source and destination image
// instead of just the cx portion but this saves us having to iterate over each line.
@ -542,10 +572,10 @@ LLDSPEC gColor gdisp_lld_get_pixel_color(GDisplay* g) {
LLDSPEC void gdisp_lld_blit_area(GDisplay* g) {
gU32 srcstart, dststart;
srcstart = LTDC_PIXELBYTES * ((gU32)g->p.x2 * g->p.y1 * + g->p.x1) + (gU32)g->p.ptr;
dststart = (gU32)PIXEL_ADDR(g, PIXIL_POS(g, g->p.x, g->p.y));
srcstart = LTDC_PIXELBYTES * ((gU32)g->p.x2 * g->p.y1 + g->p.x1) + (gU32)g->p.ptr;
dststart = (gU32)PIXEL_ADDR(g, PIXEL_POS(g, g->p.x, g->p.y));
#if LTDC_DMA_CACHE_FLUSH
#if STM32LTDC_DMA_CACHE_FLUSH
{
// This is slightly less than optimal as we flush the whole line in the source and destination image
// instead of just the cx portion but this saves us having to iterate over each line.
@ -588,6 +618,6 @@ LLDSPEC gColor gdisp_lld_get_pixel_color(GDisplay* g) {
}
#endif
#endif /* LTDC_USE_DMA2D */
#endif /* STM32LTDC_USE_DMA2D */
#endif /* GFX_USE_GDISP */

View File

@ -14,29 +14,32 @@
/* Driver hardware support. */
/*===========================================================================*/
#define LTDC_USE_DMA2D GFXON
#define GDISP_HARDWARE_DRAWPIXEL GFXON
#define GDISP_HARDWARE_PIXELREAD GFXON
#define GDISP_HARDWARE_CONTROL GFXON
// Both these pixel formats are supported - pick one.
// RGB565 obviously is faster and uses less RAM but with lower color resolution than RGB888
#if defined(GDISP_LTDC_USE_RGB565) && GDISP_LTDC_USE_RGB565
#if defined(STM32LTDC_USE_RGB565) && STM32LTDC_USE_RGB565
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
#if GDISP_TOTAL_DISPLAYS > 1
#error "LTDC: You must use RGB888 pixel format with LTDC when using dual layers as only RGB888 currently supports using alpha"
#if defined(STM32LTDC_USE_LAYER2) && STM32LTDC_USE_LAYER2
#error "GDISP - STM32LTDC: You must use RGB888 pixel format with LTDC when using both layers as only RGB888 currently supports using alpha."
#endif
#else
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
#endif
/*===========================================================================*/
/* Don't change stuff below this line. Please. */
/*===========================================================================*/
#if LTDC_USE_DMA2D
// LLD command to swap buffers if double buffering is enabled.
#if STM32LTDC_USE_DOUBLEBUFFERING
#define STM32LTDC_CONTROL_SHOW_BUFFER (GDISP_CONTROL_LLD+0)
#endif
// Adjust driver config if DMA2D is enabled.
#if STM32LTDC_USE_DMA2D
// DMA2D supports accelerated fills
#define GDISP_HARDWARE_FILLS GFXON

View File

@ -0,0 +1,91 @@
# Usage
To use this driver:
1. Add in your `gfxconf.h`:
a) `#define GFX_USE_GDISP GFXON`
2. To your makefile add the following lines:
```
include $(GFXLIB)/gfx.mk
include $(GFXLIB)/drivers/gdisp/STM32LTDC/driver.mk
```
3. Add a `board_STM32LTDC.h` to you project directory (or board directory)
based on one of the templates.
# Configuration
Configuration options available in `gfxconf.h`:
| Option | Default | Description |
| --- | --- | --- |
| `STM32LTDC_DMA_CACHE_FLUSH` | `GFXOFF` | Whether to flush the DMA cache on DMA2D operations. This will be turned on automatically on certian platforms/systems. |
| `STM32LTDC_USE_DMA2D` | `GFXON` | Whether to use the DMA2D peripheral for hardware acceleration. |
| `STM32LTDC_USE_LAYER2` | `GFXOFF` | Whether to use the 2nd LTDC layer. See the corresponding section below. |
| `STM32LTDC_USE_DOUBLEBUFFERING` | `GFXOFF` | Whether to use double buffering. See the corresponding section below. |
| `STM32LTDC_USE_RGB565` | `GFXOFF` | Whether to use RGB565 instead of RGB888. |
# 2nd layer
To use the 2nd LTDC layer:
- set `STM32LTDC_USE_LAYER2` to `GFXON` in `gfxconf.h`.
- set `GDISP_TOTAL_DISPLAYS` to `2` in `gfxconf.h`.
The 2nd layer is exposed as a separate display. Use `gdispGetDisplay()` to retrieve the individual layers.
For more information, see:
- https://wiki.ugfx.io/index.php/Multiple_displays#Example_-_Same_controller
- https://wiki.ugfx.io/index.php/Multiple_displays#Access_the_displays
# Double buffering
To use double buffering:
- set `STM32LTDC_USE_DOUBLEBUFFERING` to `GFXON` in `gfxconf.h`.
- set `GDISP_TOTAL_DISPLAYS` to `2` in `gfxconf.h`.
When double buffering is enabled, the 2nd LTDC layer cannot be used. While this limitation is easy to remove from a software perspective, there is little benefit in doing so. Double buffering requires, as the name implies, twice the memory. If the 2nd layer would be used together with double buffering strategy, a total of four full framebuffers would be required. Years of real-world experience shows that there's practically never enough memory bandwidth available to do this.
To use double buffering in an application, retrieve the two buffers via `gdispGetDisplay()`.
Whenever a buffer swap is necessary, use `gdispGControl(g, STM32LTDC_CONTROL_SHOW_BUFFER, NULL);` where `g` is the buffer to be shown.
Simple example:
```c
#include "gfx.h"
static GDisplay* _display1;
static GDisplay* _display2;
// Requests a buffer swap on the driver level
static void _setActiveBuffer(GDisplay* g)
{
gdispGControl(g, STM32LTDC_CONTROL_SHOW_BUFFER, NULL);
}
int main(void)
{
// Initialize uGFX library
gfxInit();
// Get the two buffers
_display1 = gdispGetDisplay(0);
if (!_display1)
gfxHalt("could not get display 1");
_display2 = gdispGetDisplay(1);
if (!_display2)
gfxHalt("could not get display 2");
// Render to each buffer
gdispGClear(_display1, GFX_BLUE);
gdispGClear(_display2, GFX_RED);
// Switch between buffers
while (gTrue) {
gfxSleepMilliseconds(800);
_setActiveBuffer(_display1);
gfxSleepMilliseconds(800);
_setActiveBuffer(_display2);
}
return 0;
}
```

View File

@ -1,11 +0,0 @@
To use this driver:
1. Add in your gfxconf.h:
a) #define GFX_USE_GDISP GFXON
2. To your makefile add the following lines:
include $(GFXLIB)/gfx.mk
include $(GFXLIB)/drivers/gdisp/STM32LTDC/driver.mk
3. Add a board_STM32LTDC.h to you project directory (or board directory)
based on one of the templates.

View File

@ -0,0 +1,8 @@
list(APPEND ugfx_INCLUDE_DIRS
${CMAKE_CURRENT_LIST_DIR}
)
list(APPEND ugfx_SOURCES
${CMAKE_CURRENT_LIST_DIR}/gdisp_lld_framebuffer.c
)

View File

@ -24,6 +24,7 @@ S6D1121 - Mid-sized color LCD displays eg RGB565 320x240
SPFD54124B - Mid-sized color LCD displays eg RGB565 320x240
SSD1289 - Mid-sized color LCD displays eg RGB565 320x240
SSD1306 - Small monochrome LCD
SSD1312 - Small monochrome LCD (usually 128x32 or 128x64 OLED)
SSD1322 - Small 16 level grayscale LCD
SSD1331 - Small hardware accelerated OLED display RGB565 96x64
SSD1351 - Mid-sized color LCD displays eg RGB565 320x240

View File

@ -0,0 +1,8 @@
list(APPEND ugfx_INCLUDE_DIRS
${CMAKE_CURRENT_LIST_DIR}
)
list(APPEND ugfx_SOURCES
${CMAKE_CURRENT_LIST_DIR}/gmouse_lld_linux_event.c
)

View File

@ -0,0 +1,48 @@
set(ROOT_PATH ${UGFX_ROOT}/drivers/multiple/SDL)
# Defaults
if (NOT UGFX_DEPENDENCY_SDL2_DOWNLOAD)
set(UGFX_DEPENDENCY_SDL2_DOWNLOAD OFF)
endif()
# Get or find SDL2
if (UGFX_DEPENDENCY_SDL2_DOWNLOAD)
include(FetchContent)
FetchContent_Declare(
SDL2
GIT_REPOSITORY https://github.com/libsdl-org/SDL
GIT_TAG release-2.26.5
)
FetchContent_MakeAvailable(SDL2)
if (NOT UGFX_DEPENDENCY_SDL2_TARGET)
set(UGFX_DEPENDENCY_SDL2_TARGET SDL2-static)
endif()
else()
find_package(
SDL2
REQUIRED
)
if (NOT UGFX_DEPENDENCY_SDL2_TARGET)
set(UGFX_DEPENDENCY_SDL2_TARGET SDL2::SDL2)
endif()
endif()
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/gdisp_lld_SDL.c
)
list(APPEND ugfx_DEFS
GFX_OS_PRE_INIT_FUNCTION=sdl_driver_init
)
list(APPEND ugfx_LIBS
${UGFX_DEPENDENCY_SDL2_TARGET}
)

View File

@ -174,8 +174,8 @@ static struct SDL_UGFXContext *context;
static sem_t *ctx_mutex;
static sem_t *input_event;
#define CTX_MUTEX_NAME "ugfx_ctx_mutex"
#define INPUT_EVENT_NAME "ugfx_input_event"
#define CTX_MUTEX_NAME "/ugfx_ctx_mutex"
#define INPUT_EVENT_NAME "/ugfx_input_event"
static int SDL_loop (void) {
@ -311,12 +311,12 @@ static void *SDL_input_event_loop (void *arg) {
// Must be executed on early stage of initialization: before threads and timer
void sdl_driver_init (void) {
if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) != 0){
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
exit (1) ;
}
if ((context = (struct SDL_UGFXContext*) mmap (0,sizeof (struct SDL_UGFXContext ),PROT_WRITE|PROT_READ,(MAP_ANONYMOUS | MAP_SHARED),0,0)) ==MAP_FAILED) {
if ((context = (struct SDL_UGFXContext*) mmap (0, sizeof(struct SDL_UGFXContext), PROT_WRITE|PROT_READ, (MAP_ANONYMOUS | MAP_SHARED), -1, 0)) == MAP_FAILED) {
perror("Failed to allocate shared memory");
exit(1);
}

View File

@ -24,3 +24,4 @@ and a touchscreen driver.
4. Modify your makefile to add `sdl2-config --libs --cflags` to the CFLAGS line. i.e.
CFLAGS = `sdl2-config --libs --cflags`

View File

@ -0,0 +1,13 @@
set(ROOT_PATH ${UGFX_ROOT}/drivers/multiple/Win32)
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/gdisp_lld_Win32.c
)
list(APPEND ugfx_LIBS
gdi32
)

View File

@ -99,7 +99,11 @@
static gBool Win32MouseInit(GMouse *m, unsigned driverinstance);
static gBool Win32MouseRead(GMouse *m, GMouseReading *prd);
const GMouseVMT const GMOUSE_DRIVER_VMT[1] = {{
/**
* This should be: const GMouseVMT const GMOUSE_DRIVER_VMT[1] = {{
* However, some major compilers complain about the duplicate const specifier even though this is perfectly valid standard C.
*/
const GMouseVMT GMOUSE_DRIVER_VMT[1] = {{
{
GDRIVER_TYPE_MOUSE,
GMOUSE_VFLG_NOPOLL|GMOUSE_VFLG_DYNAMICONLY,
@ -643,12 +647,30 @@ static LRESULT myWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
#endif
#if GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD
case WM_ACTIVATE:
// Copy the lock key states into the uGFX keyboard as it might have changed while we were away
// For simplicity we do this on both activate and deactivate.
if (keyboard && keyboard->pLayout) {
if (GetKeyState(VK_NUMLOCK) & 1)
keyboard->keystate |= GKEYSTATE_NUMLOCK;
else
keyboard->keystate &= ~GKEYSTATE_NUMLOCK;
if (GetKeyState(VK_CAPITAL) & 1)
keyboard->keystate |= GKEYSTATE_CAPSLOCK;
else
keyboard->keystate &= ~GKEYSTATE_CAPSLOCK;
if (GetKeyState(VK_SCROLL) & 1)
keyboard->keystate |= GKEYSTATE_SCROLLLOCK;
else
keyboard->keystate &= ~GKEYSTATE_SCROLLLOCK;
}
break;
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
case WM_KEYDOWN:
case WM_KEYUP:
// A layout is being used: Send scan codes to the keyboard buffer
if (keyboard && keyboard->pLayout && keypos < (int)sizeof(keybuffer)-1 && (wParam & 0xFF) > 0x01) {
if (keyboard && keyboard->pLayout && keypos < (int)sizeof(keybuffer)-1 && (wParam & 0xFF) >= VK_BACK) {
if (Msg == WM_KEYUP || Msg == WM_SYSKEYUP)
keybuffer[keypos++] = 0x00; // Keyup
else if (HIWORD(lParam) & KF_REPEAT)
@ -885,7 +907,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
// Create the associated mouse
#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
priv->mouseenabled = hWndParent ? gFalse : gTrue;
priv->mouse = (GMouse *)gdriverRegister((const GDriverVMT const *)GMOUSE_DRIVER_VMT, g);
priv->mouse = (GMouse *)gdriverRegister((const GDriverVMT*)GMOUSE_DRIVER_VMT, g);
#endif
sprintf(buf, APP_NAME " - %u", g->systemdisplay+1);
@ -1275,11 +1297,17 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
gPixel * buffer;
RECT rect;
BITMAPV4HEADER bmpInfo;
#if GDISP_NEED_CONTROL
gPixel* bufferBase;
#endif
// Make everything relative to the start of the line
priv = g->priv;
buffer = g->p.ptr;
buffer += g->p.x2*g->p.y1;
buffer += g->p.x2 * g->p.y1 + g->p.x1;
#if GDISP_NEED_CONTROL
bufferBase = buffer; // Keep pointer to original buffer for correct free()-ing later on
#endif
memset(&bmpInfo, 0, sizeof(bmpInfo));
bmpInfo.bV4Size = sizeof(bmpInfo);
@ -1365,7 +1393,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
#endif
#if GDISP_NEED_CONTROL
if (buffer != (gPixel *)g->p.ptr)
if (bufferBase != buffer)
free(buffer);
#endif
}

View File

@ -0,0 +1,14 @@
set(ROOT_PATH ${UGFX_ROOT}/drivers/multiple/X)
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/gdisp_lld_X.c
)
list(APPEND ugfx_LIBS
X11
)

View File

@ -36,6 +36,7 @@
// #define GFX_FREERTOS_USE_TRACE GFXOFF
//#define GFX_USE_OS_WIN32 GFXOFF
//#define GFX_USE_OS_LINUX GFXOFF
//#define GFX_USE_OS_FREEBSD GFXOFF
//#define GFX_USE_OS_OSX GFXOFF
//#define GFX_USE_OS_ECOS GFXOFF
//#define GFX_USE_OS_RAWRTOS GFXOFF

View File

@ -0,0 +1,9 @@
set(ROOT_PATH ${UGFX_ROOT}/src/gadc)
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/gadc.c
)

View File

@ -0,0 +1,9 @@
set(ROOT_PATH ${UGFX_ROOT}/src/gaudio)
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/gaudio.c
)

View File

@ -555,16 +555,23 @@ static void line_clip(GDisplay *g) {
/* Driver exported functions. */
/*===========================================================================*/
// Gather GDISP VMT(S)
// These are only needed in _gdispInit(). However, we want to prevent generating nested-externs compiler warnings.
#if defined(GDISP_DRIVER_LIST)
extern GDISPVMTLIST GDISP_DRIVER_LIST;
#else
extern const GDISPVMT GDISPVMT_OnlyOne[1];
#endif
void _gdispInit(void)
{
// GDISP_DRIVER_LIST is defined - create each driver instance
#if defined(GDISP_DRIVER_LIST)
{
unsigned i;
typedef const GDISPVMT const GDISPVMTLIST[1];
typedef const GDISPVMT GDISPVMTLIST[1];
extern GDISPVMTLIST GDISP_DRIVER_LIST;
static const GDISPVMT * const dclist[] = {GDISP_DRIVER_LIST};
static const GDISPVMT* dclist[] = { GDISP_DRIVER_LIST };
for(i = 0; i < sizeof(dclist)/sizeof(dclist[0]); i++) {
if (!(dclist[i]->d.flags & GDISP_VFLG_DYNAMICONLY))
@ -574,7 +581,6 @@ void _gdispInit(void)
#elif GDISP_TOTAL_DISPLAYS > 1
{
unsigned i;
extern const GDISPVMT const GDISPVMT_OnlyOne[1];
if (!(GDISPVMT_OnlyOne->d.flags & GDISP_VFLG_DYNAMICONLY)) {
for(i = 0; i < GDISP_TOTAL_DISPLAYS; i++)
@ -583,8 +589,6 @@ void _gdispInit(void)
}
#else
{
extern const GDISPVMT const GDISPVMT_OnlyOne[1];
if (!(GDISPVMT_OnlyOne->d.flags & GDISP_VFLG_DYNAMICONLY))
gdriverRegister(&GDISPVMT_OnlyOne->d, 0);
}
@ -2881,6 +2885,10 @@ void gdispGBlitArea(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoor
case gOrientationPortrait:
g->p.ptr = g->g.Width >= g->g.Height ? (void *)gOrientation90 : (void *)gOrientation0;
break;
case gOrientation0:
case gOrientation90:
case gOrientation180:
case gOrientation270:
default:
break;
}

View File

@ -0,0 +1,27 @@
set(ROOT_PATH ${UGFX_ROOT}/src/gdisp)
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
${ROOT_PATH}/mcufont
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/gdisp.c
${ROOT_PATH}/gdisp_fonts.c
${ROOT_PATH}/gdisp_pixmap.c
${ROOT_PATH}/gdisp_image.c
${ROOT_PATH}/gdisp_image_native.c
${ROOT_PATH}/gdisp_image_gif.c
${ROOT_PATH}/gdisp_image_bmp.c
${ROOT_PATH}/gdisp_image_jpg.c
${ROOT_PATH}/gdisp_image_png.c
${ROOT_PATH}/mcufont/mf_encoding.c
${ROOT_PATH}/mcufont/mf_font.c
${ROOT_PATH}/mcufont/mf_justify.c
${ROOT_PATH}/mcufont/mf_kerning.c
${ROOT_PATH}/mcufont/mf_rlefont.c
${ROOT_PATH}/mcufont/mf_bwfont.c
${ROOT_PATH}/mcufont/mf_scaledfont.c
${ROOT_PATH}/mcufont/mf_wordwrap.c
)

View File

@ -1270,6 +1270,9 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
#define fontMaxWidth gFontMaxWidth
#define fontBaselineX gFontBaselineX
#define fontBaselineY gFontBaselineY
#if GDISP_NEED_IMAGE || defined(__DOXYGEN__)
typedef gImage gdispImage;
#endif
#endif
#endif /* GFX_USE_GDISP */

View File

@ -216,7 +216,7 @@ typedef gU16 gColorformat;
*/
#define LUMA_OF(c) ((RED_OF(c)+((gU16)GREEN_OF(c)<<1)+BLUE_OF(c))>>2)
#define RED_OF(c) (((c) & 0xF800)>>8)
#define GREEN_OF(c) (((c)&0x007E)>>3)
#define GREEN_OF(c) (((c)&0x07E0)>>3)
#define BLUE_OF(c) (((c)&0x001F)<<3)
/** @} */

View File

@ -732,7 +732,11 @@ typedef struct GDISPVMT {
#endif
// Build the VMT
const GDISPVMT const GDISP_DRIVER_VMT[1] = {{
/*
* This should read: const GDISPVMT const GDISP_DRIVER_VMT[1] = {{
* However, some major C compilers complain about duplicate const specifiers although this is perfectly valid standard C.
*/
const GDISPVMT GDISP_DRIVER_VMT[1] = {{
{ GDRIVER_TYPE_DISPLAY, 0, sizeof(GDisplay), _gdispInitDriver, _gdispPostInitDriver, _gdispDeInitDriver },
gdisp_lld_init,
#if GDISP_HARDWARE_DEINIT

View File

@ -12,62 +12,62 @@
#include "gdisp_image_support.h"
#if GDISP_NEED_IMAGE_NATIVE
extern gdispImageError gdispImageOpen_NATIVE(gdispImage *img);
extern void gdispImageClose_NATIVE(gdispImage *img);
extern gdispImageError gdispImageCache_NATIVE(gdispImage *img);
extern gdispImageError gdispGImageDraw_NATIVE(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
extern gDelay gdispImageNext_NATIVE(gdispImage *img);
extern gdispImageError gdispImageOpen_NATIVE(gImage *img);
extern void gdispImageClose_NATIVE(gImage *img);
extern gdispImageError gdispImageCache_NATIVE(gImage *img);
extern gdispImageError gdispGImageDraw_NATIVE(GDisplay *g, gImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
extern gDelay gdispImageNext_NATIVE(gImage *img);
#endif
#if GDISP_NEED_IMAGE_GIF
extern gdispImageError gdispImageOpen_GIF(gdispImage *img);
extern void gdispImageClose_GIF(gdispImage *img);
extern gdispImageError gdispImageCache_GIF(gdispImage *img);
extern gdispImageError gdispGImageDraw_GIF(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
extern gDelay gdispImageNext_GIF(gdispImage *img);
extern gdispImageError gdispImageOpen_GIF(gImage *img);
extern void gdispImageClose_GIF(gImage *img);
extern gdispImageError gdispImageCache_GIF(gImage *img);
extern gdispImageError gdispGImageDraw_GIF(GDisplay *g, gImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
extern gDelay gdispImageNext_GIF(gImage *img);
#endif
#if GDISP_NEED_IMAGE_BMP
extern gdispImageError gdispImageOpen_BMP(gdispImage *img);
extern void gdispImageClose_BMP(gdispImage *img);
extern gdispImageError gdispImageCache_BMP(gdispImage *img);
extern gdispImageError gdispGImageDraw_BMP(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
extern gDelay gdispImageNext_BMP(gdispImage *img);
extern gU16 gdispImageGetPaletteSize_BMP(gdispImage *img);
extern gColor gdispImageGetPalette_BMP(gdispImage *img, gU16 index);
extern gBool gdispImageAdjustPalette_BMP(gdispImage *img, gU16 index, gColor newColor);
extern gdispImageError gdispImageOpen_BMP(gImage *img);
extern void gdispImageClose_BMP(gImage *img);
extern gdispImageError gdispImageCache_BMP(gImage *img);
extern gdispImageError gdispGImageDraw_BMP(GDisplay *g, gImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
extern gDelay gdispImageNext_BMP(gImage *img);
extern gU16 gdispImageGetPaletteSize_BMP(gImage *img);
extern gColor gdispImageGetPalette_BMP(gImage *img, gU16 index);
extern gBool gdispImageAdjustPalette_BMP(gImage *img, gU16 index, gColor newColor);
#endif
#if GDISP_NEED_IMAGE_JPG
extern gdispImageError gdispImageOpen_JPG(gdispImage *img);
extern void gdispImageClose_JPG(gdispImage *img);
extern gdispImageError gdispImageCache_JPG(gdispImage *img);
extern gdispImageError gdispGImageDraw_JPG(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
extern gDelay gdispImageNext_JPG(gdispImage *img);
extern gdispImageError gdispImageOpen_JPG(gImage *img);
extern void gdispImageClose_JPG(gImage *img);
extern gdispImageError gdispImageCache_JPG(gImage *img);
extern gdispImageError gdispGImageDraw_JPG(GDisplay *g, gImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
extern gDelay gdispImageNext_JPG(gImage *img);
#endif
#if GDISP_NEED_IMAGE_PNG
extern gdispImageError gdispImageOpen_PNG(gdispImage *img);
extern void gdispImageClose_PNG(gdispImage *img);
extern gdispImageError gdispImageCache_PNG(gdispImage *img);
extern gdispImageError gdispGImageDraw_PNG(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
extern gDelay gdispImageNext_PNG(gdispImage *img);
extern gdispImageError gdispImageOpen_PNG(gImage *img);
extern void gdispImageClose_PNG(gImage *img);
extern gdispImageError gdispImageCache_PNG(gImage *img);
extern gdispImageError gdispGImageDraw_PNG(GDisplay *g, gImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
extern gDelay gdispImageNext_PNG(gImage *img);
#endif
/* The structure defining the routines for image drawing */
typedef struct gdispImageHandlers {
gdispImageError (*open)(gdispImage *img); /* The open function */
void (*close)(gdispImage *img); /* The close function */
gdispImageError (*cache)(gdispImage *img); /* The cache function */
gdispImageError (*open)(gImage *img); /* The open function */
void (*close)(gImage *img); /* The close function */
gdispImageError (*cache)(gImage *img); /* The cache function */
gdispImageError (*draw)(GDisplay *g,
gdispImage *img,
gImage *img,
gCoord x, gCoord y,
gCoord cx, gCoord cy,
gCoord sx, gCoord sy); /* The draw function */
gDelay (*next)(gdispImage *img); /* The next frame function */
gU16 (*getPaletteSize)(gdispImage *img); /* Retrieve the size of the palette (number of entries) */
gColor (*getPalette)(gdispImage *img, gU16 index); /* Retrieve a specific color value of the palette */
gBool (*adjustPalette)(gdispImage *img, gU16 index, gColor newColor); /* Replace a color value in the palette */
gDelay (*next)(gImage *img); /* The next frame function */
gU16 (*getPaletteSize)(gImage *img); /* Retrieve the size of the palette (number of entries) */
gColor (*getPalette)(gImage *img, gU16 index); /* Retrieve a specific color value of the palette */
gBool (*adjustPalette)(gImage *img, gU16 index, gColor newColor); /* Replace a color value in the palette */
} gdispImageHandlers;
static gdispImageHandlers ImageHandlers[] = {
@ -103,11 +103,11 @@ static gdispImageHandlers ImageHandlers[] = {
#endif
};
void gdispImageInit(gdispImage *img) {
void gdispImageInit(gImage *img) {
img->type = GDISP_IMAGE_TYPE_UNKNOWN;
}
gdispImageError gdispImageOpenGFile(gdispImage *img, GFILE *f) {
gdispImageError gdispImageOpenGFile(gImage *img, GFILE *f) {
gdispImageError err;
if (!img)
@ -142,7 +142,7 @@ unrecoverable:
return err;
}
void gdispImageClose(gdispImage *img) {
void gdispImageClose(gImage *img) {
if (!img)
return;
if (img->fns)
@ -154,23 +154,23 @@ void gdispImageClose(gdispImage *img) {
img->priv = 0;
}
gBool gdispImageIsOpen(gdispImage *img) {
gBool gdispImageIsOpen(gImage *img) {
return img && img->type != GDISP_IMAGE_TYPE_UNKNOWN && img->fns != 0;
}
void gdispImageSetBgColor(gdispImage *img, gColor bgcolor) {
void gdispImageSetBgColor(gImage *img, gColor bgcolor) {
if (!img)
return;
img->bgcolor = bgcolor;
}
gdispImageError gdispImageCache(gdispImage *img) {
gdispImageError gdispImageCache(gImage *img) {
if (!img) return GDISP_IMAGE_ERR_NULLPOINTER;
if (!img->fns) return GDISP_IMAGE_ERR_BADFORMAT;
return img->fns->cache(img);
}
gdispImageError gdispGImageDraw(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy) {
gdispImageError gdispGImageDraw(GDisplay *g, gImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy) {
if (!img) return GDISP_IMAGE_ERR_NULLPOINTER;
if (!img->fns) return GDISP_IMAGE_ERR_BADFORMAT;
@ -186,25 +186,25 @@ gdispImageError gdispGImageDraw(GDisplay *g, gdispImage *img, gCoord x, gCoord y
return img->fns->draw(g, img, x, y, cx, cy, sx, sy);
}
gDelay gdispImageNext(gdispImage *img) {
gDelay gdispImageNext(gImage *img) {
if (!img) return GDISP_IMAGE_ERR_NULLPOINTER;
if (!img->fns) return GDISP_IMAGE_ERR_BADFORMAT;
return img->fns->next(img);
}
gU16 gdispImageGetPaletteSize(gdispImage *img) {
gU16 gdispImageGetPaletteSize(gImage *img) {
if (!img || !img->fns) return 0;
if (!img->fns->getPaletteSize) return 0;
return img->fns->getPaletteSize(img);
}
gColor gdispImageGetPalette(gdispImage *img, gU16 index) {
gColor gdispImageGetPalette(gImage *img, gU16 index) {
if (!img || !img->fns) return 0;
if (!img->fns->getPalette) return 0;
return img->fns->getPalette(img, index);
}
gBool gdispImageAdjustPalette(gdispImage *img, gU16 index, gColor newColor) {
gBool gdispImageAdjustPalette(gImage *img, gU16 index, gColor newColor) {
if (!img || !img->fns) return gFalse;
if (!img->fns->adjustPalette) return gFalse;
return img->fns->adjustPalette(img, index, newColor);
@ -212,7 +212,7 @@ gBool gdispImageAdjustPalette(gdispImage *img, gU16 index, gColor newColor) {
// Helper Routines
void *gdispImageAlloc(gdispImage *img, gMemSize sz) {
void *gdispImageAlloc(gImage *img, gMemSize sz) {
#if GDISP_NEED_IMAGE_ACCOUNTING
void *ptr;
@ -229,7 +229,7 @@ void *gdispImageAlloc(gdispImage *img, gMemSize sz) {
#endif
}
void gdispImageFree(gdispImage *img, void *ptr, gMemSize sz) {
void gdispImageFree(gImage *img, void *ptr, gMemSize sz) {
#if GDISP_NEED_IMAGE_ACCOUNTING
gfxFree(ptr);
img->memused -= sz;

View File

@ -56,7 +56,7 @@ typedef gU16 gdispImageFlags;
/**
* @brief The structure for an image
*/
typedef struct gdispImage {
typedef struct gImage {
gdispImageType type; /* @< The image type */
gdispImageFlags flags; /* @< The image flags */
gColor bgcolor; /* @< The default background color */
@ -68,15 +68,15 @@ typedef struct gdispImage {
#endif
const struct gdispImageHandlers * fns; /* @< Don't mess with this! */
void * priv; /* @< Don't mess with this! */
} gdispImage;
} gImage;
/**
* @brief Initialise a gdispImage object
* @brief Initialise a gImage object
*
* @param[in] img The image structure to initialise
*
*/
void gdispImageInit(gdispImage *img);
void gdispImageInit(gImage *img);
/**
* @brief Open an image using an open GFILE and get it ready for drawing
@ -89,7 +89,7 @@ void gdispImageInit(gdispImage *img);
* @pre The GFILE must be open for reading.
*
* @note This determines which decoder to use and then initialises all other fields
* in the gdispImage structure.
* in the gImage structure.
* @note The image background color is set to White.
* @note There are three types of return - everything OK, partial success and unrecoverable
* failures. For everything OK it returns GDISP_IMAGE_ERR_OK. A partial success can
@ -102,7 +102,7 @@ void gdispImageInit(gdispImage *img);
* (eg GDISP_IMAGE_ERR_UNSUPPORTED_OK)
* still need to be closed when you are finished with them.
*/
gdispImageError gdispImageOpenGFile(gdispImage *img, GFILE *f);
gdispImageError gdispImageOpenGFile(gImage *img, GFILE *f);
/**
* @brief Open an image in a file and get it ready for drawing
@ -156,7 +156,7 @@ gdispImageError gdispImageOpenGFile(gdispImage *img, GFILE *f);
*
* @note Also calls the IO close function (if it hasn't already been called).
*/
void gdispImageClose(gdispImage *img);
void gdispImageClose(gImage *img);
/**
* @brief Is an image open.
@ -169,7 +169,7 @@ void gdispImageClose(gdispImage *img);
* is open. Clearing the Image structure to 0's will guarantee the image
* is seen as being closed.
*/
gBool gdispImageIsOpen(gdispImage *img);
gBool gdispImageIsOpen(gImage *img);
/**
* @brief Set the background color of the image.
@ -182,7 +182,7 @@ gBool gdispImageIsOpen(gdispImage *img);
* @note This color is only used when an image has to restore part of the background before
* continuing with drawing that includes transparency eg some GIF animations.
*/
void gdispImageSetBgColor(gdispImage *img, gColor bgcolor);
void gdispImageSetBgColor(gImage *img, gColor bgcolor);
/**
* @brief Cache the image
@ -200,7 +200,7 @@ void gdispImageSetBgColor(gdispImage *img, gColor bgcolor);
* example, a GDISP_IMAGE_ERR_NOMEMORY error simply means there isn't enough RAM to
* cache the image.
*/
gdispImageError gdispImageCache(gdispImage *img);
gdispImageError gdispImageCache(gImage *img);
/**
* @brief Draw the image
@ -221,7 +221,7 @@ gdispImageError gdispImageCache(gdispImage *img);
* is drawing. This may be significantly slower than if the image has been cached (but
* uses a lot less RAM)
*/
gdispImageError gdispGImageDraw(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
gdispImageError gdispGImageDraw(GDisplay *g, gImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
#define gdispImageDraw(img,x,y,cx,cy,sx,sy) gdispGImageDraw(GDISP,img,x,y,cx,cy,sx,sy)
/**
@ -243,7 +243,7 @@ gdispImageError gdispGImageDraw(GDisplay *g, gdispImage *img, gCoord x, gCoord y
* @note Calling gdispImageDraw() after getting a gDelayForever will go back to drawing the first
* frame/page.
*/
gDelay gdispImageNext(gdispImage *img);
gDelay gdispImageNext(gImage *img);
/**
* @brief Get the number of entries in the color palette.
@ -253,7 +253,7 @@ gDelay gdispImageNext(gdispImage *img);
*
* @pre gdispImageOpen() must have returned successfully.
*/
gU16 gdispImageGetPaletteSize(gdispImage *img);
gU16 gdispImageGetPaletteSize(gImage *img);
/**
* @brief Get an entry in the color palette.
@ -266,7 +266,7 @@ gU16 gdispImageGetPaletteSize(gdispImage *img);
*
* @note This function will return 0 if the index is out of bounds or if the image doesn't use a color palette.
*/
gColor gdispImageGetPalette(gdispImage *img, gU16 index);
gColor gdispImageGetPalette(gImage *img, gU16 index);
/**
* @brief Modify an entry in the color palette.
@ -279,7 +279,7 @@ gColor gdispImageGetPalette(gdispImage *img, gU16 index);
* @pre gdispImageOpen() must have returned successfully.
* @note This function will return @p gFalse if the index is out of bounds or if the image doesn't use a color palette.
*/
gBool gdispImageAdjustPalette(gdispImage *img, gU16 index, gColor newColor);
gBool gdispImageAdjustPalette(gImage *img, gU16 index, gColor newColor);
#endif /* GFX_USE_GDISP && GDISP_NEED_IMAGE */
#endif /* _GDISP_IMAGE_H */

View File

@ -11,6 +11,16 @@
#include "gdisp_image_support.h"
#if GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE * (COLOR_TYPE_BITS/8) < 40
#if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
#warning "GDISP: GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE must be at least 40 bytes. It has been adjusted for you."
#elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
COMPILER_WARNING("GDISP: GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE must be at least 40 bytes. It has been adjusted for you.")
#endif
#undef GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE
#define GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE ((40 + (COLOR_TYPE_BITS/8) - 1) / (COLOR_TYPE_BITS/8))
#endif
typedef struct gdispImagePrivate_BMP {
gU8 bmpflags;
#define BMP_V2 0x01 // Version 2 (old) header format
@ -45,7 +55,7 @@ typedef struct gdispImagePrivate_BMP {
gPixel buf[GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE];
} gdispImagePrivate_BMP;
void gdispImageClose_BMP(gdispImage *img) {
void gdispImageClose_BMP(gImage *img) {
gdispImagePrivate_BMP *priv;
priv = (gdispImagePrivate_BMP *)img->priv;
@ -61,7 +71,7 @@ void gdispImageClose_BMP(gdispImage *img) {
}
}
gdispImageError gdispImageOpen_BMP(gdispImage *img) {
gdispImageError gdispImageOpen_BMP(gImage *img) {
gdispImagePrivate_BMP *priv;
gU8 hdr[2];
gU16 aword;
@ -352,7 +362,7 @@ unsupportedcleanup:
return GDISP_IMAGE_ERR_UNSUPPORTED; // Not supported
}
static gCoord getPixels(gdispImage *img, gCoord x) {
static gCoord getPixels(gImage *img, gCoord x) {
gdispImagePrivate_BMP * priv;
gColor * pc;
gCoord len;
@ -555,7 +565,7 @@ static gCoord getPixels(gdispImage *img, gCoord x) {
} else if (b[1] == 2) { // Delta x, y
// There are always at least 2 bytes in an RLE code
if (gfileRead(img->f, &b, 2) != 2)
return GDISP_IMAGE_ERR_BADDATA;
return (gCoord)GDISP_IMAGE_ERR_BADDATA;
priv->rlerun = b[0] + (gU16)b[1] * img->width;
priv->rlecode = 0; // Who knows what color this should really be
priv->bmpflags |= BMP_RLE_ENC;
@ -691,7 +701,7 @@ static gCoord getPixels(gdispImage *img, gCoord x) {
}
}
gdispImageError gdispImageCache_BMP(gdispImage *img) {
gdispImageError gdispImageCache_BMP(gImage *img) {
gdispImagePrivate_BMP * priv;
gColor * pcs;
gColor * pcd;
@ -749,7 +759,7 @@ gdispImageError gdispImageCache_BMP(gdispImage *img) {
return GDISP_IMAGE_ERR_OK;
}
gdispImageError gdispGImageDraw_BMP(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy) {
gdispImageError gdispGImageDraw_BMP(GDisplay *g, gImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy) {
gdispImagePrivate_BMP * priv;
gCoord mx, my;
gCoord pos, len, st;
@ -815,14 +825,14 @@ gdispImageError gdispGImageDraw_BMP(GDisplay *g, gdispImage *img, gCoord x, gCoo
return GDISP_IMAGE_ERR_OK;
}
gDelay gdispImageNext_BMP(gdispImage *img) {
gDelay gdispImageNext_BMP(gImage *img) {
(void) img;
/* No more frames/pages */
return gDelayForever;
}
gU16 gdispImageGetPaletteSize_BMP(gdispImage *img) {
gU16 gdispImageGetPaletteSize_BMP(gImage *img) {
#if GDISP_NEED_IMAGE_BMP_1 || GDISP_NEED_IMAGE_BMP_4 || GDISP_NEED_IMAGE_BMP_8
gdispImagePrivate_BMP *priv;
@ -839,7 +849,7 @@ gU16 gdispImageGetPaletteSize_BMP(gdispImage *img) {
#endif
}
gColor gdispImageGetPalette_BMP(gdispImage *img, gU16 index) {
gColor gdispImageGetPalette_BMP(gImage *img, gU16 index) {
#if GDISP_NEED_IMAGE_BMP_1 || GDISP_NEED_IMAGE_BMP_4 || GDISP_NEED_IMAGE_BMP_8
gdispImagePrivate_BMP *priv;
@ -860,7 +870,7 @@ gColor gdispImageGetPalette_BMP(gdispImage *img, gU16 index) {
#endif
}
gBool gdispImageAdjustPalette_BMP(gdispImage *img, gU16 index, gColor newColor) {
gBool gdispImageAdjustPalette_BMP(gImage *img, gU16 index, gColor newColor) {
#if GDISP_NEED_IMAGE_BMP_1 || GDISP_NEED_IMAGE_BMP_4 || GDISP_NEED_IMAGE_BMP_8
gdispImagePrivate_BMP *priv;

View File

@ -106,7 +106,7 @@ typedef struct gdispImagePrivate_GIF {
*
* Pre: Frame info has been read.
*/
static gdispImageError startDecodeGif(gdispImage *img) {
static gdispImageError startDecodeGif(gImage *img) {
gdispImagePrivate_GIF * priv;
gifimgdecode * decode;
gU16 cnt;
@ -170,7 +170,7 @@ baddatacleanup:
*
* Pre: Frame info has been read.
*/
static void stopDecodeGif(gdispImage *img) {
static void stopDecodeGif(gImage *img) {
gdispImagePrivate_GIF * priv;
priv = (gdispImagePrivate_GIF *)img->priv;
@ -201,7 +201,7 @@ static gU16 getPrefixGif(gifimgdecode *decode, gU16 code) {
*
* Note: The resulting pixels are stored in decode->buf
*/
static gU16 getBytesGif(gdispImage *img) {
static gU16 getBytesGif(gImage *img) {
gdispImagePrivate_GIF * priv;
gifimgdecode * decode;
gU16 cnt;
@ -334,7 +334,7 @@ static gU16 getBytesGif(gdispImage *img) {
*
* Pre: The file position is at the start of the frame.
*/
static gdispImageError initFrameGif(gdispImage *img) {
static gdispImageError initFrameGif(gImage *img) {
gdispImagePrivate_GIF * priv;
gifimgcache * cache;
gU8 blocktype;
@ -493,7 +493,7 @@ static gdispImageError initFrameGif(gdispImage *img) {
}
}
void gdispImageClose_GIF(gdispImage *img) {
void gdispImageClose_GIF(gImage *img) {
gdispImagePrivate_GIF * priv;
gifimgcache * cache;
gifimgcache * ncache;
@ -514,7 +514,7 @@ void gdispImageClose_GIF(gdispImage *img) {
}
}
gdispImageError gdispImageOpen_GIF(gdispImage *img) {
gdispImageError gdispImageOpen_GIF(gImage *img) {
gdispImagePrivate_GIF *priv;
gU8 hdr[6];
gU16 aword;
@ -595,7 +595,7 @@ gdispImageError gdispImageOpen_GIF(gdispImage *img) {
}
}
gdispImageError gdispImageCache_GIF(gdispImage *img) {
gdispImageError gdispImageCache_GIF(gImage *img) {
gdispImagePrivate_GIF * priv;
gifimgcache * cache;
gifimgdecode * decode;
@ -766,7 +766,7 @@ baddatacleanup:
return GDISP_IMAGE_ERR_BADDATA;
}
gdispImageError gdispGImageDraw_GIF(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy) {
gdispImageError gdispGImageDraw_GIF(GDisplay *g, gImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy) {
gdispImagePrivate_GIF * priv;
gifimgdecode * decode;
gU8 * q = 0;
@ -1106,7 +1106,7 @@ baddatacleanup:
return GDISP_IMAGE_ERR_BADDATA;
}
gDelay gdispImageNext_GIF(gdispImage *img) {
gDelay gdispImageNext_GIF(gImage *img) {
gdispImagePrivate_GIF * priv;
gDelay delay;
gU8 blocksz;

View File

@ -50,19 +50,19 @@ typedef struct JDEC {
gU8* mcubuf; /* Working buffer for the MCU */
void* pool; /* Pointer to available memory pool */
unsigned sz_pool; /* Size of momory pool (bytes available) */
gdispImage* img; /* Pointer to I/O device identifiler for the session */
gImage* img; /* Pointer to I/O device identifiler for the session */
} JDEC;
/* TJpgDec API functions */
gdispImageError jd_prepare(JDEC*, void*, gdispImage*);
gdispImageError jd_decomp(JDEC*, unsigned(*)(gdispImage*,void*,JRECT*), gU8);
gdispImageError jd_prepare(JDEC*, void*, gImage*);
gdispImageError jd_decomp(JDEC*, unsigned(*)(gImage*,void*,JRECT*), gU8);
/*---------------------------------------------------------------------------*/
typedef struct gdispImagePrivate_JPG {
gPixel *frame0cache;
} gdispImagePrivate_JPG;
gdispImageError gdispImageOpen_JPG(gdispImage *img){
gdispImageError gdispImageOpen_JPG(gImage *img){
gdispImagePrivate_JPG *priv;
gU8 hdr[4];
unsigned len;
@ -119,7 +119,7 @@ gdispImageError gdispImageOpen_JPG(gdispImage *img){
}
}
void gdispImageClose_JPG(gdispImage *img){
void gdispImageClose_JPG(gImage *img){
gdispImagePrivate_JPG *priv = (gdispImagePrivate_JPG *)img->priv;
if(priv){
if (priv->frame0cache){
@ -129,7 +129,7 @@ void gdispImageClose_JPG(gdispImage *img){
}
}
static unsigned gdispImage_JPG_WriteToCache(gdispImage *img, void *bitmap, JRECT *rect)
static unsigned gdispImage_JPG_WriteToCache(gImage *img, void *bitmap, JRECT *rect)
{
gdispImagePrivate_JPG *priv;
gU8 *in;
@ -147,7 +147,7 @@ static unsigned gdispImage_JPG_WriteToCache(gdispImage *img, void *bitmap, JRECT
return 1;
}
gdispImageError gdispImageCache_JPG(gdispImage *img) {
gdispImageError gdispImageCache_JPG(gImage *img) {
gdispImagePrivate_JPG *priv;
JDEC *jd;
gdispImageError r;
@ -176,7 +176,7 @@ gdispImageError gdispImageCache_JPG(gdispImage *img) {
return r;
}
gdispImageError gdispGImageDraw_JPG(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy){
gdispImageError gdispGImageDraw_JPG(GDisplay *g, gImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy){
gdispImagePrivate_JPG * priv;
priv = (gdispImagePrivate_JPG *)img->priv;
@ -198,7 +198,7 @@ gdispImageError gdispGImageDraw_JPG(GDisplay *g, gdispImage *img, gCoord x, gCoo
return GDISP_IMAGE_ERR_OK;
}
gDelay gdispImageNext_JPG(gdispImage *img) {
gDelay gdispImageNext_JPG(gImage *img) {
(void) img;
/* No more frames/pages */
@ -766,7 +766,7 @@ gdispImageError mcu_load (
static
gdispImageError mcu_output (
JDEC* jd, /* Pointer to the decompressor object */
unsigned (*outfunc)(gdispImage*, void*, JRECT*), /* RGB output function */
unsigned (*outfunc)(gImage*, void*, JRECT*), /* RGB output function */
unsigned x, /* MCU position in the image (left of the MCU) */
unsigned y /* MCU position in the image (top of the MCU) */
)
@ -963,7 +963,7 @@ gdispImageError restart (
gdispImageError jd_prepare (
JDEC* jd, /* Blank decompressor object */
void* pool, /* Working buffer for the decompression session */
gdispImage* img /* I/O device identifier for the session */
gImage* img /* I/O device identifier for the session */
)
{
gU8 *seg, b;
@ -1124,7 +1124,7 @@ gdispImageError jd_prepare (
gdispImageError jd_decomp (
JDEC* jd, /* Initialized decompression object */
unsigned (*outfunc)(gdispImage*, void*, JRECT*), /* RGB output function */
unsigned (*outfunc)(gImage*, void*, JRECT*), /* RGB output function */
gU8 scale /* Output de-scaling factor (0 to 3) */
)
{

View File

@ -23,15 +23,15 @@
/**
* Helper Routines Needed
*/
void *gdispImageAlloc(gdispImage *img, gMemSize sz);
void gdispImageFree(gdispImage *img, void *ptr, gMemSize sz);
void *gdispImageAlloc(gImage *img, gMemSize sz);
void gdispImageFree(gImage *img, void *ptr, gMemSize sz);
typedef struct gdispImagePrivate_NATIVE {
gPixel *frame0cache;
gPixel buf[BLIT_BUFFER_SIZE_NATIVE];
} gdispImagePrivate_NATIVE;
void gdispImageClose_NATIVE(gdispImage *img) {
void gdispImageClose_NATIVE(gImage *img) {
gdispImagePrivate_NATIVE * priv;
priv = (gdispImagePrivate_NATIVE *)img->priv;
@ -43,7 +43,7 @@ void gdispImageClose_NATIVE(gdispImage *img) {
}
}
gdispImageError gdispImageOpen_NATIVE(gdispImage *img) {
gdispImageError gdispImageOpen_NATIVE(gImage *img) {
gU8 hdr[HEADER_SIZE_NATIVE];
/* Read the 8 byte header */
@ -70,7 +70,7 @@ gdispImageError gdispImageOpen_NATIVE(gdispImage *img) {
return GDISP_IMAGE_ERR_OK;
}
gdispImageError gdispImageCache_NATIVE(gdispImage *img) {
gdispImageError gdispImageCache_NATIVE(gImage *img) {
gMemSize len;
gdispImagePrivate_NATIVE * priv;
@ -93,7 +93,7 @@ gdispImageError gdispImageCache_NATIVE(gdispImage *img) {
return GDISP_IMAGE_ERR_OK;
}
gdispImageError gdispGImageDraw_NATIVE(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy) {
gdispImageError gdispGImageDraw_NATIVE(GDisplay *g, gImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy) {
gCoord mx, mcx;
gFileSize pos;
gMemSize len;
@ -141,7 +141,7 @@ gdispImageError gdispGImageDraw_NATIVE(GDisplay *g, gdispImage *img, gCoord x, g
return GDISP_IMAGE_ERR_OK;
}
gDelay gdispImageNext_NATIVE(gdispImage *img) {
gDelay gdispImageNext_NATIVE(gImage *img) {
(void) img;
/* No more frames/pages */

View File

@ -111,7 +111,7 @@ typedef struct PNG_zinflate {
// Put all the decoding structures together.
// Note this is immediately followed by 2 scan lines of uncompressed image data for filtering (dynamic size).
typedef struct PNG_decode {
gdispImage *img;
gImage *img;
PNG_info *pinfo;
PNG_input i;
PNG_output o;
@ -1127,7 +1127,7 @@ static gBool PNG_unfilter_type0(PNG_decode *d) { // PNG filter method 0
* Public PNG functions
*---------------------------------------------------------------*/
void gdispImageClose_PNG(gdispImage *img) {
void gdispImageClose_PNG(gImage *img) {
PNG_info *pinfo;
pinfo = (PNG_info *)img->priv;
@ -1141,7 +1141,7 @@ void gdispImageClose_PNG(gdispImage *img) {
}
}
gdispImageError gdispImageOpen_PNG(gdispImage *img) {
gdispImageError gdispImageOpen_PNG(gImage *img) {
PNG_info *pinfo;
gU32 pos;
gU32 len;
@ -1497,7 +1497,7 @@ exit_nonmem:
return GDISP_IMAGE_ERR_NOMEMORY;
}
gdispImageError gdispGImageDraw_PNG(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy) {
gdispImageError gdispGImageDraw_PNG(GDisplay *g, gImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy) {
PNG_info *pinfo;
PNG_decode *d;
@ -1546,7 +1546,7 @@ exit_baddata:
return GDISP_IMAGE_ERR_BADDATA;
}
gdispImageError gdispImageCache_PNG(gdispImage *img) {
gdispImageError gdispImageCache_PNG(gImage *img) {
PNG_info *pinfo;
unsigned chunknext;
unsigned chunklen;
@ -1621,7 +1621,7 @@ baddata:
return GDISP_IMAGE_ERR_BADDATA;
}
gDelay gdispImageNext_PNG(gdispImage *img) {
gDelay gdispImageNext_PNG(gImage *img) {
(void) img;
/* No more frames/pages */

View File

@ -120,8 +120,8 @@
#endif
void *gdispImageAlloc(gdispImage *img, gMemSize sz);
void gdispImageFree(gdispImage *img, void *ptr, gMemSize sz);
void *gdispImageAlloc(gImage *img, gMemSize sz);
void gdispImageFree(gImage *img, void *ptr, gMemSize sz);
#if GFX_CPU_ENDIAN == GFX_CPU_ENDIAN_UNKNOWN
extern const gU8 gdispImageEndianArray[4];

View File

@ -389,8 +389,8 @@
#define GDISP_NEED_IMAGE_BMP_32 GFXON
#endif
/**
* @brief The BMP blit buffer size.
* @details Defaults to 32
* @brief The BMP blit buffer size in pixels.
* @details Defaults to 32 pixels
* @note Bigger is faster but requires more RAM.
* @note This must be greater than 40 bytes and 32 pixels as we read our headers into this space as well.
*/

View File

@ -63,13 +63,13 @@ gPixel *gdispPixmapGetBits(GDisplay *g);
#if GDISP_NEED_PIXMAP_IMAGE || defined(__DOXYGEN__)
/**
* @brief Get a pointer to a native format gdispImage.
* @return A pointer to a NATIVE format gdispImage in memory or NULL if this display is not a pixmap.
* @brief Get a pointer to a native format gImage.
* @return A pointer to a NATIVE format gImage in memory or NULL if this display is not a pixmap.
* @pre GDISP_NEED_PIXAMP_IMAGE must be GFXON in your gfxconf.h
*
* @param[in] g The pixmap virtual display
*
* @return The pointer to the native gdispImage
* @return The pointer to the native gImage
*
* @note The pointer returned can be passed to @p gdispImageOpenMemory() or to @p gfileOpenMemory().
* @note If you are just wanting to copy to a real display it is more efficient to use @p gdispGetPixmapBits() and @p gdispGBlitArea().

View File

@ -0,0 +1,9 @@
set(ROOT_PATH ${UGFX_ROOT}/src/gdriver)
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/gdriver.c
)

View File

@ -86,8 +86,16 @@ typedef struct GDriverVMT {
* const GDriverVMT const * mylist = { DRIVER_LIST };
* </code>
*
* @note This could be one single typedef. However, some major compilers complain about duplicate const specifiers even though this is perfectly
* valid standard C. As this problem has become worse over time we opt for splitting this into two separate typedefs to prevent these
* compilers from throwing warnings.
* The single typedef would look like this:
* <code>
* typedef const struct GDriverVMT const GDriverVMTList[1];
* </code>
*/
typedef const struct GDriverVMT const GDriverVMTList[1];
typedef const struct GDriverVMT ConstGDriverVMT;
typedef ConstGDriverVMT const GDriverVMTList[1];
/*===========================================================================*/
/* External declarations. */

View File

@ -0,0 +1,9 @@
set(ROOT_PATH ${UGFX_ROOT}/src/gevent)
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/gevent.c
)

View File

@ -36,8 +36,11 @@
/**
* The order of the file-systems below determines the order
* that they are searched to find a file.
*
* This should read: static const GFILEVMT const * FsArray[] = {
* However, some major C compilers complain about duplicate const specifiers although this is perfectly valid standard C.
*/
static const GFILEVMT const * FsArray[] = {
static const GFILEVMT* FsArray[] = {
#if GFILE_NEED_USERFS
&FsUSERVMT,
#endif

View File

@ -0,0 +1,24 @@
set(ROOT_PATH ${UGFX_ROOT}/src/gfile)
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/gfile.c
${ROOT_PATH}/gfile_fs_native.c
${ROOT_PATH}/gfile_fs_ram.c
${ROOT_PATH}/gfile_fs_rom.c
${ROOT_PATH}/gfile_fs_fatfs.c
${ROOT_PATH}/gfile_fs_petitfs.c
${ROOT_PATH}/gfile_fs_mem.c
${ROOT_PATH}/gfile_fs_chibios.c
${ROOT_PATH}/gfile_fs_strings.c
${ROOT_PATH}/gfile_printg.c
${ROOT_PATH}/gfile_scang.c
${ROOT_PATH}/gfile_stdio.c
${ROOT_PATH}/gfile_fatfs_wrapper.c
${ROOT_PATH}/gfile_fatfs_diskio_chibios.c
${ROOT_PATH}/gfile_petitfs_wrapper.c
${ROOT_PATH}/gfile_petitfs_diskio_chibios.c
)

View File

@ -34,7 +34,12 @@ typedef struct ROMFS_DIRENTRY {
#define ROMFS_DIRENTRY_HEAD 0
#include "romfs_files.h"
static const ROMFS_DIRENTRY const *FsROMHead = ROMFS_DIRENTRY_HEAD;
/*
* This should be: static const ROMFS_DIRENTRY const *FsROMHead = ROMFS_DIRENTRY_HEAD;
* However, some major compilers complain about the duplicate const specifier even though this is perfectly valid standard C.
*/
static const ROMFS_DIRENTRY *FsROMHead = ROMFS_DIRENTRY_HEAD;
typedef struct ROMFileList {
gfileList fl;

View File

@ -54,7 +54,8 @@ static char *ltoa_wd(char *p, long num, unsigned radix, long divisor) {
int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg) {
int ret;
char *p, *s, c, filler;
char *p, c, filler;
const char *s;
int i, precision, width;
gBool is_long, left_align;
long l;
@ -80,7 +81,7 @@ int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg) {
}
fmt++;
p = s = tmpbuf;
s = p = tmpbuf;
left_align = gFalse;
filler = ' ';
width = 0;
@ -140,7 +141,7 @@ int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg) {
s = "(null)";
if (precision == 0)
precision = 32767;
for (p = s; *p && (--precision >= 0); p++);
for (p = (char*)s; *p && (--precision >= 0); p++);
break;
case 'D':
case 'd':

View File

@ -0,0 +1,14 @@
set(ROOT_PATH ${UGFX_ROOT}/src/ginput)
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/ginput.c
${ROOT_PATH}/ginput_mouse.c
${ROOT_PATH}/ginput_keyboard.c
${ROOT_PATH}/ginput_keyboard_microcode.c
${ROOT_PATH}/ginput_toggle.c
${ROOT_PATH}/ginput_dial.c
)

View File

@ -663,7 +663,11 @@ void _gmouseInit(void) {
// One and only one mouse
#else
{
extern const GMouseVMT const GMOUSEVMT_OnlyOne[1];
/*
* This should be: extern const GMouseVMT const GMOUSEVMT_OnlyOne[1];
* However, some major compilers complain about the duplicate const specifier even though this is perfectly valid standard C.
*/
extern const GMouseVMT GMOUSEVMT_OnlyOne[1];
if (!(GMOUSEVMT_OnlyOne->d.flags & GMOUSE_VFLG_DYNAMICONLY))
gdriverRegister(&GMOUSEVMT_OnlyOne->d, GDISP);
@ -833,4 +837,3 @@ void _gmouseWakeupI(GMouse *m) {
}
#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */
/** @} */

View File

@ -0,0 +1,13 @@
set(ROOT_PATH ${UGFX_ROOT}/src/gmisc)
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/gmisc.c
${ROOT_PATH}/gmisc_arrayops.c
${ROOT_PATH}/gmisc_matrix2d.c
${ROOT_PATH}/gmisc_trig.c
${ROOT_PATH}/gmisc_hittest.c
)

22
src/gos/gos.cmake 100644
View File

@ -0,0 +1,22 @@
set(ROOT_PATH ${UGFX_ROOT}/src/gos)
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/gos_chibios.c
${ROOT_PATH}/gos_freertos.c
${ROOT_PATH}/gos_win32.c
${ROOT_PATH}/gos_linux.c
${ROOT_PATH}/gos_osx.c
${ROOT_PATH}/gos_raw32.c
${ROOT_PATH}/gos_ecos.c
${ROOT_PATH}/gos_rawrtos.c
${ROOT_PATH}/gos_arduino.c
${ROOT_PATH}/gos_cmsis.c
${ROOT_PATH}/gos_nios.c
${ROOT_PATH}/gos_zephyr.c
${ROOT_PATH}/gos_x_threads.c
${ROOT_PATH}/gos_x_heap.c
)

View File

@ -468,6 +468,8 @@
#include "gos_win32.h"
#elif GFX_USE_OS_LINUX
#include "gos_linux.h"
#elif GFX_USE_OS_FREEBSD
#include "gos_linux.h"
#elif GFX_USE_OS_OSX
#include "gos_osx.h"
#elif GFX_USE_OS_RAW32

View File

@ -11,7 +11,7 @@
#include <string.h>
#if CH_KERNEL_MAJOR < 2 || CH_KERNEL_MAJOR > 5
#if CH_KERNEL_MAJOR < 2 || CH_KERNEL_MAJOR > 7
#error "GOS: Unsupported version of ChibiOS"
#endif

View File

@ -35,7 +35,11 @@
#endif
typedef systime_t gTicks;
typedef cnt_t gSemcount;
#if CH_KERNEL_MAJOR >= 6
typedef void gThreadreturn;
#else
typedef msg_t gThreadreturn;
#endif
typedef tprio_t gThreadpriority;
#define gSemMaxCount ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
@ -45,7 +49,12 @@ typedef tprio_t gThreadpriority;
#define GFX_THREAD_STACK(name, sz) WORKING_AREA(name, sz)
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
#if CH_KERNEL_MAJOR >= 6
#define gfxThreadReturn(retval) return
#else
#define gfxThreadReturn(retval) return retval
#endif
#if CH_KERNEL_MAJOR <= 2
typedef struct {

View File

@ -10,7 +10,7 @@
#include "../../gfx.h"
#if GFX_USE_OS_LINUX
#if GFX_USE_OS_LINUX || GFX_USE_OS_FREEBSD
// Linux seems to have deprecated pthread_yield() and now says to use sched_yield()
#define USE_SCHED_NOT_PTHREAD_YIELD GFXON
@ -238,4 +238,4 @@ gThreadreturn gfxThreadWait(gThread thread) {
}
#endif // GFX_USE_POSIX_SEMAPHORES
#endif /* GFX_USE_OS_LINUX */
#endif /* GFX_USE_OS_LINUX || GFX_USE_OS_FREEBSD */

View File

@ -8,7 +8,7 @@
#ifndef _GOS_LINUX_H
#define _GOS_LINUX_H
#if GFX_USE_OS_LINUX
#if GFX_USE_OS_LINUX || GFX_USE_OS_FREEBSD
// We don't put this in the general sys_options.h as it is Linux specific.
#ifndef GFX_USE_POSIX_SEMAPHORES
@ -88,6 +88,6 @@ void gfxSemSignal(gSem *psem);
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
gThreadreturn gfxThreadWait(gThread thread);
#endif /* GFX_USE_OS_LINUX */
#endif /* GFX_USE_OS_LINUX || GFX_USE_OS_FREEBSD */
#endif /* _GOS_LINUX_H */

View File

@ -48,6 +48,13 @@
#ifndef GFX_USE_OS_LINUX
#define GFX_USE_OS_LINUX GFXOFF
#endif
/**
* @brief Use a FreeBSD based system running X11
* @details Defaults to GFXOFF
*/
#ifndef GFX_USE_OS_FREEBSD
#define GFX_USE_OS_FREEBSD GFXOFF
#endif
/**
* @brief Use a Mac OS-X based system
* @details Defaults to GFXOFF

View File

@ -16,11 +16,11 @@
#ifndef _GOS_RULES_H
#define _GOS_RULES_H
#if !GFX_USE_OS_CHIBIOS && !GFX_USE_OS_WIN32 && !GFX_USE_OS_LINUX && !GFX_USE_OS_OSX && !GFX_USE_OS_RAW32 && !GFX_USE_OS_FREERTOS && !GFX_USE_OS_ECOS && !GFX_USE_OS_RAWRTOS && !GFX_USE_OS_ARDUINO && !GFX_USE_OS_CMSIS && !GFX_USE_OS_CMSIS2 && !GFX_USE_OS_KEIL && !GFX_USE_OS_RTX5 && !GFX_USE_OS_NIOS && !GFX_USE_OS_ZEPHYR && !GFX_USE_OS_QT
#if !GFX_USE_OS_CHIBIOS && !GFX_USE_OS_WIN32 && !GFX_USE_OS_LINUX && !GFX_USE_OS_FREEBSD && !GFX_USE_OS_OSX && !GFX_USE_OS_RAW32 && !GFX_USE_OS_FREERTOS && !GFX_USE_OS_ECOS && !GFX_USE_OS_RAWRTOS && !GFX_USE_OS_ARDUINO && !GFX_USE_OS_CMSIS && !GFX_USE_OS_CMSIS2 && !GFX_USE_OS_KEIL && !GFX_USE_OS_RTX5 && !GFX_USE_OS_NIOS && !GFX_USE_OS_ZEPHYR && !GFX_USE_OS_QT
#error "GOS: No operating system has been defined."
#endif
#if GFX_USE_OS_CHIBIOS + GFX_USE_OS_WIN32 + GFX_USE_OS_LINUX + GFX_USE_OS_OSX + GFX_USE_OS_RAW32 + GFX_USE_OS_FREERTOS + GFX_USE_OS_ECOS + GFX_USE_OS_RAWRTOS + GFX_USE_OS_ARDUINO + GFX_USE_OS_CMSIS + GFX_USE_OS_CMSIS2 + GFX_USE_OS_KEIL + GFX_USE_OS_RTX5 + GFX_USE_OS_NIOS + GFX_USE_OS_ZEPHYR + GFX_USE_OS_QT != 1 * GFXON
#if GFX_USE_OS_CHIBIOS + GFX_USE_OS_WIN32 + GFX_USE_OS_LINUX + GFX_USE_OS_FREEBSD + GFX_USE_OS_OSX + GFX_USE_OS_RAW32 + GFX_USE_OS_FREERTOS + GFX_USE_OS_ECOS + GFX_USE_OS_RAWRTOS + GFX_USE_OS_ARDUINO + GFX_USE_OS_CMSIS + GFX_USE_OS_CMSIS2 + GFX_USE_OS_KEIL + GFX_USE_OS_RTX5 + GFX_USE_OS_NIOS + GFX_USE_OS_ZEPHYR + GFX_USE_OS_QT != 1 * GFXON
#error "GOS: More than one operation system has been defined as GFXON."
#endif
@ -33,7 +33,7 @@
#endif
#if GFX_EMULATE_MALLOC
#if GFX_USE_OS_WIN32 || GFX_USE_OS_LINUX || GFX_USE_OS_OSX || GFX_USE_OS_ECOS || \
#if GFX_USE_OS_WIN32 || GFX_USE_OS_LINUX || GFX_USE_OS_FREEBSD || GFX_USE_OS_OSX || GFX_USE_OS_ECOS || \
(GFX_OS_HEAP_SIZE == 0 && (GFX_USE_OS_RAW32 || GFX_USE_OS_ARDUINO || GFX_USE_OS_CMSIS || GFX_USE_OS_CMSIS2 || GFX_USE_OS_KEIL || GFX_USE_OS_RTX5))
#if GFX_DISPLAY_RULE_WARNINGS
#if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT

View File

@ -127,5 +127,3 @@ gThreadreturn gfxThreadWait(gThread thread) {
}
#endif /* GFX_USE_OS_WIN32 */
/** @} */

View File

@ -6,7 +6,7 @@
*/
/**
* @file src/gos/gos_zepyhr.h
* @file src/gos/gos_zephyr.h
* @brief GOS - Operating System Support header file for Zephyr RTOS.
* Zephyr SDK 0.9.1
*/
@ -90,4 +90,3 @@ gTicks gfxSystemTicks();
#endif /* GFX_USE_OS_ZEPHYR */
#endif /* _GOS_H */
/** @} */

View File

@ -321,7 +321,7 @@ void _gqueueDeinit(void)
}
gBool gfxQueueFSyncPut(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gDelay ms) {
if (!pitem) return; // Safety
if (!pitem) return gFalse; // Safety
gfxSemInit(&pitem->sem, 0, 1);
pitem->next = 0;
@ -340,7 +340,7 @@ void _gqueueDeinit(void)
}
gBool gfxQueueFSyncPush(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gDelay ms) {
if (!pitem) return; // Safety
if (!pitem) return gFalse; // Safety
gfxSemInit(&pitem->sem, 0, 1);
gfxSystemLock();
@ -356,7 +356,7 @@ void _gqueueDeinit(void)
}
gBool gfxQueueFSyncInsert(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gfxQueueFSyncItem *pafter, gDelay ms) {
if (!pitem) return; // Safety
if (!pitem) return gFalse; // Safety
gfxSemInit(&pitem->sem, 0, 1);
gfxSystemLock();

View File

@ -0,0 +1,9 @@
set(ROOT_PATH ${UGFX_ROOT}/src/gqueue)
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/gqueue.c
)

View File

@ -0,0 +1,9 @@
set(ROOT_PATH ${UGFX_ROOT}/src/gtimer)
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/gtimer.c
)

View File

@ -51,7 +51,7 @@ const char* gtransString(const char* string)
return _languageCurrent->strings[i];
}
const char* gtransIndex(unsigned index)
const char* gtransIndex(gU32 index)
{
if (!_languageCurrent) {
return 0;

View File

@ -0,0 +1,9 @@
set(ROOT_PATH ${UGFX_ROOT}/src/gtrans)
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/gtrans.c
)

View File

@ -27,7 +27,7 @@
* @brief A table containing translated strings.
*/
typedef struct transTable {
unsigned numEntries; /**< The number of strings that this table contains */
gU32 numEntries; /**< The number of strings that this table contains */
const char** strings; /**< The translated strings */
} transTable;
@ -59,7 +59,7 @@ const char* gtransString(const char* string);
*
* @return The string at the given index of the current language or 0 if it doesn't exist.
*/
const char* gtransIndex(unsigned index);
const char* gtransIndex(gU32 index);
/**
* @brief Set the base language.

View File

@ -403,7 +403,7 @@ void gwinBlitArea(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord s
#endif
#if GDISP_NEED_IMAGE
gdispImageError gwinDrawImage(GHandle gh, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy) {
gdispImageError gwinDrawImage(GHandle gh, gImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy) {
gdispImageError ret;
if (!_gwinDrawStart(gh)) return GDISP_IMAGE_ERR_OK;
@ -414,5 +414,3 @@ void gwinBlitArea(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord s
#endif
#endif /* GFX_USE_GWIN */
/** @} */

View File

@ -0,0 +1,30 @@
set(ROOT_PATH ${UGFX_ROOT}/src/gwin)
list(APPEND ugfx_INCLUDE_DIRS
${ROOT_PATH}
${UGFX_ROOT}/3rdparty/tinygl-0.4-ugfx/include
)
list(APPEND ugfx_SOURCES
${ROOT_PATH}/gwin.c
${ROOT_PATH}/gwin_widget.c
${ROOT_PATH}/gwin_wm.c
${ROOT_PATH}/gwin_console.c
${ROOT_PATH}/gwin_graph.c
${ROOT_PATH}/gwin_button.c
${ROOT_PATH}/gwin_slider.c
${ROOT_PATH}/gwin_checkbox.c
${ROOT_PATH}/gwin_image.c
${ROOT_PATH}/gwin_label.c
${ROOT_PATH}/gwin_radio.c
${ROOT_PATH}/gwin_list.c
${ROOT_PATH}/gwin_progressbar.c
${ROOT_PATH}/gwin_progressbar.c
${ROOT_PATH}/gwin_container.c
${ROOT_PATH}/gwin_frame.c
${ROOT_PATH}/gwin_tabset.c
${ROOT_PATH}/gwin_gl3d.c
${ROOT_PATH}/gwin_keyboard.c
${ROOT_PATH}/gwin_keyboard_layout.c
${ROOT_PATH}/gwin_textedit.c
)

Some files were not shown because too many files have changed in this diff Show More