Merge branch 'master' into gwin

ugfx_release_2.6
inmarket 2014-05-01 18:10:31 +10:00
commit cb99e4ab09
34 changed files with 1691 additions and 1991 deletions

1
.gitignore vendored
View File

@ -9,4 +9,5 @@ build
*.lst
*.o
*.map
*.sublime-*
src/gdisp/fonts/*.dat

View File

@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.
PROJECT_NAME = uGFX
PROJECT_NAME =
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
@ -44,14 +44,14 @@ PROJECT_NUMBER = 2.0
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.
PROJECT_BRIEF =
PROJECT_BRIEF = "version 2.0"
# With the PROJECT_LOGO tag one can specify an logo or icon that is included in
# the documentation. The maximum height of the logo should not exceed 55 pixels
# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo
# to the output directory.
PROJECT_LOGO =
PROJECT_LOGO = docs/rsc/ugfx_logo_doxygen.png
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
# into which the generated documentation will be written. If a relative path is
@ -230,13 +230,11 @@ TAB_SIZE = 2
# "Side Effects:". You can put \n's in the value part of an alias to insert
# newlines.
ALIASES = "iclass=@par Function Class:\n This is an <b>I-Class</b> API, this function can be invoked from within a system lock zone by both threads and interrupt handlers." \
"sclass=@par Function Class:\n This is an <b>S-Class</b> API, this function can be invoked from within a system lock zone by threads only." \
"api=@par Function Class:\n Normal API, this function can be invoked by regular system threads but not from within a lock zone." \
"notapi=@par Function Class:\n Not an API, this function is for internal use only." \
"isr=@par Function Class:\n Interrupt handler, this function should not be directly invoked." \
"init=@par Function Class:\n Initializer, this function just initializes an object and can be invoked before the kernel is initialized." \
"special=@par Function Class:\n Special function, this function has special requirements see the notes."
ALIASES = "iclass=@par Function Class:\n This is an <b>I-Class</b> API, this function can be invoked from within a system lock zone by both threads and interrupt handlers." \
"sclass=@par Function Class:\n This is an <b>S-Class</b> API, this function can be invoked from within a system lock zone by threads only." \
"api=@par Function Class:\n Normal API, this function can be invoked by regular system threads." \
"notapi=@par Function Class:\n Not an API, this function is for internal use only." \
"isr=@par Function Class:\n Interrupt handler, this function should not be directly invoked."
# This tag can be used to specify a number of word-keyword mappings (TCL only).
# A mapping has the form "name=value". For example adding "class=itcl::class"
@ -755,7 +753,7 @@ WARN_LOGFILE =
# spaces.
# Note: If this tag is empty the current directory is searched.
INPUT =
INPUT = .
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@ -2051,7 +2049,7 @@ PERL_PATH = /usr/bin/perl
# powerful graphs.
# The default value is: YES.
CLASS_DIAGRAMS = YES
CLASS_DIAGRAMS = NO
# You can define message sequence charts within doxygen comments using the \msc
# command. Doxygen will then run the mscgen tool (see:
@ -2124,7 +2122,7 @@ DOT_FONTPATH =
# The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES.
CLASS_GRAPH = YES
CLASS_GRAPH = NO
# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a
# graph for each documented class showing the direct and indirect implementation
@ -2198,7 +2196,7 @@ INCLUDED_BY_GRAPH = NO
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
CALL_GRAPH = YES
CALL_GRAPH = NO
# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
# dependency graph for every global function or class method.

View File

@ -3,3 +3,4 @@ GFXSRC +=
GFXDEFS += -DGFX_USE_OS_CHIBIOS=TRUE
include $(GFXLIB)/drivers/gdisp/ILI9341/gdisp_lld.mk
include $(GFXLIB)/drivers/ginput/touch/MCU/ginput_lld.mk
include $(GFXLIB)/drivers/gaudio/vs1053/driver.mk

View File

@ -0,0 +1,97 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#ifndef GAUDIO_PLAY_BOARD_H
#define GAUDIO_PLAY_BOARD_H
#define SET_CS palSetPad(GPIOC, GPIOC_MP3_CS)
#define CLR_CS palClearPad(GPIOC, GPIOC_MP3_CS)
#define SET_RST palSetPad(GPIOC, GPIOC_MP3_RST)
#define CLR_RST palClearPad(GPIOC, GPIOC_MP3_RST)
#define SET_DCS palSetPad(GPIOC, GPIOC_MP3_DCS)
#define CLR_DCS palClearPad(GPIOC, GPIOC_MP3_DCS)
#define GET_DREQ palReadPad(GPIOC, GPIOC_MP3_DREQ)
#define SPI_PORT &SPID3
static const SPIConfig spicfg_init = {
0,
GPIOC,
GPIOC_MP3_CS,
SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0,
};
static const SPIConfig spicfg = {
0,
GPIOC,
GPIOC_MP3_CS,
SPI_CR1_BR_0,
};
// Initialise the board
static inline void board_init(void) {
palSetPadMode(GPIOC, GPIOC_MP3_CS, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOC, GPIOC_MP3_RST, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOC, GPIOC_MP3_DCS, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOC, GPIOC_MP3_DREQ, PAL_MODE_INPUT);
SET_CS; SET_RST; SET_DCS;
spiStart(SPI_PORT, &spicfg_init);
}
// Chip is initialised enough so we can talk fast to it
#define board_init_end() spiStart(SPI_PORT, &spicfg)
// Reset the board
#define board_reset() { CLR_RST; gfxSleepMilliseconds(1); SET_RST; }
// Returns the state of the dreq pin
#define board_dreq() GET_DREQ
// Start a command write
static inline void board_startcmdwrite(void) {
#if SPI_USE_MUTUAL_EXCLUSION
spiAcquireBus(SPI_PORT);
#endif
CLR_CS;
}
// End a command write
static inline void board_endcmdwrite(void) {
SET_CS;
#if SPI_USE_MUTUAL_EXCLUSION
spiReleaseBus(SPI_PORT);
#endif
}
// Start a command read
#define board_startcmdread() board_startcmdwrite()
// End a command read
#define board_endcmdread() board_endcmdwrite()
// Start a data write
static inline void board_startdatawrite(void) {
#if SPI_USE_MUTUAL_EXCLUSION
spiAcquireBus(SPI_PORT);
#endif
CLR_DCS;
}
// End a data write
static inline void board_enddatawrite(void) {
#if SPI_USE_MUTUAL_EXCLUSION
spiReleaseBus(SPI_PORT);
#endif
SET_DCS;
}
// Write data to the SPI port
#define board_spiwrite(buf, len) spiSend(SPI_PORT, len, buf)
// Read data from the SPI port
#define board_spiread(buf, len) spiReceive(SPI_PORT, len, buf)
#endif /* GAUDIO_PLAY_BOARD_H */

View File

@ -3,7 +3,8 @@ running under ChibiOS with the ILI9341 display.
On this board uGFX currently supports:
- GDISP via the ILI9341 display
- GINPUT-touch via the MCU driver
- GINPUT-touch via the MCU driver
- GAUDIO (play only) via the vs1053 driver
Note there are two variants of this board - one with the ILI9341 display
and an older one with a different display. This one is for the ILI9341 display.

View File

@ -0,0 +1,3 @@
DEMODIR = $(GFXLIB)/demos/modules/gwin/label
GFXINC += $(DEMODIR)
GFXSRC += $(DEMODIR)/main.c

View File

@ -0,0 +1,243 @@
/**
* This file has a different license to the rest of the uGFX system.
* You can copy, modify and distribute this file as you see fit.
* You do not need to publish your source modifications to this file.
* The only thing you are not permitted to do is to relicense it
* under a different license.
*/
/**
* Copy this file into your project directory and rename it as gfxconf.h
* Edit your copy to turn on the uGFX features you want to use.
* The values below are the defaults. You should delete anything
* you are leaving as default.
*
* Please use spaces instead of tabs in this file.
*/
#ifndef _GFXCONF_H
#define _GFXCONF_H
/* The operating system to use. One of these must be defined - preferably in your Makefile */
//#define GFX_USE_OS_CHIBIOS TRUE
//#define GFX_USE_OS_WIN32 TRUE
//#define GFX_USE_OS_LINUX TRUE
//#define GFX_USE_OS_OSX TRUE
///////////////////////////////////////////////////////////////////////////
// GDISP //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GDISP TRUE
#define GDISP_NEED_AUTOFLUSH FALSE
#define GDISP_NEED_TIMERFLUSH FALSE
#define GDISP_NEED_VALIDATION TRUE
#define GDISP_NEED_CLIP TRUE
#define GDISP_NEED_CIRCLE FALSE
#define GDISP_NEED_ELLIPSE FALSE
#define GDISP_NEED_ARC FALSE
#define GDISP_NEED_CONVEX_POLYGON FALSE
#define GDISP_NEED_SCROLL FALSE
#define GDISP_NEED_PIXELREAD FALSE
#define GDISP_NEED_CONTROL FALSE
#define GDISP_NEED_QUERY FALSE
#define GDISP_NEED_MULTITHREAD FALSE
#define GDISP_NEED_STREAMING FALSE
#define GDISP_NEED_TEXT TRUE
#define GDISP_NEED_ANTIALIAS TRUE
#define GDISP_NEED_UTF8 TRUE
#define GDISP_NEED_TEXT_KERNING TRUE
#define GDISP_INCLUDE_FONT_UI1 FALSE
#define GDISP_INCLUDE_FONT_UI2 FALSE
#define GDISP_INCLUDE_FONT_LARGENUMBERS FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS10 FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS12 TRUE
#define GDISP_INCLUDE_FONT_DEJAVUSANS16 FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS24 FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS32 FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12 FALSE
#define GDISP_INCLUDE_FONT_FIXED_10X20 FALSE
#define GDISP_INCLUDE_FONT_FIXED_7X14 FALSE
#define GDISP_INCLUDE_FONT_FIXED_5X8 FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS12_AA FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS16_AA FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS24_AA FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS32_AA FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12_AA FALSE
#define GDISP_INCLUDE_USER_FONTS FALSE
#define GDISP_NEED_IMAGE FALSE
#define GDISP_NEED_IMAGE_NATIVE FALSE
#define GDISP_NEED_IMAGE_GIF FALSE
#define GDISP_NEED_IMAGE_BMP FALSE
#define GDISP_NEED_IMAGE_BMP_1 FALSE
#define GDISP_NEED_IMAGE_BMP_4 FALSE
#define GDISP_NEED_IMAGE_BMP_4_RLE FALSE
#define GDISP_NEED_IMAGE_BMP_8 FALSE
#define GDISP_NEED_IMAGE_BMP_8_RLE FALSE
#define GDISP_NEED_IMAGE_BMP_16 FALSE
#define GDISP_NEED_IMAGE_BMP_24 FALSE
#define GDISP_NEED_IMAGE_BMP_32 FALSE
#define GDISP_NEED_IMAGE_JPG FALSE
#define GDISP_NEED_IMAGE_PNG FALSE
#define GDISP_NEED_IMAGE_ACCOUNTING FALSE
#define GDISP_NEED_STARTUP_LOGO FALSE
#define GDISP_DEFAULT_ORIENTATION GDISP_ROTATE_LANDSCAPE
#define GDISP_LINEBUF_SIZE 128
#define GDISP_TOTAL_DISPLAYS 1
#if GDISP_TOTAL_DISPLAYS > 1
#define GDISP_HARDWARE_STREAM_WRITE FALSE
#define GDISP_HARDWARE_STREAM_READ FALSE
#define GDISP_HARDWARE_STREAM_POS FALSE
#define GDISP_HARDWARE_DRAWPIXEL FALSE
#define GDISP_HARDWARE_CLEARS FALSE
#define GDISP_HARDWARE_FILLS FALSE
#define GDISP_HARDWARE_BITFILLS FALSE
#define GDISP_HARDWARE_SCROLL FALSE
#define GDISP_HARDWARE_PIXELREAD FALSE
#define GDISP_HARDWARE_CONTROL FALSE
#define GDISP_HARDWARE_QUERY FALSE
#define GDISP_HARDWARE_CLIP FALSE
#endif
#define GDISP_TOTAL_CONTROLLERS 1
#if GDISP_TOTAL_CONTROLLERS > 1
#define GDISP_CONTROLLER_LIST GDISPVMT_Win32, GDISPVMT_Win32
#define GDISP_CONTROLLER_DISPLAYS 1, 1
#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
#endif
#define GDISP_USE_GFXNET FALSE
#define GDISP_GFXNET_PORT 13001
#define GDISP_GFXNET_CUSTOM_LWIP_STARTUP FALSE
#define GDISP_DONT_WAIT_FOR_NET_DISPLAY FALSE
#define GDISP_GFXNET_UNSAFE_SOCKETS FALSE
///////////////////////////////////////////////////////////////////////////
// GWIN //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GWIN TRUE
#define GWIN_NEED_WINDOWMANAGER TRUE
#define GWIN_NEED_CONSOLE FALSE
#define GWIN_CONSOLE_USE_HISTORY FALSE
#define GWIN_CONSOLE_HISTORY_AVERAGING FALSE
#define GWIN_CONSOLE_HISTORY_ATCREATE FALSE
#define GWIN_CONSOLE_ESCSEQ FALSE
#define GWIN_CONSOLE_USE_BASESTREAM FALSE
#define GWIN_CONSOLE_USE_FLOAT FALSE
#define GWIN_NEED_GRAPH FALSE
#define GWIN_NEED_WIDGET FALSE
#define GWIN_NEED_HIERARCHY FALSE
#define GWIN_NEED_LABEL TRUE
#define GWIN_LABEL_ATTRIBUTE TRUE
#define GWIN_NEED_BUTTON FALSE
#define GWIN_BUTTON_LAZY_RELEASE FALSE
#define GWIN_NEED_SLIDER FALSE
#define GWIN_NEED_CHECKBOX FALSE
#define GWIN_NEED_IMAGE FALSE
#define GWIN_NEED_IMAGE_ANIMATION FALSE
#define GWIN_NEED_RADIO FALSE
#define GWIN_NEED_LIST FALSE
#define GWIN_NEED_LIST_IMAGES FALSE
#define GWIN_NEED_PROGRESSBAR FALSE
#define GWIN_NEED_FRAME FALSE
///////////////////////////////////////////////////////////////////////////
// GEVENT //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GEVENT TRUE
#define GEVENT_ASSERT_NO_RESOURCE FALSE
#define GEVENT_MAXIMUM_SIZE 32
#define GEVENT_MAX_SOURCE_LISTENERS 32
///////////////////////////////////////////////////////////////////////////
// GTIMER //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GTIMER TRUE
#define GTIMER_THREAD_PRIORITY HIGH_PRIORITY
#define GTIMER_THREAD_WORKAREA_SIZE 2048
///////////////////////////////////////////////////////////////////////////
// GQUEUE //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GQUEUE TRUE
#define GQUEUE_NEED_ASYNC TRUE
#define GQUEUE_NEED_GSYNC FALSE
#define GQUEUE_NEED_FSYNC FALSE
#define GQUEUE_NEED_BUFFERS FALSE
///////////////////////////////////////////////////////////////////////////
// GINPUT //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GINPUT TRUE
#define GINPUT_NEED_MOUSE TRUE
#define GINPUT_NEED_KEYBOARD FALSE
#define GINPUT_NEED_TOGGLE FALSE
#define GINPUT_NEED_DIAL FALSE
///////////////////////////////////////////////////////////////////////////
// GFILE //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GFILE FALSE
#define GFILE_NEED_PRINTG FALSE
#define GFILE_NEED_SCANG FALSE
#define GFILE_NEED_STRINGS FALSE
#define GFILE_NEED_STDIO FALSE
#define GFILE_ALLOW_FLOATS FALSE
#define GFILE_ALLOW_DEVICESPECIFIC FALSE
#define GFILE_MAX_GFILES 3
#define GFILE_NEED_MEMFS FALSE
#define GFILE_NEED_ROMFS FALSE
#define GFILE_NEED_RAMFS FALSE
#define GFILE_NEED_FATFS FALSE
#define GFILE_NEED_NATIVEFS FALSE
#define GFILE_NEED_CHBIOSFS FALSE
///////////////////////////////////////////////////////////////////////////
// GADC //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GADC FALSE
#define GADC_MAX_LOWSPEED_DEVICES 4
///////////////////////////////////////////////////////////////////////////
// GAUDIO //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GAUDIO FALSE
#define GAUDIO_NEED_PLAY FALSE
#define GAUDIO_NEED_RECORD FALSE
///////////////////////////////////////////////////////////////////////////
// GMISC //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GMISC FALSE
#define GMISC_NEED_ARRAYOPS FALSE
#define GMISC_NEED_FASTTRIG FALSE
#define GMISC_NEED_FIXEDTRIG FALSE
#define GMISC_NEED_INVSQRT FALSE
#define GMISC_INVSQRT_MIXED_ENDIAN FALSE
#define GMISC_INVSQRT_REAL_SLOW FALSE
#endif /* _GFXCONF_H */

View File

@ -0,0 +1,84 @@
/*
* Copyright (c) 2012, 2013, Joel Bodenmann aka Tectu <joel@unormal.org>
* Copyright (c) 2012, 2013, Andrew Hannam aka inmarket
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "gfx.h"
GListener gl;
GHandle ghLabel1, ghLabel2;
static void createWidgets(void) {
GWidgetInit wi;
// Apply some default values for GWIN
wi.customDraw = 0;
wi.customParam = 0;
wi.customStyle = 0;
wi.g.show = TRUE;
// Create the IP label
wi.g.width = 200; wi.g.height = 20; wi.g.x = 10, wi.g.y = 80;
wi.text = "192.168.1.42";
ghLabel1 = gwinLabelCreate(NULL, &wi);
gwinLabelSetAttribute(ghLabel1, 100, "Current IP:");
// Create the DHCP label
wi.g.width = 200; wi.g.height = 20; wi.g.x = 10, wi.g.y = 100;
wi.text = "Off";
ghLabel2 = gwinLabelCreate(NULL, &wi);
gwinLabelSetAttribute(ghLabel2, 100, "DHCP:");
}
int main(void) {
GEvent* pe;
// Initialize the display
gfxInit();
// Set the widget defaults
gwinSetDefaultFont(gdispOpenFont("*"));
gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE);
gdispClear(White);
// Attach the mouse input
gwinAttachMouse(0);
// create the widget
createWidgets();
// We want to listen for widget events
geventListenerInit(&gl);
gwinAttachListener(&gl);
while(1) {
// Get an Event
pe = geventEventWait(&gl, TIME_INFINITE);
}
return 0;
}

View File

@ -30,93 +30,19 @@
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GDISP TRUE
#define GDISP_NEED_AUTOFLUSH FALSE
#define GDISP_NEED_TIMERFLUSH FALSE
#define GDISP_NEED_VALIDATION TRUE
#define GDISP_NEED_CLIP TRUE
#define GDISP_NEED_CIRCLE TRUE
#define GDISP_NEED_ELLIPSE FALSE
#define GDISP_NEED_ARC FALSE
#define GDISP_NEED_CONVEX_POLYGON TRUE
#define GDISP_NEED_SCROLL FALSE
#define GDISP_NEED_PIXELREAD FALSE
//#define GDISP_NEED_SCROLL TRUE
#define GDISP_NEED_CONTROL TRUE
#define GDISP_NEED_QUERY FALSE
#define GDISP_NEED_MULTITHREAD FALSE
#define GDISP_NEED_STREAMING FALSE
#define GDISP_NEED_TEXT TRUE
#define GDISP_NEED_ANTIALIAS TRUE
#define GDISP_NEED_UTF8 TRUE
#define GDISP_NEED_TEXT_KERNING TRUE
#define GDISP_INCLUDE_FONT_UI1 FALSE
#define GDISP_INCLUDE_FONT_UI2 TRUE
#define GDISP_INCLUDE_FONT_LARGENUMBERS FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS10 FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS12 FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS16 FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS24 FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS32 FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12 FALSE
#define GDISP_INCLUDE_FONT_FIXED_10X20 FALSE
#define GDISP_INCLUDE_FONT_FIXED_7X14 FALSE
#define GDISP_INCLUDE_FONT_FIXED_5X8 FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS12_AA FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS16_AA FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS24_AA FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANS32_AA FALSE
#define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12_AA FALSE
#define GDISP_INCLUDE_USER_FONTS FALSE
#define GDISP_NEED_IMAGE TRUE
#define GDISP_NEED_IMAGE_NATIVE FALSE
#define GDISP_NEED_IMAGE_GIF TRUE
#define GDISP_NEED_IMAGE_BMP TRUE
#define GDISP_NEED_IMAGE_BMP_1 FALSE
#define GDISP_NEED_IMAGE_BMP_4 FALSE
#define GDISP_NEED_IMAGE_BMP_4_RLE FALSE
#define GDISP_NEED_IMAGE_BMP_8 FALSE
#define GDISP_NEED_IMAGE_BMP_8_RLE FALSE
#define GDISP_NEED_IMAGE_BMP_16 FALSE
#define GDISP_NEED_IMAGE_BMP_24 TRUE
#define GDISP_NEED_IMAGE_BMP_32 FALSE
#define GDISP_NEED_IMAGE_JPG FALSE
#define GDISP_NEED_IMAGE_PNG FALSE
#define GDISP_NEED_IMAGE_ACCOUNTING FALSE
#define GDISP_NEED_STARTUP_LOGO FALSE
#define GDISP_DEFAULT_ORIENTATION GDISP_ROTATE_LANDSCAPE
#define GDISP_LINEBUF_SIZE 128
#define GDISP_TOTAL_DISPLAYS 1
#if GDISP_TOTAL_DISPLAYS > 1
#define GDISP_HARDWARE_STREAM_WRITE FALSE
#define GDISP_HARDWARE_STREAM_READ FALSE
#define GDISP_HARDWARE_STREAM_POS FALSE
#define GDISP_HARDWARE_DRAWPIXEL FALSE
#define GDISP_HARDWARE_CLEARS FALSE
#define GDISP_HARDWARE_FILLS FALSE
#define GDISP_HARDWARE_BITFILLS FALSE
#define GDISP_HARDWARE_SCROLL FALSE
#define GDISP_HARDWARE_PIXELREAD FALSE
#define GDISP_HARDWARE_CONTROL FALSE
#define GDISP_HARDWARE_QUERY FALSE
#define GDISP_HARDWARE_CLIP FALSE
#endif
#define GDISP_TOTAL_CONTROLLERS 1
#if GDISP_TOTAL_CONTROLLERS > 1
#define GDISP_CONTROLLER_LIST GDISPVMT_Win32, GDISPVMT_Win32
#define GDISP_CONTROLLER_DISPLAYS 1, 1
#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
#endif
#define GDISP_USE_GFXNET FALSE
#define GDISP_GFXNET_PORT 13001
#define GDISP_GFXNET_CUSTOM_LWIP_STARTUP FALSE
#define GDISP_DONT_WAIT_FOR_NET_DISPLAY FALSE
#define GDISP_GFXNET_UNSAFE_SOCKETS FALSE
///////////////////////////////////////////////////////////////////////////
// GWIN //
@ -126,56 +52,36 @@
#define GWIN_NEED_WINDOWMANAGER TRUE
#define GWIN_NEED_CONSOLE TRUE
#define GWIN_CONSOLE_USE_HISTORY FALSE
#define GWIN_CONSOLE_HISTORY_AVERAGING FALSE
#define GWIN_CONSOLE_HISTORY_ATCREATE FALSE
#define GWIN_CONSOLE_ESCSEQ FALSE
#define GWIN_CONSOLE_USE_BASESTREAM FALSE
#define GWIN_CONSOLE_USE_FLOAT FALSE
#define GWIN_NEED_GRAPH TRUE
#define GWIN_NEED_WIDGET TRUE
#define GWIN_NEED_LABEL TRUE
#define GWIN_NEED_BUTTON TRUE
#define GWIN_BUTTON_LAZY_RELEASE FALSE
// #define GWIN_BUTTON_LAZY_RELEASE TRUE
#define GWIN_NEED_SLIDER TRUE
#define GWIN_NEED_CHECKBOX TRUE
#define GWIN_NEED_IMAGE TRUE
#define GWIN_NEED_IMAGE_ANIMATION TRUE
#define GWIN_NEED_RADIO TRUE
#define GWIN_NEED_LIST TRUE
#define GWIN_NEED_LIST_IMAGES TRUE
#define GWIN_NEED_PROGRESSBAR TRUE
///////////////////////////////////////////////////////////////////////////
// GEVENT //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GEVENT TRUE
#define GEVENT_ASSERT_NO_RESOURCE FALSE
#define GEVENT_MAXIMUM_SIZE 32
#define GEVENT_MAX_SOURCE_LISTENERS 32
///////////////////////////////////////////////////////////////////////////
// GTIMER //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GTIMER TRUE
#define GTIMER_THREAD_PRIORITY HIGH_PRIORITY
#define GTIMER_THREAD_WORKAREA_SIZE 2048
///////////////////////////////////////////////////////////////////////////
// GQUEUE //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GQUEUE TRUE
#define GQUEUE_NEED_ASYNC TRUE
#define GQUEUE_NEED_GSYNC FALSE
#define GQUEUE_NEED_FSYNC FALSE
#define GQUEUE_NEED_BUFFERS FALSE
///////////////////////////////////////////////////////////////////////////
// GINPUT //
@ -183,59 +89,15 @@
#define GFX_USE_GINPUT TRUE
#define GINPUT_NEED_MOUSE TRUE
#define GINPUT_NEED_KEYBOARD FALSE
#define GINPUT_NEED_TOGGLE FALSE
#define GINPUT_NEED_DIAL FALSE
//#define GINPUT_NEED_TOGGLE TRUE
//#define GINPUT_NEED_DIAL TRUE
///////////////////////////////////////////////////////////////////////////
// GFILE //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GFILE TRUE
#define GFILE_NEED_PRINTG FALSE
#define GFILE_NEED_SCANG FALSE
#define GFILE_NEED_STRINGS FALSE
#define GFILE_NEED_STDIO FALSE
#define GFILE_ALLOW_FLOATS FALSE
#define GFILE_ALLOW_DEVICESPECIFIC FALSE
#define GFILE_MAX_GFILES 3
#define GFILE_NEED_MEMFS FALSE
#define GFILE_NEED_ROMFS TRUE
#define GFILE_NEED_RAMFS FALSE
#define GFILE_NEED_FATFS FALSE
#define GFILE_NEED_NATIVEFS FALSE
#define GFILE_NEED_CHBIOSFS FALSE
///////////////////////////////////////////////////////////////////////////
// GADC //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GADC FALSE
#define GADC_MAX_LOWSPEED_DEVICES 4
///////////////////////////////////////////////////////////////////////////
// GAUDIO //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GAUDIO FALSE
#define GAUDIO_NEED_PLAY FALSE
#define GAUDIO_NEED_RECORD FALSE
///////////////////////////////////////////////////////////////////////////
// GMISC //
///////////////////////////////////////////////////////////////////////////
#define GFX_USE_GMISC FALSE
#define GMISC_NEED_ARRAYOPS FALSE
#define GMISC_NEED_FASTTRIG FALSE
#define GMISC_NEED_FIXEDTRIG FALSE
#define GMISC_NEED_INVSQRT FALSE
#define GMISC_INVSQRT_MIXED_ENDIAN FALSE
#define GMISC_INVSQRT_REAL_SLOW FALSE
//#define GFILE_NEED_NATIVEFS TRUE
#endif /* _GFXCONF_H */

View File

@ -237,7 +237,7 @@ static void createWidgets(void) {
gdispImageOpenFile(&imgYesNo, "image_yesno.gif");
gwinListItemSetImage(ghList3, 1, &imgYesNo);
gwinListItemSetImage(ghList3, 3, &imgYesNo);
wi.g.x = 0+3*(LIST_WIDTH+5); wi.text = "L2";
wi.g.x = 0+3*(LIST_WIDTH+5); wi.text = "L4";
ghList4 = gwinListCreate(0, &wi, TRUE);
gwinListAddItem(ghList4, "Item 0", FALSE);
gwinListAddItem(ghList4, "Item 1", FALSE);
@ -258,7 +258,7 @@ static void createWidgets(void) {
// Image
wi.g.x = 20; wi.g.y = 2*TAB_HEIGHT+20; wi.g.width = 200; wi.g.height = 100;
ghImage1 = gwinImageCreate(0, &wi.g);
gwinImageOpenFile(ghImage1, "romfs_img_ugfx.bmp");
gwinImageOpenFile(ghImage1, "romfs_img_ugfx.gif");
// Progressbar
wi.g.show = FALSE; wi.customDraw = 0;
@ -381,16 +381,16 @@ int main(void) {
// Initialize the display
gfxInit();
// Set the widget defaults
gwinSetDefaultFont(gdispOpenFont("*"));
gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE);
gdispClear(White);
// Connect the mouse
#if GINPUT_NEED_MOUSE
gwinAttachMouse(0);
#endif
// Set the widget defaults
gwinSetDefaultFont(gdispOpenFont("*"));
gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE);
gdispClear(White);
// Create the gwin windows/widgets
createWidgets();

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -10,7 +10,7 @@ FEATURE: Added gdispGDrawThickLine() by user jpa-
DEPRECATE: TDISP module removed
FIX: Console does not execute gwinPrintf() anymore if not visible
FEATURE: Added gwinGetColor() and gwinGetBgColor()
FEATURE: Console does now have an optional buffer (GWIN_CONSOLE_USE_HISTORY)
FEATURE: Console now has an optional backing store buffer (GWIN_CONSOLE_USE_HISTORY)
FEATURE: Added smooth scrolling to list widget
FEATURE: Increased performance of gwinListAddItem()
FEATURE: Added gfxDeinit()
@ -20,10 +20,19 @@ FEATURE: Image file handling changed to use new GFILE module.
DEPRECTATE: Old image opening functions deprecated.
FEATURE: Restructure and simplify the include path for GFX
FEATURE: Added LGDP4532 driver by user shilow
FIX: Updated board files to support api changes in ChibiOS/RT 2.6.4
FEATURE: Support for ChibiOS/RT 3.x
FEATURE: Added gwinProgressbarStop() and gwinProgressbarReset()
FEATURE: Added generic ILI93xx driver by xlh1460
FEATURE: Added gwinListEnableRender()
FEATURE: Added gwinLabelSetAttribute()
FEATURE: Complete restructure of the GAUDIN and GAUDOUT into a common GAUDIO module
FEATURE: Added a PWM audio play driver
FEATURE: Update GADC audio recording driver to new GAUDIO format
FEATURE: Added vs1053 audio play driver
FEATURE: Added GAUDIO wave-play demo
FEATURE: Added many GWIN simple demo's and updated the combined widget demo
FEATURE: Added gwinEnable() and gwinDisable()
*** changes after 1.9 ***

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,7 @@
# List the required driver.
GFXSRC += $(GFXLIB)/drivers/gaudio/vs1053/gaudio_play_lld.c
# Required include directories
GFXINC += $(GFXLIB)/drivers/gaudio/vs1053
GFXDEFS += -DGFX_USE_GTIMER=GFX_USE_GAUDIO

View File

@ -0,0 +1,71 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#ifndef GAUDIO_PLAY_BOARD_H
#define GAUDIO_PLAY_BOARD_H
// Initialise the board
static void board_init(void) {
}
// Chip is initialised enough so we can talk fast to it
static void board_init_end(void) {
}
// Reset the board
static void board_reset(void) {
}
// Returns the state of the dreq pin
static bool board_dreq(void) {
}
// Start a command write
static void board_startcmdwrite(void) {
}
// End a command write
static void board_endcmdwrite(void) {
}
// Start a command read
static void board_startcmdread(void) {
}
// End a command read
static void board_endcmdread(void) {
}
// Start a data write
static void board_startdatawrite(void) {
}
// End a data write
static void board_enddatawrite(void) {
}
// Write data to the SPI port
static void board_spiwrite(const uint8_t *buf, unsigned len) {
}
// Read data from the SPI port
static void board_spiread(uint8_t *buf, unsigned len) {
}
#endif /* GAUDIO_PLAY_BOARD_H */

View File

@ -0,0 +1,29 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#ifndef GAUDIO_PLAY_CONFIG_H
#define GAUDIO_PLAY_CONFIG_H
#if GFX_USE_GAUDIO && GAUDIO_NEED_PLAY
/*===========================================================================*/
/* Driver hardware support. */
/*===========================================================================*/
#define GAUDIO_PLAY_MAX_SAMPLE_FREQUENCY 48000
#define GAUDIO_PLAY_NUM_FORMATS 2
#define GAUDIO_PLAY_FORMAT1 ARRAY_DATA_16BITSIGNED
#define GAUDIO_PLAY_FORMAT2 ARRAY_DATA_8BITUNSIGNED
#define GAUDIO_PLAY_NUM_CHANNELS 2
#define GAUDIO_PLAY_CHANNEL0_IS_STEREO FALSE
#define GAUDIO_PLAY_CHANNEL1_IS_STEREO TRUE
#define GAUDIO_PLAY_MONO 0
#define GAUDIO_PLAY_STEREO 1
#endif /* GFX_USE_GAUDIO && GAUDIO_NEED_PLAY */
#endif /* GAUDIO_PLAY_CONFIG_H */

View File

@ -0,0 +1,348 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#include "gfx.h"
#if GFX_USE_GAUDIO && GAUDIO_NEED_PLAY
/* Include the driver defines */
#include "src/gaudio/driver_play.h"
/* Include the vs1053 registers */
#include "drivers/gaudio/vs1053/vs1053.h"
/* Include the board interface */
#include "gaudio_play_board.h"
// Override-able parameters
#ifndef VS1053_CLK
#define VS1053_CLK 12288000
#endif
#ifndef VS1053_FIRMWARE_PATCH
#define VS1053_FIRMWARE_PATCH FALSE
#endif
// Load the patch file if desired. New format patches only.
#if VS1053_FIRMWARE_PATCH
#define SKIP_PLUGIN_VARNAME
static const uint16_t plugin[] = { /* Compressed plugin */
#include "vs1053_patch.plg"
};
#endif
// Set various stuff based on the clock
#if VS1053_CLK >= 16192000
#define SCI_MODE_STARTUP (SCI_MODE_DEFAULTS|SM_CLK_RANGE)
#define VS1053_CLKI (VS1053_CLK/2)
#else
#define SCI_MODE_STARTUP (SCI_MODE_DEFAULTS)
#define VS1053_CLKI (VS1053_CLK)
#endif
#if VS1053_CLKI > 13000000 || VS1053_CLKI < 12000000
#error "GAUDIO(vs1053): VS1053_CLK is out of range"
#endif
#if VS1053_CLKI == 12288000
#define SC_FREQ_ADJUST 0x0000
#else
#define SC_FREQ_ADJUST ((VS1053_CLKI-8000000)/4000)
#endif
#define VS1053_MAX_SAMPLE_RATE (VS1053_CLKI/256)
#if VS1053_CLKI > 1228800
#define SC_CLOCK_MODE (SC_MULT_3|SC_ADD_1|SC_FREQ_ADJUST)
#else
#define SC_CLOCK_MODE (SC_MULT_3_5|SC_ADD_1|SC_FREQ_ADJUST)
#endif
// Our static variables
static bool_t vs1053_isinit;
static GTimer playTimer;
// Some common macro's
#define waitforready() while(!board_dreq()) gfxSleepMilliseconds(5)
static void cmd_write(uint16_t addr, uint16_t data) {
char buf[4];
buf[0] = 2;
buf[1] = (char)addr;
buf[2] = (char)(data >> 8);
buf[3] = (char)data;
waitforready();
board_startcmdwrite();
board_spiwrite(buf, 4);
board_endcmdwrite();
}
#if VS1053_CLK > 12288000
static inline void cmd_writenodreq(uint16_t addr, uint16_t data) {
uint8_t buf[4];
// This is the same as cmd_write() except for it doesn't wait for dreq first
buf[0] = 2;
buf[1] = (uint8_t)addr;
buf[2] = (uint8_t)(data >> 8);
buf[3] = (uint8_t)data;
board_startcmdwrite();
board_spiwrite(buf, 4);
board_endcmdwrite();
}
#endif
static uint16_t cmd_read(uint16_t addr) {
uint8_t buf[2];
buf[0] = 3;
buf[1] = (char)addr;
board_startcmdread();
board_spiwrite(buf, 2);
board_spiread(buf, 2);
board_endcmdread();
return (((uint16_t)buf[0])<<8)|buf[1];
}
static void data_write(const uint8_t *data, unsigned len) {
board_startdatawrite();
board_spiwrite(data, len);
board_enddatawrite();
}
#if VS1053_FIRMWARE_PATCH
static void LoadUserCode(void) {
int i;
uint16_t addr, n, val;
for(i=0; i<sizeof(plugin)/sizeof(plugin[0]);) {
addr = plugin[i++];
n = plugin[i++];
if (n & 0x8000U) { /* RLE run, replicate n samples */
n &= 0x7FFF;
val = plugin[i++];
while (n--)
cmd_write(addr, val);
} else { /* Copy run, copy n samples */
while (n--)
cmd_write(addr, plugin[i++]);
}
}
}
#endif
static void vs1053_hard_reset(void) {
gtimerInit(&playTimer);
board_init();
board_reset();
#if VS1053_CLK > 12288000
cmd_writenodreq(SCI_MODE, SCI_MODE_STARTUP); // Set super-clock before dreq
#endif
// Set up registers
cmd_write(SCI_MODE, SCI_MODE_STARTUP); // Set mode
cmd_write(SCI_CLOCKF, SC_CLOCK_MODE); // Set clocks
board_init_end(); // Clocks are now set up
cmd_write(SCI_BASS, 0x0000); // No treble or bass boost
cmd_write(SCI_VOL, VOL_MAX); // Maximum volume
// Load any firmware
#if VS1053_FIRMWARE_PATCH
LoadUserCode();
// Reset mode just in case
cmd_write(SCI_MODE, SCI_MODE_STARTUP);
#endif
}
static void vs1053_soft_reset(void) {
cmd_write(SCI_MODE, cmd_read(SCI_MODE)|SM_RESET);
gfxSleepMilliseconds(1); // Wait for at least 2uS
waitforready();
// Reload any firmware
#if VS1053_FIRMWARE_PATCH
LoadUserCode();
// Reset mode just in case
cmd_write(SCI_MODE, SCI_MODE_STARTUP);
#endif
}
static uint16_t vs1053_getendbyte(void) {
cmd_write(SCI_WRAMADDR, WRAMADDR_EXTRAPARAMS+4);
return cmd_read(SCI_WRAM);
}
static GTimer playTimer;
static GDataBuffer *pplay;
static size_t playlen;
static uint8_t *pdata;
static void FeedData(void *param) {
unsigned len;
(void) param;
// While there is data space
while (board_dreq()) {
// Send up to 32 bytes
len = playlen;
if (len > 32) len = 32;
data_write(pdata, len);
pdata += len;
playlen -= len;
// Have we finished the buffer
while (!playlen) {
gfxSystemLock();
gaudioPlayReleaseDataBlockI(pplay);
// Get a new data buffer
if (!(pplay = gaudioPlayGetDataBlockI())) {
// We should really only do the play-done when the audio
// has really finished playing. Unfortunately there seems
// to be no documented way of determining this.
gaudioPlayDoneI();
gfxSystemUnlock();
gtimerStop(&playTimer);
return;
}
// Set up ready for the new buffer
playlen = pplay->len;
pdata = (uint8_t *)(pplay+1);
gfxSystemUnlock();
}
}
}
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
bool_t gaudio_play_lld_init(uint16_t channel, uint32_t frequency, ArrayDataFormat format) {
uint32_t brate;
uint32_t bps;
uint8_t buf[4];
static const uint8_t hdr1[] = {
'R', 'I', 'F', 'F',
0xFF, 0xFF, 0xFF, 0xFF,
'W', 'A', 'V', 'E',
'f', 'm', 't', ' ',
16, 0, 0, 0,
0x01, 0x00,
};
static const uint8_t hdr2[] = {
'd', 'a', 't', 'a',
0xFF, 0xFF, 0xFF, 0xFF,
};
if (format != ARRAY_DATA_8BITUNSIGNED && format != ARRAY_DATA_16BITSIGNED)
return FALSE;
if (frequency > VS1053_MAX_SAMPLE_RATE)
return FALSE;
// Reset the chip if needed
if (!vs1053_isinit) {
vs1053_hard_reset();
vs1053_isinit = TRUE;
}
// Setup
bps = (gfxSampleFormatBits(format)+7)/8;
if (channel == GAUDIO_PLAY_STEREO)
bps *= 2;
brate = frequency * bps;
// Write the RIFF header
waitforready();
data_write(hdr1, sizeof(hdr1));
buf[0] = channel == GAUDIO_PLAY_STEREO ? 2 : 1; buf[1] = 0; data_write(buf, 2);
buf[0] = frequency; buf[1] = frequency>>8; buf[2] = frequency>>16; buf[3] = frequency>>24; data_write(buf, 4);
buf[0] = brate; buf[1] = brate>>8; buf[2] = brate>>16; buf[3] = brate>>24; data_write(buf, 4);
waitforready(); // 32 bytes max before checking
buf[0] = bps; buf[1] = 0; data_write(buf, 2);
buf[0] = gfxSampleFormatBits(format); buf[1] = 0; data_write(buf, 2);
data_write(hdr2, sizeof(hdr2));
return TRUE;
}
bool_t gaudio_play_lld_set_volume(uint8_t vol) {
// Volume is 0xFE -> 0x00. Adjust vol to match
vol = ~vol;
if (vol == 0xFF) vol = 0xFE;
cmd_write(SCI_VOL, ((uint16_t)vol) << 8 | vol);
return TRUE;
}
void gaudio_play_lld_start(void) {
gfxSystemLock();
// Get a new data buffer
if (pplay || !(pplay = gaudioPlayGetDataBlockI())) {
gfxSystemUnlock(); // Nothing to do
return;
}
// Set up ready for the new buffer
playlen = pplay->len;
pdata = (uint8_t *)(pplay+1);
gfxSystemUnlock();
// Start the playing by starting the timer and executing FeedData immediately just to get things started
// We really should set the timer to be equivalent to half the available data but that is just too hard to calculate.
gtimerStart(&playTimer, FeedData, 0, TRUE, 5);
FeedData(0);
}
void gaudio_play_lld_stop(void) {
uint8_t ch;
unsigned i;
// Stop the timer interrupt
gtimerStop(&playTimer);
// We may need to clean up the remaining buffer.
gfxSystemLock();
if (pplay) {
gaudioPlayReleaseDataBlockI(pplay);
pplay = 0;
gaudioPlayDoneI();
}
gfxSystemUnlock();
// Set CANCEL
cmd_write(SCI_MODE, cmd_read(SCI_MODE)|SM_CANCEL);
// Write up to 2048 bytes of data
ch = 0;
for(i = 0; i < 2048; i++) {
if (!(i & 0x1F)) {
waitforready();
if (!(cmd_read(SCI_MODE) & SM_CANCEL))
break;
}
data_write(&ch, 1);
}
// Make sure the cancel worked
waitforready();
if ((cmd_read(SCI_MODE) & SM_CANCEL))
vs1053_soft_reset();
// Send the terminating data
ch = vs1053_getendbyte();
for(i = 0; i < 2052; i++) {
if (!(i & 0x1F))
waitforready();
data_write(&ch, 1);
}
}
#endif /* GFX_USE_GAUDIO && GAUDIO_NEED_PLAY */

View File

@ -0,0 +1,4 @@
This chip supports playing in many formats including MP3 etc.
For this driver however we only support PCM in 8 bit unisgned and 16 bit signed formats.
Requires GFX_USE_GTIMER

View File

@ -0,0 +1,101 @@
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
#ifndef _VS1053_H
#define _VS1053_H
// Registers
#define SCI_MODE 0x00
#define SM_DIFF 0x0001
#define SM_LAYER12 0x0002
#define SM_RESET 0x0004
#define SM_CANCEL 0x0008
#define SM_EARSPEAKER_LO 0x0010
#define SM_TESTS 0x0020
#define SM_STREAM 0x0040
#define SM_EARSPEAKER_HI 0x0080
#define SM_DACT 0x0100
#define SM_SDIORD 0x0200
#define SM_SDISHARE 0x0400
#define SM_SDINEW 0x0800
#define SM_ADPCM 0x1000
#define SM_LINE1 0x4000
#define SM_CLK_RANGE 0x8000
#define SCI_MODE_DEFAULTS (SM_LINE1|SM_SDINEW)
#define SCI_STATUS 0x01
#define SS_DO_NOT_JUMP 0x8000
#define SS_SWING_MASK 0x7000
#define SS_SWING_SHIFT 12
#define SS_VCM_OVERLOAD 0x0800
#define SS_VCM_DISABLE 0x0400
#define SS_VER_MASK 0x00F0
#define SS_VER_SHIFT 4
#define SS_APDOWN2 0x0008
#define SS_APDOWN1 0x0004
#define SS_SS_AD_CLOCK 0x0002
#define SS_REFERENCE_SEL 0x0001
#define SCI_BASS 0x02
#define ST_AMPLITUDE_MASK 0xF000
#define ST_AMPLITUDE_SHIFT 12
#define ST_FREQLIMIT_MASK 0x0F00
#define ST_FREQLIMIT_SHIFT 8
#define SB_AMPLITUDE_MASK 0x00F0
#define SB_AMPLITUDE_SHIFT 4
#define SB_FREQLIMIT_MASK 0x000F
#define SB_FREQLIMIT_SHIFT 0
#define SCI_CLOCKF 0x03
#define SC_MULT_1 0x0000
#define SC_MULT_2 0x2000
#define SC_MULT_2_5 0x4000
#define SC_MULT_3 0x6000
#define SC_MULT_3_5 0x8000
#define SC_MULT_4 0xa000
#define SC_MULT_4_5 0xc000
#define SC_MULT_5 0xe000
#define SC_ADD_NONE 0x0000
#define SC_ADD_1 0x0800
#define SC_ADD_1_5 0x1000
#define SC_ADD_2 0x1800
#define SC_FREQ_MASK 0x07FF
#define SCI_DECODE_TIME 0x04
#define SCI_AUDATA 0x05
#define SR_RATE_MASK 0xFFFE
#define SR_IS_STEREO 0x0001
#define SCI_WRAM 0x06
#define SCI_WRAMADDR 0x07
#define WRAMADDR_XDATA 0x1800
#define WRAMADDR_YDATA 0x5800
#define WRAMADDR_INSTR 0x8040
#define WRAMADDR_IO 0xC000
#define WRAMADDR_EXTRAPARAMS 0x1E02
#define SCI_HDAT0 0x08
#define SCI_HDAT1 0x09
#define HD_FMT_NONE 0x0000
#define HD_FMT_WAV 0x7665
#define HD_FMT_AAC_ADTS 0x4154
#define HD_FMT_AAC_ADIF 0x4144
#define HD_FMT_AAC_M4A 0x4D34
#define HD_FMT_WMA 0x574D
#define HD_FMT_MIDI 0x4D54
#define HD_FMT_OGG 0x4F67
#define HD_FMT_MP3_MIN 0xFFE0
#define HD_FMT_MP3_MAX 0xFFFF
#define SCI_AIADDR 0x0A
#define SCI_VOL 0x0B
#define VOL_LEFT_MASK 0xFF00
#define VOL_LEFT_SHIFT 8
#define VOL_RIGHT_MASK 0x00FF
#define VOL_RIGHT_SHIFT 0
#define VOL_POWERDOWN 0xFFFF
#define VOL_MAX 0x0000
#define VOL_MIN 0xFEFE
#define SCI_AICTRL0 0x0C
#define SCI_AICTRL1 0x0D
#define SCI_AICTRL2 0x0E
#define SCI_AICTRL3 0x0F
#endif /* _VS1053_H */

View File

@ -136,6 +136,7 @@
#define GWIN_NEED_WIDGET FALSE
#define GWIN_NEED_HIERARCHY FALSE
#define GWIN_NEED_LABEL FALSE
#define GWIN_LABEL_ATTRIBUTE FALSE
#define GWIN_NEED_BUTTON FALSE
#define GWIN_BUTTON_LAZY_RELEASE FALSE
#define GWIN_NEED_SLIDER FALSE
@ -147,6 +148,7 @@
#define GWIN_NEED_LIST_IMAGES FALSE
#define GWIN_NEED_PROGRESSBAR FALSE
#define GWIN_NEED_FRAME FALSE
#define GWIN_FLAT_STYLING FALSE
///////////////////////////////////////////////////////////////////////////

View File

@ -174,7 +174,7 @@ void gdispImageClose(gdispImage *img) {
}
bool_t gdispImageIsOpen(gdispImage *img) {
return img->fns != 0;
return img->type != GDISP_IMAGE_TYPE_UNKNOWN && img->fns != 0;
}
void gdispImageSetBgColor(gdispImage *img, color_t bgcolor) {

View File

@ -25,6 +25,8 @@
#define RND_CNR_SIZE 5 // Rounded corner size for rounded buttons
#define ARROWHEAD_DIVIDER 4 // A quarter of the height for the arrow head
#define ARROWBODY_DIVIDER 4 // A quarter of the width for the arrow body
#define TOP_FADE 50 // (TOP_FADE/255)% fade to white for top of button
#define BOTTOM_FADE 25 // (BOTTOM_FADE/255)% fade to black for bottom of button
// Our pressed state
#define GBUTTON_FLG_PRESSED (GWIN_FIRST_CONTROL_FLAG<<0)
@ -109,7 +111,7 @@ static const gwidgetVMT buttonVMT = {
_gwidgetRedraw, // The redraw routine
0, // The after-clear routine
},
gwinButtonDraw_3D, // The default drawing routine
gwinButtonDraw_Normal, // The default drawing routine
#if GINPUT_NEED_MOUSE
{
MouseDown, // Process mouse down events
@ -164,17 +166,42 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) {
return &gw->pstyle->enabled;
}
void gwinButtonDraw_3D(GWidgetObject *gw, void *param) {
const GColorSet * pcol;
(void) param;
#if GWIN_FLAT_STYLING
void gwinButtonDraw_Normal(GWidgetObject *gw, void *param) {
const GColorSet * pcol;
(void) param;
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
pcol = getDrawColors(gw);
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
pcol = getDrawColors(gw);
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter);
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge);
}
#else
void gwinButtonDraw_Normal(GWidgetObject *gw, void *param) {
const GColorSet * pcol;
fixed alpha;
fixed dalpha;
coord_t i;
color_t tcol, bcol;
(void) param;
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
pcol = getDrawColors(gw);
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter);
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge);
}
/* Fill the box blended from variants of the fill color */
tcol = gdispBlendColor(White, pcol->fill, TOP_FADE);
bcol = gdispBlendColor(Black, pcol->fill, BOTTOM_FADE);
dalpha = FIXED(255)/gw->g.height;
for(alpha = 0, i = 0; i < gw->g.height; i++, alpha += dalpha)
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+i, gw->g.x+gw->g.width-2, gw->g.y+i, gdispBlendColor(bcol, tcol, NONFIXED(alpha)));
gdispGDrawStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, justifyCenter);
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge);
}
#endif
#if GDISP_NEED_ARC
void gwinButtonDraw_Rounded(GWidgetObject *gw, void *param) {

View File

@ -111,7 +111,7 @@ bool_t gwinButtonIsPressed(GHandle gh);
* @api
* @{
*/
void gwinButtonDraw_3D(GWidgetObject *gw, void *param); // @< A standard 3D button
void gwinButtonDraw_Normal(GWidgetObject *gw, void *param); // @< A standard button
#if GDISP_NEED_ARC || defined(__DOXYGEN__)
void gwinButtonDraw_Rounded(GWidgetObject *gw, void *param); // @< A rounded rectangle button
#endif

View File

@ -140,6 +140,10 @@ GHandle gwinGImageCreate(GDisplay *g, GImageObject *gobj, GWindowInit *pInit) {
}
bool_t gwinImageOpenGFile(GHandle gh, GFILE *f) {
// is it a valid handle?
if (gh->vmt != (gwinVMT *)&imageVMT)
return FALSE;
if (gdispImageIsOpen(&widget(gh)->image))
gdispImageClose(&widget(gh)->image);
@ -159,6 +163,10 @@ bool_t gwinImageOpenGFile(GHandle gh, GFILE *f) {
}
gdispImageError gwinImageCache(GHandle gh) {
// is it a valid handle?
if (gh->vmt != (gwinVMT *)&imageVMT)
return GDISP_IMAGE_ERR_BADFORMAT;
return gdispImageCache(&widget(gh)->image);
}

View File

@ -371,6 +371,9 @@ void gwinSetStyle(GHandle gh, const GWidgetStyle *pstyle) {
}
const GWidgetStyle *gwinGetStyle(GHandle gh) {
if (!(gh->flags & GWIN_FLG_WIDGET))
return 0;
return gw->pstyle;
}

View File

@ -23,6 +23,7 @@
// macros to assist in data type conversions
#define gh2obj ((GLabelObject *)gh)
#define gw2obj ((GLabelObject *)gw)
// flags for the GLabelObject
#define GLABEL_FLG_WAUTO (GWIN_FIRST_CONTROL_FLAG << 0)
@ -44,28 +45,7 @@ static coord_t getheight(const char *text, font_t font, coord_t maxwidth) {
return gdispGetFontMetric(font, fontHeight);
}
static void gwinLabelDefaultDraw(GWidgetObject *gw, void *param) {
coord_t w, h;
(void) param;
w = (gw->g.flags & GLABEL_FLG_WAUTO) ? getwidth(gw->text, gw->g.font, gdispGGetWidth(gw->g.display) - gw->g.x) : gw->g.width;
h = (gw->g.flags & GLABEL_FLG_HAUTO) ? getheight(gw->text, gw->g.font, gdispGGetWidth(gw->g.display) - gw->g.x) : gw->g.height;
if (gw->g.width != w || gw->g.height != h) {
gwinResize(&gw->g, w, h);
return;
}
// render the text
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font,
(gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
justifyLeft);
// render the border (if any)
if (gw->g.flags & GLABEL_FLG_BORDER)
gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.edge : gw->pstyle->disabled.edge);
}
static void gwinLabelDefaultDraw(GWidgetObject *gw, void *param);
static const gwidgetVMT labelVMT = {
{
@ -121,8 +101,10 @@ GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit)
if (!(widget = (GLabelObject *)_gwidgetCreate(g, &widget->w, pInit, &labelVMT)))
return 0;
// no borders by default
flags &=~ GLABEL_FLG_BORDER;
#if GWIN_LABEL_ATTRIBUTE
widget->tab = 0;
widget->attr = 0;
#endif
widget->w.g.flags |= flags;
gwinSetVisible(&widget->w.g, pInit->g.show);
@ -141,6 +123,62 @@ void gwinLabelSetBorder(GHandle gh, bool_t border) {
gh2obj->w.g.flags &=~ GLABEL_FLG_BORDER;
}
#if GWIN_LABEL_ATTRIBUTE
void gwinLabelSetAttribute(GHandle gh, coord_t tab, const char* attr) {
// is it a valid handle?
if (gh->vmt != (gwinVMT *)&labelVMT)
return;
gh2obj->tab = tab;
gh2obj->attr = attr;
gwinRedraw(gh);
}
#endif // GWIN_LABEL_ATTRIBUTE
static void gwinLabelDefaultDraw(GWidgetObject *gw, void *param) {
coord_t w, h;
(void) param;
// is it a valid handle?
if (gw->g.vmt != (gwinVMT *)&labelVMT)
return;
w = (gw->g.flags & GLABEL_FLG_WAUTO) ? getwidth(gw->text, gw->g.font, gdispGGetWidth(gw->g.display) - gw->g.x) : gw->g.width;
h = (gw->g.flags & GLABEL_FLG_HAUTO) ? getheight(gw->text, gw->g.font, gdispGGetWidth(gw->g.display) - gw->g.x) : gw->g.height;
if (gw->g.width != w || gw->g.height != h) {
gwinResize(&gw->g, w, h);
return;
}
#if GWIN_LABEL_ATTRIBUTE
if (gw2obj->attr != 0) {
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw2obj->attr, gw->g.font,
(gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
justifyLeft);
gdispGFillStringBox(gw->g.display, gw->g.x + gw2obj->tab, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font,
(gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
justifyLeft);
} else {
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font,
(gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
justifyLeft);
}
#else
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font,
(gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
justifyLeft);
#endif
// render the border (if any)
if (gw->g.flags & GLABEL_FLG_BORDER)
gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.edge : gw->pstyle->disabled.edge);
}
#endif // GFX_USE_GWIN && GFX_NEED_LABEL
/** @} */

View File

@ -32,6 +32,11 @@
// An label window
typedef struct GLabelObject {
GWidgetObject w;
#if GWIN_LABEL_ATTRIBUTE
coord_t tab;
const char* attr;
#endif
} GLabelObject;
#ifdef __cplusplus
@ -63,6 +68,33 @@ GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit);
*/
void gwinLabelSetBorder(GHandle gh, bool_t border);
#if GWIN_LABEL_ATTRIBUTE || defined(__DOXYGEN__)
/**
* @brief Add an text attribute in front of the normal label text
* @details Often you want to display a text like this:
* Current IP: 192.168.1.42
* In that case, the actual IP will be variable, the text in front of it
* always remains the same. The static text is called the attribute and can be
* set using this function.
* Furthermore, the tab can be set in order to vertically align multiple labels.
* Please check out the website for further explanation, illustraions and usage
* examples.
*
* @note The attribute text is not copied into private memory and so it
* must be a constant string, not one allocated in a stack buffer.
* @note Use of this construct is discouraged. The appropriate way is to
* create two labels - one for the static text and one for the
* dynamic text.
*
* @param[in] gh The widget handle (must be a label handle)
* @param[in] tab The distance of the label text from the left widget edge
* @param[in] attr The attribute to be displayed
*
* @api
*/
void gwinLabelSetAttribute(GHandle gh, coord_t tab, const char* attr);
#endif
#ifdef __cplusplus
}
#endif

View File

@ -76,102 +76,7 @@ static void sendListEvent(GWidgetObject *gw, int item) {
}
}
static void gwinListDefaultDraw(GWidgetObject* gw, void* param) {
(void)param;
#if GDISP_NEED_CONVEX_POLYGON
static const point upArrow[] = { {0, ARROW}, {ARROW, ARROW}, {ARROW/2, 0} };
static const point downArrow[] = { {0, 0}, {ARROW, 0}, {ARROW/2, ARROW} };
#endif
const gfxQueueASyncItem* qi;
int i;
coord_t x, y, iheight, iwidth;
color_t fill;
const GColorSet * ps;
#if GWIN_NEED_LIST_IMAGES
coord_t sy;
#endif
// dont render if render has been disabled
if (!(gw->g.flags & GLIST_FLG_ENABLERENDER)) {
return;
}
ps = (gw->g.flags & GWIN_FLG_ENABLED) ? &gw->pstyle->enabled : &gw->pstyle->disabled;
iheight = gdispGetFontMetric(gw->g.font, fontHeight) + VERTICAL_PADDING;
x = 1;
// the scroll area
if (gw->g.flags & GLIST_FLG_SCROLLSMOOTH) {
iwidth = gw->g.width - 2 - 4;
if (gw2obj->cnt > 0) {
int max_scroll_value = gw2obj->cnt * iheight - gw->g.height-2;
if (max_scroll_value > 0) {
int bar_height = (gw->g.height-2) * (gw->g.height-2) / (gw2obj->cnt * iheight);
gdispGFillArea(gw->g.display, gw->g.x + gw->g.width-4, gw->g.y + 1, 2, gw->g.height-1, gw->pstyle->background);
gdispGFillArea(gw->g.display, gw->g.x + gw->g.width-4, gw->g.y + gw2obj->top * ((gw->g.height-2)-bar_height) / max_scroll_value, 2, bar_height, ps->edge);
}
}
} else if ((gw2obj->cnt > (gw->g.height-2) / iheight) || (gw->g.flags & GLIST_FLG_SCROLLALWAYS)) {
iwidth = gw->g.width - (SCROLLWIDTH+3);
gdispGFillArea(gw->g.display, gw->g.x+iwidth+2, gw->g.y+1, SCROLLWIDTH, gw->g.height-2, gdispBlendColor(ps->fill, gw->pstyle->background, 128));
gdispGDrawLine(gw->g.display, gw->g.x+iwidth+1, gw->g.y+1, gw->g.x+iwidth+1, gw->g.y+gw->g.height-2, ps->edge);
#if GDISP_NEED_CONVEX_POLYGON
gdispGFillConvexPoly(gw->g.display, gw->g.x+iwidth+((SCROLLWIDTH-ARROW)/2+2), gw->g.y+(ARROW/2+1), upArrow, 3, ps->fill);
gdispGFillConvexPoly(gw->g.display, gw->g.x+iwidth+((SCROLLWIDTH-ARROW)/2+2), gw->g.y+gw->g.height-(ARROW+ARROW/2+1), downArrow, 3, ps->fill);
#else
#warning "GWIN: Lists display better when GDISP_NEED_CONVEX_POLGON is turned on"
gdispGFillArea(gw->g.display, gw->g.x+iwidth+((SCROLLWIDTH-ARROW)/2+2), gw->g.y+(ARROW/2+1), ARROW, ARROW, ps->fill);
gdispGFillArea(gw->g.display, gw->g.x+iwidth+((SCROLLWIDTH-ARROW)/2+2), gw->g.y+gw->g.height-(ARROW+ARROW/2+1), ARROW, ARROW, ps->fill);
#endif
} else
iwidth = gw->g.width - 2;
#if GWIN_NEED_LIST_IMAGES
if ((gw->g.flags & GLIST_FLG_HASIMAGES)) {
x += iheight;
iwidth -= iheight;
}
#endif
// Find the top item
for (qi = gfxQueueASyncPeek(&gw2obj->list_head), i = iheight - 1; i < gw2obj->top && qi; qi = gfxQueueASyncNext(qi), i+=iheight);
// the list frame
gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, ps->edge);
// Set the clipping region so we do not override the frame.
gdispGSetClip(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2);
// Draw until we run out of room or items
for (y = 1-(gw2obj->top%iheight); y < gw->g.height-2 && qi; qi = gfxQueueASyncNext(qi), y += iheight) {
fill = (qi2li->flags & GLIST_FLG_SELECTED) ? ps->fill : gw->pstyle->background;
gdispGFillArea(gw->g.display, gw->g.x+1, gw->g.y+y, iwidth, iheight, fill);
#if GWIN_NEED_LIST_IMAGES
if ((gw->g.flags & GLIST_FLG_HASIMAGES)) {
// Clear the image area
if (qi2li->pimg && gdispImageIsOpen(qi2li->pimg)) {
// Calculate which image
sy = (qi2li->flags & GLIST_FLG_SELECTED) ? 0 : (iheight-VERTICAL_PADDING);
if (!(gw->g.flags & GWIN_FLG_ENABLED))
sy += 2*(iheight-VERTICAL_PADDING);
while (sy > qi2li->pimg->height)
sy -= iheight-VERTICAL_PADDING;
// Draw the image
gdispImageSetBgColor(qi2li->pimg, fill);
gdispGImageDraw(gw->g.display, qi2li->pimg, gw->g.x+1, gw->g.y+y, iheight-VERTICAL_PADDING, iheight-VERTICAL_PADDING, 0, sy);
}
}
#endif
gdispGFillStringBox(gw->g.display, gw->g.x+x+HORIZONTAL_PADDING, gw->g.y+y, iwidth-HORIZONTAL_PADDING, iheight, qi2li->text, gw->g.font, ps->text, fill, justifyLeft);
}
// Fill any remaining item space
if (y < gw->g.height-1)
gdispGFillArea(gw->g.display, gw->g.x+1, gw->g.y+y, iwidth, gw->g.height-1-y, gw->pstyle->background);
}
static void gwinListDefaultDraw(GWidgetObject* gw, void* param);
#if GINPUT_NEED_MOUSE
static void MouseSelect(GWidgetObject* gw, coord_t x, coord_t y) {
@ -209,24 +114,23 @@ static void gwinListDefaultDraw(GWidgetObject* gw, void* param) {
// a mouse down has occurred over the list area
static void MouseDown(GWidgetObject* gw, coord_t x, coord_t y) {
int pgsz;
coord_t iheight;
(void) x;
coord_t iheight, pgsz;
// Save our mouse start position
gw2obj->start_mouse_x = x;
gw2obj->start_mouse_y = y;
gw2obj->last_mouse_y = y;
iheight = gdispGetFontMetric(gw->g.font, fontHeight) + VERTICAL_PADDING;
pgsz = (gw->g.height-2);
if (pgsz < 1) pgsz = 1;
// For smooth scrolling, scrolling is done in the MouseMove and selection is done on MouseUp
if (gw->g.flags & GLIST_FLG_SCROLLSMOOTH)
return;
// Some initial stuff
iheight = gdispGetFontMetric(gw->g.font, fontHeight) + VERTICAL_PADDING;
pgsz = gw->g.height-2;
// Handle click over the scroll bar
if (gw2obj->cnt > (pgsz / iheight) && x >= gw->g.width-(SCROLLWIDTH+2)) {
if (x >= gw->g.width-(SCROLLWIDTH+2) && (gw2obj->cnt > pgsz/iheight || (gw->g.flags & GLIST_FLG_SCROLLALWAYS))) {
if (y < 2*ARROW) {
if (gw2obj->top > 0) {
gw2obj->top -= iheight;
@ -450,6 +354,10 @@ void gwinListSetScroll(GHandle gh, scroll_t flag) {
int gwinListAddItem(GHandle gh, const char* item_name, bool_t useAlloc) {
ListItem *newItem;
// is it a valid handle?
if (gh->vmt != (gwinVMT *)&listVMT)
return -1;
if (useAlloc) {
size_t len = strlen(item_name)+1;
if (!(newItem = gfxAlloc(sizeof(ListItem) + len)))
@ -687,6 +595,106 @@ const char* gwinListGetSelectedText(GHandle gh) {
}
#endif
static void gwinListDefaultDraw(GWidgetObject* gw, void* param) {
(void)param;
#if GDISP_NEED_CONVEX_POLYGON
static const point upArrow[] = { {0, ARROW}, {ARROW, ARROW}, {ARROW/2, 0} };
static const point downArrow[] = { {0, 0}, {ARROW, 0}, {ARROW/2, ARROW} };
#endif
const gfxQueueASyncItem* qi;
int i;
coord_t x, y, iheight, iwidth;
color_t fill;
const GColorSet * ps;
#if GWIN_NEED_LIST_IMAGES
coord_t sy;
#endif
// is it a valid handle?
if (gw->g.vmt != (gwinVMT *)&listVMT)
return;
// don't render if render has been disabled
if (!(gw->g.flags & GLIST_FLG_ENABLERENDER))
return;
ps = (gw->g.flags & GWIN_FLG_ENABLED) ? &gw->pstyle->enabled : &gw->pstyle->disabled;
iheight = gdispGetFontMetric(gw->g.font, fontHeight) + VERTICAL_PADDING;
x = 1;
// the scroll area
if (gw->g.flags & GLIST_FLG_SCROLLSMOOTH) {
iwidth = gw->g.width - 2 - 4;
if (gw2obj->cnt > 0) {
int max_scroll_value = gw2obj->cnt * iheight - gw->g.height-2;
if (max_scroll_value > 0) {
int bar_height = (gw->g.height-2) * (gw->g.height-2) / (gw2obj->cnt * iheight);
gdispGFillArea(gw->g.display, gw->g.x + gw->g.width-4, gw->g.y + 1, 2, gw->g.height-1, gw->pstyle->background);
gdispGFillArea(gw->g.display, gw->g.x + gw->g.width-4, gw->g.y + gw2obj->top * ((gw->g.height-2)-bar_height) / max_scroll_value, 2, bar_height, ps->edge);
}
}
} else if ((gw2obj->cnt > (gw->g.height-2) / iheight) || (gw->g.flags & GLIST_FLG_SCROLLALWAYS)) {
iwidth = gw->g.width - (SCROLLWIDTH+3);
gdispGFillArea(gw->g.display, gw->g.x+iwidth+2, gw->g.y+1, SCROLLWIDTH, gw->g.height-2, gdispBlendColor(ps->fill, gw->pstyle->background, 128));
gdispGDrawLine(gw->g.display, gw->g.x+iwidth+1, gw->g.y+1, gw->g.x+iwidth+1, gw->g.y+gw->g.height-2, ps->edge);
#if GDISP_NEED_CONVEX_POLYGON
gdispGFillConvexPoly(gw->g.display, gw->g.x+iwidth+((SCROLLWIDTH-ARROW)/2+2), gw->g.y+(ARROW/2+1), upArrow, 3, ps->fill);
gdispGFillConvexPoly(gw->g.display, gw->g.x+iwidth+((SCROLLWIDTH-ARROW)/2+2), gw->g.y+gw->g.height-(ARROW+ARROW/2+1), downArrow, 3, ps->fill);
#else
#warning "GWIN: Lists display better when GDISP_NEED_CONVEX_POLGON is turned on"
gdispGFillArea(gw->g.display, gw->g.x+iwidth+((SCROLLWIDTH-ARROW)/2+2), gw->g.y+(ARROW/2+1), ARROW, ARROW, ps->fill);
gdispGFillArea(gw->g.display, gw->g.x+iwidth+((SCROLLWIDTH-ARROW)/2+2), gw->g.y+gw->g.height-(ARROW+ARROW/2+1), ARROW, ARROW, ps->fill);
#endif
} else
iwidth = gw->g.width - 2;
#if GWIN_NEED_LIST_IMAGES
if ((gw->g.flags & GLIST_FLG_HASIMAGES)) {
x += iheight;
iwidth -= iheight;
}
#endif
// Find the top item
for (qi = gfxQueueASyncPeek(&gw2obj->list_head), i = iheight - 1; i < gw2obj->top && qi; qi = gfxQueueASyncNext(qi), i+=iheight);
// the list frame
gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, ps->edge);
// Set the clipping region so we do not override the frame.
gdispGSetClip(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2);
// Draw until we run out of room or items
for (y = 1-(gw2obj->top%iheight); y < gw->g.height-2 && qi; qi = gfxQueueASyncNext(qi), y += iheight) {
fill = (qi2li->flags & GLIST_FLG_SELECTED) ? ps->fill : gw->pstyle->background;
gdispGFillArea(gw->g.display, gw->g.x+1, gw->g.y+y, iwidth, iheight, fill);
#if GWIN_NEED_LIST_IMAGES
if ((gw->g.flags & GLIST_FLG_HASIMAGES)) {
// Clear the image area
if (qi2li->pimg && gdispImageIsOpen(qi2li->pimg)) {
// Calculate which image
sy = (qi2li->flags & GLIST_FLG_SELECTED) ? 0 : (iheight-VERTICAL_PADDING);
if (!(gw->g.flags & GWIN_FLG_ENABLED))
sy += 2*(iheight-VERTICAL_PADDING);
while (sy > qi2li->pimg->height)
sy -= iheight-VERTICAL_PADDING;
// Draw the image
gdispImageSetBgColor(qi2li->pimg, fill);
gdispGImageDraw(gw->g.display, qi2li->pimg, gw->g.x+1, gw->g.y+y, iheight-VERTICAL_PADDING, iheight-VERTICAL_PADDING, 0, sy);
}
}
#endif
gdispGFillStringBox(gw->g.display, gw->g.x+x+HORIZONTAL_PADDING, gw->g.y+y, iwidth-HORIZONTAL_PADDING, iheight, qi2li->text, gw->g.font, ps->text, fill, justifyLeft);
}
// Fill any remaining item space
if (y < gw->g.height-1)
gdispGFillArea(gw->g.display, gw->g.x+1, gw->g.y+y, iwidth, gw->g.height-1-y, gw->pstyle->background);
}
#endif // GFX_USE_GWIN && GWIN_NEED_LIST
/** @} */

View File

@ -43,7 +43,7 @@ static const gwidgetVMT progressbarVMT = {
{
"Progressbar", // The classname
sizeof(GProgressbarObject), // The object size
_destroy, // The destroy routine
_destroy, // The destroy routine
_gwidgetRedraw, // The redraw routine
0, // The after-clear routine
},
@ -180,7 +180,7 @@ void gwinProgressbarDecrement(GHandle gh) {
}
// used by gwinProgressbarStart();
void _progressbarCallback(void *param) {
static void _progressbarCallback(void *param) {
#define gsw ((GProgressbarObject *)gh)
GHandle gh = (GHandle)param;
@ -206,11 +206,13 @@ void gwinProgressbarStart(GHandle gh, delaytime_t delay) {
gtimerInit(&(gsw->gt));
gtimerStart(&(gsw->gt), _progressbarCallback, gh, FALSE, gsw->delay);
// if this is not made, the progressbar will not start when the it's already visible
if (gsw->w.g.flags & GWIN_FLG_VISIBLE) {
gwinSetVisible(gh, FALSE);
gwinSetVisible(gh, TRUE);
}
#if 0
// if this is not made, the progressbar will not start when it's already visible
if (gsw->w.g.flags & GWIN_FLG_VISIBLE) {
gwinSetVisible(gh, FALSE);
gwinSetVisible(gh, TRUE);
}
#endif
#undef gsw
}
@ -239,13 +241,6 @@ void gwinProgressbarDraw_Std(GWidgetObject *gw, void *param) {
if (gw->g.vmt != (gwinVMT *)&progressbarVMT)
return;
// disable the auto-update timer if any
#if GFX_USE_GTIMER
if (gtimerIsActive(&(gsw->gt)) && !(gw->g.flags & GWIN_FLG_ENABLED)) {
gtimerStop(&(gsw->gt));
}
#endif
// get the colors right
if ((gw->g.flags & GWIN_FLG_ENABLED))
pcol = &gw->pstyle->pressed;

View File

@ -21,6 +21,11 @@
#include "src/gwin/class_gwin.h"
#define GRADIO_TAB_CNR 3 // Diagonal corner on active tab
#define GRADIO_TOP_FADE 50 // (GRADIO_TOP_FADE/255)% fade to white for top of tab/button
#define GRADIO_BOTTOM_FADE 25 // (GRADIO_BOTTOM_FADE/255)% fade to black for bottom of tab/button
#define GRADIO_OUTLINE_FADE 128 // (GRADIO_OUTLINE_FADE/255)% fade to background for active tab edge
// Our pressed state
#define GRADIO_FLG_PRESSED (GWIN_FIRST_CONTROL_FLAG<<0)
@ -195,34 +200,86 @@ void gwinRadioDraw_Radio(GWidgetObject *gw, void *param) {
#undef gcw
}
void gwinRadioDraw_Button(GWidgetObject *gw, void *param) {
const GColorSet * pcol;
(void) param;
#if GWIN_FLAT_STYLING
void gwinRadioDraw_Button(GWidgetObject *gw, void *param) {
const GColorSet * pcol;
(void) param;
if (gw->g.vmt != (gwinVMT *)&radioVMT) return;
pcol = getDrawColors(gw);
if (gw->g.vmt != (gwinVMT *)&radioVMT) return;
pcol = getDrawColors(gw);
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter);
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge);
}
void gwinRadioDraw_Tab(GWidgetObject *gw, void *param) {
const GColorSet * pcol;
(void) param;
if (gw->g.vmt != (gwinVMT *)&radioVMT) return;
pcol = getDrawColors(gw);
if ((gw->g.flags & GRADIO_FLG_PRESSED)) {
gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, pcol->edge);
gdispGFillStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-1, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter);
} else {
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter);
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge);
}
}
void gwinRadioDraw_Tab(GWidgetObject *gw, void *param) {
const GColorSet * pcol;
(void) param;
if (gw->g.vmt != (gwinVMT *)&radioVMT) return;
pcol = getDrawColors(gw);
if ((gw->g.flags & GRADIO_FLG_PRESSED)) {
gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, pcol->edge);
gdispGFillStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-1, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter);
} else {
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter);
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge);
}
}
#else
void gwinRadioDraw_Button(GWidgetObject *gw, void *param) {
const GColorSet * pcol;
fixed alpha;
fixed dalpha;
coord_t i;
color_t tcol, bcol;
(void) param;
if (gw->g.vmt != (gwinVMT *)&radioVMT) return;
pcol = getDrawColors(gw);
/* Fill the box blended from variants of the fill color */
tcol = gdispBlendColor(White, pcol->fill, GRADIO_TOP_FADE);
bcol = gdispBlendColor(Black, pcol->fill, GRADIO_BOTTOM_FADE);
dalpha = FIXED(255)/gw->g.height;
for(alpha = 0, i = 0; i < gw->g.height; i++, alpha += dalpha)
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+i, gw->g.x+gw->g.width-2, gw->g.y+i, gdispBlendColor(bcol, tcol, NONFIXED(alpha)));
gdispGDrawStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, justifyCenter);
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge);
}
void gwinRadioDraw_Tab(GWidgetObject *gw, void *param) {
const GColorSet * pcol;
fixed alpha;
fixed dalpha;
coord_t i;
color_t tcol, bcol;
(void) param;
if (gw->g.vmt != (gwinVMT *)&radioVMT) return;
pcol = getDrawColors(gw);
if ((gw->g.flags & GRADIO_FLG_PRESSED)) {
tcol = gdispBlendColor(pcol->edge, gw->pstyle->background, GRADIO_OUTLINE_FADE);
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font, pcol->text, gw->g.bgcolor, justifyCenter);
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y, gw->g.x+gw->g.width-(GRADIO_TAB_CNR+1), gw->g.y, tcol);
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-(GRADIO_TAB_CNR+1), gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+GRADIO_TAB_CNR, tcol);
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y+GRADIO_TAB_CNR, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, tcol);
} else {
/* Fill the box blended from variants of the fill color */
tcol = gdispBlendColor(White, pcol->fill, GRADIO_TOP_FADE);
bcol = gdispBlendColor(Black, pcol->fill, GRADIO_BOTTOM_FADE);
dalpha = FIXED(255)/gw->g.height;
for(alpha = 0, i = 0; i < gw->g.height; i++, alpha += dalpha)
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+i, gw->g.x+gw->g.width-2, gw->g.y+i, gdispBlendColor(bcol, tcol, NONFIXED(alpha)));
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter);
}
}
#endif
#endif /* GFX_USE_GWIN && GWIN_NEED_BUTTON */
/** @} */

View File

@ -344,6 +344,24 @@ extern "C" {
*/
void gwinSetEnabled(GHandle gh, bool_t enabled);
/**
* @brief Enables a widget
*
* @param[in] gh The window handle
*
* @api
*/
#define gwinEnable(gh) gwinSetEnabled(gh, TRUE);
/**
* @brief Disables a widget
*
* @param[in] gh The window handle
*
* @api
*/
#define gwinDisable(gh) gwinSetEnabled(gh, FALSE);
/**
* @brief Gets the enabled state of a window
* @return TRUE if enabled

View File

@ -112,6 +112,15 @@
* @name GWIN Optional Parameters
* @{
*/
/**
* @brief Use flat styling for controls rather than a 3D look
* @details Defaults to FALSE
* @note This may appear better on color-restricted displays
* @note Flat styling is less graphics and cpu intensive (marginally) than the default 3D look.
*/
#ifndef GWIN_FLAT_STYLING
#define GWIN_FLAT_STYLING FALSE
#endif
/**
* @brief Buttons should not insist the mouse is over the button on mouse release
* @details Defaults to FALSE