aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTectu <joel@unormal.org>2012-08-13 04:12:42 +0200
committerTectu <joel@unormal.org>2012-08-13 04:12:42 +0200
commite27d04d002a40f3b514eeeb60d374df6a8a1280c (patch)
tree7c20e6edd42cd4f20eda183a16ce66c5e8c7105e
parent54229cbdaaf585b5adf9b085229a22c9824c112c (diff)
downloaduGFX-e27d04d002a40f3b514eeeb60d374df6a8a1280c.tar.gz
uGFX-e27d04d002a40f3b514eeeb60d374df6a8a1280c.tar.bz2
uGFX-e27d04d002a40f3b514eeeb60d374df6a8a1280c.zip
restructure
-rw-r--r--drivers/gdisp/gdispNokia6610/GE12.h81
-rw-r--r--drivers/gdisp/gdispNokia6610/GE8.h67
-rw-r--r--drivers/gdisp/gdispNokia6610/gdisp_lld.c688
-rw-r--r--drivers/gdisp/gdispNokia6610/gdisp_lld.mk5
-rw-r--r--drivers/gdisp/gdispNokia6610/gdisp_lld_board_example.h97
-rw-r--r--drivers/gdisp/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h199
-rw-r--r--drivers/gdisp/gdispNokia6610/gdisp_lld_config.h66
-rw-r--r--drivers/gdisp/gdispNokia6610/readme.txt17
-rw-r--r--drivers/gdisp/gdispS6d1121/gdisp_lld.c688
-rw-r--r--drivers/gdisp/gdispS6d1121/gdisp_lld.mk5
-rw-r--r--drivers/gdisp/gdispS6d1121/gdisp_lld_config.h66
-rw-r--r--drivers/gdisp/gdispS6d1121/readme.txt16
-rw-r--r--drivers/gdisp/gdispS6d1121/s6d1121_lld.c.h244
-rw-r--r--drivers/gdisp/gdispSsd1289/gdisp_lld.c610
-rw-r--r--drivers/gdisp/gdispSsd1289/gdisp_lld.mk5
-rw-r--r--drivers/gdisp/gdispSsd1289/gdisp_lld_config.h66
-rw-r--r--drivers/gdisp/gdispSsd1289/readme.txt16
-rw-r--r--drivers/gdisp/gdispSsd1289/ssd1289_lld.c.h322
-rw-r--r--drivers/gdisp/gdispTestStub/gdisp_lld.c361
-rw-r--r--drivers/gdisp/gdispTestStub/gdisp_lld.mk5
-rw-r--r--drivers/gdisp/gdispTestStub/gdisp_lld_config.h66
-rw-r--r--drivers/gdisp/gdispTestStub/readme.txt17
-rw-r--r--drivers/gdisp/gdispVMT/gdisp_lld.c249
-rw-r--r--drivers/gdisp/gdispVMT/gdisp_lld.mk7
-rw-r--r--drivers/gdisp/gdispVMT/gdisp_lld_config.h67
-rw-r--r--drivers/gdisp/gdispVMT/gdisp_lld_driver1.c51
-rw-r--r--drivers/gdisp/gdispVMT/gdisp_lld_driver2.c51
-rw-r--r--drivers/gdisp/gdispVMT/readme.txt23
-rw-r--r--drivers/touchpad/touchpadADS7843/readme.txt9
-rw-r--r--drivers/touchpad/touchpadADS7843/touchpad_lld.c146
-rw-r--r--drivers/touchpad/touchpadADS7843/touchpad_lld.mk6
-rw-r--r--drivers/touchpad/touchpadADS7843/touchpad_lld_config.h44
-rw-r--r--drivers/touchpad/touchpadXPT2046/readme.txt9
-rw-r--r--drivers/touchpad/touchpadXPT2046/touchpad_lld.c158
-rw-r--r--drivers/touchpad/touchpadXPT2046/touchpad_lld.mk6
-rw-r--r--drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h44
-rw-r--r--include/gdisp.h266
-rw-r--r--include/gdisp_emulation.c549
-rw-r--r--include/gdisp_fonts.h90
-rw-r--r--include/gdisp_lld.h599
-rw-r--r--include/gdisp_lld_msgs.h165
-rw-r--r--include/glcd.h136
-rw-r--r--include/touchpad.h93
-rw-r--r--include/touchpad_lld.h106
-rw-r--r--old/console.c171
-rw-r--r--old/console.h84
-rw-r--r--old/graph/graph.c75
-rw-r--r--old/graph/graph.h72
-rw-r--r--old/graph/graph.mk3
-rw-r--r--old/gui/gui.c334
-rw-r--r--old/gui/gui.h115
-rw-r--r--old/gui/gui.mk3
-rw-r--r--readme1.txt28
-rw-r--r--readme2.txt19
-rw-r--r--src/gdisp-readme.txt14
-rw-r--r--src/gdisp.c997
-rw-r--r--src/gdisp_fonts.c655
-rw-r--r--src/touchpad.c261
-rw-r--r--templates/gdispXXXXX/gdisp_lld.c490
-rw-r--r--templates/gdispXXXXX/gdisp_lld.mk5
-rw-r--r--templates/gdispXXXXX/gdisp_lld_config.h66
-rw-r--r--templates/gdispXXXXX/readme.txt35
-rw-r--r--templates/readme.txt4
63 files changed, 10012 insertions, 0 deletions
diff --git a/drivers/gdisp/gdispNokia6610/GE12.h b/drivers/gdisp/gdispNokia6610/GE12.h
new file mode 100644
index 00000000..7f438d9a
--- /dev/null
+++ b/drivers/gdisp/gdispNokia6610/GE12.h
@@ -0,0 +1,81 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef GE12_H
+#define GE12_H
+
+// *************************************************************************************
+// LCD Include File for Philips PCF8833 STN RGB- 132x132x3 Driver (GE12)
+//
+// Taken from Philips data sheet Feb 14, 2003
+// *************************************************************************************
+
+// Philips PCF8833 LCD controller command codes
+#define NOP 0x00 // nop
+#define SWRESET 0x01 // software reset
+#define BSTROFF 0x02 // booster voltage OFF
+#define BSTRON 0x03 // booster voltage ON
+#define RDDIDIF 0x04 // read display identification
+#define RDDST 0x09 // read display status
+#define SLEEPIN 0x10 // sleep in
+#define SLEEPOUT 0x11 // sleep out
+#define PTLON 0x12 // partial display mode
+#define NORON 0x13 // display normal mode
+#define INVOFF 0x20 // inversion OFF
+#define INVON 0x21 // inversion ON
+#define DALO 0x22 // all pixel OFF
+#define DAL 0x23 // all pixel ON
+#define SETCON 0x25 // write contrast
+#define DISPOFF 0x28 // display OFF
+#define DISPON 0x29 // display ON
+#define CASET 0x2A // column address set
+#define PASET 0x2B // page address set
+#define RAMWR 0x2C // memory write
+#define RGBSET 0x2D // colour set
+#define PTLAR 0x30 // partial area
+#define VSCRDEF 0x33 // vertical scrolling definition
+#define TEOFF 0x34 // test mode
+#define TEON 0x35 // test mode
+#define MADCTL 0x36 // memory access control
+#define SEP 0x37 // vertical scrolling start address
+#define IDMOFF 0x38 // idle mode OFF
+#define IDMON 0x39 // idle mode ON
+#define COLMOD 0x3A // interface pixel format
+#define SETVOP 0xB0 // set Vop
+#define BRS 0xB4 // bottom row swap
+#define TRS 0xB6 // top row swap
+#define DISCTR 0xB9 // display control
+#define DOR 0xBA // data order
+#define TCDFE 0xBD // enable/disable DF temperature compensation
+#define TCVOPE 0xBF // enable/disable Vop temp comp
+#define EC 0xC0 // internal or external oscillator
+#define SETMUL 0xC2 // set multiplication factor
+#define TCVOPAB 0xC3 // set TCVOP slopes A and B
+#define TCVOPCD 0xC4 // set TCVOP slopes c and d
+#define TCDF 0xC5 // set divider frequency
+#define DF8COLOR 0xC6 // set divider frequency 8-color mode
+#define SETBS 0xC7 // set bias system
+#define RDTEMP 0xC8 // temperature read back
+#define NLI 0xC9 // n-line inversion
+#define RDID1 0xDA // read ID1
+#define RDID2 0xDB // read ID2
+#define RDID3 0xDC // read ID3
+
+#endif /* GE12_H */
diff --git a/drivers/gdisp/gdispNokia6610/GE8.h b/drivers/gdisp/gdispNokia6610/GE8.h
new file mode 100644
index 00000000..3ae0be77
--- /dev/null
+++ b/drivers/gdisp/gdispNokia6610/GE8.h
@@ -0,0 +1,67 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef GE8_H
+#define GE8_H
+
+// *****************************************************************************
+// Include file for Epson S1D15G00 LCD Controller (GE8)
+//
+// Author: James P Lynch August 30, 2007
+// Modified for GDISP: Andrew Hannam August 2, 2012
+//
+// *****************************************************************************
+
+#define DISON 0xAF // Display on
+#define DISOFF 0xAE // Display off
+#define DISNOR 0xA6 // Normal display
+#define DISINV 0xA7 // Inverse display
+#define COMSCN 0xBB // Common scan direction
+#define DISCTL 0xCA // Display control
+#define SLPIN 0x95 // Sleep in
+#define SLPOUT 0x94 // Sleep out
+#define PASET 0x75 // Page address set
+#define CASET 0x15 // Column address set
+#define DATCTL 0xBC // Data scan direction, etc.
+#define RGBSET8 0xCE // 256-color position set
+#define RAMWR 0x5C // Writing to memory
+#define RAMRD 0x5D // Reading from memory
+#define PTLIN 0xA8 // Partial display in
+#define PTLOUT 0xA9 // Partial display out
+#define RMWIN 0xE0 // Read and modify write
+#define RMWOUT 0xEE // End
+#define ASCSET 0xAA // Area scroll set
+#define SCSTART 0xAB // Scroll start set
+#define OSCON 0xD1 // Internal oscillation on
+#define OSCOFF 0xD2 // Internal oscillation off
+#define PWRCTR 0x20 // Power control
+#define VOLCTR 0x81 // Electronic volume control
+#define VOLUP 0xD6 // Increment electronic control by 1
+#define VOLDOWN 0xD7 // Decrement electronic control by 1
+#define TMPGRD 0x82 // Temperature gradient set
+#define EPCTIN 0xCD // Control EEPROM
+#define EPCOUT 0xCC // Cancel EEPROM control
+#define EPMWR 0xFC // Write into EEPROM
+#define EPMRD 0xFD // Read from EEPROM
+#define EPSRRD1 0x7C // Read register 1
+#define EPSRRD2 0x7D // Read register 2
+#define NOP 0x25 // NOP instruction
+
+#endif /* GE8_H */
diff --git a/drivers/gdisp/gdispNokia6610/gdisp_lld.c b/drivers/gdisp/gdispNokia6610/gdisp_lld.c
new file mode 100644
index 00000000..5ebe2177
--- /dev/null
+++ b/drivers/gdisp/gdispNokia6610/gdisp_lld.c
@@ -0,0 +1,688 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispNokia6610/gdisp_lld.c
+ * @brief GDISP Graphics Driver subsystem low level driver source for the Nokia6610 display.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+#include "gdisp.h"
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+/* Include the emulation code for things we don't support */
+#include "gdisp_emulation.c"
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+/* Controller definitions */
+#if defined(LCD_USE_GE8)
+ #include "GE8.h"
+#elif defined(LCD_USE_GE12)
+ #include "GE12.h"
+#else
+ #error "gdispNokia6610: Either LCD_USE_GE8 or LCD_USE_GE12 must be defined depending on your controller"
+#endif
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+#include "gdisp_fonts.h"
+
+#if defined(BOARD_OLIMEX_SAM7_EX256)
+ #include "gdisp_lld_board_olimexsam7ex256.h"
+#else
+ /* Include the user supplied board definitions */
+ #include "gdisp_lld_board.h"
+#endif
+
+#define gdisp_lld_write_command(cmd) GDISP_LLD(write_spi)((cmd) & ~0x0100)
+#define gdisp_lld_write_data(data) GDISP_LLD(write_spi)((data) | 0x0100)
+
+static __inline void gdisp_lld_setviewport(coord_t x, coord_t y, coord_t cx, coord_t cy) {
+ gdisp_lld_write_command(CASET); // Column address set
+ gdisp_lld_write_data(x);
+ gdisp_lld_write_data(x+cx-1);
+ gdisp_lld_write_command(PASET); // Page address set
+ gdisp_lld_write_data(y);
+ gdisp_lld_write_data(y+cy-1);
+}
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/* ---- Required Routines ---- */
+/*
+ The following 2 routines are required.
+ All other routines are optional.
+*/
+
+/**
+ * @brief Low level GDISP driver initialization.
+ *
+ * @notapi
+ */
+bool_t GDISP_LLD(init)(void) {
+ /* Initialise your display */
+ GDISP_LLD(init_board)();
+
+ // Hardware reset
+ GDISP_LLD(setpin_reset)(TRUE);
+ chThdSleepMilliseconds(20);
+ GDISP_LLD(setpin_reset)(FALSE);
+ chThdSleepMilliseconds(20);
+
+ #if defined(LCD_USE_GE8)
+ #if 1
+ gdisp_lld_write_command(DISCTL); // Display control
+ gdisp_lld_write_data(0x00); // P1: 0x00 = 2 divisions, switching period=8 (default)
+ gdisp_lld_write_data(0x20); // P2: 0x20 = nlines/4 - 1 = 132/4 - 1 = 32)
+ gdisp_lld_write_data(0x00); // P3: 0x00 = no inversely highlighted lines
+ gdisp_lld_write_command(COMSCN); // COM scan
+ gdisp_lld_write_data(1); // P1: 0x01 = Scan 1->80, 160<-81
+ gdisp_lld_write_command(OSCON); // Internal oscilator ON
+ gdisp_lld_write_command(SLPOUT); // Sleep out
+ gdisp_lld_write_command(PWRCTR); // Power control
+ gdisp_lld_write_data(0x0f); // reference voltage regulator on, circuit voltage follower on, BOOST ON
+ // Interesting - all the code seems to say this should be done. But my display doesn't want it!
+ //gdisp_lld_write_command(DISINV); // Inverse display
+ gdisp_lld_write_command(DATCTL); // Data control
+ gdisp_lld_write_data(0x01); // P1: 0x01 = page address inverted, column address normal, address scan in column direction
+ gdisp_lld_write_data(0x00); // P2: 0x00 = RGB sequence (default value)
+ gdisp_lld_write_data(0x02); // P3: 0x02 = Grayscale -> 16 (selects 12-bit color, type A)
+ gdisp_lld_write_command(VOLCTR); // Voltage control (contrast setting)
+ gdisp_lld_write_data(32); // P1 = 32 volume value (experiment with this value to get the best contrast)
+ gdisp_lld_write_data(3); // P2 = 3 resistance ratio (only value that works)
+ chThdSleepMilliseconds(100); // allow power supply to stabilize
+ gdisp_lld_write_command(DISON); // Turn on the display
+ #else
+ // Alternative
+ gdisp_lld_write_command(DISCTL); // Display control
+ gdisp_lld_write_data(0x00); // default
+ gdisp_lld_write_data(0x20); // (32 + 1) * 4 = 132 lines (of which 130 are visible)
+ gdisp_lld_write_data(0x0a); // default
+ gdisp_lld_write_command(COMSCN); // COM scan
+ gdisp_lld_write_data(0x00); // Scan 1-80
+ gdisp_lld_write_command(OSCON); // Internal oscilator ON
+ chThdSleepMilliseconds(100); // wait aproximetly 100ms
+ gdisp_lld_write_command(SLPOUT); // Sleep out
+ gdisp_lld_write_command(VOLCTR); // Voltage control
+ gdisp_lld_write_data(0x1F); // middle value of V1
+ gdisp_lld_write_data(0x03); // middle value of resistance value
+ gdisp_lld_write_command(TMPGRD); // Temperature gradient
+ gdisp_lld_write_data(0x00); // default
+ gdisp_lld_write_command(PWRCTR); // Power control
+ gdisp_lld_write_data(0x0f); // referance voltage regulator on, circuit voltage follower on, BOOST ON
+ gdisp_lld_write_command(DISNOR); // Normal display
+ gdisp_lld_write_command(DISINV); // Inverse display
+ gdisp_lld_write_command(PTLOUT); // Partial area off
+ // gdisp_lld_write_command(ASCSET); // Scroll area set
+ // gdisp_lld_write_data(0);
+ // gdisp_lld_write_data(0);
+ // gdisp_lld_write_data(40);
+ // gdisp_lld_write_data(3);
+ // gdisp_lld_write_command(SCSTART); // Vertical scrool address start
+ // gdisp_lld_write_data(0);
+ gdisp_lld_write_command(DATCTL); // Data control
+ gdisp_lld_write_data(0x00); // all inversions off, column direction
+ gdisp_lld_write_data(0x03); // RGB sequence
+ gdisp_lld_write_data(0x02); // Grayscale -> 16
+ gdisp_lld_write_command(PASET); // Page Address set
+ gdisp_lld_write_data(0);
+ gdisp_lld_write_data(131);
+ gdisp_lld_write_command(CASET); // Page Column set
+ gdisp_lld_write_data(0);
+ gdisp_lld_write_data(131);
+ gdisp_lld_write_command(DISON); // Turn on the display
+ #endif
+
+ #elif defined(LCD_USE_GE12)
+ #if 1
+ gdisp_lld_write_command(SLEEPOUT); // Sleep out
+ gdisp_lld_write_command(INVON); // Inversion on: seems to be required for this controller
+ gdisp_lld_write_command(COLMOD); // Color Interface Pixel Format
+ gdisp_lld_write_data(0x03); // 0x03 = 12 bits-per-pixel
+ gdisp_lld_write_command(MADCTL); // Memory access controler
+ gdisp_lld_write_data(0xC8); // 0xC0 = mirror x and y, reverse rgb
+ gdisp_lld_write_command(SETCON); // Write contrast
+ gdisp_lld_write_data(0x30); // contrast - experiental value
+ chThdSleepMilliseconds(20);
+ gdisp_lld_write_command(DISPON); // Display On
+ #else
+ // Alternative
+ // Hardware reset commented out
+ gdisp_lld_write_command(SOFTRST); // Software Reset
+ chThdSleepMilliseconds(20);
+ gdisp_lld_write_command(INITESC); // Initial escape
+ chThdSleepMilliseconds(20);
+ gdisp_lld_write_command(REFSET); // Refresh set
+ gdisp_lld_write_data(0);
+ gdisp_lld_write_command(DISPCTRL); // Set Display control
+ gdisp_lld_write_data(128); // Set the lenght of one selection term
+ gdisp_lld_write_data(128); // Set N inversion -> no N inversion
+ gdisp_lld_write_data(134); // Set frame frequence and bias rate -> 2 devision of frequency and 1/8 bias, 1/67 duty, 96x67 size
+ gdisp_lld_write_data(84); // Set duty parameter
+ gdisp_lld_write_data(69); // Set duty parameter
+ gdisp_lld_write_data(82); // Set duty parameter
+ gdisp_lld_write_data(67); // Set duty parameter
+ gdisp_lld_write_command(GRAYSCALE0); // Grey scale 0 position set - 15 parameters
+ gdisp_lld_write_data(1); // GCP1 - gray lavel to be output when the RAM data is "0001"
+ gdisp_lld_write_data(2); // GCP2 - gray lavel to be output when the RAM data is "0010"
+ gdisp_lld_write_data(4); // GCP3 - gray lavel to be output when the RAM data is "0011"
+ gdisp_lld_write_data(8); // GCP4 - gray lavel to be output when the RAM data is "0100"
+ gdisp_lld_write_data(16); // GCP5 - gray lavel to be output when the RAM data is "0101"
+ gdisp_lld_write_data(30); // GCP6 - gray lavel to be output when the RAM data is "0110"
+ gdisp_lld_write_data(40); // GCP7 - gray lavel to be output when the RAM data is "0111"
+ gdisp_lld_write_data(50); // GCP8 - gray lavel to be output when the RAM data is "1000"
+ gdisp_lld_write_data(60); // GCP9 - gray lavel to be output when the RAM data is "1001"
+ gdisp_lld_write_data(70); // GCP10 - gray lavel to be output when the RAM data is "1010"
+ gdisp_lld_write_data(80); // GCP11 - gray lavel to be output when the RAM data is "1011"
+ gdisp_lld_write_data(90); // GCP12 - gray lavel to be output when the RAM data is "1100"
+ gdisp_lld_write_data(100); // GCP13 - gray lavel to be output when the RAM data is "1101"
+ gdisp_lld_write_data(110); // GCP14 - gray lavel to be output when the RAM data is "1110"
+ gdisp_lld_write_data(127); // GCP15 - gray lavel to be output when the RAM data is "1111"
+ gdisp_lld_write_command(GAMMA); // Gamma curve set - select gray scale - GRAYSCALE 0 or GREYSCALE 1
+ gdisp_lld_write_data(1); // Select grey scale 0
+ gdisp_lld_write_command(COMMONDRV); // Command driver output
+ gdisp_lld_write_data(0); // Set COM1-COM41 side come first, normal mod
+ gdisp_lld_write_command(NORMALMODE); // Set Normal mode (my)
+ // gdisp_lld_write_command(INVERSIONOFF); // Inversion off
+ gdisp_lld_write_command(COLADDRSET); // Column address set
+ gdisp_lld_write_data(0);
+ gdisp_lld_write_data(131);
+ gdisp_lld_write_command(PAGEADDRSET); // Page address set
+ gdisp_lld_write_data(0);
+ gdisp_lld_write_data(131);
+ gdisp_lld_write_command(ACCESSCTRL); // Memory access controler
+ gdisp_lld_write_data(0x40); // horizontal
+ //gdisp_lld_write_data(0x20); // vertical
+ gdisp_lld_write_command(PWRCTRL); // Power control
+ gdisp_lld_write_data(4); // Internal resistance, V1OUT -> high power mode, oscilator devision rate
+ gdisp_lld_write_command(SLEEPOUT); // Sleep out
+ gdisp_lld_write_command(VOLTCTRL); // Voltage control - voltage control and write contrast define LCD electronic volume
+ //gdisp_lld_write_data(0x7f); // full voltage control
+ //gdisp_lld_write_data(0x03); // must be "1"
+ gdisp_lld_write_command(CONTRAST); // Write contrast
+ gdisp_lld_write_data(0x3b); // contrast
+ chThdSleepMilliseconds(20);
+ gdisp_lld_write_command(TEMPGRADIENT); // Temperature gradient
+ for(i=0; i<14; i++) gdisp_lld_write_data(0);
+ gdisp_lld_write_command(BOOSTVON); // Booster voltage ON
+ gdisp_lld_write_command(DISPLAYON); // Finally - Display On
+ #endif
+ #endif
+
+ /* Turn on the back-light */
+ GDISP_LLD(setpin_backlight)(TRUE);
+
+ /* Initialise the GDISP structure to match */
+ GDISP.Width = 132;
+ GDISP.Height = 132;
+ GDISP.Orientation = portrait;
+ GDISP.Powermode = powerOn;
+ GDISP.Backlight = 100;
+ GDISP.Contrast = 50;
+ return TRUE;
+}
+
+/**
+ * @brief Draws a pixel on the display.
+ *
+ * @param[in] x X location of the pixel
+ * @param[in] y Y location of the pixel
+ * @param[in] color The color of the pixel
+ *
+ * @notapi
+ */
+void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ if (x >= GDISP.Width || y >= GDISP.Height) return;
+ #endif
+ gdisp_lld_setviewport(x, y, 1, 1);
+ gdisp_lld_write_command(RAMWR);
+ gdisp_lld_write_data((color >> 4) & 0xFF);
+ gdisp_lld_write_data((color << 4) & 0xF0);
+ gdisp_lld_write_command(NOP);
+}
+
+/* ---- Optional Routines ---- */
+/*
+ All the below routines are optional.
+ Defining them will increase speed but everything
+ will work if they are not defined.
+ If you are not using a routine - turn it off using
+ the appropriate GDISP_HARDWARE_XXXX macro.
+ Don't bother coding for obvious similar routines if
+ there is no performance penalty as the emulation software
+ makes a good job of using similar routines.
+ eg. If fillarea() is defined there is little
+ point in defining clear() unless the
+ performance bonus is significant.
+ For good performance it is suggested to implement
+ fillarea() and blitarea().
+*/
+
+#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__)
+ /**
+ * @brief Clear the display.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] color The color of the pixel
+ *
+ * @notapi
+ */
+ void GDISP_LLD(clear(color_t color) {
+ /* NOT IMPLEMENTED */
+ /* Nothing to be gained by implementing this
+ * as fillarea is just as fast.
+ */
+ }
+#endif
+
+#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a line.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x0, y0 The start of the line
+ * @param[in] x1, y1 The end of the line
+ * @param[in] color The color of the line
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__)
+ /**
+ * @brief Fill an area with a color.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The start filled area
+ * @param[in] cx, cy The width and height to be filled
+ * @param[in] color The color of the fill
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
+ unsigned i, tuples;
+
+ #if GDISP_NEED_VALIDATION
+ if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
+ if (x+cx > GDISP.Width) cx = GDISP.Width - x;
+ if (y+cy > GDISP.Height) cy = GDISP.Height - y;
+ #endif
+
+ tuples = (cx*cy+1)/2; // With an odd sized area we over-print by one pixel.
+ // This extra pixel is ignored by the controller.
+
+ gdisp_lld_setviewport(x, y, cx, cy);
+ gdisp_lld_write_command(RAMWR);
+ for(i=0; i < tuples; i++) {
+ gdisp_lld_write_data((color >> 4) & 0xFF);
+ gdisp_lld_write_data(((color << 4) & 0xF0)|((color >> 8) & 0x0F));
+ gdisp_lld_write_data(color & 0xFF);
+ }
+ }
+#endif
+
+#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__)
+ /**
+ * @brief Fill an area with a bitmap.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The start filled area
+ * @param[in] cx, cy The width and height to be filled
+ * @param[in] buffer The pixels to use to fill the area.
+ *
+ * @notapi
+ */
+ void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) {
+ unsigned i, area, tuples;
+ #ifndef GDISP_PACKED_PIXELS
+ color_t c1, c2;
+ #endif
+
+ #if GDISP_NEED_VALIDATION
+ if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
+ if (x+cx > GDISP.Width) return;
+ if (y+cy > GDISP.Height) cy = GDISP.Height - y;
+ #endif
+
+ area = cx*cy;
+
+ gdisp_lld_setviewport(x, y, cx, cy);
+ gdisp_lld_write_command(RAMWR);
+
+ #ifdef GDISP_PACKED_PIXELS
+ // 3 bytes per 2 pixels + an extra 2 bytes if the total size is odd.
+ // Note we can't just over-estimate this and let the controller handle the extra pixel
+ // as that might over-run our source buffer (very bad in some circumstances).
+ tuples = (area/2)*3+(area & 0x01)*2;
+ for(i=0; i < tuples; i++)
+ gdisp_lld_write_data(*buffer++);
+ if (area & 0x01)
+ gdisp_lld_write_command(NOP);
+ #else
+ // Although this controller uses packed pixels we support unpacked pixel
+ // formats in this blit by packing the data as we feed it to the controller.
+ tuples = area/2;
+ for(i=0; i < tuples; i++) {
+ c1 = *buffer++;
+ c2 = *buffer++;
+ gdisp_lld_write_data((c1 >> 4) & 0xFF);
+ gdisp_lld_write_data(((c1 << 4) & 0xF0)|((c2 >> 8) & 0x0F));
+ gdisp_lld_write_data(c2 & 0xFF);
+ }
+ if (area & 0x01) {
+ c1 = *buffer++;
+ gdisp_lld_write_data((c1 >> 4) & 0xFF);
+ gdisp_lld_write_data((c1 << 4) & 0xF0);
+ gdisp_lld_write_command(NOP);
+ }
+ #endif
+ }
+#endif
+
+/* Circular Drawing Functions */
+#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a circle.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the circle is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color of the circle
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Create a filled circle.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the circle is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color of the circle
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw an ellipse.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the ellipse is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the ellipse
+ * @param[in] a, b The dimensions of the ellipse
+ * @param[in] color The color of the ellipse
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Create a filled ellipse.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the ellipse is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the ellipse
+ * @param[in] a, b The dimensions of the ellipse
+ * @param[in] color The color of the ellipse
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__)
+ #include "gdisp_fonts.h"
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a character using a transparent background.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The top-left corner of the text
+ * @param[in] c The character to print
+ * @param[in] color The color of the character
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a character using a filled background.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The top-left corner of the text
+ * @param[in] c The character to print
+ * @param[in] color The color of the character
+ * @param[in] bgcolor The background color
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__)
+ /**
+ * @brief Get the color of a particular pixel.
+ * @note Optional.
+ * @note If x,y is off the screen, the result is undefined.
+ *
+ * @param[in] x, y The start of the text
+ *
+ * @notapi
+ */
+ color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__)
+ /**
+ * @brief Scroll vertically a section of the screen.
+ * @note Optional.
+ * @note If x,y + cx,cy is off the screen, the result is undefined.
+ * @note If lines is >= cy, it is equivelent to a area fill with bgcolor.
+ *
+ * @param[in] x, y The start of the area to be scrolled
+ * @param[in] cx, cy The size of the area to be scrolled
+ * @param[in] lines The number of lines to scroll (Can be positive or negative)
+ * @param[in] bgcolor The color to fill the newly exposed area.
+ *
+ * @notapi
+ */
+ void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__)
+ /**
+ * @brief Driver Control
+ * @detail Unsupported control codes are ignored.
+ * @note The value parameter should always be typecast to (void *).
+ * @note There are some predefined and some specific to the low level driver.
+ * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t
+ * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t
+ * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver
+ * that only supports off/on anything other
+ * than zero is on.
+ * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100.
+ * GDISP_CONTROL_LLD - Low level driver control constants start at
+ * this value.
+ *
+ * @param[in] what What to do.
+ * @param[in] value The value to use (always cast to a void *).
+ *
+ * @notapi
+ */
+ void GDISP_LLD(control)(int what, void *value) {
+ /* NOT IMPLEMENTED YET */
+ switch(what) {
+ case GDISP_CONTROL_POWER:
+ if (GDISP.Powermode == (gdisp_powermode_t)value)
+ return;
+ switch((gdisp_powermode_t)value) {
+ case powerOff:
+ /* Code here */
+ break;
+ case powerOn:
+ /* Code here */
+ /* You may need this ---
+ if (GDISP.Powermode != powerSleep)
+ GDISP_LLD(init();
+ */
+ break;
+ case powerSleep:
+ /* Code here */
+ break;
+ default:
+ return;
+ }
+ GDISP.Powermode = (gdisp_powermode_t)value;
+ return;
+ case GDISP_CONTROL_ORIENTATION:
+ if (GDISP.Orientation == (gdisp_orientation_t)value)
+ return;
+ // WriteSpiData(0x48); // no mirror Y (temporary to satisfy Olimex bmptoarray utility)
+ // WriteSpiData(0xC8); // restore to (mirror x and y, reverse rgb)
+ switch((gdisp_orientation_t)value) {
+ case portrait:
+ /* Code here */
+ GDISP.Height = SCREEN_HEIGHT;
+ GDISP.Width = SCREEN_WIDTH;
+ break;
+ case landscape:
+ /* Code here */
+ GDISP.Height = SCREEN_WIDTH;
+ GDISP.Width = SCREEN_HEIGHT;
+ break;
+ case portraitInv:
+ /* Code here */
+ GDISP.Height = SCREEN_HEIGHT;
+ GDISP.Width = SCREEN_WIDTH;
+ break;
+ case landscapeInv:
+ /* Code here */
+ GDISP.Height = SCREEN_WIDTH;
+ GDISP.Width = SCREEN_HEIGHT;
+ break;
+ default:
+ return;
+ }
+ GDISP.Orientation = (gdisp_orientation_t)value;
+ return;
+/*
+ case GDISP_CONTROL_BACKLIGHT:
+ case GDISP_CONTROL_CONTRAST:
+*/
+ }
+ }
+#endif
+
+#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__)
+/**
+ * @brief Query a driver value.
+ * @detail Typecase the result to the type you want.
+ * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen
+ * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen
+ * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode
+ * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation
+ * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100)
+ * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100).
+ * GDISP_QUERY_LLD - Low level driver control constants start at
+ * this value.
+ *
+ * @param[in] what What to Query
+ *
+ * @notapi
+ */
+void *GDISP_LLD(query)(unsigned what) {
+ switch(what) {
+ case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width;
+ case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height;
+ case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode;
+ case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation;
+ case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight;
+ case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast;
+ case GDISP_QUERY_LLD+0:
+ /* Code here */
+ default: return (void *)-1;
+ }
+}
+#endif
+
+#endif /* HAL_USE_GDISP */
+/** @} */
diff --git a/drivers/gdisp/gdispNokia6610/gdisp_lld.mk b/drivers/gdisp/gdispNokia6610/gdisp_lld.mk
new file mode 100644
index 00000000..4c980c3c
--- /dev/null
+++ b/drivers/gdisp/gdispNokia6610/gdisp_lld.mk
@@ -0,0 +1,5 @@
+# List the required driver.
+LCDSRC += $(LCDLIB)/drivers/gdisp/gdispNokia6610/gdisp_lld.c
+
+# Required include directories
+LCDINC += $(LCDLIB)/drivers/gdisp/gdispNokia6610
diff --git a/drivers/gdisp/gdispNokia6610/gdisp_lld_board_example.h b/drivers/gdisp/gdispNokia6610/gdisp_lld_board_example.h
new file mode 100644
index 00000000..0e2b806e
--- /dev/null
+++ b/drivers/gdisp/gdispNokia6610/gdisp_lld_board_example.h
@@ -0,0 +1,97 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispNokia6610/gdisp_lld_board_example.h
+ * @brief GDISP Graphic Driver subsystem board interface for the Nokia6610 display.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_LLD_BOARD_H
+#define _GDISP_LLD_BOARD_H
+
+/**
+ * @brief Initialise the board for the display.
+ * @notes Performs the following functions:
+ * 1. initialise the spi port used by your display
+ * 2. initialise the reset pin (initial state not-in-reset)
+ * 3. initialise the chip select pin (initial state not-active)
+ * 4. initialise the backlight pin (initial state back-light off)
+ *
+ * @notapi
+ */
+static __inline void GDISP_LLD(init_board)(void) {
+ /* Code here */
+}
+
+/**
+ * @brief Set or clear the lcd reset pin.
+ *
+ * @param[in] state TRUE = lcd in reset, FALSE = normal operation
+ *
+ * @notapi
+ */
+static __inline void GDISP_LLD(setpin_reset)(bool_t state) {
+ /* Code here */
+}
+
+/**
+ * @brief Set or clear the lcd back-light pin.
+ *
+ * @param[in] state TRUE = lcd back-light on, FALSE = lcd back-light off
+ *
+ * @notapi
+ */
+static __inline void GDISP_LLD(setpin_backlight)(bool_t state) {
+ /* Code here */
+}
+
+/**
+ * @brief Send a 9 bit command/data to the lcd.
+ * @note The chip select may need to be asserted/de-asserted
+ * around the actual spi write
+ *
+ * @param[in] data The data to send
+ *
+ * @notapi
+ */
+static __inline void GDISP_LLD(write_spi)(uint16_t data) {
+ /* Code here */
+}
+
+#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__)
+/**
+ * @brief Read data from the lcd.
+ *
+ * @return The data from the lcd
+ * @note The chip select may need to be asserted/de-asserted
+ * around the actual spi read
+ *
+ * @notapi
+ */
+static __inline uint16_t GDISP_LLD(read_spi)(void) {
+ /* Code here */
+}
+#endif
+
+#endif /* _GDISP_LLD_BOARD_H */
+/** @} */
diff --git a/drivers/gdisp/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h b/drivers/gdisp/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h
new file mode 100644
index 00000000..b5b4b1d5
--- /dev/null
+++ b/drivers/gdisp/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h
@@ -0,0 +1,199 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h
+ * @brief GDISP Graphic Driver subsystem board interface for the Olimex SAM7-EX256 board.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_LLD_BOARD_H
+#define _GDISP_LLD_BOARD_H
+
+// mask definitions
+#define BIT0 0x00000001
+#define BIT1 0x00000002
+#define BIT2 0x00000004
+#define BIT3 0x00000008
+#define BIT4 0x00000010
+#define BIT5 0x00000020
+#define BIT6 0x00000040
+#define BIT7 0x00000080
+#define BIT8 0x00000100
+#define BIT9 0x00000200
+#define BIT10 0x00000400
+#define BIT11 0x00000800
+#define BIT12 0x00001000
+#define BIT13 0x00002000
+#define BIT14 0x00004000
+#define BIT15 0x00008000
+#define BIT16 0x00010000
+#define BIT17 0x00020000
+#define BIT18 0x00040000
+#define BIT19 0x00080000
+#define BIT20 0x00100000
+#define BIT21 0x00200000
+#define BIT22 0x00400000
+#define BIT23 0x00800000
+#define BIT24 0x01000000
+#define BIT25 0x02000000
+#define BIT26 0x04000000
+#define BIT27 0x08000000
+#define BIT28 0x10000000
+#define BIT29 0x20000000
+#define BIT30 0x40000000
+#define BIT31 0x80000000
+
+// ******************************************************
+// Pointers to AT91SAM7X256 peripheral data structures
+// ******************************************************
+volatile AT91PS_PIO pPIOA = AT91C_BASE_PIOA;
+volatile AT91PS_PIO pPIOB = AT91C_BASE_PIOB;
+volatile AT91PS_SPI pSPI = AT91C_BASE_SPI0;
+volatile AT91PS_PMC pPMC = AT91C_BASE_PMC;
+volatile AT91PS_PDC pPDC = AT91C_BASE_PDC_SPI0;
+
+/**
+ * @brief Initialise the board for the display.
+ * @notes Performs the following functions:
+ * 1. initialise the spi port used by your display
+ * 2. initialise the reset pin (initial state not-in-reset)
+ * 3. initialise the chip select pin (initial state not-active)
+ * 4. initialise the backlight pin (initial state back-light off)
+ *
+ * @notapi
+ */
+static __inline void GDISP_LLD(init_board)(void) {
+ // *********************************************************************************************
+ // InitSpi( )
+ //
+ // Sets up SPI channel 0 for communications to Nokia 6610 LCD Display
+ //
+ // I/O ports used: PA2 = LCD Reset (set to low to reset)
+ // PA12 = LCD chip select (set to low to select the LCD chip)
+ // PA16 = SPI0_MISO Master In - Slave Out (not used in LCD interface)
+ // PA17 = SPI0_MOSI Master Out - Slave In pin (Serial Data to LCD slave)
+ // PA18 = SPI0_SPCK Serial Clock (to LCD slave)
+ // PB20 = backlight control (normally PWM control, 1 = full on)
+ //
+ // *********************************************************************************************}
+
+ /* This code should really use the ChibiOS driver for these functions */
+
+ // Pin for backlight
+ pPIOB->PIO_CODR = PIOB_LCD_BL_MASK; // Set PB20 to LOW
+ pPIOB->PIO_OER = PIOB_LCD_BL_MASK; // Configure PB20 as output
+
+ // Reset pin
+ pPIOA->PIO_SODR = PIOA_LCD_RESET_MASK; // Set PA2 to HIGH
+ pPIOA->PIO_OER = PIOA_LCD_RESET_MASK; // Configure PA2 as output
+
+ // CS pin - this seems to be ignored
+ // pPIOA->PIO_SODR = BIT12; // Set PA2 to HIGH
+ // pPIOA->PIO_OER = BIT12; // Configure PA2 as output
+
+ // Init SPI0
+ // Disable the following pins from PIO control (will be used instead by the SPI0 peripheral)
+ // BIT12 = PA12 -> SPI0_NPCS0 chip select
+ // BIT16 = PA16 -> SPI0_MISO Master In - Slave Out (not used in LCD interface)
+ // BIT17 = PA17 -> SPI0_MOSI Master Out - Slave In pin (Serial Data to LCD slave)
+ // BIT18 = PA18 -> SPI0_SPCK Serial Clock (to LCD slave)
+ pPIOA->PIO_PDR = BIT12 | BIT16 | BIT17 | BIT18;
+ pPIOA->PIO_ASR = BIT12 | BIT16 | BIT17 | BIT18;
+ pPIOA->PIO_BSR = 0;
+
+ //enable the clock of SPI
+ pPMC->PMC_PCER = 1 << AT91C_ID_SPI0;
+
+ // Fixed mode
+ pSPI->SPI_CR = 0x81; //SPI Enable, Sowtware reset
+ pSPI->SPI_CR = 0x01; //SPI Enable
+
+ //pSPI->SPI_MR = 0xE0019; //Master mode, fixed select, disable decoder, FDIV=1 (MCK), PCS=1110
+ pSPI->SPI_MR = 0xE0011; //Master mode, fixed select, disable decoder, FDIV=0 (MCK), PCS=1110
+
+ //pSPI->SPI_CSR[0] = 0x01010C11; //9bit, CPOL=1, ClockPhase=0, SCLK = 48Mhz/32*12 = 125kHz
+ pSPI->SPI_CSR[0] = 0x01010311; //9bit, CPOL=1, ClockPhase=0, SCLK = 48Mhz/8 = 6MHz if using commented MR line above
+}
+
+/**
+ * @brief Set or clear the lcd reset pin.
+ *
+ * @param[in] state TRUE = lcd in reset, FALSE = normal operation
+ *
+ * @notapi
+ */
+static __inline void GDISP_LLD(setpin_reset)(bool_t state) {
+ if (state)
+ palClearPad(IOPORT1, PIOA_LCD_RESET);
+// pPIOA->PIO_CODR = PIOA_LCD_RESET_MASK;
+ else
+ palSetPad(IOPORT1, PIOA_LCD_RESET);
+// pPIOA->PIO_SODR = PIOA_LCD_RESET_MASK;
+}
+
+/**
+ * @brief Set or clear the lcd back-light pin.
+ *
+ * @param[in] state TRUE = lcd back-light on, FALSE = lcd back-light off
+ *
+ * @notapi
+ */
+static __inline void GDISP_LLD(setpin_backlight)(bool_t state) {
+ if (state)
+ palSetPad(IOPORT2, PIOB_LCD_BL);
+// pPIOB->PIO_SODR = PIOB_LCD_BL_MASK;
+ else
+ palClearPad(IOPORT2, PIOB_LCD_BL);
+// pPIOB->PIO_CODR = PIOB_LCD_BL_MASK;
+}
+
+/**
+ * @brief Send a 9 bit command/data to the lcd.
+ *
+ * @param[in] data The data to send
+ *
+ * @notapi
+ */
+static __inline void GDISP_LLD(write_spi)(uint16_t data) {
+ // wait for the previous transfer to complete
+ while((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0);
+ // send the data
+ pSPI->SPI_TDR = data;
+}
+
+#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__)
+/**
+ * @brief Read data from the lcd.
+ *
+ * @return The data from the lcd
+ *
+ * @notapi
+ */
+static __inline uint16_t GDISP_LLD(read_spi)(void) {
+ #error "gdispNokia6610: GDISP_HARDWARE_READPIXEL and GDISP_HARDWARE_SCROLL are not supported on this board"
+ return 0;
+}
+#endif
+
+#endif /* _GDISP_LLD_BOARD_H */
+/** @} */
diff --git a/drivers/gdisp/gdispNokia6610/gdisp_lld_config.h b/drivers/gdisp/gdispNokia6610/gdisp_lld_config.h
new file mode 100644
index 00000000..9e2d1258
--- /dev/null
+++ b/drivers/gdisp/gdispNokia6610/gdisp_lld_config.h
@@ -0,0 +1,66 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispNokia6610/gdisp_lld_config.h
+ * @brief GDISP Graphic Driver subsystem low level driver header for the Nokia6610 display.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_LLD_CONFIG_H
+#define _GDISP_LLD_CONFIG_H
+
+#if HAL_USE_GDISP
+
+/*===========================================================================*/
+/* Driver hardware support. */
+/*===========================================================================*/
+
+#define GDISP_DRIVER_NAME "Nokia6610"
+#define GDISP_LLD(x) gdisp_lld_##x##_Nokia6610
+
+#define GDISP_HARDWARE_LINES FALSE
+#define GDISP_HARDWARE_CLEARS FALSE
+#define GDISP_HARDWARE_FILLS TRUE
+#define GDISP_HARDWARE_BITFILLS TRUE
+#define GDISP_HARDWARE_CIRCLES FALSE
+#define GDISP_HARDWARE_CIRCLEFILLS FALSE
+#define GDISP_HARDWARE_ELLIPSES FALSE
+#define GDISP_HARDWARE_ELLIPSEFILLS FALSE
+#define GDISP_HARDWARE_TEXT FALSE
+#define GDISP_HARDWARE_TEXTFILLS FALSE
+#define GDISP_HARDWARE_SCROLL FALSE
+#define GDISP_HARDWARE_PIXELREAD FALSE
+#define GDISP_HARDWARE_CONTROL FALSE
+#define GDISP_HARDWARE_QUERY FALSE
+
+#define GDISP_SOFTWARE_TEXTFILLDRAW TRUE
+#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE
+
+#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB444
+#define GDISP_PACKED_PIXELS FALSE
+#define GDISP_PACKED_LINES FALSE
+
+#endif /* HAL_USE_GDISP */
+
+#endif /* _GDISP_LLD_CONFIG_H */
+/** @} */
diff --git a/drivers/gdisp/gdispNokia6610/readme.txt b/drivers/gdisp/gdispNokia6610/readme.txt
new file mode 100644
index 00000000..facb400f
--- /dev/null
+++ b/drivers/gdisp/gdispNokia6610/readme.txt
@@ -0,0 +1,17 @@
+To use this driver:
+
+1. Add in your halconf.h:
+ a) #define HAL_USE_GDISP TRUE
+ b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD
+ c) One (only) of:
+ #define LCD_USE_GE8 /* The Epson controller */
+ #define LCD_USE_GE12 /* The Philips controller */
+ d) If you are not using a known board then create a gdisp_lld_board.h file
+ and ensure it is on your include path.
+ Use the gdisp_lld_board_example.h file as a basis.
+ Currently known boards are:
+ Olimex SAM7-EX256
+
+2. To your makefile add the following lines:
+ include $(CHIBIOS)/os/halext/halext.mk
+ include $(CHIBIOS)/os/halext/drivers/gdispXXXXX/gdisp_lld.mk
diff --git a/drivers/gdisp/gdispS6d1121/gdisp_lld.c b/drivers/gdisp/gdispS6d1121/gdisp_lld.c
new file mode 100644
index 00000000..5811a6ed
--- /dev/null
+++ b/drivers/gdisp/gdispS6d1121/gdisp_lld.c
@@ -0,0 +1,688 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispS6d1121/gdisp_lld.c
+ * @brief GDISP Graphics Driver subsystem low level driver source for the S6d1121 display.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+#include "gdisp.h"
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+/* Include the emulation code for things we don't support */
+#include "gdisp_emulation.c"
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+#include "s6d1121_lld.c.h"
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/* ---- Required Routines ---- */
+/*
+ The following 2 routines are required.
+ All other routines are optional.
+*/
+
+/**
+ * @brief Low level GDISP driver initialization.
+ *
+ * @notapi
+ */
+bool_t GDISP_LLD(init)(void) {
+ palSetPadMode(LCD_RST_GPIO, LCD_RST_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
+ // A Good idea to reset the module before using
+ LCD_RST_LOW;
+ s6d1121_delay(2);
+ LCD_RST_HIGH; // Hardware Reset
+ s6d1121_delay(2);
+
+ #ifdef LCD_USE_GPIO
+ // IO Default Configurations
+ palSetPadMode(LCD_CS_GPIO, LCD_CS_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
+ palSetPadMode(LCD_WR_GPIO, LCD_WR_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
+ palSetPadMode(LCD_RD_GPIO, LCD_RD_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
+ palSetPadMode(LCD_RS_GPIO, LCD_RS_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
+ palSetPadMode(LCD_BL_GPIO, LCD_BL_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
+
+ palSetGroupMode(LCD_D0_GPIO, 0x0000000F, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
+ palSetGroupMode(LCD_D4_GPIO, 0x0000FFF0, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
+
+ LCD_CS_HIGH;
+ LCD_RD_HIGH;
+ LCD_WR_HIGH;
+ LCD_BL_LOW;
+
+ #elif defined(LCD_USE_FSMC)
+ #if defined(STM32F1XX)
+ /* FSMC setup. TODO: this only works for STM32F1 */
+ rccEnableAHB(RCC_AHBENR_FSMCEN, 0);
+
+ /* TODO: pin setup */
+ #elif defined(STM32F4XX)
+ /* STM32F4 FSMC init */
+ rccEnableAHB3(RCC_AHB3ENR_FSMCEN, 0);
+
+ /* set pins to FSMC mode */
+ IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8) |
+ (1 << 9) | (1 << 10) | (1 << 11) | (1 << 14) | (1 << 15), 0};
+
+ IOBus busE = {GPIOE, (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12) |
+ (1 << 13) | (1 << 14) | (1 << 15), 0};
+
+ palSetBusMode(&busD, PAL_MODE_ALTERNATE(12));
+ palSetBusMode(&busE, PAL_MODE_ALTERNATE(12));
+ #else
+ #error "FSMC not implemented for this device"
+ #endif
+
+ int FSMC_Bank = 0;
+ /* FSMC timing */
+ FSMC_Bank1->BTCR[FSMC_Bank+1] = (10) | (10 << 8) | (10 << 16);
+
+ /* Bank1 NOR/SRAM control register configuration */
+ FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN;
+ #endif
+
+ lld_lcdWriteReg(0x11,0x2004);
+ lld_lcdWriteReg(0x13,0xCC00);
+ lld_lcdWriteReg(0x15,0x2600);
+ lld_lcdWriteReg(0x14,0x252A);
+ lld_lcdWriteReg(0x12,0x0033);
+ lld_lcdWriteReg(0x13,0xCC04);
+
+ s6d1121_delay(1);
+
+ lld_lcdWriteReg(0x13,0xCC06);
+
+ s6d1121_delay(1);
+
+ lld_lcdWriteReg(0x13,0xCC4F);
+
+ s6d1121_delay(1);
+
+ lld_lcdWriteReg(0x13,0x674F);
+ lld_lcdWriteReg(0x11,0x2003);
+
+ s6d1121_delay(1);
+
+ // Gamma Setting
+ lld_lcdWriteReg(0x30,0x2609);
+ lld_lcdWriteReg(0x31,0x242C);
+ lld_lcdWriteReg(0x32,0x1F23);
+ lld_lcdWriteReg(0x33,0x2425);
+ lld_lcdWriteReg(0x34,0x2226);
+ lld_lcdWriteReg(0x35,0x2523);
+ lld_lcdWriteReg(0x36,0x1C1A);
+ lld_lcdWriteReg(0x37,0x131D);
+ lld_lcdWriteReg(0x38,0x0B11);
+ lld_lcdWriteReg(0x39,0x1210);
+ lld_lcdWriteReg(0x3A,0x1315);
+ lld_lcdWriteReg(0x3B,0x3619);
+ lld_lcdWriteReg(0x3C,0x0D00);
+ lld_lcdWriteReg(0x3D,0x000D);
+
+ lld_lcdWriteReg(0x16,0x0007);
+ lld_lcdWriteReg(0x02,0x0013);
+ lld_lcdWriteReg(0x03,0x0003);
+ lld_lcdWriteReg(0x01,0x0127);
+
+ s6d1121_delay(1);
+
+ lld_lcdWriteReg(0x08,0x0303);
+ lld_lcdWriteReg(0x0A,0x000B);
+ lld_lcdWriteReg(0x0B,0x0003);
+ lld_lcdWriteReg(0x0C,0x0000);
+ lld_lcdWriteReg(0x41,0x0000);
+ lld_lcdWriteReg(0x50,0x0000);
+ lld_lcdWriteReg(0x60,0x0005);
+ lld_lcdWriteReg(0x70,0x000B);
+ lld_lcdWriteReg(0x71,0x0000);
+ lld_lcdWriteReg(0x78,0x0000);
+ lld_lcdWriteReg(0x7A,0x0000);
+ lld_lcdWriteReg(0x79,0x0007);
+ lld_lcdWriteReg(0x07,0x0051);
+
+ s6d1121_delay(1);
+
+ lld_lcdWriteReg(0x07,0x0053);
+ lld_lcdWriteReg(0x79,0x0000);
+
+ lld_lcdResetViewPort();
+
+ /* Now initialise the GDISP structure */
+ GDISP.Width = SCREEN_WIDTH;
+ GDISP.Height = SCREEN_HEIGHT;
+ GDISP.Orientation = portrait;
+ GDISP.Powermode = powerOn;
+ GDISP.Backlight = 100;
+ GDISP.Contrast = 50;
+ return TRUE;
+}
+
+/**
+ * @brief Draws a pixel on the display.
+ *
+ * @param[in] x X location of the pixel
+ * @param[in] y Y location of the pixel
+ * @param[in] color The color of the pixel
+ *
+ * @notapi
+ */
+void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ if (x >= GDISP.Width || y >= GDISP.Height) return;
+ #endif
+ lld_lcdSetCursor(x, y);
+ lld_lcdWriteReg(0x0022, color);
+}
+
+/* ---- Optional Routines ---- */
+/*
+ All the below routines are optional.
+ Defining them will increase speed but everything
+ will work if they are not defined.
+ If you are not using a routine - turn it off using
+ the appropriate GDISP_HARDWARE_XXXX macro.
+ Don't bother coding for obvious similar routines if
+ there is no performance penalty as the emulation software
+ makes a good job of using similar routines.
+ eg. If fillarea() is defined there is little
+ point in defining clear() unless the
+ performance bonus is significant.
+ For good performance it is suggested to implement
+ fillarea() and blitarea().
+*/
+
+#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__)
+ /**
+ * @brief Clear the display.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] color The color of the pixel
+ *
+ * @notapi
+ */
+ void GDISP_LLD(clear)(color_t color) {
+ unsigned i;
+
+ lld_lcdSetCursor(0, 0);
+ lld_lcdWriteStreamStart();
+
+ for(i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; i++)
+ lld_lcdWriteData(color);
+
+ lld_lcdWriteStreamStop();
+ }
+#endif
+
+#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a line.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x0, y0 The start of the line
+ * @param[in] x1, y1 The end of the line
+ * @param[in] color The color of the line
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ /* Need to clip to screen */
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__)
+ /**
+ * @brief Fill an area with a color.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The start filled area
+ * @param[in] cx, cy The width and height to be filled
+ * @param[in] color The color of the fill
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
+ if (x+cx > GDISP.Width) cx = GDISP.Width - x;
+ if (y+cy > GDISP.Height) cy = GDISP.Height - y;
+ #endif
+
+ unsigned i, area;
+
+ area = cx*cy;
+ lld_lcdSetViewPort(x, y, cx, cy);
+ lld_lcdWriteStreamStart();
+ for(i = 0; i < area; i++)
+ lld_lcdWriteData(color);
+ lld_lcdWriteStreamStop();
+ lld_lcdResetViewPort();
+ }
+#endif
+
+#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__)
+ /**
+ * @brief Fill an area with a bitmap.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The start filled area
+ * @param[in] cx, cy The width and height to be filled
+ * @param[in] buffer The pixels to use to fill the area.
+ *
+ * @notapi
+ */
+ void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) {
+ unsigned i, area;
+
+ #if GDISP_NEED_VALIDATION
+ if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
+ if (x+cx > GDISP.Width) return;
+ if (y+cy > GDISP.Height) cy = GDISP.Height - y;
+ #endif
+
+ area = cx*cy;
+ lld_lcdSetViewPort(x, y, cx, cy);
+ lld_lcdWriteStreamStart();
+ for(i = 0; i < area; i++)
+ lld_lcdWriteData(*buffer++);
+ lld_lcdWriteStreamStop();
+ lld_lcdResetViewPort();
+ }
+#endif
+
+/* Circular Drawing Functions */
+#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a circle.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the circle is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color of the circle
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ /* Code here */
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Create a filled circle.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the circle is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color of the circle
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ /* Code here */
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw an ellipse.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the ellipse is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the ellipse
+ * @param[in] a, b The dimensions of the ellipse
+ * @param[in] color The color of the ellipse
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ /* Code here */
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Create a filled ellipse.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the ellipse is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the ellipse
+ * @param[in] a, b The dimensions of the ellipse
+ * @param[in] color The color of the ellipse
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ /* Code here */
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__)
+ #include "gdisp_fonts.h"
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a character using a transparent background.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The top-left corner of the text
+ * @param[in] c The character to print
+ * @param[in] color The color of the character
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ /* Code here */
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a character using a filled background.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The top-left corner of the text
+ * @param[in] c The character to print
+ * @param[in] color The color of the character
+ * @param[in] bgcolor The background color
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
+ #if GDISP_NEED_VALIDATION
+ /* Code here */
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__)
+ /**
+ * @brief Get the color of a particular pixel.
+ * @note Optional.
+ * @note If x,y is off the screen, the result is undefined.
+ *
+ * @param[in] x, y The start of the text
+ *
+ * @notapi
+ */
+ color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) {
+ /* This routine is marked "DO NOT USE" in the original
+ * GLCD driver. We just keep our GDISP_HARDWARE_READPIXEL
+ * turned off for now.
+ */
+ color_t color;
+
+ #if GDISP_NEED_VALIDATION
+ if (x >= GDISP.Width || y >= GDISP.Height) return 0;
+ #endif
+
+ lld_lcdSetCursor(x, y);
+ lld_lcdWriteStreamStart();
+
+ color = lld_lcdReadData();
+ color = lld_lcdReadData();
+
+ lld_lcdWriteStreamStop();
+
+ return color;
+ }
+#endif
+
+#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__)
+ /**
+ * @brief Scroll vertically a section of the screen.
+ * @note Optional.
+ * @note If x,y + cx,cy is off the screen, the result is undefined.
+ * @note If lines is >= cy, it is equivelent to a area fill with bgcolor.
+ *
+ * @param[in] x, y The start of the area to be scrolled
+ * @param[in] cx, cy The size of the area to be scrolled
+ * @param[in] lines The number of lines to scroll (Can be positive or negative)
+ * @param[in] bgcolor The color to fill the newly exposed area.
+ *
+ * @notapi
+ */
+ void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
+ /* This is marked as "TODO: Test this" in the original GLCD driver.
+ * For now we just leave the GDISP_HARDWARE_SCROLL off.
+ */
+ static color_t buf[((SCREEN_HEIGHT > SCREEN_WIDTH ) ? SCREEN_HEIGHT : SCREEN_WIDTH)];
+ coord_t row0, row1;
+ unsigned i, gap, abslines;
+
+ abslines = lines < 0 ? -lines : lines;
+
+ #if GDISP_NEED_VALIDATION
+ if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
+ if (x+cx > GDISP.Width) cx = GDISP.Width - x;
+ if (y+cy > GDISP.Height) cy = GDISP.Height - y;
+ #endif
+
+ if (!abslines) return;
+ if (abslines >= cy) {
+ abslines = cy;
+ gap = 0;
+ } else {
+ gap = cy - abslines;
+ for(i = 0; i < gap; i++) {
+ if(lines > 0) {
+ row0 = y + i + lines;
+ row1 = y + i;
+ } else {
+ row0 = (y - i - 1) + lines;
+ row1 = (y - i - 1);
+ }
+
+ /* read row0 into the buffer and then write at row1*/
+ lld_lcdSetViewPort(x, row0, cx, 1);
+ lld_lcdReadStreamStart();
+ lld_lcdReadStream(buf, cx);
+ lld_lcdReadStreamStop();
+
+ lld_lcdSetViewPort(x, row1, cx, 1);
+ lld_lcdWriteStreamStart();
+ lld_lcdWriteStream(buf, cx);
+ lld_lcdWriteStreamStop();
+ }
+ }
+
+ /* fill the remaining gap */
+ lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines);
+ lld_lcdWriteStreamStart();
+ gap = cx*abslines;
+ for(i = 0; i < gap; i++) lld_lcdWriteData(bgcolor);
+ lld_lcdWriteStreamStop();
+ lld_lcdResetViewPort();
+ }
+#endif
+
+#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__)
+ /**
+ * @brief Driver Control
+ * @detail Unsupported control codes are ignored.
+ * @note The value parameter should always be typecast to (void *).
+ * @note There are some predefined and some specific to the low level driver.
+ * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t
+ * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t
+ * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver
+ * that only supports off/on anything other
+ * than zero is on.
+ * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100.
+ * GDISP_CONTROL_LLD - Low level driver control constants start at
+ * this value.
+ *
+ * @param[in] what What to do.
+ * @param[in] value The value to use (always cast to a void *).
+ *
+ * @notapi
+ */
+ void GDISP_LLD(control)(unsigned what, void *value) {
+ switch(what) {
+ case GDISP_CONTROL_POWER:
+ if (GDISP.Powermode == (gdisp_powermode_t)value)
+ return;
+ switch((gdisp_powermode_t)value) {
+ case powerOff:
+ /* Code here */
+ /* break; */
+ case powerOn:
+ /* Code here */
+ /* You may need this ---
+ if (GDISP.Powermode != powerSleep)
+ GDISP_LLD(init();
+ */
+ /* break; */
+ case powerSleep:
+ /* Code here */
+ /* break; */
+ default:
+ return;
+ }
+ GDISP.Powermode = (gdisp_powermode_t)value;
+ return;
+ case GDISP_CONTROL_ORIENTATION:
+ if (GDISP.Orientation == (gdisp_orientation_t)value)
+ return;
+ switch((gdisp_orientation_t)value) {
+ case portrait:
+ lld_lcdWriteReg(0x0001,0x0127);
+ lld_lcdWriteReg(0x03, 0b0011);
+ GDISP.Height = SCREEN_HEIGHT;
+ GDISP.Width = SCREEN_WIDTH;
+ break;
+ case landscape:
+ lld_lcdWriteReg(0x0001,0x0027);
+ lld_lcdWriteReg(0x0003, 0b1011);
+ GDISP.Height = SCREEN_WIDTH;
+ GDISP.Width = SCREEN_HEIGHT;
+ break;
+ case portraitInv:
+ lld_lcdWriteReg(0x0001,0x0127);
+ lld_lcdWriteReg(0x0003, 0b0000);
+ GDISP.Height = SCREEN_HEIGHT;
+ GDISP.Width = SCREEN_WIDTH;
+ break;
+ case landscapeInv:
+ lld_lcdWriteReg(0x0001,0x0027);
+ lld_lcdWriteReg(0x0003, 0b1000);
+ GDISP.Height = SCREEN_WIDTH;
+ GDISP.Width = SCREEN_HEIGHT;
+ break;
+ default:
+ return;
+ }
+ GDISP.Orientation = (gdisp_orientation_t)value;
+ return;
+/*
+ case GDISP_CONTROL_BACKLIGHT:
+ case GDISP_CONTROL_CONTRAST:
+*/
+ }
+ }
+#endif
+
+#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__)
+/**
+ * @brief Query a driver value.
+ * @detail Typecase the result to the type you want.
+ * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen
+ * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen
+ * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode
+ * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation
+ * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100)
+ * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100).
+ * GDISP_QUERY_LLD - Low level driver control constants start at
+ * this value.
+ *
+ * @param[in] what What to Query
+ *
+ * @notapi
+ */
+void *GDISP_LLD(query)(unsigned what) {
+ switch(what) {
+ case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width;
+ case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height;
+ case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode;
+ case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation;
+ case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight;
+ case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast;
+ case GDISP_QUERY_LLD+0:
+ /* Code here */
+ default: return (void *)-1;
+ }
+}
+#endif
+
+#endif /* HAL_USE_GDISP */
+/** @} */
diff --git a/drivers/gdisp/gdispS6d1121/gdisp_lld.mk b/drivers/gdisp/gdispS6d1121/gdisp_lld.mk
new file mode 100644
index 00000000..1f9f093a
--- /dev/null
+++ b/drivers/gdisp/gdispS6d1121/gdisp_lld.mk
@@ -0,0 +1,5 @@
+# List the required driver.
+LCDSRC += $(LCDLIB)/drivers/gdisp/gdispS6d1121/gdisp_lld.c
+
+# Required include directories
+LCDINC += $(LCDLIB)/drivers/gdisp/gdispS6d1121
diff --git a/drivers/gdisp/gdispS6d1121/gdisp_lld_config.h b/drivers/gdisp/gdispS6d1121/gdisp_lld_config.h
new file mode 100644
index 00000000..ee3fdeee
--- /dev/null
+++ b/drivers/gdisp/gdispS6d1121/gdisp_lld_config.h
@@ -0,0 +1,66 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispS6d1121/gdisp_lld_config.h
+ * @brief GDISP Graphic Driver subsystem low level driver header for the S6d1121 display.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_LLD_CONFIG_H
+#define _GDISP_LLD_CONFIG_H
+
+#if HAL_USE_GDISP
+
+/*===========================================================================*/
+/* Driver hardware support. */
+/*===========================================================================*/
+
+#define GDISP_DRIVER_NAME "S6d1121"
+#define GDISP_LLD(x) gdisp_lld_##x##_S6d1121
+
+#define GDISP_HARDWARE_LINES FALSE
+#define GDISP_HARDWARE_CLEARS TRUE
+#define GDISP_HARDWARE_FILLS TRUE
+#define GDISP_HARDWARE_BITFILLS TRUE
+#define GDISP_HARDWARE_CIRCLES FALSE
+#define GDISP_HARDWARE_CIRCLEFILLS FALSE
+#define GDISP_HARDWARE_ELLIPSES FALSE
+#define GDISP_HARDWARE_ELLIPSEFILLS FALSE
+#define GDISP_HARDWARE_TEXT FALSE
+#define GDISP_HARDWARE_TEXTFILLS FALSE
+#define GDISP_HARDWARE_SCROLL TRUE
+#define GDISP_HARDWARE_PIXELREAD FALSE
+#define GDISP_HARDWARE_CONTROL TRUE
+#define GDISP_HARDWARE_QUERY FALSE
+
+#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE
+#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE
+
+#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
+#define GDISP_PACKED_PIXELS FALSE
+#define GDISP_PACKED_LINES FALSE
+
+#endif /* HAL_USE_GDISP */
+
+#endif /* _GDISP_LLD_CONFIG_H */
+/** @} */
diff --git a/drivers/gdisp/gdispS6d1121/readme.txt b/drivers/gdisp/gdispS6d1121/readme.txt
new file mode 100644
index 00000000..fc24d4a2
--- /dev/null
+++ b/drivers/gdisp/gdispS6d1121/readme.txt
@@ -0,0 +1,16 @@
+To use this driver:
+
+1. Add in your halconf.h:
+ a) #define HAL_USE_GDISP TRUE
+ b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD
+ c) One (only) of:
+ #define LCD_USE_GPIO
+ #define LCD_USE_SPI
+ #define LCD_USE_FSMC
+ d) All of the following (with appropriate values):
+ #define SCREEN_WIDTH 320
+ #define SCREEN_HEIGHT 240
+
+2. To your makefile add the following lines:
+ include $(CHIBIOS)/os/halext/halext.mk
+ include $(CHIBIOS)/os/halext/drivers/gdispS6d1121/gdisp_lld.mk
diff --git a/drivers/gdisp/gdispS6d1121/s6d1121_lld.c.h b/drivers/gdisp/gdispS6d1121/s6d1121_lld.c.h
new file mode 100644
index 00000000..c1539fe7
--- /dev/null
+++ b/drivers/gdisp/gdispS6d1121/s6d1121_lld.c.h
@@ -0,0 +1,244 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef S6D1121_H
+#define S6D1121_H
+
+// I/O assignments
+#define LCD_BL_GPIO GPIOB
+#define LCD_BL_PIN 8
+
+#define LCD_CS_GPIO GPIOD
+#define LCD_CS_PIN 7
+
+#define LCD_RS_GPIO GPIOD
+#define LCD_RS_PIN 11
+
+#define LCD_RST_GPIO GPIOD
+#define LCD_RST_PIN 10
+
+#define LCD_RD_GPIO GPIOD
+#define LCD_RD_PIN 9
+
+#define LCD_WR_GPIO GPIOD
+#define LCD_WR_PIN 8
+
+#define LCD_D0_GPIO GPIOD
+#define LCD_D4_GPIO GPIOE
+
+/* all interfaces use RST via GPIO */
+/* TODO: option to disable RST; assumes RST is tied high */
+#define LCD_RST_LOW palClearPad(LCD_RST_GPIO, LCD_RST_PIN)
+#define LCD_RST_HIGH palSetPad(LCD_RST_GPIO, LCD_RST_PIN)
+
+#define s6d1121_delay(n) halPolledDelay(MS2RTT(n));
+
+#if defined(LCD_USE_GPIO)
+
+ #define LCD_CS_LOW palClearPad(LCD_CS_GPIO, LCD_CS_PIN)
+ #define LCD_CS_HIGH palSetPad(LCD_CS_GPIO, LCD_CS_PIN)
+
+ #define LCD_RS_LOW palClearPad(LCD_RS_GPIO, LCD_RS_PIN)
+ #define LCD_RS_HIGH palSetPad(LCD_RS_GPIO, LCD_RS_PIN)
+
+ #define LCD_RD_LOW palClearPad(LCD_RD_GPIO, LCD_RD_PIN)
+ #define LCD_RD_HIGH palSetPad(LCD_RD_GPIO, LCD_RD_PIN)
+
+ #define LCD_WR_LOW palClearPad(LCD_WR_GPIO, LCD_WR_PIN)
+ #define LCD_WR_HIGH palSetPad(LCD_WR_GPIO, LCD_WR_PIN)
+
+ #define LCD_BL_LOW palClearPad(LCD_BL_GPIO, LCD_BL_PIN)
+ #define LCD_BL_HIGH palSetPad(LCD_BL_GPIO, LCD_BL_PIN)
+
+
+ static inline void lld_lcddelay(void) { asm volatile ("nop"); asm volatile ("nop"); }
+ static inline void lld_lcdwrite(uint16_t db) {
+ LCD_D4_GPIO->BSRR.W=((~db&0xFFF0)<<16)|(db&0xFFF0);
+ LCD_D0_GPIO->BSRR.W=((~db&0x000F)<<16)|(db&0x000F);
+ LCD_WR_LOW;
+ lld_lcddelay();
+ LCD_WR_HIGH;
+ }
+ static __inline uint16_t lld_lcdReadData(void) {
+ uint16_t value=0;
+
+ LCD_RS_HIGH; LCD_WR_HIGH; LCD_RD_LOW;
+ #ifndef STM32F4XX
+ // change pin mode to digital input
+ LCD_DATA_PORT->CRH = 0x47444444;
+ LCD_DATA_PORT->CRL = 0x47444444;
+ #endif
+ #ifndef STM32F4XX
+ // change pin mode back to digital output
+ LCD_DATA_PORT->CRH = 0x33333333;
+ LCD_DATA_PORT->CRL = 0x33333333;
+ #endif
+ LCD_RD_HIGH;
+ return value;
+ }
+ static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) {
+ uint16_t lcdRAM;
+
+ LCD_CS_LOW; LCD_RS_LOW;
+ lld_lcdwrite(lcdReg);
+ LCD_RS_HIGH;
+ lcdRAM = lld_lcdReadData();
+ LCD_CS_HIGH;
+ return lcdRAM;
+ }
+ static void lld_lcdWriteIndex(uint16_t lcdReg) {
+ LCD_RS_LOW;
+ lld_lcdwrite(lcdReg);
+ LCD_RS_HIGH;
+ }
+ static void lld_lcdWriteData(uint16_t lcdData) {
+ lld_lcdwrite(lcdData);
+ }
+ static void lld_lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) {
+ LCD_CS_LOW;
+ lld_lcdWriteIndex(lcdReg);
+ lld_lcdWriteData(lcdRegValue);
+ LCD_CS_HIGH;
+ }
+ static __inline void lld_lcdWriteStreamStart(void) {
+ LCD_CS_LOW;
+ lld_lcdWriteIndex(0x0022);
+ }
+ static __inline void lld_lcdWriteStreamStop(void) {
+ LCD_CS_HIGH;
+ }
+ static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
+ uint16_t i;
+
+ for(i = 0; i < size; i++) { lld_lcdwrite(buffer[i]); }
+ }
+ static __inline void lld_lcdReadStreamStart(void) { /* TODO */ }
+ static __inline void lld_lcdReadStreamStop(void) { /* TODO */ }
+ static __inline void lld_lcdReadStream(uint16_t *UNUSED(buffer), size_t UNUSED(size)) { /* TODO */ }
+
+#elif defined(LCD_USE_FSMC)
+ #define LCD_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */
+ #define LCD_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */
+
+ static __inline void lld_lcdWriteIndex(uint16_t index) { LCD_REG = index; }
+ static __inline void lld_lcdWriteData(uint16_t data) { LCD_RAM = data; }
+ static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) {
+ LCD_REG = lcdReg;
+ LCD_RAM = lcdRegValue;
+ }
+ static __inline uint16_t lld_lcdReadData(void) { return (LCD_RAM); }
+ static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) {
+ LCD_REG = lcdReg;
+ return LCD_RAM;
+ }
+ static __inline void lld_lcdWriteStreamStart(void) { LCD_REG = 0x0022; }
+ static __inline void lld_lcdWriteStreamStop(void) {}
+ static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
+ uint16_t i;
+ for(i = 0; i < size; i++) LCD_RAM = buffer[i];
+ }
+ static __inline void lld_lcdReadStreamStart(void) { LCD_REG = 0x0022; }
+ static __inline void lld_lcdReadStreamStop(void) {}
+ static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) {
+ uint16_t i;
+ volatile uint16_t dummy;
+
+ /* throw away first value read */
+ dummy = LCD_RAM;
+ for(i = 0; i < size; i++) buffer[i] = LCD_RAM;
+ }
+
+#elif defined(LCD_USE_SPI)
+ #error "gdispS6d1121: LCD_USE_SPI not implemented yet"
+
+#else
+ #error "gdispS6d1121: No known LCD_USE_XXX has been defined"
+#endif
+
+static void lld_lcdSetCursor(coord_t x, coord_t y) {
+ /* R20h - 8 bit
+ * R21h - 9 bit
+ */
+ switch(GDISP.Orientation) {
+ case portraitInv:
+ lld_lcdWriteReg(0x0020, (SCREEN_WIDTH-1-x) & 0x00FF);
+ lld_lcdWriteReg(0x0021, (SCREEN_HEIGHT-1-y) & 0x01FF);
+ break;
+ case portrait:
+ lld_lcdWriteReg(0x0020, x & 0x00FF);
+ lld_lcdWriteReg(0x0021, y & 0x01FF);
+ break;
+ case landscape:
+ lld_lcdWriteReg(0x0020, y & 0x00FF);
+ lld_lcdWriteReg(0x0021, x & 0x01FF);
+ break;
+ case landscapeInv:
+ lld_lcdWriteReg(0x0020, (SCREEN_WIDTH - y - 1) & 0x00FF);
+ lld_lcdWriteReg(0x0021, (SCREEN_HEIGHT - x - 1) & 0x01FF);
+ break;
+ }
+}
+
+static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) {
+ /* HSA / HEA are 8 bit
+ * VSA / VEA are 9 bit
+ * use masks 0x00FF and 0x01FF to enforce this
+ */
+
+ switch(GDISP.Orientation) {
+ case portrait:
+ lld_lcdWriteReg(0x46, (((x+cx-1) << 8) & 0xFF00 ) | (x & 0x00FF));
+ lld_lcdWriteReg(0x48, y & 0x01FF);
+ lld_lcdWriteReg(0x47, (y+cy-1) & 0x01FF);
+ break;
+ case landscape:
+ lld_lcdWriteReg(0x46, (((x+cx-1) << 8) & 0xFF00) | ((y+cy) & 0x00FF));
+ lld_lcdWriteReg(0x48, x & 0x01FF);
+ lld_lcdWriteReg(0x47, (x+cx-1) & 0x01FF);
+ break;
+ case portraitInv:
+ lld_lcdWriteReg(0x46, (((SCREEN_WIDTH-x-1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (x+cx)) & 0x00FF));
+ lld_lcdWriteReg(0x48, (SCREEN_HEIGHT-(y+cy)) & 0x01FF);
+ lld_lcdWriteReg(0x47, (SCREEN_HEIGHT-y-1) & 0x01FF);
+ break;
+ case landscapeInv:
+ lld_lcdWriteReg(0x46, (((SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (y+cy)) & 0x00FF));
+ lld_lcdWriteReg(0x48, (SCREEN_HEIGHT - (x+cx)) & 0x01FF);
+ lld_lcdWriteReg(0x47, (SCREEN_HEIGHT - x - 1) & 0x01FF);
+ break;
+ }
+
+ lld_lcdSetCursor(x, y);
+}
+
+static void lld_lcdResetViewPort(void) {
+ switch(GDISP.Orientation) {
+ case portrait:
+ case portraitInv:
+ lld_lcdSetViewPort(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ break;
+ case landscape:
+ case landscapeInv:
+ lld_lcdSetViewPort(0, 0, SCREEN_HEIGHT, SCREEN_WIDTH);
+ break;
+ }
+}
+
+#endif /* S6D1121_H */
diff --git a/drivers/gdisp/gdispSsd1289/gdisp_lld.c b/drivers/gdisp/gdispSsd1289/gdisp_lld.c
new file mode 100644
index 00000000..7dfb83a7
--- /dev/null
+++ b/drivers/gdisp/gdispSsd1289/gdisp_lld.c
@@ -0,0 +1,610 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispSsd1289/gdisp_lld.c
+ * @brief GDISP Graphics Driver subsystem low level driver source for the Ssd1289 display.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+#include "gdisp.h"
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+/* Include the emulation code for things we don't support */
+#include "gdisp_emulation.c"
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+#include "ssd1289_lld.c.h"
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/* ---- Required Routines ---- */
+/*
+ The following 2 routines are required.
+ All other routines are optional.
+*/
+
+/**
+ * @brief Low level GDISP driver initialization.
+ *
+ * @notapi
+ */
+bool_t GDISP_LLD(init)(void) {
+ uint16_t deviceCode;
+
+ #ifdef LCD_USE_FSMC
+ /* FSMC setup. TODO: this only works for STM32F1 */
+ rccEnableAHB(RCC_AHBENR_FSMCEN, 0);
+ int FSMC_Bank = 0;
+ /* timing structure */
+ /* from datasheet:
+ address setup: 0ns
+ address hold: 0ns
+ Data setup: 5ns
+ Data hold: 5ns
+ Data access: 250ns
+ output hold: 100ns
+ */
+ FSMC_Bank1->BTCR[FSMC_Bank+1] = FSMC_BTR1_ADDSET_1 | FSMC_BTR1_DATAST_1;
+
+ /* Bank1 NOR/SRAM control register configuration */
+ FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN;
+ #endif
+
+ deviceCode = lld_lcdReadReg(0x0000);
+
+ lld_lcdWriteReg(0x0000,0x0001); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0003,0xA8A4); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x000C,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x000D,0x080C); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x000E,0x2B00); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x001E,0x00B0); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0001,0x2B3F); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0002,0x0600); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0010,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0011,0x6070); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0005,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0006,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0016,0xEF1C); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0017,0x0003); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0007,0x0133); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x000B,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x000F,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0041,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0042,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0048,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0049,0x013F); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x004A,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x004B,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0044,0xEF00); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0045,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0046,0x013F); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0030,0x0707); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0031,0x0204); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0032,0x0204); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0033,0x0502); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0034,0x0507); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0035,0x0204); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0036,0x0204); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0037,0x0502); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x003A,0x0302); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x003B,0x0302); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0023,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0024,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x0025,0x8000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x004f,0x0000); lld_lcdDelay(5);
+ lld_lcdWriteReg(0x004e,0x0000); lld_lcdDelay(5);
+
+ /* Initialise the GDISP structure */
+ GDISP.Width = SCREEN_WIDTH;
+ GDISP.Height = SCREEN_HEIGHT;
+ GDISP.Orientation = portrait;
+ GDISP.Powermode = powerOn;
+ GDISP.Backlight = 100;
+ GDISP.Contrast = 50;
+ return TRUE;
+}
+
+/**
+ * @brief Draws a pixel on the display.
+ *
+ * @param[in] x X location of the pixel
+ * @param[in] y Y location of the pixel
+ * @param[in] color The color of the pixel
+ *
+ * @notapi
+ */
+void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ if (x >= GDISP.Width || y >= GDISP.Height) return;
+ #endif
+ lld_lcdSetCursor(x, y);
+ lld_lcdWriteReg(0x0022, color);
+}
+
+/* ---- Optional Routines ---- */
+/*
+ All the below routines are optional.
+ Defining them will increase speed but everything
+ will work if they are not defined.
+ If you are not using a routine - turn it off using
+ the appropriate GDISP_HARDWARE_XXXX macro.
+ Don't bother coding for obvious similar routines if
+ there is no performance penalty as the emulation software
+ makes a good job of using similar routines.
+ eg. If gfillarea() is defined there is little
+ point in defining clear() unless the
+ performance bonus is significant.
+ For good performance it is suggested to implement
+ fillarea() and blitarea().
+*/
+
+#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__)
+ /**
+ * @brief Clear the display.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] color The color of the pixel
+ *
+ * @notapi
+ */
+ void GDISP_LLD(clear)(color_t color) {
+ unsigned i;
+
+ lld_lcdSetCursor(0, 0);
+ lld_lcdWriteStreamStart();
+
+ for(i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; i++)
+ lld_lcdWriteData(color);
+
+ lld_lcdWriteStreamStop();
+ }
+#endif
+
+#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a line.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x0, y0 The start of the line
+ * @param[in] x1, y1 The end of the line
+ * @param[in] color The color of the line
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__)
+ /**
+ * @brief Fill an area with a color.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The start filled area
+ * @param[in] cx, cy The width and height to be filled
+ * @param[in] color The color of the fill
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
+ if (x+cx > GDISP.Width) cx = GDISP.Width - x;
+ if (y+cy > GDISP.Height) cy = GDISP.Height - y;
+ #endif
+
+ unsigned i, area;
+
+ area = cx*cy;
+ lld_lcdSetViewPort(x, y, cx, cy);
+ lld_lcdWriteStreamStart();
+ for(i = 0; i < area; i++)
+ lld_lcdWriteData(color);
+ lld_lcdWriteStreamStop();
+ lld_lcdResetViewPort();
+ }
+#endif
+
+#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__)
+ /**
+ * @brief Fill an area with a bitmap.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The start filled area
+ * @param[in] cx, cy The width and height to be filled
+ * @param[in] buffer The pixels to use to fill the area.
+ *
+ * @notapi
+ */
+ void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) {
+ unsigned i, area;
+
+ #if GDISP_NEED_VALIDATION
+ if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
+ if (x+cx > GDISP.Width) return;
+ if (y+cy > GDISP.Height) cy = GDISP.Height - y;
+ #endif
+
+ area = cx*cy;
+ lld_lcdSetViewPort(x, y, cx, cy);
+ lld_lcdWriteStreamStart();
+ for(i = 0; i < area; i++)
+ lld_lcdWriteData(*buffer++);
+ lld_lcdWriteStreamStop();
+ lld_lcdResetViewPort();
+ }
+#endif
+
+/* Circular Drawing Functions */
+#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a circle.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the circle is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color of the circle
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Create a filled circle.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the circle is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color of the circle
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw an ellipse.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the ellipse is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the ellipse
+ * @param[in] a, b The dimensions of the ellipse
+ * @param[in] color The color of the ellipse
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Create a filled ellipse.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the ellipse is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the ellipse
+ * @param[in] a, b The dimensions of the ellipse
+ * @param[in] color The color of the ellipse
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__)
+ #include "gdisp_fonts.h"
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a character using a transparent background.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The top-left corner of the text
+ * @param[in] c The character to print
+ * @param[in] color The color of the character
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a character using a filled background.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The top-left corner of the text
+ * @param[in] c The character to print
+ * @param[in] color The color of the character
+ * @param[in] bgcolor The background color
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
+ /* NOT IMPLEMENTED */
+ }
+#endif
+
+#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__)
+ /**
+ * @brief Get the color of a particular pixel.
+ * @note Optional.
+ * @note If x,y is off the screen, the result is undefined.
+ *
+ * @param[in] x, y The start of the text
+ *
+ * @notapi
+ */
+ color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) {
+ color_t color;
+
+ #if GDISP_NEED_VALIDATION
+ if (x >= GDISP.Width || y >= GDISP.Height) return 0;
+ #endif
+
+ lld_lcdSetCursor(x, y);
+ lld_lcdWriteStreamStart();
+
+ color = lld_lcdReadData();
+ color = lld_lcdReadData();
+
+ lld_lcdWriteStreamStop();
+
+ return color;
+ }
+#endif
+
+#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__)
+ /**
+ * @brief Scroll vertically a section of the screen.
+ * @note Optional.
+ * @note If x,y + cx,cy is off the screen, the result is undefined.
+ * @note If lines is >= cy, it is equivelent to a area fill with bgcolor.
+ *
+ * @param[in] x, y The start of the area to be scrolled
+ * @param[in] cx, cy The size of the area to be scrolled
+ * @param[in] lines The number of lines to scroll (Can be positive or negative)
+ * @param[in] bgcolor The color to fill the newly exposed area.
+ *
+ * @notapi
+ */
+ void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
+ static color_t buf[((SCREEN_HEIGHT > SCREEN_WIDTH ) ? SCREEN_HEIGHT : SCREEN_WIDTH)];
+ coord_t row0, row1;
+ unsigned i, gap, abslines;
+
+ abslines = lines < 0 ? -lines : lines;
+
+ #if GDISP_NEED_VALIDATION
+ if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
+ if (x+cx > GDISP.Width) cx = GDISP.Width - x;
+ if (y+cy > GDISP.Height) cy = GDISP.Height - y;
+ #endif
+
+ if (!abslines) return;
+ if (abslines >= cy) {
+ abslines = cy;
+ gap = 0;
+ } else {
+ gap = cy - abslines;
+ for(i = 0; i < gap; i++) {
+ if(lines > 0) {
+ row0 = y + i + lines;
+ row1 = y + i;
+ } else {
+ row0 = (y - i - 1) + lines;
+ row1 = (y - i - 1);
+ }
+
+ /* read row0 into the buffer and then write at row1*/
+ lld_lcdSetViewPort(x, row0, cx, 1);
+ lld_lcdReadStreamStart();
+ lld_lcdReadStream(buf, cx);
+ lld_lcdReadStreamStop();
+
+ lld_lcdSetViewPort(x, row1, cx, 1);
+ lld_lcdWriteStreamStart();
+ lld_lcdWriteStream(buf, cx);
+ lld_lcdWriteStreamStop();
+ }
+ }
+
+ /* fill the remaining gap */
+ lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines);
+ lld_lcdWriteStreamStart();
+ gap = cx*abslines;
+ for(i = 0; i < gap; i++) lld_lcdWriteData(color);
+ lld_lcdWriteStreamStop();
+ lld_lcdResetViewPort();
+ }
+#endif
+
+#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__)
+ /**
+ * @brief Driver Control
+ * @detail Unsupported control codes are ignored.
+ * @note The value parameter should always be typecast to (void *).
+ * @note There are some predefined and some specific to the low level driver.
+ * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t
+ * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t
+ * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver
+ * that only supports off/on anything other
+ * than zero is on.
+ * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100.
+ * GDISP_CONTROL_LLD - Low level driver control constants start at
+ * this value.
+ *
+ * @param[in] what What to do.
+ * @param[in] value The value to use (always cast to a void *).
+ *
+ * @notapi
+ */
+ void GDISP_LLD(control)(unsigned what, void *value) {
+ switch(what) {
+ case GDISP_CONTROL_POWER:
+ if (GDISP.Powermode == (gdisp_powermode_t)value)
+ return;
+ switch((gdisp_powermode_t)value) {
+ case powerOff:
+ lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode
+ lld_lcdWriteReg(0x0007, 0x0000); // halt operation
+ lld_lcdWriteReg(0x0000, 0x0000); // turn off oszillator
+ lld_lcdWriteReg(0x0010, 0x0001); // enter sleepmode
+ break;
+ case powerOn:
+ lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode
+ if (GDISP.Powermode != powerSleep)
+ GDISP_LLD(init)();
+ break;
+ case powerSleep:
+ lld_lcdWriteReg(0x0010, 0x0001); // enter sleep mode
+ break;
+ default:
+ return;
+ }
+ GDISP.Powermode = (gdisp_powermode_t)value;
+ return;
+ case GDISP_CONTROL_ORIENTATION:
+ if (GDISP.Orientation == (gdisp_orientation_t)value)
+ return;
+ switch((gdisp_orientation_t)value) {
+ case portrait:
+ lld_lcdWriteReg(0x0001, 0x2B3F);
+ /* ID = 11 AM = 0 */
+ lld_lcdWriteReg(0x0011, 0x6070);
+ GDISP.Height = SCREEN_HEIGHT;
+ GDISP.Width = SCREEN_WIDTH;
+ break;
+ case landscape:
+ lld_lcdWriteReg(0x0001, 0x293F);
+ /* ID = 11 AM = 1 */
+ lld_lcdWriteReg(0x0011, 0x6078);
+ GDISP.Height = SCREEN_WIDTH;
+ GDISP.Width = SCREEN_HEIGHT;
+ break;
+ case portraitInv:
+ lld_lcdWriteReg(0x0001, 0x2B3F);
+ /* ID = 01 AM = 0 */
+ lld_lcdWriteReg(0x0011, 0x6040);
+ GDISP.Height = SCREEN_HEIGHT;
+ GDISP.Width = SCREEN_WIDTH;
+ break;
+ case landscapeInv:
+ lld_lcdWriteReg(0x0001, 0x293F);
+ /* ID = 01 AM = 1 */
+ lld_lcdWriteReg(0x0011, 0x6048);
+ GDISP.Height = SCREEN_WIDTH;
+ GDISP.Width = SCREEN_HEIGHT;
+ break;
+ default:
+ return;
+ }
+ GDISP.Orientation = (gdisp_orientation_t)value;
+ return;
+/*
+ case GDISP_CONTROL_BACKLIGHT:
+ case GDISP_CONTROL_CONTRAST:
+*/
+ }
+ }
+#endif
+
+#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__)
+/**
+ * @brief Query a driver value.
+ * @detail Typecase the result to the type you want.
+ * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen
+ * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen
+ * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode
+ * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation
+ * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100)
+ * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100).
+ * GDISP_QUERY_LLD - Low level driver control constants start at
+ * this value.
+ *
+ * @param[in] what What to Query
+ *
+ * @notapi
+ */
+void *GDISP_LLD(query)(unsigned what) {
+ switch(what) {
+ case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width;
+ case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height;
+ case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode;
+ case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation;
+ case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight;
+ case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast;
+ case GDISP_QUERY_LLD+0:
+ /* Code here */
+ default: return (void *)-1;
+ }
+}
+#endif
+
+#endif /* HAL_USE_GDISP */
+/** @} */
diff --git a/drivers/gdisp/gdispSsd1289/gdisp_lld.mk b/drivers/gdisp/gdispSsd1289/gdisp_lld.mk
new file mode 100644
index 00000000..8167cbfb
--- /dev/null
+++ b/drivers/gdisp/gdispSsd1289/gdisp_lld.mk
@@ -0,0 +1,5 @@
+# List the required driver.
+LCDSRC += $(LCDLIB)/drivers/gdisp/gdispSsd1289/gdisp_lld.c
+
+# Required include directories
+LCDINC += $(LCDLIB)/drivers/gdisp/gdispSsd1289
diff --git a/drivers/gdisp/gdispSsd1289/gdisp_lld_config.h b/drivers/gdisp/gdispSsd1289/gdisp_lld_config.h
new file mode 100644
index 00000000..123ce875
--- /dev/null
+++ b/drivers/gdisp/gdispSsd1289/gdisp_lld_config.h
@@ -0,0 +1,66 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispSsd1289/gdisp_lld_config.h
+ * @brief GDISP Graphic Driver subsystem low level driver header for the Ssd1289 display.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_LLD_CONFIG_H
+#define _GDISP_LLD_CONFIG_H
+
+#if HAL_USE_GDISP
+
+/*===========================================================================*/
+/* Driver hardware support. */
+/*===========================================================================*/
+
+#define GDISP_DRIVER_NAME "SSD1289"
+#define GDISP_LLD(x) gdisp_lld_##x##_SSD1289
+
+#define GDISP_HARDWARE_LINES FALSE
+#define GDISP_HARDWARE_CLEARS TRUE
+#define GDISP_HARDWARE_FILLS TRUE
+#define GDISP_HARDWARE_BITFILLS TRUE
+#define GDISP_HARDWARE_CIRCLES FALSE
+#define GDISP_HARDWARE_CIRCLEFILLS FALSE
+#define GDISP_HARDWARE_ELLIPSES FALSE
+#define GDISP_HARDWARE_ELLIPSEFILLS FALSE
+#define GDISP_HARDWARE_TEXT FALSE
+#define GDISP_HARDWARE_TEXTFILLS FALSE
+#define GDISP_HARDWARE_SCROLL TRUE
+#define GDISP_HARDWARE_PIXELREAD TRUE
+#define GDISP_HARDWARE_CONTROL TRUE
+#define GDISP_HARDWARE_QUERY FALSE
+
+#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE
+#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE
+
+#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
+#define GDISP_PACKED_PIXELS FALSE
+#define GDISP_PACKED_LINES FALSE
+
+#endif /* HAL_USE_GDISP */
+
+#endif /* _GDISP_LLD_CONFIG_H */
+/** @} */
diff --git a/drivers/gdisp/gdispSsd1289/readme.txt b/drivers/gdisp/gdispSsd1289/readme.txt
new file mode 100644
index 00000000..17d22223
--- /dev/null
+++ b/drivers/gdisp/gdispSsd1289/readme.txt
@@ -0,0 +1,16 @@
+To use this driver:
+
+1. Add in your halconf.h:
+ a) #define HAL_USE_GDISP TRUE
+ b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD
+ c) One (only) of:
+ #define LCD_USE_GPIO
+ #define LCD_USE_SPI
+ #define LCD_USE_FSMC
+ d) All of the following (with appropriate values):
+ #define SCREEN_WIDTH 320
+ #define SCREEN_HEIGHT 240
+
+2. To your makefile add the following lines:
+ include $(CHIBIOS)/os/halext/halext.mk
+ include $(CHIBIOS)/os/halext/drivers/gdispSsd1289/gdisp_lld.mk
diff --git a/drivers/gdisp/gdispSsd1289/ssd1289_lld.c.h b/drivers/gdisp/gdispSsd1289/ssd1289_lld.c.h
new file mode 100644
index 00000000..7c0fade2
--- /dev/null
+++ b/drivers/gdisp/gdispSsd1289/ssd1289_lld.c.h
@@ -0,0 +1,322 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef SSD1289_H
+#define SSD1289_H
+
+#if defined(LCD_USE_GPIO)
+ #define Set_CS palSetPad(LCD_CMD_PORT, LCD_CS);
+ #define Clr_CS palClearPad(LCD_CMD_PORT, LCD_CS);
+ #define Set_RS palSetPad(LCD_CMD_PORT, LCD_RS);
+ #define Clr_RS palClearPad(LCD_CMD_PORT, LCD_RS);
+ #define Set_WR palSetPad(LCD_CMD_PORT, LCD_WR);
+ #define Clr_WR palClearPad(LCD_CMD_PORT, LCD_WR);
+ #define Set_RD palSetPad(LCD_CMD_PORT, LCD_RD);
+ #define Clr_RD palClearPad(LCD_CMD_PORT, LCD_RD);
+
+ static __inline void lld_lcdWriteIndex(uint16_t index) {
+ Clr_RS; Set_RD;
+ lld_lcdWriteGPIO(index);
+ Clr_WR; Set_WR;
+ }
+ static __inline void lld_lcdWriteData(uint16_t data) {
+ Set_RS;
+ lld_lcdWriteGPIO(data);
+ Clr_WR; Set_WR;
+ }
+ static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) {
+ Clr_CS;
+ lld_lcdWriteIndex(lcdReg);
+ lld_lcdWriteData(lcdRegValue);
+ Set_CS;
+ }
+ static __inline uint16_t lld_lcdReadData(void) {
+ uint16_t value;
+
+ Set_RS; Set_WR; Clr_RD;
+ value = lld_lcdReadGPIO();
+ Set_RD;
+ return value;
+ }
+ static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) {
+ uint16_t value;
+
+ Clr_CS;
+ lld_lcdWriteIndex(lcdReg);
+ value = lld_lcdReadData();
+ Set_CS;
+ return value;
+ }
+
+ static __inline void lld_lcdWriteStreamStart(void) {
+ Clr_CS;
+ lld_lcdWriteIndex(0x0022);
+ }
+
+ static __inline void lld_lcdWriteStreamStop(void) {
+ Set_CS;
+ }
+
+ static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
+ uint16_t i;
+
+ Set_RS;
+ for(i = 0; i < size; i++) { lld_lcdWriteGPIO(buffer[i]); Clr_WR; Set_WR; }
+ }
+
+ static __inline void lld_lcdReadStreamStart(void) {
+ Clr_CS
+ lld_lcdWriteIndex(0x0022);
+ }
+
+ static __inline void lld_lcdReadStreamStop(void) {
+ Set_CS;
+ }
+
+ static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) {
+ uint16_t i;
+ volatile uint16_t dummy;
+
+ dummy = lld_lcdReadData();
+ for(i = 0; i < size; i++) buffer[i] = lld_lcdReadData();
+ }
+
+#elif defined(LCD_USE_FSMC)
+ /* LCD Registers */
+ #define R0 0x00
+ #define R1 0x01
+ #define R2 0x02
+ #define R3 0x03
+ #define R4 0x04
+ #define R5 0x05
+ #define R6 0x06
+ #define R7 0x07
+ #define R8 0x08
+ #define R9 0x09
+ #define R10 0x0A
+ #define R12 0x0C
+ #define R13 0x0D
+ #define R14 0x0E
+ #define R15 0x0F
+ #define R16 0x10
+ #define R17 0x11
+ #define R18 0x12
+ #define R19 0x13
+ #define R20 0x14
+ #define R21 0x15
+ #define R22 0x16
+ #define R23 0x17
+ #define R24 0x18
+ #define R25 0x19
+ #define R26 0x1A
+ #define R27 0x1B
+ #define R28 0x1C
+ #define R29 0x1D
+ #define R30 0x1E
+ #define R31 0x1F
+ #define R32 0x20
+ #define R33 0x21
+ #define R34 0x22
+ #define R36 0x24
+ #define R37 0x25
+ #define R40 0x28
+ #define R41 0x29
+ #define R43 0x2B
+ #define R45 0x2D
+ #define R48 0x30
+ #define R49 0x31
+ #define R50 0x32
+ #define R51 0x33
+ #define R52 0x34
+ #define R53 0x35
+ #define R54 0x36
+ #define R55 0x37
+ #define R56 0x38
+ #define R57 0x39
+ #define R59 0x3B
+ #define R60 0x3C
+ #define R61 0x3D
+ #define R62 0x3E
+ #define R63 0x3F
+ #define R64 0x40
+ #define R65 0x41
+ #define R66 0x42
+ #define R67 0x43
+ #define R68 0x44
+ #define R69 0x45
+ #define R70 0x46
+ #define R71 0x47
+ #define R72 0x48
+ #define R73 0x49
+ #define R74 0x4A
+ #define R75 0x4B
+ #define R76 0x4C
+ #define R77 0x4D
+ #define R78 0x4E
+ #define R79 0x4F
+ #define R80 0x50
+ #define R81 0x51
+ #define R82 0x52
+ #define R83 0x53
+ #define R96 0x60
+ #define R97 0x61
+ #define R106 0x6A
+ #define R118 0x76
+ #define R128 0x80
+ #define R129 0x81
+ #define R130 0x82
+ #define R131 0x83
+ #define R132 0x84
+ #define R133 0x85
+ #define R134 0x86
+ #define R135 0x87
+ #define R136 0x88
+ #define R137 0x89
+ #define R139 0x8B
+ #define R140 0x8C
+ #define R141 0x8D
+ #define R143 0x8F
+ #define R144 0x90
+ #define R145 0x91
+ #define R146 0x92
+ #define R147 0x93
+ #define R148 0x94
+ #define R149 0x95
+ #define R150 0x96
+ #define R151 0x97
+ #define R152 0x98
+ #define R153 0x99
+ #define R154 0x9A
+ #define R157 0x9D
+ #define R192 0xC0
+ #define R193 0xC1
+ #define R229 0xE5
+
+ #define LCD_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */
+ #define LCD_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */
+
+ static __inline void lld_lcdWriteIndex(uint16_t index) { LCD_REG = index; }
+ static __inline void lld_lcdWriteData(uint16_t data) { LCD_RAM = data; }
+ static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) {
+ LCD_REG = lcdReg;
+ LCD_RAM = lcdRegValue;
+ }
+ static __inline uint16_t lld_lcdReadData(void) { return (LCD_RAM); }
+ static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) {
+ volatile uint16_t dummy;
+
+ LCD_REG = lcdReg;
+ dummy = LCD_RAM;
+ return (LCD_RAM);
+ }
+ static __inline void lld_lcdWriteStreamStart(void) { LCD_REG = 0x0022; }
+ static __inline void lld_lcdWriteStreamStop(void) {}
+ static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
+ uint16_t i;
+
+ for(i = 0; i < size; i++) LCD_RAM = buffer[i];
+ }
+ static __inline void lld_lcdReadStreamStart(void) { LCD_REG = 0x0022; }
+ static __inline void lld_lcdReadStreamStop(void) {}
+ static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) {
+ uint16_t i;
+ volatile uint16_t dummy;
+
+ dummy = LCD_RAM; /* throw away first value read */
+ for(i = 0; i < size; i++) buffer[i] = LCD_RAM;
+ }
+
+#elif defined(LCD_USE_SPI)
+ #error "gdispSsd1289: LCD_USE_SPI not implemented yet"
+
+#else
+ #error "gdispSsd1289: No known LCD_USE_XXX has been defined"
+#endif
+
+static __inline void lld_lcdDelay(uint16_t us) {
+ chThdSleepMicroseconds(us);
+}
+
+static void lld_lcdSetCursor(uint16_t x, uint16_t y) {
+ /* Reg 0x004E is an 8 bit value
+ * Reg 0x004F is 9 bit
+ * Use a bit mask to make sure they are not set too high
+ */
+ switch(GDISP.Orientation) {
+ case portraitInv:
+ lld_lcdWriteReg(0x004e, (SCREEN_WIDTH-1-x) & 0x00FF);
+ lld_lcdWriteReg(0x004f, (SCREEN_HEIGHT-1-y) & 0x01FF);
+ break;
+ case portrait:
+ lld_lcdWriteReg(0x004e, x & 0x00FF);
+ lld_lcdWriteReg(0x004f, y & 0x01FF);
+ break;
+ case landscape:
+ lld_lcdWriteReg(0x004e, y & 0x00FF);
+ lld_lcdWriteReg(0x004f, x & 0x01FF);
+ break;
+ case landscapeInv:
+ lld_lcdWriteReg(0x004e, (SCREEN_WIDTH - y - 1) & 0x00FF);
+ lld_lcdWriteReg(0x004f, (SCREEN_HEIGHT - x - 1) & 0x01FF);
+ break;
+ }
+}
+
+static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) {
+ lld_lcdSetCursor(x, y);
+
+ /* Reg 0x44 - Horizontal RAM address position
+ * Upper Byte - HEA
+ * Lower Byte - HSA
+ * 0 <= HSA <= HEA <= 0xEF
+ * Reg 0x45,0x46 - Vertical RAM address position
+ * Lower 9 bits gives 0-511 range in each value
+ * 0 <= Reg(0x45) <= Reg(0x46) <= 0x13F
+ */
+
+ switch(GDISP.Orientation) {
+ case portrait:
+ lld_lcdWriteReg(0x44, (((x+cx-1) << 8) & 0xFF00 ) | (x & 0x00FF));
+ lld_lcdWriteReg(0x45, y & 0x01FF);
+ lld_lcdWriteReg(0x46, (y+cy-1) & 0x01FF);
+ break;
+ case landscape:
+ lld_lcdWriteReg(0x44, (((x+cx-1) << 8) & 0xFF00) | ((y+cy) & 0x00FF));
+ lld_lcdWriteReg(0x45, x & 0x01FF);
+ lld_lcdWriteReg(0x46, (x+cx-1) & 0x01FF);
+ break;
+ case portraitInv:
+ lld_lcdWriteReg(0x44, (((SCREEN_WIDTH-x-1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (x+cx)) & 0x00FF));
+ lld_lcdWriteReg(0x45, (SCREEN_HEIGHT-(y+cy)) & 0x01FF);
+ lld_lcdWriteReg(0x46, (SCREEN_HEIGHT-y-1) & 0x01FF);
+ break;
+ case landscapeInv:
+ lld_lcdWriteReg(0x44, (((SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (y+cy)) & 0x00FF));
+ lld_lcdWriteReg(0x45, (SCREEN_HEIGHT - (x+cx)) & 0x01FF);
+ lld_lcdWriteReg(0x46, (SCREEN_HEIGHT - x - 1) & 0x01FF);
+ break;
+ }
+
+ lld_lcdSetCursor(x, y);
+}
+
+static __inline void lld_lcdResetViewPort(void) {}
+
+#endif /* SSD1289_H */
diff --git a/drivers/gdisp/gdispTestStub/gdisp_lld.c b/drivers/gdisp/gdispTestStub/gdisp_lld.c
new file mode 100644
index 00000000..fd8410fb
--- /dev/null
+++ b/drivers/gdisp/gdispTestStub/gdisp_lld.c
@@ -0,0 +1,361 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispTestStub/gdisp_lld.c
+ * @brief GDISP Graphics Driver subsystem low level driver source (stub).
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+#include "gdisp.h"
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+/* Include the emulation code for things we don't support */
+#include "gdisp_emulation.c"
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/* ---- Required Routines ---- */
+/*
+ The following 2 routines are required.
+ All other routines are optional.
+*/
+
+/**
+ * @brief Low level GDISP driver initialization.
+ *
+ * @notapi
+ */
+bool_t GDISP_LLD(init)(void) {
+ /* Initialise the GDISP structure */
+ GDISP.Width = 128;
+ GDISP.Height = 128;
+ GDISP.Orientation = portrait;
+ GDISP.Powermode = powerOff;
+ GDISP.Backlight = 100;
+ GDISP.Contrast = 50;
+ return TRUE;
+}
+
+/**
+ * @brief Draws a pixel on the display.
+ *
+ * @param[in] x X location of the pixel
+ * @param[in] y Y location of the pixel
+ * @param[in] color The color of the pixel
+ *
+ * @notapi
+ */
+void GDISP_LLD(drawpixel)(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(color)) {
+}
+
+/* ---- Optional Routines ---- */
+/*
+ All the below routines are optional.
+ Defining them will increase speed but everything
+ will work if they are not defined.
+ If you are not using a routine - turn it off using
+ the appropriate GDISP_HARDWARE_XXXX macro.
+ Don't bother coding for obvious similar routines if
+ there is no performance penalty as the emulation software
+ makes a good job of using similar routines.
+ eg. If fillarea() is defined there is little
+ point in defining clear() unless the
+ performance bonus is significant.
+ For good performance it is suggested to implement
+ fillarea() and blitarea().
+*/
+
+#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__)
+ /**
+ * @brief Clear the display.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] color The color of the pixel
+ *
+ * @notapi
+ */
+ void GDISP_LLD(clear)(color_t UNUSED(color)) {
+ }
+#endif
+
+#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a line.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x0, y0 The start of the line
+ * @param[in] x1, y1 The end of the line
+ * @param[in] color The color of the line
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawline)(coord_t UNUSED(x0), coord_t UNUSED(y0), coord_t UNUSED(x1), coord_t UNUSED(y1), color_t UNUSED(color)) {
+ }
+#endif
+
+#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__)
+ /**
+ * @brief Fill an area with a color.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The start filled area
+ * @param[in] cx, cy The width and height to be filled
+ * @param[in] color The color of the fill
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillarea)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), color_t UNUSED(color)) {
+ }
+#endif
+
+#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__)
+ /**
+ * @brief Fill an area with a bitmap.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The start filled area
+ * @param[in] cx, cy The width and height to be filled
+ * @param[in] buffer The pixels to use to fill the area.
+ *
+ * @notapi
+ */
+ void GDISP_LLD(blitarea)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), const pixel_t *UNUSED(buffer)) {
+ }
+#endif
+
+/* Circular Drawing Functions */
+#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a circle.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the circle is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color of the circle
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawcircle)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) {
+ }
+#endif
+
+#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Create a filled circle.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the circle is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color of the circle
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillcircle)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) {
+ }
+#endif
+
+#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw an ellipse.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the ellipse is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the ellipse
+ * @param[in] a, b The dimensions of the ellipse
+ * @param[in] color The color of the ellipse
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawellipse)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) {
+ }
+#endif
+
+#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Create a filled ellipse.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the ellipse is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the ellipse
+ * @param[in] a, b The dimensions of the ellipse
+ * @param[in] color The color of the ellipse
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillellipse)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) {
+ }
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a character using a transparent background.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The top-left corner of the text
+ * @param[in] c The character to print
+ * @param[in] color The color of the character
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawchar)(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color)) {
+ }
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a character using a filled background.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The top-left corner of the text
+ * @param[in] c The character to print
+ * @param[in] color The color of the character
+ * @param[in] bgcolor The background color
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillchar)(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color), color_t UNUSED(bgcolor)) {
+ }
+#endif
+
+#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__)
+ /**
+ * @brief Get the color of a particular pixel.
+ * @note Optional.
+ * @note If x,y is off the screen, the result is undefined.
+ *
+ * @param[in] x, y The start of the text
+ *
+ * @notapi
+ */
+ color_t GDISP_LLD(getpixelcolor)(coord_t UNUSED(x), coord_t UNUSED(y)) {
+ return 0;
+ }
+#endif
+
+#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__)
+ /**
+ * @brief Scroll vertically a section of the screen.
+ * @note Optional.
+ * @note If x,y + cx,cy is off the screen, the result is undefined.
+ * @note If lines is >= cy, it is equivelent to a area fill with bgcolor.
+ *
+ * @param[in] x, y The start of the area to be scrolled
+ * @param[in] cx, cy The size of the area to be scrolled
+ * @param[in] lines The number of lines to scroll (Can be positive or negative)
+ * @param[in] bgcolor The color to fill the newly exposed area.
+ *
+ * @notapi
+ */
+ void GDISP_LLD(verticalscroll)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), int UNUSED(lines), color_t UNUSED(bgcolor)) {
+ }
+#endif
+
+#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__)
+ /**
+ * @brief Driver Control
+ * @detail Unsupported control codes are ignored.
+ * @note The value parameter should always be typecast to (void *).
+ * @note There are some predefined and some specific to the low level driver.
+ * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t
+ * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t
+ * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver
+ * that only supports off/on anything other
+ * than zero is on.
+ * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100.
+ * GDISP_CONTROL_LLD - Low level driver control constants start at
+ * this value.
+ *
+ * @param[in] what What to do.
+ * @param[in] value The value to use (always cast to a void *).
+ *
+ * @notapi
+ */
+ void GDISP_LLD(control)(unsigned UNUSED(what), void *UNUSED(value)) {
+ }
+#endif
+
+#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__)
+/**
+ * @brief Query a driver value.
+ * @detail Typecase the result to the type you want.
+ * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen
+ * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen
+ * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode
+ * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation
+ * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100)
+ * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100).
+ * GDISP_QUERY_LLD - Low level driver control constants start at
+ * this value.
+ *
+ * @param[in] what What to Query
+ *
+ * @notapi
+ */
+void *GDISP_LLD(query)(unsigned what) {
+ switch(what) {
+ case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width;
+ case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height;
+ case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode;
+ case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation;
+ case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight;
+ case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast;
+ case GDISP_QUERY_LLD+0:
+ /* Code here */
+ default: return (void *)-1;
+ }
+}
+#endif
+
+#endif /* HAL_USE_GDISP */
+/** @} */
diff --git a/drivers/gdisp/gdispTestStub/gdisp_lld.mk b/drivers/gdisp/gdispTestStub/gdisp_lld.mk
new file mode 100644
index 00000000..9c5d02ea
--- /dev/null
+++ b/drivers/gdisp/gdispTestStub/gdisp_lld.mk
@@ -0,0 +1,5 @@
+# List the required driver.
+LCDSRC += $(LCDLIB)/drivers/gdisp/gdispTestStub/gdisp_lld.c
+
+# Required include directories
+LCDINC += $(LCDLIB)/drivers/gdisp/gdispTestStub
diff --git a/drivers/gdisp/gdispTestStub/gdisp_lld_config.h b/drivers/gdisp/gdispTestStub/gdisp_lld_config.h
new file mode 100644
index 00000000..d66e050f
--- /dev/null
+++ b/drivers/gdisp/gdispTestStub/gdisp_lld_config.h
@@ -0,0 +1,66 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispTestStub/gdisp_lld_config.h
+ * @brief GDISP Graphic Driver subsystem low level driver header (stub).
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_LLD_CONFIG_H
+#define _GDISP_LLD_CONFIG_H
+
+#if HAL_USE_GDISP
+
+/*===========================================================================*/
+/* Driver hardware support. */
+/*===========================================================================*/
+
+#define GDISP_DRIVER_NAME "TestStub"
+#define GDISP_LLD(x) gdisp_lld_##x##_TestStub
+
+#define GDISP_HARDWARE_LINES FALSE
+#define GDISP_HARDWARE_CLEARS FALSE
+#define GDISP_HARDWARE_FILLS FALSE
+#define GDISP_HARDWARE_BITFILLS FALSE
+#define GDISP_HARDWARE_CIRCLES FALSE
+#define GDISP_HARDWARE_CIRCLEFILLS FALSE
+#define GDISP_HARDWARE_ELLIPSES FALSE
+#define GDISP_HARDWARE_ELLIPSEFILLS FALSE
+#define GDISP_HARDWARE_TEXT FALSE
+#define GDISP_HARDWARE_TEXTFILLS FALSE
+#define GDISP_HARDWARE_SCROLL GDISP_NEED_SCROLL
+#define GDISP_HARDWARE_PIXELREAD GDISP_NEED_PIXELREAD
+#define GDISP_HARDWARE_CONTROL FALSE
+#define GDISP_HARDWARE_QUERY FALSE
+
+#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE
+#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE
+
+#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
+#define GDISP_PACKED_PIXELS FALSE
+#define GDISP_PACKED_LINES FALSE
+
+#endif /* HAL_USE_GDISP */
+
+#endif /* _GDISP_LLD_CONFIG_H */
+/** @} */
diff --git a/drivers/gdisp/gdispTestStub/readme.txt b/drivers/gdisp/gdispTestStub/readme.txt
new file mode 100644
index 00000000..83611acf
--- /dev/null
+++ b/drivers/gdisp/gdispTestStub/readme.txt
@@ -0,0 +1,17 @@
+This low level driver is a test stub that doesn't talk to any
+real hardware. It is included to allow testing of the compilation
+process.
+
+Do not use this driver as a template for new drivers. Use the
+ templates/gdispXXXXX directory for that.
+
+To use this driver:
+
+1. Add in your halconf.h:
+ a) #define HAL_USE_GDISP TRUE
+ b) Any optional high level driver defines (see gdisp.h)
+ you want to compile test eg: GDISP_NEED_MULTITHREAD
+
+2. To your makefile add the following lines:
+ include $(CHIBIOS)/os/halext/halext.mk
+ include $(CHIBIOS)/os/halext/drivers/gdispTestStub/gdisp_lld.mk
diff --git a/drivers/gdisp/gdispVMT/gdisp_lld.c b/drivers/gdisp/gdispVMT/gdisp_lld.c
new file mode 100644
index 00000000..1528f470
--- /dev/null
+++ b/drivers/gdisp/gdispVMT/gdisp_lld.c
@@ -0,0 +1,249 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispVMT/gdisp_lld.c
+ * @brief GDISP Graphics Driver subsystem low level driver source for VMT.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+#include "gdisp.h"
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+#define GDISP_LLD_NO_STRUCT
+
+/* Include the emulation code for things we don't support */
+#include "gdisp_emulation.c"
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+#define GDISP_LLD1(x) GDISP_VMT_NAME1(gdisp_lld_##x##_)
+#define GDISP_LLD2(x) GDISP_VMT_NAME2(gdisp_lld_##x##_)
+
+/* Prototypes for lld driver functions */
+bool_t GDISP_LLD1(init)(void);
+void GDISP_LLD1(clear)(color_t color);
+void GDISP_LLD1(drawpixel)(coord_t x, coord_t y, color_t color);
+void GDISP_LLD1(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
+void GDISP_LLD1(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer);
+void GDISP_LLD1(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color);
+#if GDISP_NEED_CIRCLE
+ void GDISP_LLD1(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color);
+ void GDISP_LLD1(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color);
+#endif
+#if GDISP_NEED_ELLIPSE
+ void GDISP_LLD1(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+ void GDISP_LLD1(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+#endif
+#if GDISP_NEED_TEXT
+ void GDISP_LLD1(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color);
+ void GDISP_LLD1(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor);
+#endif
+#if GDISP_NEED_PIXELREAD
+ color_t GDISP_LLD1(getpixelcolor)(coord_t x, coord_t y);
+#endif
+#if GDISP_NEED_SCROLL
+ void GDISP_LLD1(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor);
+#endif
+#if GDISP_NEED_CONTROL
+ void GDISP_LLD1(control)(unsigned what, void *value);
+#endif
+#if GDISP_NEED_QUERY
+ void *GDISP_LLD1(query)(unsigned what);
+#endif
+
+bool_t GDISP_LLD2(init)(void);
+void GDISP_LLD2(clear)(color_t color);
+void GDISP_LLD2(drawpixel)(coord_t x, coord_t y, color_t color);
+void GDISP_LLD2(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
+void GDISP_LLD2(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer);
+void GDISP_LLD2(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color);
+#if GDISP_NEED_CIRCLE
+ void GDISP_LLD2(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color);
+ void GDISP_LLD2(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color);
+#endif
+#if GDISP_NEED_ELLIPSE
+ void GDISP_LLD2(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+ void GDISP_LLD2(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+#endif
+#if GDISP_NEED_TEXT
+ void GDISP_LLD2(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color);
+ void GDISP_LLD2(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor);
+#endif
+#if GDISP_NEED_PIXELREAD
+ color_t GDISP_LLD2(getpixelcolor)(coord_t x, coord_t y);
+#endif
+#if GDISP_NEED_SCROLL
+ void GDISP_LLD2(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor);
+#endif
+#if GDISP_NEED_CONTROL
+ void GDISP_LLD2(control)(unsigned what, void *value);
+#endif
+#if GDISP_NEED_QUERY
+ void *GDISP_LLD2(query)(unsigned what);
+#endif
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/* Our VMT table variables */
+void GDISP_LLD_VMT(clear)(color_t color);
+void GDISP_LLD_VMT(drawpixel)(coord_t x, coord_t y, color_t color);
+void GDISP_LLD_VMT(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
+void GDISP_LLD_VMT(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer);
+void GDISP_LLD_VMT(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color);
+
+#if GDISP_NEED_CIRCLE
+void GDISP_LLD_VMT(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color);
+void GDISP_LLD_VMT(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color);
+#endif
+
+#if GDISP_NEED_ELLIPSE
+void GDISP_LLD_VMT(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+void GDISP_LLD_VMT(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+#endif
+
+/* Text Rendering Functions */
+#if GDISP_NEED_TEXT
+void GDISP_LLD_VMT(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color);
+void GDISP_LLD_VMT(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor);
+#endif
+
+/* Pixel readback */
+#if GDISP_NEED_PIXELREAD
+color_t GDISP_LLD_VMT(getpixelcolor)(coord_t x, coord_t y);
+#endif
+
+/* Scrolling Function - clears the area scrolled out */
+#if GDISP_NEED_SCROLL
+void GDISP_LLD_VMT(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor);
+#endif
+
+/* Set driver specific control */
+#if GDISP_NEED_CONTROL
+void GDISP_LLD_VMT(control)(unsigned what, void *value);
+#endif
+/* Set driver specific control */
+#if GDISP_NEED_QUERY
+void *GDISP_LLD_VMT(query)(unsigned what);
+#endif
+
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+bool_t gdisp_lld_init_VMT(void) {
+ if (GDISP_VMT_NAME1(gdisp_lld_init_)()) {
+ gdisp_lld_clear_VMT = GDISP_VMT_NAME1(gdisp_lld_clear_);
+ gdisp_lld_drawpixel_VMT = GDISP_VMT_NAME1(gdisp_lld_drawpixel_);
+ gdisp_lld_fillarea_VMT = GDISP_VMT_NAME1(gdisp_lld_fillarea_);
+ gdisp_lld_blitarea_VMT = GDISP_VMT_NAME1(gdisp_lld_blitarea_);
+ gdisp_lld_drawline_VMT = GDISP_VMT_NAME1(gdisp_lld_drawline_);
+ #if GDISP_NEED_CIRCLE
+ gdisp_lld_drawcircle_VMT = GDISP_VMT_NAME1(gdisp_lld_drawcircle_);
+ gdisp_lld_fillcircle_VMT = GDISP_VMT_NAME1(gdisp_lld_fillcircle_);
+ #endif
+ #if GDISP_NEED_ELLIPSE
+ gdisp_lld_drawellipse_VMT = GDISP_VMT_NAME1(gdisp_lld_drawellipse_);
+ gdisp_lld_fillellipse_VMT = GDISP_VMT_NAME1(gdisp_lld_fillellipse_);
+ #endif
+ #if GDISP_NEED_TEXT
+ gdisp_lld_drawchar_VMT = GDISP_VMT_NAME1(gdisp_lld_drawchar_);
+ gdisp_lld_fillchar_VMT = GDISP_VMT_NAME1(gdisp_lld_fillchar_);
+ #endif
+ #if GDISP_NEED_PIXELREAD
+ gdisp_lld_getpixelcolor_VMT = GDISP_VMT_NAME1(gdisp_lld_pixelread_);
+ #endif
+ #if GDISP_NEED_SCROLL
+ gdisp_lld_verticalscroll_VMT = GDISP_VMT_NAME1(gdisp_lld_scroll_);
+ #endif
+ #if GDISP_NEED_CONTROL
+ gdisp_lld_control_VMT = GDISP_VMT_NAME1(gdisp_lld_control_);
+ #endif
+ #if GDISP_NEED_QUERY
+ gdisp_lld_query_VMT = GDISP_VMT_NAME1(gdisp_lld_query_);
+ #endif
+
+ return TRUE;
+ }
+
+ if (GDISP_VMT_NAME2(gdisp_lld_init_)()) {
+ gdisp_lld_clear_VMT = GDISP_VMT_NAME2(gdisp_lld_clear_);
+ gdisp_lld_drawpixel_VMT = GDISP_VMT_NAME2(gdisp_lld_drawpixel_);
+ gdisp_lld_fillarea_VMT = GDISP_VMT_NAME2(gdisp_lld_fillarea_);
+ gdisp_lld_blitarea_VMT = GDISP_VMT_NAME2(gdisp_lld_blitarea_);
+ gdisp_lld_drawline_VMT = GDISP_VMT_NAME2(gdisp_lld_drawline_);
+ #if GDISP_NEED_CIRCLE
+ gdisp_lld_drawcircle_VMT = GDISP_VMT_NAME2(gdisp_lld_drawcircle_);
+ gdisp_lld_fillcircle_VMT = GDISP_VMT_NAME2(gdisp_lld_fillcircle_);
+ #endif
+ #if GDISP_NEED_ELLIPSE
+ gdisp_lld_drawellipse_VMT = GDISP_VMT_NAME2(gdisp_lld_drawellipse_);
+ gdisp_lld_fillellipse_VMT = GDISP_VMT_NAME2(gdisp_lld_fillellipse_);
+ #endif
+ #if GDISP_NEED_TEXT
+ gdisp_lld_drawchar_VMT = GDISP_VMT_NAME2(gdisp_lld_drawchar_);
+ gdisp_lld_fillchar_VMT = GDISP_VMT_NAME2(gdisp_lld_fillchar_);
+ #endif
+ #if GDISP_NEED_PIXELREAD
+ gdisp_lld_getpixelcolor_VMT = GDISP_VMT_NAME2(gdisp_lld_pixelread_);
+ #endif
+ #if GDISP_NEED_SCROLL
+ gdisp_lld_verticalscroll_VMT = GDISP_VMT_NAME2(gdisp_lld_scroll_);
+ #endif
+ #if GDISP_NEED_CONTROL
+ gdisp_lld_control_VMT = GDISP_VMT_NAME2(gdisp_lld_control_);
+ #endif
+ #if GDISP_NEED_QUERY
+ gdisp_lld_query_VMT = GDISP_VMT_NAME2(gdisp_lld_query_);
+ #endif
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+#endif /* HAL_USE_GDISP */
+/** @} */
diff --git a/drivers/gdisp/gdispVMT/gdisp_lld.mk b/drivers/gdisp/gdispVMT/gdisp_lld.mk
new file mode 100644
index 00000000..f89470a6
--- /dev/null
+++ b/drivers/gdisp/gdispVMT/gdisp_lld.mk
@@ -0,0 +1,7 @@
+# List the required driver.
+LCDSRC += ${CHIBIOS}/os/halext/drivers/gdispVMT/gdisp_lld.c \
+ ${CHIBIOS}/os/halext/drivers/gdispVMT/gdisp_lld_driver1.c \
+ ${CHIBIOS}/os/halext/drivers/gdispVMT/gdisp_lld_driver2.c
+
+# Required include directories
+LCDINC += ${CHIBIOS}/os/halext/drivers/gdispVMT
diff --git a/drivers/gdisp/gdispVMT/gdisp_lld_config.h b/drivers/gdisp/gdispVMT/gdisp_lld_config.h
new file mode 100644
index 00000000..6c6f7c80
--- /dev/null
+++ b/drivers/gdisp/gdispVMT/gdisp_lld_config.h
@@ -0,0 +1,67 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispVMT/gdisp_lld_config.h
+ * @brief GDISP Graphic Driver subsystem low level driver header template.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_LLD_CONFIG_H
+#define _GDISP_LLD_CONFIG_H
+
+#if HAL_USE_GDISP
+
+/*===========================================================================*/
+/* Driver hardware support. */
+/*===========================================================================*/
+
+#define GDISP_DRIVER_NAME "VMT"
+#define GDISP_LLD(x) gdisp_lld_##x##_VMT
+#define GDISP_LLD_VMT(x) (*GDISP_LLD(x))
+
+#define GDISP_HARDWARE_LINES TRUE
+#define GDISP_HARDWARE_CLEARS TRUE
+#define GDISP_HARDWARE_FILLS TRUE
+#define GDISP_HARDWARE_BITFILLS TRUE
+#define GDISP_HARDWARE_CIRCLES TRUE
+#define GDISP_HARDWARE_CIRCLEFILLS TRUE
+#define GDISP_HARDWARE_ELLIPSES TRUE
+#define GDISP_HARDWARE_ELLIPSEFILLS TRUE
+#define GDISP_HARDWARE_TEXT TRUE
+#define GDISP_HARDWARE_TEXTFILLS TRUE
+#define GDISP_HARDWARE_SCROLL TRUE
+#define GDISP_HARDWARE_PIXELREAD TRUE
+#define GDISP_HARDWARE_CONTROL TRUE
+#define GDISP_HARDWARE_QUERY TRUE
+
+#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE
+#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE
+
+#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
+#define GDISP_PACKED_PIXELS FALSE
+#define GDISP_PACKED_LINES FALSE
+
+#endif /* HAL_USE_GDISP */
+
+#endif /* _GDISP_LLD_CONFIG_H */
+/** @} */
diff --git a/drivers/gdisp/gdispVMT/gdisp_lld_driver1.c b/drivers/gdisp/gdispVMT/gdisp_lld_driver1.c
new file mode 100644
index 00000000..f088623e
--- /dev/null
+++ b/drivers/gdisp/gdispVMT/gdisp_lld_driver1.c
@@ -0,0 +1,51 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispVMT/gdisp_lld.c
+ * @brief GDISP Graphics Driver subsystem low level driver source for VMT.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+#define CONFIGFILE() <../GDISP_VMT_NAME1(gdisp)/gdisp_lld_config.h>
+#define DRIVERFILE() <../GDISP_VMT_NAME1(gdisp)/gdisp_lld.c>
+
+/* We don't need these in our VMT referenced driver */
+#undef GDISP_NEED_MSGAPI
+#define GDISP_NEED_MSGAPI FALSE
+
+/* Include the specific config file we want */
+#include CONFIGFILE()
+
+/* Bring in our API */
+#include "gdisp.h"
+
+/* Add the low level driver */
+#include DRIVERFILE()
+
+#endif /* HAL_USE_GDISP */
+/** @} */
diff --git a/drivers/gdisp/gdispVMT/gdisp_lld_driver2.c b/drivers/gdisp/gdispVMT/gdisp_lld_driver2.c
new file mode 100644
index 00000000..325a53e6
--- /dev/null
+++ b/drivers/gdisp/gdispVMT/gdisp_lld_driver2.c
@@ -0,0 +1,51 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdispVMT/gdisp_lld.c
+ * @brief GDISP Graphics Driver subsystem low level driver source for VMT.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+#define CONFIGFILE() <../GDISP_VMT_NAME2(gdisp)/gdisp_lld_config.h>
+#define DRIVERFILE() <../GDISP_VMT_NAME2(gdisp)/gdisp_lld.c>
+
+/* We don't need these in our VMT referenced driver */
+#undef GDISP_NEED_MSGAPI
+#define GDISP_NEED_MSGAPI FALSE
+
+/* Include the specific config file we want */
+#include CONFIGFILE()
+
+/* Bring in our API */
+#include "gdisp.h"
+
+/* Add the low level driver */
+#include DRIVERFILE()
+
+#endif /* HAL_USE_GDISP */
+/** @} */
diff --git a/drivers/gdisp/gdispVMT/readme.txt b/drivers/gdisp/gdispVMT/readme.txt
new file mode 100644
index 00000000..91d3f58c
--- /dev/null
+++ b/drivers/gdisp/gdispVMT/readme.txt
@@ -0,0 +1,23 @@
+This driver enables you to have two underlying drivers handling different hardware.
+A choice is made at run-time of which driver to call based on which driver succeeds
+to initialise first (init returns TRUE).
+
+To use this driver:
+
+1. Add in your halconf.h:
+ a) #define HAL_USE_GDISP TRUE
+ b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD
+ c) Define these:
+ #define GDISP_VMT_NAME1(x) x##YourDriver1
+ #define GDISP_VMT_NAME2(x) x##YourDriver2
+ Note YourDriver1 & 2 are the basenames of the directories containing the driver.
+ Note that both drivers must be the same pixel format which is
+ GDISP_PIXELFORMAT_RGB565 by default. Alter gdispVMT/gdisp_lld_config.h if your
+ pixel format is different on both drivers.
+ d) Any driver specific defines. If both drivers use the same defines then they must
+ accept the same values for the define.
+
+2. To your makefile add the following lines:
+ include $(CHIBIOS)/os/halext/halext.mk
+ include $(CHIBIOS)/os/halext/drivers/gdispVMT/gdisp_lld.mk
+ \ No newline at end of file
diff --git a/drivers/touchpad/touchpadADS7843/readme.txt b/drivers/touchpad/touchpadADS7843/readme.txt
new file mode 100644
index 00000000..34a57bc0
--- /dev/null
+++ b/drivers/touchpad/touchpadADS7843/readme.txt
@@ -0,0 +1,9 @@
+To use this driver:
+
+1. Add in your halconf.h:
+ a) #define HAL_USE_TOUCHPAD TRUE
+
+2. To your makefile add the following lines:
+ include $(LCDLIB)/lcd.mk
+ include $(LCDLIB)/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.mk
+
diff --git a/drivers/touchpad/touchpadADS7843/touchpad_lld.c b/drivers/touchpad/touchpadADS7843/touchpad_lld.c
new file mode 100644
index 00000000..a5265995
--- /dev/null
+++ b/drivers/touchpad/touchpadADS7843/touchpad_lld.c
@@ -0,0 +1,146 @@
+/*
+ ChibiOS-LCD-Driver - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file touchpadADS7843/touchpad_lld.c
+ * @brief Touchpad Driver subsystem low level driver source.
+ *
+ * @addtogroup TOUCHPAD
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+#include "touchpad.h"
+
+#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS)
+#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS)
+
+#ifdef UNUSED
+#elif defined(__GNUC__)
+# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
+#elif defined(__LCLINT__)
+# define UNUSED(x) /*@unused@*/ x
+#else
+# define UNUSED(x) x
+#endif
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+#if !defined(__DOXYGEN__)
+ TOUCHPADDriver Touchpad;
+#endif
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/* ---- Required Routines ---- */
+
+/**
+ * @brief Low level Touchpad driver initialization.
+ *
+ * @notapi
+ */
+void tp_lld_init(TOUCHPADDriver *tp) {
+ spiStart(tp->spid, tp->spicfg);
+}
+
+/**
+ * @brief Reads out the X direction.
+ *
+ * @notapi
+ */
+uint16_t tp_lld_read_x(void) {
+ uint8_t txbuf[1];
+ uint8_t rxbuf[2];
+ uint16_t y;
+
+ txbuf[0] = 0xd0;
+ TP_CS_LOW;
+ spiSend(&SPID1, 1, txbuf);
+ spiReceive(&SPID1, 2, rxbuf);
+ TP_CS_HIGH;
+
+ y = rxbuf[0] << 4;
+ y |= rxbuf[1] >> 4;
+
+ return y;
+}
+
+/*
+ * @brief Reads out the X direction.
+ *
+ * @notapi
+ */
+uint16_t tp_lld_read_y(void) {
+ uint8_t txbuf[1];
+ uint8_t rxbuf[2];
+ uint16_t y;
+
+ txbuf[0] = 0x90;
+ TP_CS_LOW;
+ spiSend(&SPID1, 1, txbuf);
+ spiReceive(&SPID1, 2, rxbuf);
+ TP_CS_HIGH;
+
+ y = rxbuf[0] << 4;
+ y |= rxbuf[1] >> 4;
+
+ return y;
+}
+
+/* ---- Optional Routines ---- */
+#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__)
+ /*
+ * @brief for checking if touchpad is pressed or not.
+ *
+ * @return 1 if pressed / 0 if not pressed
+ *
+ * @noapi
+ */
+ uint8_t tp_lld_irq(void) {
+ return (!palReadPad(TP_IRQ_PORT, TP_IRQ));
+ }
+#endif
+
+#endif /* HAL_USE_TOUCHPAD */
+/** @} */
+
diff --git a/drivers/touchpad/touchpadADS7843/touchpad_lld.mk b/drivers/touchpad/touchpadADS7843/touchpad_lld.mk
new file mode 100644
index 00000000..f70f0dd1
--- /dev/null
+++ b/drivers/touchpad/touchpadADS7843/touchpad_lld.mk
@@ -0,0 +1,6 @@
+# List the required driver.
+LCDSRC += $(LCDLIB)/drivers/touchpad/touchpadADS7843/touchpad_lld.c
+
+# Required include directories
+LCDINC += $(LCDLIB)/drivers/touchpad/touchpadADS7843
+
diff --git a/drivers/touchpad/touchpadADS7843/touchpad_lld_config.h b/drivers/touchpad/touchpadADS7843/touchpad_lld_config.h
new file mode 100644
index 00000000..1e878795
--- /dev/null
+++ b/drivers/touchpad/touchpadADS7843/touchpad_lld_config.h
@@ -0,0 +1,44 @@
+/*
+ ChibiOS-LCD-Driver - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file touchpadADS7843/touchpad_lld_config.h
+ * @brief Touchpad Driver subsystem low level driver.
+ *
+ * @addtogroup TOUCHPAD
+ * @{
+ */
+
+#ifndef _TOUCHPAD_LLD_CONFIG_H
+#define _TOUCHPAD_LLD_CONFIG_H
+
+#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver hardware support. */
+/*===========================================================================*/
+
+#define TOUCHPAD_HAS_IRQ TRUE
+#define TOUCHPAD_HAS_PRESSURE FALSE
+
+#endif /* HAL_USE_TOUCHPAD */
+
+#endif /* _TOUCHPAD_LLD_CONFIG_H */
+/** @} */
diff --git a/drivers/touchpad/touchpadXPT2046/readme.txt b/drivers/touchpad/touchpadXPT2046/readme.txt
new file mode 100644
index 00000000..992d346d
--- /dev/null
+++ b/drivers/touchpad/touchpadXPT2046/readme.txt
@@ -0,0 +1,9 @@
+To use this driver:
+
+1. Add in your halconf.h:
+ a) #define HAL_USE_TOUCHPAD TRUE
+
+2. To your makefile add the following lines:
+ include $(LCDLIB)/lcd.mk
+ include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk
+
diff --git a/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/drivers/touchpad/touchpadXPT2046/touchpad_lld.c
new file mode 100644
index 00000000..195c8aa6
--- /dev/null
+++ b/drivers/touchpad/touchpadXPT2046/touchpad_lld.c
@@ -0,0 +1,158 @@
+/*
+ ChibiOS-LCD-Driver - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file touchpadXPT2046/touchpad_lld.c
+ * @brief Touchpad Driver subsystem low level driver source.
+ *
+ * @addtogroup TOUCHPAD
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+#include "touchpad.h"
+
+#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS)
+#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS)
+
+#ifdef UNUSED
+#elif defined(__GNUC__)
+# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
+#elif defined(__LCLINT__)
+# define UNUSED(x) /*@unused@*/ x
+#else
+# define UNUSED(x) x
+#endif
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+#if !defined(__DOXYGEN__)
+ TOUCHPADDriver Touchpad;
+#endif
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/* ---- Required Routines ---- */
+
+/**
+ * @brief Low level Touchpad driver initialization.
+ *
+ * @notapi
+ */
+void tp_lld_init(TOUCHPADDriver *tp) {
+ spiStart(tp->spid, tp->spicfg);
+}
+
+/**
+ * @brief Reads out the X direction.
+ *
+ * @notapi
+ */
+uint16_t tp_lld_read_x(void) {
+ uint8_t txbuf[1];
+ uint8_t rxbuf[2];
+ uint16_t y;
+
+ txbuf[0] = 0xd0;
+ TP_CS_LOW;
+ spiSend(&SPID1, 1, txbuf);
+ spiReceive(&SPID1, 2, rxbuf);
+ TP_CS_HIGH;
+
+ y = rxbuf[0] << 4;
+ y |= rxbuf[1] >> 4;
+
+ return y;
+}
+
+/*
+ * @brief Reads out the Y direction.
+ *
+ * @notapi
+ */
+uint16_t tp_lld_read_y(void) {
+ uint8_t txbuf[1];
+ uint8_t rxbuf[2];
+ uint16_t y;
+
+ txbuf[0] = 0x90;
+ TP_CS_LOW;
+ spiSend(&SPID1, 1, txbuf);
+ spiReceive(&SPID1, 2, rxbuf);
+ TP_CS_HIGH;
+
+ y = rxbuf[0] << 4;
+ y |= rxbuf[1] >> 4;
+
+ return y;
+}
+
+/* ---- Optional Routines ---- */
+#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__)
+ /*
+ * @brief for checking if touchpad is pressed or not.
+ *
+ * @return 1 if pressed / 0 if not pressed
+ *
+ * @notapi
+ */
+ uint8_t tp_lld_irq(void) {
+ return (!palReadPad(TP_IRQ_PORT, TP_IRQ));
+ }
+#endif
+
+#if TOUCHPAD_HAS_PRESSURE || defined(__DOXYGEN__)
+ /*
+ * @brief Reads out the Z direction / pressure.
+ *
+ * @notapi
+ */
+ uint16_t tp_lld_read_z(void) {
+ /* ToDo */
+ return 42;
+ }
+#endif
+
+#endif /* HAL_USE_TOUCHPAD */
+/** @} */
+
diff --git a/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk b/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk
new file mode 100644
index 00000000..26e27c1c
--- /dev/null
+++ b/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk
@@ -0,0 +1,6 @@
+# List the required driver.
+LCDSRC += $(LCDLIB)/drivers/touchpad/touchpadXPT2046/touchpad_lld.c
+
+# Required include directories
+LCDINC += $(LCDLIB)/drivers/touchpad/touchpadXPT2046
+
diff --git a/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h b/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h
new file mode 100644
index 00000000..4ddd8da0
--- /dev/null
+++ b/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h
@@ -0,0 +1,44 @@
+/*
+ ChibiOS-LCD-Driver - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file touchpadXPT2046/touchpad_lld_config.h
+ * @brief Touchppad Driver subsystem low level driver.
+ *
+ * @addtogroup TOUCHPAD
+ * @{
+ */
+
+#ifndef _TOUCHPAD_LLD_CONFIG_H
+#define _TOUCHPAD_LLD_CONFIG_H
+
+#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver hardware support. */
+/*===========================================================================*/
+
+#define TOUCHPAD_HAS_IRQ TRUE
+#define TOUCHPAD_HAS_PRESSURE TRUE
+
+#endif /* HAL_USE_TOUCHPAD */
+
+#endif /* _TOUCHPAD_LLD_CONFIG_H */
+/** @} */
diff --git a/include/gdisp.h b/include/gdisp.h
new file mode 100644
index 00000000..b5a59cf9
--- /dev/null
+++ b/include/gdisp.h
@@ -0,0 +1,266 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @file gdisp.h
+ * @brief GDISP Graphic Driver subsystem header file.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+#ifndef _GDISP_H
+#define _GDISP_H
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+/**
+ * @brief Some basic colors
+ */
+#define White HTML2COLOR(0xFFFFFF)
+#define Black HTML2COLOR(0x000000)
+#define Gray HTML2COLOR(0x808080)
+#define Grey Gray
+#define Blue HTML2COLOR(0x0000FF)
+#define Red HTML2COLOR(0xFF0000)
+#define Fuchsia HTML2COLOR(0xFF00FF)
+#define Magenta Fuchsia
+#define Green HTML2COLOR(0x008000)
+#define Yellow HTML2COLOR(0xFFFF00)
+#define Aqua HTML2COLOR(0x00FFFF)
+#define Cyan Aqua
+#define Lime HTML2COLOR(0x00FF00)
+#define Maroon HTML2COLOR(0x800000)
+#define Navy HTML2COLOR(0x000080)
+#define Olive HTML2COLOR(0x808000)
+#define Purple HTML2COLOR(0x800080)
+#define Silver HTML2COLOR(0xC0C0C0)
+#define Teal HTML2COLOR(0x008080)
+#define Orange HTML2COLOR(0xFFA500)
+#define Pink HTML2COLOR(0xFFC0CB)
+#define SkyBlue HTML2COLOR(0x87CEEB)
+
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/**
+ * @name GDISP more complex functionality to be compiled
+ * @{
+ */
+ /**
+ * @brief Do the drawing functions need to be thread-safe.
+ * @details Defaults to FALSE
+ * @note Both GDISP_NEED_MULTITHREAD and GDISP_NEED_ASYNC make
+ * the gdisp API thread-safe.
+ * @note This is more efficient than GDISP_NEED_ASYNC as it only
+ * requires a context switch if something else is already
+ * drawing.
+ */
+ #ifndef GDISP_NEED_MULTITHREAD
+ #define GDISP_NEED_MULTITHREAD FALSE
+ #endif
+
+ /**
+ * @brief Use asynchronous calls (multi-thread safe).
+ * @details Defaults to FALSE
+ * @note Both GDISP_NEED_MULTITHREAD and GDISP_NEED_ASYNC make
+ * the gdisp API thread-safe.
+ * @note Turning this on adds two context switches per transaction
+ * so it can significantly slow graphics drawing.
+ */
+ #ifndef GDISP_NEED_ASYNC
+ #define GDISP_NEED_ASYNC FALSE
+ #endif
+/** @} */
+
+#if GDISP_NEED_MULTITHREAD && GDISP_NEED_ASYNC
+ #error "GDISP: Only one of GDISP_NEED_MULTITHREAD and GDISP_NEED_ASYNC should be defined."
+#endif
+
+#if GDISP_NEED_ASYNC
+ /* Messaging API is required for Async Multi-Thread */
+ #undef GDISP_NEED_MSGAPI
+ #define GDISP_NEED_MSGAPI TRUE
+#endif
+
+/*===========================================================================*/
+/* Low Level Driver details and error checks. */
+/*===========================================================================*/
+
+/* Include the low level driver information */
+#include "gdisp_lld.h"
+
+/*===========================================================================*/
+/* Type definitions */
+/*===========================================================================*/
+
+/**
+ * @brief Type for the text justification.
+ */
+typedef enum justify {justifyLeft, justifyCenter, justifyRight} justify_t;
+/**
+ * @brief Type for the font metric.
+ */
+typedef enum fontmetric {fontHeight, fontDescendersHeight, fontLineSpacing, fontCharPadding, fontMinWidth, fontMaxWidth} fontmetric_t;
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
+/**
+ * @brief Predefined fonts.
+ */
+extern const struct font fontSmall;
+extern const struct font fontSmallDouble;
+extern const struct font fontSmallNarrow;
+extern const struct font fontLarger;
+extern const struct font fontLargerDouble;
+extern const struct font fontLargerNarrow;
+extern const struct font fontUI1;
+extern const struct font fontUI1Double;
+extern const struct font fontUI1Narrow;
+extern const struct font fontUI2;
+extern const struct font fontUI2Double;
+extern const struct font fontUI2Narrow;
+extern const struct font fontLargeNumbers;
+extern const struct font fontLargeNumbersDouble;
+extern const struct font fontLargeNumbersNarrow;
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if GDISP_NEED_MULTITHREAD || GDISP_NEED_ASYNC
+
+ /* Base Functions */
+ bool_t gdispInit(void);
+ bool_t gdispIsBusy(void);
+
+ /* Drawing Functions */
+ void gdispClear(color_t color);
+ void gdispDrawPixel(coord_t x, coord_t y, color_t color);
+ void gdispDrawLine(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color);
+ void gdispFillArea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
+ void gdispBlitArea(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer);
+
+ /* Circle Functions */
+ #if GDISP_NEED_CIRCLE
+ void gdispDrawCircle(coord_t x, coord_t y, coord_t radius, color_t color);
+ void gdispFillCircle(coord_t x, coord_t y, coord_t radius, color_t color);
+ #endif
+
+ /* Ellipse Functions */
+ #if GDISP_NEED_ELLIPSE
+ void gdispDrawEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+ void gdispFillEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+ #endif
+
+ /* Basic Text Rendering Functions */
+ #if GDISP_NEED_TEXT
+ void gdispDrawChar(coord_t x, coord_t y, char c, font_t font, color_t color);
+ void gdispFillChar(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor);
+ #endif
+
+ /* Read a pixel Function */
+ #if GDISP_NEED_PIXELREAD
+ color_t gdispGetPixelColor(coord_t x, coord_t y);
+ #endif
+
+ /* Scrolling Function - clears the area scrolled out */
+ #if GDISP_NEED_SCROLL
+ void gdispVerticalScroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor);
+ #endif
+
+ /* Set driver specific control */
+ #if GDISP_NEED_CONTROL
+ void gdispControl(unsigned what, void *value);
+ #endif
+
+ /* Query driver specific data */
+ #if GDISP_NEED_CONTROL
+ void *gdispQuery(unsigned what);
+ #endif
+
+#else
+
+ /* The same as above but use the low level driver directly if no multi-thread support is needed */
+ #define gdispInit(gdisp) GDISP_LLD(init)()
+ #define gdispIsBusy() FALSE
+ #define gdispClear(color) GDISP_LLD(clear)(color)
+ #define gdispDrawPixel(x, y, color) GDISP_LLD(drawpixel)(x, y, color)
+ #define gdispDrawLine(x0, y0, x1, y1, color) GDISP_LLD(drawline)(x0, y0, x1, y1, color)
+ #define gdispFillArea(x, y, cx, cy, color) GDISP_LLD(fillarea)(x, y, cx, cy, color)
+ #define gdispBlitArea(x, y, cx, cy, buffer) GDISP_LLD(blitarea)(x, y, cx, cy, buffer)
+ #define gdispDrawCircle(x, y, radius, color) GDISP_LLD(drawcircle)(x, y, radius, color)
+ #define gdispFillCircle(x, y, radius, color) GDISP_LLD(fillcircle)(x, y, radius, color)
+ #define gdispDrawEllipse(x, y, a, b, color) GDISP_LLD(drawellipse)(x, y, a, b, color)
+ #define gdispFillEllipse(x, y, a, b, color) GDISP_LLD(fillellipse)(x, y, a, b, color)
+ #define gdispDrawChar(x, y, c, font, color) GDISP_LLD(drawchar)(x, y, c, font, color)
+ #define gdispFillChar(x, y, c, font, color, bgcolor) GDISP_LLD(fillchar)(x, y, c, font, color, bgcolor)
+ #define gdispGetPixelColor(x, y) GDISP_LLD(getpixelcolor)(x, y)
+ #define gdispVerticalScroll(x, y, cx, cy, lines, bgcolor) GDISP_LLD(verticalscroll)(x, y, cx, cy, lines, bgcolor)
+ #define gdispControl(what, value) GDISP_LLD(control)(what, value)
+ #define gdispQuery(what) GDISP_LLD(query)(what)
+
+#endif
+
+void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
+
+/* Extra Text Functions */
+#if GDISP_NEED_TEXT
+ void gdispDrawString(coord_t x, coord_t y, const char *str, font_t font, color_t color);
+ void gdispFillString(coord_t x, coord_t y, const char *str, font_t font, color_t color, color_t bgcolor);
+ void gdispFillStringBox(coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, font_t font, color_t color, color_t bgColor, justify_t justify);
+ coord_t gdispGetFontMetric(font_t font, fontmetric_t metric);
+ coord_t gdispGetCharWidth(char c, font_t font);
+ coord_t gdispGetStringWidth(const char* str, font_t font);
+#endif
+
+/* Support routine for packed pixel formats */
+#ifndef gdispPackPixels
+ void gdispPackPixels(const pixel_t *buf, coord_t cx, coord_t x, coord_t y, color_t color);
+#endif
+
+/* Macro definitions for common gets and sets */
+#define gdispSetPowerMode(powerMode) gdispControl(GDISP_CONTROL_POWER, (void *)(unsigned)(powerMode))
+#define gdispSetOrientation(newOrientation) gdispControl(GDISP_CONTROL_ORITENTATION, (void *)(unsigned)(newOrientation))
+#define gdispSetBacklight(percent) gdispControl(GDISP_CONTROL_BACKLIGHT, (void *)(unsigned)(percent))
+#define gdispSetContrast(percent) gdispControl(GDISP_CONTROL_CONTRAST, (void *)(unsigned)(percent))
+
+#define gdispGetWidth() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_WIDTH))
+#define gdispGetHeight() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_HEIGHT))
+#define gdispGetPowerMode() ((gdisp_powermode_t)(unsigned)gdispQuery(GDISP_QUERY_POWER))
+#define gdispGetOrientation() ((gdisp_orientation_t)(unsigned)gdispQuery(GDISP_QUERY_ORIENTATION))
+#define gdispGetBacklight() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_BACKLIGHT))
+#define gdispGetContrast() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_CONTRAST))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_USE_GDISP */
+
+#endif /* _GDISP_H */
+/** @} */
diff --git a/include/gdisp_emulation.c b/include/gdisp_emulation.c
new file mode 100644
index 00000000..cb3773a7
--- /dev/null
+++ b/include/gdisp_emulation.c
@@ -0,0 +1,549 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ Emulation routines included into gdisp_lld.c
+*/
+
+/*
+ Even though this is a software emulation of a low level driver
+ most validation doesn't need to happen here as eventually
+ we call a real low level driver routine and if validation is
+ required - it will do it.
+*/
+#ifndef GDISP_EMULATION_C
+#define GDISP_EMULATION_C
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+#ifdef UNUSED
+#elif defined(__GNUC__)
+# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
+#elif defined(__LCLINT__)
+# define UNUSED(x) /*@unused@*/ x
+#else
+# define UNUSED(x) x
+#endif
+
+#ifndef GDISP_LLD_NO_STRUCT
+ static struct GDISPDriver {
+ coord_t Width;
+ coord_t Height;
+ gdisp_orientation_t Orientation;
+ gdisp_powermode_t Powermode;
+ coord_t Backlight;
+ coord_t Contrast;
+ } GDISP;
+#endif
+
+#if !GDISP_HARDWARE_CLEARS
+ void GDISP_LLD(clear)(color_t color) {
+ GDISP_LLD(fillarea)(0, 0, GDISP.Width, GDISP.Height, color);
+ }
+#endif
+
+#if !GDISP_HARDWARE_LINES
+ void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
+ int16_t dy, dx;
+ int16_t addx, addy;
+ int16_t P, diff, i;
+
+ #if GDISP_HARDWARE_FILLS || GDISP_HARDWARE_SCROLL
+ // speed improvement if vertical or horizontal
+ if (x0 == x1) {
+ if (y1 > y0)
+ GDISP_LLD(fillarea)(x0, y0, 1, y1-y0+1, color);
+ else
+ GDISP_LLD(fillarea)(x0, y1, 1, y0-y1+1, color);
+ return;
+ }
+ if (y0 == y1) {
+ if (x1 > x0)
+ GDISP_LLD(fillarea)(x0, y0, x1-x0+1, 1, color);
+ else
+ GDISP_LLD(fillarea)(x0, y1, x0-x1+1, 1, color);
+ return;
+ }
+ #endif
+
+ if (x1 >= x0) {
+ dx = x1 - x0;
+ addx = 1;
+ } else {
+ dx = x0 - x1;
+ addx = -1;
+ }
+ if (y1 >= y0) {
+ dy = y1 - y0;
+ addy = 1;
+ } else {
+ dy = y0 - y1;
+ addy = -1;
+ }
+
+ if (dx >= dy) {
+ dy *= 2;
+ P = dy - dx;
+ diff = P - dx;
+
+ for(i=0; i<=dx; ++i) {
+ GDISP_LLD(drawpixel)(x0, y0, color);
+ if (P < 0) {
+ P += dy;
+ x0 += addx;
+ } else {
+ P += diff;
+ x0 += addx;
+ y0 += addy;
+ }
+ }
+ } else {
+ dx *= 2;
+ P = dx - dy;
+ diff = P - dy;
+
+ for(i=0; i<=dy; ++i) {
+ GDISP_LLD(drawpixel)(x0, y0, color);
+ if (P < 0) {
+ P += dx;
+ y0 += addy;
+ } else {
+ P += diff;
+ x0 += addx;
+ y0 += addy;
+ }
+ }
+ }
+ }
+#endif
+
+#if !GDISP_HARDWARE_FILLS
+ void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
+ #if GDISP_HARDWARE_SCROLL
+ GDISP_LLD(verticalscroll)(x, y, cx, cy, cy, color);
+ #elif GDISP_HARDWARE_LINES
+ coord_t x1, y1;
+
+ x1 = x + cx - 1;
+ y1 = y + cy;
+ for(; y < y1; y++)
+ GDISP_LLD(drawline)(x, y, x1, y, color);
+ #else
+ coord_t x0, x1, y1;
+
+ x0 = x;
+ x1 = x + cx;
+ y1 = y + cy;
+ for(; y < y1; y++)
+ for(x = x0; x < x1; x++)
+ GDISP_LLD(drawpixel)(x, y, color);
+ #endif
+ }
+#endif
+
+#if !GDISP_HARDWARE_BITFILLS
+ void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) {
+ coord_t x0, x1, y1;
+
+ x0 = x;
+ x1 = x + cx;
+ y1 = y + cy;
+ for(; y < y1; y++)
+ for(x = x0; x < x1; x++)
+ GDISP_LLD(drawpixel)(x, y, *buffer++);
+ }
+#endif
+
+#if GDISP_NEED_CIRCLE && !GDISP_HARDWARE_CIRCLES
+ void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
+ int16_t a, b, P;
+
+ a = 0;
+ b = radius;
+ P = 1 - radius;
+
+ do {
+ GDISP_LLD(drawpixel)(a+x, b+y, color);
+ GDISP_LLD(drawpixel)(b+x, a+y, color);
+ GDISP_LLD(drawpixel)(x-a, b+y, color);
+ GDISP_LLD(drawpixel)(x-b, a+y, color);
+ GDISP_LLD(drawpixel)(b+x, y-a, color);
+ GDISP_LLD(drawpixel)(a+x, y-b, color);
+ GDISP_LLD(drawpixel)(x-a, y-b, color);
+ GDISP_LLD(drawpixel)(x-b, y-a, color);
+ if (P < 0)
+ P += 3 + 2*a++;
+ else
+ P += 5 + 2*(a++ - b--);
+ } while(a <= b);
+ }
+#endif
+
+#if GDISP_NEED_CIRCLE && !GDISP_HARDWARE_CIRCLEFILLS
+ void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
+ int16_t a, b, P;
+
+ a = 0;
+ b = radius;
+ P = 1 - radius;
+
+ do {
+ GDISP_LLD(drawline)(x-a, y+b, x+a, y+b, color);
+ GDISP_LLD(drawline)(x-a, y-b, x+a, y-b, color);
+ GDISP_LLD(drawline)(x-b, y+a, x+b, y+a, color);
+ GDISP_LLD(drawline)(x-b, y-a, x+b, y-a, color);
+ if (P < 0)
+ P += 3 + 2*a++;
+ else
+ P += 5 + 2*(a++ - b--);
+ } while(a <= b);
+ }
+#endif
+
+#if GDISP_NEED_ELLIPSE && !GDISP_HARDWARE_ELLIPSES
+ void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ int dx = 0, dy = b; /* im I. Quadranten von links oben nach rechts unten */
+ long a2 = a*a, b2 = b*b;
+ long err = b2-(2*b-1)*a2, e2; /* Fehler im 1. Schritt */
+
+ do {
+ GDISP_LLD(drawpixel)(x+dx, y+dy, color); /* I. Quadrant */
+ GDISP_LLD(drawpixel)(x-dx, y+dy, color); /* II. Quadrant */
+ GDISP_LLD(drawpixel)(x-dx, y-dy, color); /* III. Quadrant */
+ GDISP_LLD(drawpixel)(x+dx, y-dy, color); /* IV. Quadrant */
+
+ e2 = 2*err;
+ if(e2 < (2*dx+1)*b2) {
+ dx++;
+ err += (2*dx+1)*b2;
+ }
+ if(e2 > -(2*dy-1)*a2) {
+ dy--;
+ err -= (2*dy-1)*a2;
+ }
+ } while(dy >= 0);
+
+ while(dx++ < a) { /* fehlerhafter Abbruch bei flachen Ellipsen (b=1) */
+ GDISP_LLD(drawpixel)(x+dx, y, color); /* -> Spitze der Ellipse vollenden */
+ GDISP_LLD(drawpixel)(x-dx, y, color);
+ }
+ }
+#endif
+
+#if GDISP_NEED_ELLIPSE && !GDISP_HARDWARE_ELLIPSEFILLS
+ void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ int dx = 0, dy = b; /* im I. Quadranten von links oben nach rechts unten */
+ long a2 = a*a, b2 = b*b;
+ long err = b2-(2*b-1)*a2, e2; /* Fehler im 1. Schritt */
+
+ do {
+ GDISP_LLD(drawline)(x-dx,y+dy,x+dx,y+dy, color);
+ GDISP_LLD(drawline)(x-dx,y-dy,x+dx,y-dy, color);
+
+ e2 = 2*err;
+ if(e2 < (2*dx+1)*b2) {
+ dx++;
+ err += (2*dx+1)*b2;
+ }
+ if(e2 > -(2*dy-1)*a2) {
+ dy--;
+ err -= (2*dy-1)*a2;
+ }
+ } while(dy >= 0);
+
+ while(dx++ < a) { /* fehlerhafter Abbruch bei flachen Ellipsen (b=1) */
+ GDISP_LLD(drawpixel)(x+dx, y, color); /* -> Spitze der Ellipse vollenden */
+ GDISP_LLD(drawpixel)(x-dx, y, color);
+ }
+ }
+#endif
+
+#if GDISP_NEED_TEXT && !GDISP_HARDWARE_TEXT
+ #include "gdisp_fonts.h"
+#endif
+
+#if GDISP_NEED_TEXT && !GDISP_HARDWARE_TEXT
+ void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) {
+ const fontcolumn_t *ptr;
+ fontcolumn_t column;
+ coord_t width, height, xscale, yscale;
+ coord_t i, j, xs, ys;
+
+ /* Check we actually have something to print */
+ width = _getCharWidth(font, c);
+ if (!width) return;
+
+ xscale = font->xscale;
+ yscale = font->yscale;
+ height = font->height * yscale;
+ width *= xscale;
+
+ ptr = _getCharData(font, c);
+
+ /* Loop through the data and display. The font data is LSBit first, down the column */
+ for(i=0; i < width; i+=xscale) {
+ /* Get the font bitmap data for the column */
+ column = *ptr++;
+
+ /* Draw each pixel */
+ for(j=0; j < height; j+=yscale, column >>= 1) {
+ if (column & 0x01) {
+ for(xs=0; xs < xscale; xs++)
+ for(ys=0; ys < yscale; ys++)
+ GDISP_LLD(drawpixel)(x+i+xs, y+j+ys, color);
+ }
+ }
+ }
+ }
+#endif
+
+#if GDISP_NEED_TEXT && !GDISP_HARDWARE_TEXTFILLS
+ void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
+ coord_t width, height;
+ coord_t xscale, yscale;
+
+ /* Check we actually have something to print */
+ width = _getCharWidth(font, c);
+ if (!width) return;
+
+ xscale = font->xscale;
+ yscale = font->yscale;
+ height = font->height * yscale;
+ width *= xscale;
+
+ /* Method 1: Use background fill and then draw the text */
+ #if GDISP_HARDWARE_TEXT || GDISP_SOFTWARE_TEXTFILLDRAW
+
+ /* Fill the area */
+ GDISP_LLD(fillarea)(x, y, width, height, bgcolor);
+
+ /* Draw the text */
+ GDISP_LLD(drawchar)(x, y, c, font, color);
+
+ /* Method 2: Create a single column bitmap and then blit it */
+ #elif GDISP_HARDWARE_BITFILLS && GDISP_SOFTWARE_TEXTBLITCOLUMN
+ {
+ const fontcolumn_t *ptr;
+ fontcolumn_t column;
+ coord_t i, j, xs, ys;
+
+ /* Working buffer for fast non-transparent text rendering [patch by Badger]
+ This needs to be larger than the largest character we can print.
+ Assume the max is double sized by one column.
+ */
+ static pixel_t buf[sizeof(fontcolumn_t)*8*2];
+
+ #if GDISP_NEED_VALIDATION
+ /* Check our buffer is big enough */
+ if (height > sizeof(buf)/sizeof(buf[0])) return;
+ #endif
+
+ ptr = _getCharData(font, c);
+
+ /* Loop through the data and display. The font data is LSBit first, down the column */
+ for(i = 0; i < width; i+=xscale) {
+ /* Get the font bitmap data for the column */
+ column = *ptr++;
+
+ /* Draw each pixel */
+ for(j = 0; j < height; j+=yscale, column >>= 1) {
+ if (column & 0x01) {
+ for(ys=0; ys < yscale; ys++)
+ gdispPackPixels(buf, 1, j+ys, 0, color);
+ } else {
+ for(ys=0; ys < yscale; ys++)
+ gdispPackPixels(buf, 1, j+ys, 0, bgcolor);
+ }
+ }
+
+ for(xs=0; xs < xscale; xs++)
+ GDISP_LLD(blitarea)(x+i+xs, y, 1, height, buf);
+ }
+ }
+
+ /* Method 3: Create a character bitmap and then blit it */
+ #elif GDISP_HARDWARE_BITFILLS
+ {
+ const fontcolumn_t *ptr;
+ fontcolumn_t column;
+ coord_t i, j, xs, ys;
+
+ /* Working buffer for fast non-transparent text rendering [patch by Badger]
+ This needs to be larger than the largest character we can print.
+ Assume the max is double sized.
+ */
+ static pixel_t buf[20*(sizeof(fontcolumn_t)*8)*2];
+
+ #if GDISP_NEED_VALIDATION
+ /* Check our buffer is big enough */
+ if ((unsigned)(width * height) > sizeof(buf)/sizeof(buf[0])) return;
+ #endif
+
+ ptr = _getCharData(font, c);
+
+ /* Loop through the data and display. The font data is LSBit first, down the column */
+ for(i = 0; i < width; i+=xscale) {
+ /* Get the font bitmap data for the column */
+ column = *ptr++;
+
+ /* Draw each pixel */
+ for(j = 0; j < height; j+=yscale, column >>= 1) {
+ if (column & 0x01) {
+ for(xs=0; xs < xscale; xs++)
+ for(ys=0; ys < yscale; ys++)
+ gdispPackPixels(buf, width, i+xs, j+ys, color);
+ } else {
+ for(xs=0; xs < xscale; xs++)
+ for(ys=0; ys < yscale; ys++)
+ gdispPackPixels(buf, width, i+xs, j+ys, bgcolor);
+ }
+ }
+ }
+
+ /* [Patch by Badger] Write all in one stroke */
+ GDISP_LLD(blitarea)(x, y, width, height, buf);
+ }
+
+ /* Method 4: Draw pixel by pixel */
+ #else
+ {
+ const fontcolumn_t *ptr;
+ fontcolumn_t column;
+ coord_t i, j, xs, ys;
+
+ ptr = _getCharData(font, c);
+
+ /* Loop through the data and display. The font data is LSBit first, down the column */
+ for(i = 0; i < width; i+=xscale) {
+ /* Get the font bitmap data for the column */
+ column = *ptr++;
+
+ /* Draw each pixel */
+ for(j = 0; j < height; j+=yscale, column >>= 1) {
+ if (column & 0x01) {
+ for(xs=0; xs < xscale; xs++)
+ for(ys=0; ys < yscale; ys++)
+ GDISP_LLD(drawpixel)(x+i, y+j, color);
+ } else {
+ for(xs=0; xs < xscale; xs++)
+ for(ys=0; ys < yscale; ys++)
+ GDISP_LLD(drawpixel)(x+i, y+j, bgcolor);
+ }
+ }
+ }
+ }
+ #endif
+ }
+#endif
+
+
+#if GDISP_NEED_CONTROL && !GDISP_HARDWARE_CONTROL
+ void GDISP_LLD(control)(unsigned UNUSED(what), void *UNUSED(value)) {
+ /* Ignore everything */
+ }
+#endif
+
+#if GDISP_NEED_QUERY && !GDISP_HARDWARE_QUERY
+void *GDISP_LLD(query)(unsigned what) {
+ switch(what) {
+ case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width;
+ case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height;
+ case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode;
+ case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation;
+ case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight;
+ case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast;
+ default: return (void *)-1;
+ }
+}
+#endif
+
+#if GDISP_NEED_MSGAPI
+ void GDISP_LLD(msgdispatch)(gdisp_lld_msg_t *msg) {
+ switch(msg->action) {
+ case GDISP_LLD_MSG_NOP:
+ break;
+ case GDISP_LLD_MSG_INIT:
+ GDISP_LLD(init)();
+ break;
+ case GDISP_LLD_MSG_CLEAR:
+ GDISP_LLD(clear)(msg->clear.color);
+ break;
+ case GDISP_LLD_MSG_DRAWPIXEL:
+ GDISP_LLD(drawpixel)(msg->drawpixel.x, msg->drawpixel.y, msg->drawpixel.color);
+ break;
+ case GDISP_LLD_MSG_FILLAREA:
+ GDISP_LLD(fillarea)(msg->fillarea.x, msg->fillarea.y, msg->fillarea.cx, msg->fillarea.cy, msg->fillarea.color);
+ break;
+ case GDISP_LLD_MSG_BLITAREA:
+ GDISP_LLD(blitarea)(msg->blitarea.x, msg->blitarea.y, msg->blitarea.cx, msg->blitarea.cy, msg->blitarea.buffer);
+ break;
+ case GDISP_LLD_MSG_DRAWLINE:
+ GDISP_LLD(drawline)(msg->drawline.x0, msg->drawline.y0, msg->drawline.x1, msg->drawline.y1, msg->drawline.color);
+ break;
+ #if GDISP_NEED_CIRCLE
+ case GDISP_LLD_MSG_DRAWCIRCLE:
+ GDISP_LLD(drawcircle)(msg->drawcircle.x, msg->drawcircle.y, msg->drawcircle.radius, msg->drawcircle.color);
+ break;
+ case GDISP_LLD_MSG_FILLCIRCLE:
+ GDISP_LLD(fillcircle)(msg->fillcircle.x, msg->fillcircle.y, msg->fillcircle.radius, msg->fillcircle.color);
+ break;
+ #endif
+ #if GDISP_NEED_ELLIPSE
+ case GDISP_LLD_MSG_DRAWELLIPSE:
+ GDISP_LLD(drawellipse)(msg->drawellipse.x, msg->drawellipse.y, msg->drawellipse.a, msg->drawellipse.b, msg->drawellipse.color);
+ break;
+ case GDISP_LLD_MSG_FILLELLIPSE:
+ GDISP_LLD(fillellipse)(msg->fillellipse.x, msg->fillellipse.y, msg->fillellipse.a, msg->fillellipse.b, msg->fillellipse.color);
+ break;
+ #endif
+ #if GDISP_NEED_TEXT
+ case GDISP_LLD_MSG_DRAWCHAR:
+ GDISP_LLD(drawchar)(msg->drawchar.x, msg->drawchar.y, msg->drawchar.c, msg->drawchar.font, msg->drawchar.color);
+ break;
+ case GDISP_LLD_MSG_FILLCHAR:
+ GDISP_LLD(fillchar)(msg->fillchar.x, msg->fillchar.y, msg->fillchar.c, msg->fillchar.font, msg->fillchar.color, msg->fillchar.bgcolor);
+ break;
+ #endif
+ #if GDISP_NEED_PIXELREAD
+ case GDISP_LLD_MSG_GETPIXELCOLOR:
+ msg->getpixelcolor.result = GDISP_LLD(getpixelcolor)(msg->getpixelcolor.x, msg->getpixelcolor.y);
+ break;
+ #endif
+ #if GDISP_NEED_SCROLL
+ case GDISP_LLD_MSG_VERTICALSCROLL:
+ GDISP_LLD(verticalscroll)(msg->verticalscroll.x, msg->verticalscroll.y, msg->verticalscroll.cx, msg->verticalscroll.cy, msg->verticalscroll.lines, msg->verticalscroll.bgcolor);
+ break;
+ #endif
+ #if GDISP_NEED_CONTROL
+ case GDISP_LLD_MSG_CONTROL:
+ GDISP_LLD(control)(msg->control.what, msg->control.value);
+ break;
+ #endif
+ #if GDISP_NEED_QUERY
+ case GDISP_LLD_MSG_QUERY:
+ msg->query.result = GDISP_LLD(query)(msg->query.what);
+ break;
+ #endif
+ }
+ }
+#endif
+
+#endif /* HAL_USE_GDISP */
+#endif /* GDISP_EMULATION_C */
diff --git a/include/gdisp_fonts.h b/include/gdisp_fonts.h
new file mode 100644
index 00000000..a1a4c3cb
--- /dev/null
+++ b/include/gdisp_fonts.h
@@ -0,0 +1,90 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @file gdisp_fonts.h
+ * @brief GDISP internal font definitions.
+ * @details This is not generally needed by an application. It is used
+ * by the low level drivers that need to understand a font.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_FONTS_H
+#define _GDISP_FONTS_H
+
+/* Don't test against HAL_USE_GDISP as we may want to use this in other non-GDISP utilities. */
+
+/**
+ * @brief The maximum height of a font.
+ * @details Either 16 or 32. Defaults to 16
+ * @note Setting this to 32 causes the font tables to take
+ * twice the internal program memory.
+ */
+#ifndef GDISP_MAX_FONT_HEIGHT
+ #define GDISP_MAX_FONT_HEIGHT 16
+#endif
+
+/**
+ * @brief The type of a font column.
+ * @note Set by defining @p GDISP_MAX_FNT_HEIGHT appropriately.
+ */
+#if GDISP_MAX_FONT_HEIGHT == 16
+ typedef uint16_t fontcolumn_t;
+#elif GDISP_MAX_FONT_HEIGHT == 32
+ typedef uint32_t fontcolumn_t;
+#else
+ #error "GDISP: GDISP_MAX_FONT_HEIGHT must be either 16 or 32"
+#endif
+
+/**
+ * @brief Internal font structure.
+ * @note This structure is followed by:
+ * 1. An array of character widths (uint8_t)
+ * 2. An array of column data offsets (relative to the font structure)
+ * 3. Each characters array of column data (fontcolumn_t)
+ * Each sub-structure must be padded to a multiple of 8 bytes
+ * to allow the tables to work across many different compilers.
+ */
+struct font {
+ uint8_t height;
+ uint8_t charPadding;
+ uint8_t lineSpacing;
+ uint8_t descenderHeight;
+ uint8_t minWidth;
+ uint8_t maxWidth;
+ char minChar;
+ char maxChar;
+ uint8_t xscale;
+ uint8_t yscale;
+ const uint8_t *widthTable;
+ const uint16_t *offsetTable;
+ const fontcolumn_t *dataTable;
+ };
+
+/**
+ * @brief Macros to get to the complex parts of the font structure.
+ */
+#define _getCharWidth(f,c) (((c) < (f)->minChar || (c) > (f)->maxChar) ? 0 : (f)->widthTable[(c) - (f)->minChar])
+#define _getCharOffset(f,c) ((f)->offsetTable[(c) - (f)->minChar])
+#define _getCharData(f,c) (&(f)->dataTable[_getCharOffset(f, c)])
+
+#endif /* _GDISP_FONTS_H */
+/** @} */
diff --git a/include/gdisp_lld.h b/include/gdisp_lld.h
new file mode 100644
index 00000000..99865a9f
--- /dev/null
+++ b/include/gdisp_lld.h
@@ -0,0 +1,599 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @file gdisp_lld.h
+ * @brief GDISP Graphic Driver subsystem low level driver header.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_LLD_H
+#define _GDISP_LLD_H
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Low level driver configuration needs */
+/*===========================================================================*/
+
+/**
+ * @name GDISP low level driver more complex functionality to be compiled
+ * @{
+ */
+ /**
+ * @brief Should all operations be clipped to the screen and colors validated.
+ * @details Defaults to TRUE.
+ * @note If this is FALSE, any operations that extend beyond the
+ * edge of the screen will have undefined results. Any
+ * out-of-range colors will produce undefined results.
+ * @note If defined then all low level and high level driver routines
+ * must check the validity of inputs and do something sensible
+ * if they are out of range. It doesn't have to be efficient,
+ * just valid.
+ */
+ #ifndef GDISP_NEED_VALIDATION
+ #define GDISP_NEED_VALIDATION TRUE
+ #endif
+
+ /**
+ * @brief Are circle functions needed.
+ * @details Defaults to TRUE
+ */
+ #ifndef GDISP_NEED_CIRCLE
+ #define GDISP_NEED_CIRCLE TRUE
+ #endif
+
+ /**
+ * @brief Are ellipse functions needed.
+ * @details Defaults to TRUE
+ */
+ #ifndef GDISP_NEED_ELLIPSE
+ #define GDISP_NEED_ELLIPSE TRUE
+ #endif
+
+ /**
+ * @brief Are text functions needed.
+ * @details Defaults to TRUE
+ */
+ #ifndef GDISP_NEED_TEXT
+ #define GDISP_NEED_TEXT TRUE
+ #endif
+
+ /**
+ * @brief Is scrolling needed.
+ * @details Defaults to FALSE
+ */
+ #ifndef GDISP_NEED_SCROLL
+ #define GDISP_NEED_SCROLL FALSE
+ #endif
+
+ /**
+ * @brief Is the capability to read pixels back needed.
+ * @details Defaults to FALSE
+ */
+ #ifndef GDISP_NEED_PIXELREAD
+ #define GDISP_NEED_PIXELREAD FALSE
+ #endif
+
+ /**
+ * @brief Control some aspect of the drivers operation.
+ * @details Defaults to FALSE
+ */
+ #ifndef GDISP_NEED_CONTROL
+ #define GDISP_NEED_CONTROL FALSE
+ #endif
+
+ /**
+ * @brief Query some aspect of the drivers operation.
+ * @details Defaults to TRUE
+ */
+ #ifndef GDISP_NEED_QUERY
+ #define GDISP_NEED_QUERY TRUE
+ #endif
+
+ /**
+ * @brief Is the messaging api interface required.
+ * @details Defaults to FALSE
+ */
+ #ifndef GDISP_NEED_MSGAPI
+ #define GDISP_NEED_MSGAPI FALSE
+ #endif
+/** @} */
+
+/*===========================================================================*/
+/* Include the low level driver configuration information */
+/*===========================================================================*/
+
+#include "gdisp_lld_config.h"
+
+/*===========================================================================*/
+/* Constants. */
+/*===========================================================================*/
+
+/**
+ * @brief Driver Control Constants
+ * @detail Unsupported control codes are ignored.
+ * @note The value parameter should always be typecast to (void *).
+ * @note There are some predefined and some specific to the low level driver.
+ * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t
+ * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t
+ * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver
+ * that only supports off/on anything other
+ * than zero is on.
+ * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100.
+ * GDISP_CONTROL_LLD - Low level driver control constants start at
+ * this value.
+ */
+#define GDISP_CONTROL_POWER 0
+#define GDISP_CONTROL_ORIENTATION 1
+#define GDISP_CONTROL_BACKLIGHT 2
+#define GDISP_CONTROL_CONTRAST 3
+#define GDISP_CONTROL_LLD 1000
+
+/**
+ * @brief Driver Query Constants
+ * @detail Unsupported query codes return (void *)-1.
+ * @note There are some predefined and some specific to the low level driver.
+ * @note The result should be typecast the required type.
+ * @note GDISP_QUERY_WIDTH - Gets the width of the screen
+ * GDISP_QUERY_HEIGHT - Gets the height of the screen
+ * GDISP_QUERY_POWER - Get the current powermode
+ * GDISP_QUERY_ORIENTATION - Get the current orientation
+ * GDISP_QUERY_BACKLIGHT - Get the backlight state (0 to 100)
+ * GDISP_QUERY_CONTRAST - Get the contrast.
+ * GDISP_QUERY_LLD - Low level driver control constants start at
+ * this value.
+ */
+#define GDISP_QUERY_WIDTH 0
+#define GDISP_QUERY_HEIGHT 1
+#define GDISP_QUERY_POWER 2
+#define GDISP_QUERY_ORIENTATION 3
+#define GDISP_QUERY_BACKLIGHT 4
+#define GDISP_QUERY_CONTRAST 5
+#define GDISP_QUERY_LLD 1000
+
+/**
+ * @brief Driver Pixel Format Constants
+ */
+#define GDISP_PIXELFORMAT_RGB565 565
+#define GDISP_PIXELFORMAT_RGB888 888
+#define GDISP_PIXELFORMAT_RGB444 444
+#define GDISP_PIXELFORMAT_RGB332 332
+#define GDISP_PIXELFORMAT_RGB666 666
+#define GDISP_PIXELFORMAT_CUSTOM 99999
+#define GDISP_PIXELFORMAT_ERROR 88888
+
+/*===========================================================================*/
+/* Error checks. */
+/*===========================================================================*/
+
+/**
+ * @name GDISP hardware accelerated support
+ * @{
+ */
+ /**
+ * @brief Hardware accelerated line drawing.
+ * @details If set to @p FALSE software emulation is used.
+ */
+ #ifndef GDISP_HARDWARE_LINES
+ #define GDISP_HARDWARE_LINES FALSE
+ #endif
+
+ /**
+ * @brief Hardware accelerated screen clears.
+ * @details If set to @p FALSE software emulation is used.
+ */
+ #ifndef GDISP_HARDWARE_CLEARS
+ #define GDISP_HARDWARE_CLEARS FALSE
+ #endif
+
+ /**
+ * @brief Hardware accelerated rectangular fills.
+ * @details If set to @p FALSE software emulation is used.
+ */
+ #ifndef GDISP_HARDWARE_FILLS
+ #define GDISP_HARDWARE_FILLS FALSE
+ #endif
+
+ /**
+ * @brief Hardware accelerated fills from an image.
+ * @details If set to @p FALSE software emulation is used.
+ */
+ #ifndef GDISP_HARDWARE_BITFILLS
+ #define GDISP_HARDWARE_BITFILLS FALSE
+ #endif
+
+ /**
+ * @brief Hardware accelerated circles.
+ * @details If set to @p FALSE software emulation is used.
+ */
+ #ifndef GDISP_HARDWARE_CIRCLES
+ #define GDISP_HARDWARE_CIRCLES FALSE
+ #endif
+
+ /**
+ * @brief Hardware accelerated filled circles.
+ * @details If set to @p FALSE software emulation is used.
+ */
+ #ifndef GDISP_HARDWARE_CIRCLEFILLS
+ #define GDISP_HARDWARE_CIRCLEFILLS FALSE
+ #endif
+
+ /**
+ * @brief Hardware accelerated ellipses.
+ * @details If set to @p FALSE software emulation is used.
+ */
+ #ifndef GDISP_HARDWARE_ELLIPSES
+ #define GDISP_HARDWARE_ELLIPSES FALSE
+ #endif
+
+ /**
+ * @brief Hardware accelerated filled ellipses.
+ * @details If set to @p FALSE software emulation is used.
+ */
+ #ifndef GDISP_HARDWARE_ELLIPSEFILLS
+ #define GDISP_HARDWARE_ELLIPSEFILLS FALSE
+ #endif
+
+ /**
+ * @brief Hardware accelerated text drawing.
+ * @details If set to @p FALSE software emulation is used.
+ */
+ #ifndef GDISP_HARDWARE_TEXT
+ #define GDISP_HARDWARE_TEXT FALSE
+ #endif
+
+ /**
+ * @brief Hardware accelerated text drawing with a filled background.
+ * @details If set to @p FALSE software emulation is used.
+ */
+ #ifndef GDISP_HARDWARE_TEXTFILLS
+ #define GDISP_HARDWARE_TEXTFILLS FALSE
+ #endif
+
+ /**
+ * @brief Hardware accelerated scrolling.
+ * @details If set to @p FALSE there is no support for scrolling.
+ */
+ #ifndef GDISP_HARDWARE_SCROLL
+ #define GDISP_HARDWARE_SCROLL FALSE
+ #endif
+
+ /**
+ * @brief Reading back of pixel values.
+ * @details If set to @p FALSE there is no support for pixel read-back.
+ */
+ #ifndef GDISP_HARDWARE_PIXELREAD
+ #define GDISP_HARDWARE_PIXELREAD FALSE
+ #endif
+
+ /**
+ * @brief The driver supports one or more control commands.
+ * @details If set to @p FALSE there is no support for control commands.
+ */
+ #ifndef GDISP_HARDWARE_CONTROL
+ #define GDISP_HARDWARE_CONTROL FALSE
+ #endif
+
+ /**
+ * @brief The driver supports a non-standard query.
+ * @details If set to @p FALSE there is no support for non-standard queries.
+ */
+ #ifndef GDISP_HARDWARE_QUERY
+ #define GDISP_HARDWARE_QUERY FALSE
+ #endif
+/** @} */
+
+/**
+ * @name GDISP software algorithm choices
+ * @{
+ */
+ /**
+ * @brief For filled text drawing, use a background fill and then draw
+ * the text instead of using a blit or direct pixel drawing.
+ * @details If set to @p TRUE background fill and then text draw is used.
+ * @note This is ignored if hardware accelerated text is supported.
+ */
+ #ifndef GDISP_SOFTWARE_TEXTFILLDRAW
+ #define GDISP_SOFTWARE_TEXTFILLDRAW FALSE
+ #endif
+
+ /**
+ * @brief For filled text drawing, when using a bitmap blit
+ * use a column by column buffer rather than a full character
+ * buffer to save memory at a small performance cost.
+ * @details If set to @p TRUE background fill one character column at a time.
+ * @note This is ignored if software text using blit is not being used.
+ */
+ #ifndef GDISP_SOFTWARE_TEXTBLITCOLUMN
+ #define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE
+ #endif
+/** @} */
+
+/**
+ * @name GDISP pixel format choices
+ * @{
+ */
+ /**
+ * @brief The native pixel format for this device
+ * @note Should be set to one of the following:
+ * GDISP_PIXELFORMAT_RGB565
+ * GDISP_PIXELFORMAT_RGB888
+ * GDISP_PIXELFORMAT_RGB444
+ * GDISP_PIXELFORMAT_RGB332
+ * GDISP_PIXELFORMAT_RGB666
+ * GDISP_PIXELFORMAT_CUSTOM
+ * @note If you set GDISP_PIXELFORMAT_CUSTOM you need to also define
+ * color_t, RGB2COLOR(r,g,b), HTML2COLOR(h),
+ * RED_OF(c), GREEN_OF(c), BLUE_OF(c),
+ * COLOR(c) and MASKCOLOR.
+ */
+ #ifndef GDISP_PIXELFORMAT
+ #define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_ERROR
+ #endif
+
+ /**
+ * @brief Do pixels require packing for a blit
+ * @note Is only valid for a pixel format that doesn't fill it's datatype. ie formats:
+ * GDISP_PIXELFORMAT_RGB888
+ * GDISP_PIXELFORMAT_RGB444
+ * GDISP_PIXELFORMAT_RGB666
+ * GDISP_PIXELFORMAT_CUSTOM
+ * @note If you use GDISP_PIXELFORMAT_CUSTOM and packed bit fills
+ * you need to also define @P gdispPackPixels(buf,cx,x,y,c)
+ * @note If you are using GDISP_HARDWARE_BITFILLS = FALSE then the pixel
+ * format must not be a packed format as the software blit does
+ * not support packed pixels
+ * @note Very few cases should actually require packed pixels as the low
+ * level driver can also pack on the fly as it is sending it
+ * to the graphics device.
+ */
+ #ifndef GDISP_PACKED_PIXELS
+ #define GDISP_PACKED_PIXELS FALSE
+ #endif
+
+ /**
+ * @brief Do lines of pixels require packing for a blit
+ * @note Ignored if GDISP_PACKED_PIXELS is FALSE
+ */
+ #ifndef GDISP_PACKED_LINES
+ #define GDISP_PACKED_LINES FALSE
+ #endif
+/** @} */
+
+/*===========================================================================*/
+/* Define the macro's for the various pixel formats */
+/*===========================================================================*/
+
+#if defined(__DOXYGEN__)
+ /**
+ * @brief The color of a pixel.
+ */
+ typedef uint16_t color_t;
+ /**
+ * @brief Convert a number (of any type) to a color_t.
+ * @details Masks any invalid bits in the color
+ */
+ #define COLOR(c) ((color_t)(c))
+ /**
+ * @brief Does the color_t type contain invalid bits that need masking.
+ */
+ #define MASKCOLOR FALSE
+ /**
+ * @brief Convert red, green, blue (each 0 to 255) into a color value.
+ */
+ #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xF8)<<8) | (((g) & 0xFC)<<3) | (((b) & 0xF8)>>3)))
+ /**
+ * @brief Convert a 6 digit HTML code (hex) into a color value.
+ */
+ #define HTML2COLOR(h) ((color_t)((((h) & 0xF80000)>>8) | (((h) & 0x00FC00)>>5) | (((h) & 0x0000F8)>>3)))
+ /**
+ * @brief Extract the red component (0 to 255) of a color value.
+ */
+ #define RED_OF(c) (((c) & 0xF800)>>8)
+ /**
+ * @brief Extract the green component (0 to 255) of a color value.
+ */
+ #define GREEN_OF(c) (((c)&0x007E)>>3)
+ /**
+ * @brief Extract the blue component (0 to 255) of a color value.
+ */
+ #define BLUE_OF(c) (((c)&0x001F)<<3)
+
+#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB565
+ typedef uint16_t color_t;
+ #define COLOR(c) ((color_t)(c))
+ #define MASKCOLOR FALSE
+ #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xF8)<<8) | (((g) & 0xFC)<<3) | (((b) & 0xF8)>>3)))
+ #define HTML2COLOR(h) ((color_t)((((h) & 0xF80000)>>8) | (((h) & 0x00FC00)>>5) | (((h) & 0x0000F8)>>3)))
+ #define RED_OF(c) (((c) & 0xF800)>>8)
+ #define GREEN_OF(c) (((c)&0x007E)>>3)
+ #define BLUE_OF(c) (((c)&0x001F)<<3)
+ #define RGB565CONVERT(red, green, blue) (uint16_t)( (( red >> 3 ) << 11 ) | (( green >> 2 ) << 5 ) | ( blue >> 3 ))
+
+
+#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB888
+ typedef uint32_t color_t;
+ #define COLOR(c) ((color_t)(((c) & 0xFFFFFF)))
+ #define MASKCOLOR TRUE
+ #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xFF)<<16) | (((g) & 0xFF) << 8) | ((b) & 0xFF)))
+ #define HTML2COLOR(h) ((color_t)(h))
+ #define RED_OF(c) (((c) & 0xFF0000)>>16)
+ #define GREEN_OF(c) (((c)&0x00FF00)>>8)
+ #define BLUE_OF(c) ((c)&0x0000FF)
+
+#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB444
+ typedef uint16_t color_t;
+ #define COLOR(c) ((color_t)(((c) & 0x0FFF)))
+ #define MASKCOLOR TRUE
+ #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xF0)<<4) | ((g) & 0xF0) | (((b) & 0xF0)>>4)))
+ #define HTML2COLOR(h) ((color_t)((((h) & 0xF00000)>>12) | (((h) & 0x00F000)>>8) | (((h) & 0x0000F0)>>4)))
+ #define RED_OF(c) (((c) & 0x0F00)>>4)
+ #define GREEN_OF(c) ((c)&0x00F0)
+ #define BLUE_OF(c) (((c)&0x000F)<<4)
+
+#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB332
+ typedef uint8_t color_t;
+ #define COLOR(c) ((color_t)(c))
+ #define MASKCOLOR FALSE
+ #define RGB2COLOR(r,g,b) ((color_t)(((r) & 0xE0) | (((g) & 0xE0)>>3) | (((b) & 0xC0)>>6)))
+ #define HTML2COLOR(h) ((color_t)((((h) & 0xE00000)>>16) | (((h) & 0x00E000)>>11) | (((h) & 0x0000C0)>>6)))
+ #define RED_OF(c) ((c) & 0xE0)
+ #define GREEN_OF(c) (((c)&0x1C)<<3)
+ #define BLUE_OF(c) (((c)&0x03)<<6)
+
+#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB666
+ typedef uint32_t color_t;
+ #define COLOR(c) ((color_t)(((c) & 0x03FFFF)))
+ #define MASKCOLOR TRUE
+ #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xFC)<<10) | (((g) & 0xFC)<<4) | (((b) & 0xFC)>>2)))
+ #define HTML2COLOR(h) ((color_t)((((h) & 0xFC0000)>>6) | (((h) & 0x00FC00)>>4) | (((h) & 0x0000FC)>>2)))
+ #define RED_OF(c) (((c) & 0x03F000)>>12)
+ #define GREEN_OF(c) (((c)&0x00FC00)>>8)
+ #define BLUE_OF(c) (((c)&0x00003F)<<2)
+
+#elif GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_CUSTOM
+ #error "GDISP: No supported pixel format has been specified."
+#endif
+
+/* Verify information for packed pixels and define a non-packed pixel macro */
+#if !GDISP_PACKED_PIXELS
+ #define gdispPackPixels(buf,cx,x,y,c) { ((color_t *)(buf))[(y)*(cx)+(x)] = (c); }
+#elif !GDISP_HARDWARE_BITFILLS
+ #error "GDISP: packed pixel formats are only supported for hardware accelerated drivers."
+#elif GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB888 \
+ && GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB444 \
+ && GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB666 \
+ && GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_CUSTOM
+ #error "GDISP: A packed pixel format has been specified for an unsupported pixel format."
+#endif
+
+#if GDISP_NEED_SCROLL && !GDISP_HARDWARE_SCROLL
+ #error "GDISP: Hardware scrolling is wanted but not supported."
+#endif
+
+#if GDISP_NEED_PIXELREAD && !GDISP_HARDWARE_PIXELREAD
+ #error "GDISP: Pixel read-back is wanted but not supported."
+#endif
+
+/*===========================================================================*/
+/* Driver types. */
+/*===========================================================================*/
+
+/**
+ * @brief The type for a coordinate or length on the screen.
+ */
+typedef uint16_t coord_t;
+/**
+ * @brief The type of a pixel.
+ */
+typedef color_t pixel_t;
+/**
+ * @brief The type of a font.
+ */
+typedef const struct font *font_t;
+/**
+ * @brief Type for the screen orientation.
+ */
+typedef enum orientation {portrait, landscape, portraitInv, landscapeInv} gdisp_orientation_t;
+/**
+ * @brief Type for the available power modes for the screen.
+ */
+typedef enum powermode {powerOff, powerSleep, powerOn} gdisp_powermode_t;
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifndef GDISP_LLD_VMT
+ /* Special magic stuff for the VMT driver */
+ #define GDISP_LLD_VMT(x) GDISP_LLD(x)
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* Core functions */
+ extern bool_t GDISP_LLD(init)(void);
+
+ /* Some of these functions will be implemented in software by the high level driver
+ depending on the GDISP_HARDWARE_XXX macros defined in gdisp_lld_config.h.
+ */
+
+ /* Drawing functions */
+ extern void GDISP_LLD_VMT(clear)(color_t color);
+ extern void GDISP_LLD_VMT(drawpixel)(coord_t x, coord_t y, color_t color);
+ extern void GDISP_LLD_VMT(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
+ extern void GDISP_LLD_VMT(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer);
+ extern void GDISP_LLD_VMT(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color);
+
+ /* Circular Drawing Functions */
+ #if GDISP_NEED_CIRCLE
+ extern void GDISP_LLD_VMT(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color);
+ extern void GDISP_LLD_VMT(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color);
+ #endif
+
+ #if GDISP_NEED_ELLIPSE
+ extern void GDISP_LLD_VMT(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+ extern void GDISP_LLD_VMT(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+ #endif
+
+ /* Text Rendering Functions */
+ #if GDISP_NEED_TEXT
+ extern void GDISP_LLD_VMT(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color);
+ extern void GDISP_LLD_VMT(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor);
+ #endif
+
+ /* Pixel readback */
+ #if GDISP_NEED_PIXELREAD
+ extern color_t GDISP_LLD_VMT(getpixelcolor)(coord_t x, coord_t y);
+ #endif
+
+ /* Scrolling Function - clears the area scrolled out */
+ #if GDISP_NEED_SCROLL
+ extern void GDISP_LLD_VMT(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor);
+ #endif
+
+ /* Set driver specific control */
+ #if GDISP_NEED_CONTROL
+ extern void GDISP_LLD_VMT(control)(unsigned what, void *value);
+ #endif
+
+ /* Query driver specific data */
+ #if GDISP_NEED_QUERY
+ extern void *GDISP_LLD_VMT(query)(unsigned what);
+ #endif
+
+ /* Messaging API */
+ #if GDISP_NEED_MSGAPI
+ #include "gdisp_lld_msgs.h"
+ extern void GDISP_LLD(msgdispatch)(gdisp_lld_msg_t *msg);
+ #endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_USE_GDISP */
+
+#endif /* _GDISP_LLD_H */
+/** @} */
diff --git a/include/gdisp_lld_msgs.h b/include/gdisp_lld_msgs.h
new file mode 100644
index 00000000..28a6707e
--- /dev/null
+++ b/include/gdisp_lld_msgs.h
@@ -0,0 +1,165 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @file gdisp_lld_msgs.h
+ * @brief GDISP Graphic Driver subsystem low level driver message structures.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_LLD_MSGS_H
+#define _GDISP_LLD_MSGS_H
+
+/* This file describes the message API for gdisp_lld */
+#if HAL_USE_GDISP && GDISP_NEED_MSGAPI
+
+typedef enum gdisp_msgaction {
+ GDISP_LLD_MSG_NOP,
+ GDISP_LLD_MSG_INIT,
+ GDISP_LLD_MSG_CLEAR,
+ GDISP_LLD_MSG_DRAWPIXEL,
+ GDISP_LLD_MSG_FILLAREA,
+ GDISP_LLD_MSG_BLITAREA,
+ GDISP_LLD_MSG_DRAWLINE,
+ #if GDISP_NEED_CIRCLE
+ GDISP_LLD_MSG_DRAWCIRCLE,
+ GDISP_LLD_MSG_FILLCIRCLE,
+ #endif
+ #if GDISP_NEED_ELLIPSE
+ GDISP_LLD_MSG_DRAWELLIPSE,
+ GDISP_LLD_MSG_FILLELLIPSE,
+ #endif
+ #if GDISP_NEED_TEXT
+ GDISP_LLD_MSG_DRAWCHAR,
+ GDISP_LLD_MSG_FILLCHAR,
+ #endif
+ #if GDISP_NEED_PIXELREAD
+ GDISP_LLD_MSG_GETPIXELCOLOR,
+ #endif
+ #if GDISP_NEED_SCROLL
+ GDISP_LLD_MSG_VERTICALSCROLL,
+ #endif
+ #if GDISP_NEED_CONTROL
+ GDISP_LLD_MSG_CONTROL,
+ #endif
+ #if GDISP_NEED_QUERY
+ GDISP_LLD_MSG_QUERY,
+ #endif
+} gdisp_msgaction_t;
+
+typedef union gdisp_lld_msg {
+ gdisp_msgaction_t action;
+ struct gdisp_lld_msg_init {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_INIT
+ } init;
+ struct gdisp_lld_msg_clear {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_CLEAR
+ color_t color;
+ } clear;
+ struct gdisp_lld_msg_drawpixel {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWPIXEL
+ coord_t x, y;
+ color_t color;
+ } drawpixel;
+ struct gdisp_lld_msg_fillarea {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLAREA
+ coord_t x, y;
+ coord_t cx, cy;
+ color_t color;
+ } fillarea;
+ struct gdisp_lld_msg_blitarea {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_BLITAREA
+ coord_t x, y;
+ coord_t cx, cy;
+ const pixel_t *buffer;
+ } blitarea;
+ struct gdisp_lld_msg_drawline {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWLINE
+ coord_t x0, y0;
+ coord_t x1, y1;
+ color_t color;
+ } drawline;
+ struct gdisp_lld_msg_drawcircle {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWCIRCLE
+ coord_t x, y;
+ coord_t radius;
+ color_t color;
+ } drawcircle;
+ struct gdisp_lld_msg_fillcircle {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLCIRCLE
+ coord_t x, y;
+ coord_t radius;
+ color_t color;
+ } fillcircle;
+ struct gdisp_lld_msg_drawellipse {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWELLIPSE
+ coord_t x, y;
+ coord_t a, b;
+ color_t color;
+ } drawellipse;
+ struct gdisp_lld_msg_fillellipse {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLELLIPSE
+ coord_t x, y;
+ coord_t a, b;
+ color_t color;
+ } fillellipse;
+ struct gdisp_lld_msg_drawchar {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWCHAR
+ coord_t x, y;
+ char c;
+ font_t font;
+ color_t color;
+ } drawchar;
+ struct gdisp_lld_msg_fillchar {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLCHAR
+ coord_t x, y;
+ char c;
+ font_t font;
+ color_t color;
+ color_t bgcolor;
+ } fillchar;
+ struct gdisp_lld_msg_getpixelcolor {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_GETPIXELCOLOR
+ coord_t x, y;
+ color_t result;
+ } getpixelcolor;
+ struct gdisp_lld_msg_verticalscroll {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_VERTICALSCROLL
+ coord_t x, y;
+ coord_t cx, cy;
+ int lines;
+ color_t bgcolor;
+ } verticalscroll;
+ struct gdisp_lld_msg_control {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_CONTROL
+ int what;
+ void * value;
+ } control;
+ struct gdisp_lld_msg_query {
+ gdisp_msgaction_t action; // GDISP_LLD_MSG_QUERY
+ int what;
+ void * result;
+ } query;
+} gdisp_lld_msg_t;
+
+#endif /* HAL_USE_GDISP */
+#endif /* _GDISP_LLD_MSGS_H */
+/** @} */
diff --git a/include/glcd.h b/include/glcd.h
new file mode 100644
index 00000000..ab2f6be2
--- /dev/null
+++ b/include/glcd.h
@@ -0,0 +1,136 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ This file is an emulation of the GLCD interface using the
+ new GDISP interface. It is probably not a perfect replica,
+ some code changes may be necessary.
+ Note it does not replicate the GLCD low level driver, just
+ the high level interface.
+ You may also need to define the various GDISP_NEED_XXX in your
+ halconf.h in order to turn on the functionality you need.
+*/
+
+#ifndef GLCD_H
+#define GLCD_H
+
+#include "ch.h"
+#include "hal.h"
+#include "gdisp.h"
+
+#define PORTRAIT (lcdGetOrientation() == portrait || lcdGetOrientation() == portraitInv)
+#define LANDSCAPE (lcdGetOrientation() == landscape || lcdGetOrientation() == landscapeInv)
+
+#define RGB565CONVERT(r, g, b) RGB2COLOR(r,g,b)
+
+enum filled {frame, filled};
+enum transparency {solid, transparent};
+#define sleepOn powerSleep
+#define sleepOff powerOn
+
+#define font_Small (&fontSmall)
+#define font_SmallDouble (&fontSmallDouble)
+#define font_SmallNarrow (&fontSmall)
+#define font_Larger (&fontLarger)
+#define font_LargerDouble (&fontLargerDouble)
+#define font_LargerNarrow (&fontLargerNarrow)
+#define font_MediumBold (&fontUI1)
+#define font_MediumBoldDouble (&fontUI1Double)
+#define font_MediumBoldNarrow (&fontUI1Narrow)
+#define font_LargeNumbers (&fontLargeNumbers)
+#define font_LargeNumbersDouble (&fontLargeNumbersDouble)
+#define font_LargeNumbersNarrow (&fontLargeNumbersNarrow)
+
+enum glcd_result { GLCD_DONE,
+ GLCD_FAILED,
+ GLCD_PROGRESS,
+ };
+
+typedef enum glcd_result glcd_result_t;
+
+/* Core functions */
+#define lcdInit(dvr) gdispInit(dvr)
+static __inline glcd_result_t lcdClear(color_t color) {
+ gdispClear(color);
+ return GLCD_DONE;
+}
+static __inline glcd_result_t lcdSetOrientation(enum orientation newO) {
+ gdispControl(GDISP_CONTROL_ORIENTATION, (void *)(int)newO);
+ return ((enum orientation)(unsigned)gdispQuery(GDISP_QUERY_ORIENTATION)) == (newO) ? GLCD_DONE : GLCD_FAILED;
+}
+static __inline glcd_result_t lcdFillArea(coord_t x0, coord_t y0, coord_t x1, coord_t y1,color_t c) {
+ gdispFillArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c));
+ return GLCD_DONE;
+}
+static __inline glcd_result_t lcdWriteArea(coord_t x0, coord_t y0, coord_t x1, coord_t y1, const pixel_t *b, coord_t n) {
+ (void)n;
+ gdispBlitArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(b));
+ return GLCD_DONE;
+}
+static __inline glcd_result_t lcdSetPowerMode(enum powermode pm) {
+ gdispControl(GDISP_CONTROL_POWER, (void *)(int)pm);
+ return ((enum powermode)(unsigned)gdispQuery(GDISP_QUERY_POWER)) == (pm) ? GLCD_DONE : GLCD_FAILED;
+}
+
+/* Drawing functions */
+static __inline glcd_result_t lcdDrawPixel(coord_t x, coord_t y, color_t c) {
+ gdispDrawPixel((x),(y),(c));
+ return GLCD_DONE;
+}
+#define lcdDrawLine(x0,y0,x1,y1,c) gdispDrawLine((x0),(y0),(x1),(y1),(c))
+#define lcdDrawRect(x0,y0,x1,y1,f,c) {if(f) gdispFillArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c)); else gdispDrawBox((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c));}
+#define lcdDrawRectString(x0,y0,x1,y1,s,f,c,b) gdispFillStringBox((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(s),(f),(c),(b),justifyLeft)
+#define lcdDrawCircle(x,y,r,f,c) {if(f) gdispFillCircle((x),(y),(r),(c)); else gdispDrawCircle((x),(y),(r),(c));}
+#define lcdDrawEllipse(x,y,a,b,f,c) {if(f) gdispFillEllipse((x),(y),(a),(b),(c)); else gdispDrawEllipse((x),(y),(a),(b),(c));}
+
+/* Text Rendering Functions */
+static __inline coord_t lcdDrawChar(coord_t x, coord_t y, char h, font_t f, color_t c, color_t b, bool_t t) {
+ if (t)
+ gdispDrawChar((x),(y),(h),(f),(c));
+ else
+ gdispFillChar((x),(y),(h),(f),(c),(b));
+ return gdispGetCharWidth((h),(f))+gdispGetFontMetric((f), fontCharPadding);
+}
+static __inline coord_t lcdDrawString(coord_t x, coord_t y, const char *s, font_t f, color_t c, color_t b, bool_t t) {
+ if (t)
+ gdispDrawString((x),(y),(s),(f),(c));
+ else
+ gdispFillString((x),(y),(s),(f),(c),(b));
+ return gdispGetStringWidth((s),(f))+gdispGetFontMetric((f), fontCharPadding);
+}
+
+/* Character measuring functions */
+#define lcdMeasureChar(h,f) (gdispGetCharWidth((h),(f))+gdispGetFontMetric((f), fontCharPadding))
+#define lcdMeasureString(s,f) (gdispGetStringWidth((s),(f))+gdispGetFontMetric((f), fontCharPadding))
+#define lcdGetFontHeight(f) gdispGetFontMetric((f), fontHeight)
+
+/* Size and orientation related */
+#define lcdGetHeight() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_HEIGHT))
+#define lcdGetWidth() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_WIDTH))
+#define lcdGetOrientation() ((enum orientation)(unsigned)gdispQuery(GDISP_QUERY_ORIENTATION))
+
+/* BGR->RGB and pixel readback */
+#define lcdBGR2RGB(c) RGB2COLOR(BLUE_OF(c),GREEN_OF(c),RED_OF(c))
+#define lcdGetPixelColor(x,y) gdispGetPixelColor((x),(y))
+
+/* Scrolling function */
+#define lcdVerticalScroll(x0,y0,x1,y1,l) gdispVerticalScroll((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,l,Black)
+
+#endif
diff --git a/include/touchpad.h b/include/touchpad.h
new file mode 100644
index 00000000..445d3202
--- /dev/null
+++ b/include/touchpad.h
@@ -0,0 +1,93 @@
+/*
+ ChibiOS-LCD-Driver/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file touchpad.h
+ * @brief TOUCHPAD Touchpad Driver subsystem header file.
+ *
+ * @addgroup TOUCHPAD
+ * @{
+ */
+#ifndef _TOUCHPAD_H
+#define _TOUCHPAD_H
+
+#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__)
+
+/**
+ * @brief specifies how many conversions are made for a readout.
+ *
+ * @note higher is more accurate, but takes more time
+ */
+#define CONVERSIONS 3
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Low Level Driver details and error checks. */
+/*===========================================================================*/
+
+/* Include the low level driver information */
+#include "touchpad_lld.h"
+
+/*===========================================================================*/
+/* Type definitions */
+/*===========================================================================*/
+
+/**
+ * @brief Struct used for calibration
+ */
+struct cal {
+ float xm;
+ float ym;
+ float xn;
+ float yn;
+};
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void tpInit(TOUCHPADDriver *tp);
+uint16_t tpReadX(void);
+uint16_t tpReadY(void);
+
+#if TOUCHPAD_HAS_IRQ
+ uint8_t tpIRQ(void);
+#endif
+
+#if TOUCHPAD_HAS_PRESSURE
+ uint16_t tpReadZ(void);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_USE_TOUCHPAD */
+
+#endif /* _TOUCHPAD_H */
+/** @} */
+
diff --git a/include/touchpad_lld.h b/include/touchpad_lld.h
new file mode 100644
index 00000000..45a561d3
--- /dev/null
+++ b/include/touchpad_lld.h
@@ -0,0 +1,106 @@
+/*
+ ChibiOS-LCD-Driver/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file touchpad_lld.h
+ * @brief TOUCHPAD Driver subsystem low level driver header.
+ *
+ * @addgroup TOUCHPAD
+ * @{
+ */
+
+#ifndef _TOUCHPAD_LLD_H
+#define _TOUCHPAD_LLD_H
+
+#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Include the low level driver configuration information */
+/*===========================================================================*/
+
+#include "touchpad_lld_config.h"
+
+/*===========================================================================*/
+/* Error checks. */
+/*===========================================================================*/
+
+#ifndef TOUCHPAD_HAS_IRQ
+ #define TOUCHPAD_HAS_IRQ FALSE
+#endif
+
+#ifndef TOUCHPAD_HAS_PRESSURE
+ #define TOUCHPAD_HAS_PRESSURE FALSE
+#endif
+
+/*===========================================================================*/
+/* Driver types. */
+/*===========================================================================*/
+
+typedef struct TOUCHPADDriver TOUCHPADDriver;
+
+/**
+ * @brief Structure representing a Touchpad driver.
+ */
+struct TOUCHPADDriver {
+ /*
+ * @brief Pointer to SPI driver.
+ */
+ SPIDriver *spid;
+
+ /*
+ * @brief SPI configuration.
+ */
+ SPIConfig *spicfg;
+};
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#if !defined(__DOXYGEN__)
+ extern TOUCHPADDriver Touchpad;
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* Core functions */
+ void tp_lld_init(TOUCHPADDriver *tp);
+ uint16_t tp_lld_read_x(void);
+ uint16_t tp_lld_read_y(void);
+
+ #if TOUCHPAD_HAS_IRQ
+ uint8_t tp_lld_irq(void);
+ #endif
+
+ #if TOUCHPAD_HAS_PRESSURE
+ uint16_t tp_lld_read_z(void);
+ #endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_USE_TOUCHPAD */
+
+#endif /* _TOUCHPAD_LLD_H */
+/** @} */
+
diff --git a/old/console.c b/old/console.c
new file mode 100644
index 00000000..caddfce2
--- /dev/null
+++ b/old/console.c
@@ -0,0 +1,171 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "ch.h"
+
+#include "glcd.h"
+#include "console.h"
+
+/*
+ * Interface implementation. The interface is write only
+ */
+
+static size_t writes(void *ip, const uint8_t *bp, size_t n) {
+ return lcdConsoleWrite((GLCDConsole *)ip, bp, n);
+}
+
+static size_t reads(void *ip, uint8_t *bp, size_t n) {
+ (void)ip;
+ (void)bp;
+ (void)n;
+
+ return 0;
+}
+
+static msg_t put(void *ip, uint8_t b) {
+ return lcdConsolePut((GLCDConsole *)ip, (char)b);
+}
+
+static msg_t get(void *ip) {
+ (void)ip;
+
+ return RDY_OK;
+}
+
+static msg_t putt(void *ip, uint8_t b, systime_t timeout) {
+ (void)timeout;
+
+ /* TODO: handle timeout */
+
+ return lcdConsolePut((GLCDConsole *)ip, (char)b);
+}
+
+static msg_t gett(void *ip, systime_t timeout) {
+ (void)ip;
+ (void)timeout;
+
+ return RDY_OK;
+}
+
+static size_t writet(void *ip, const uint8_t *bp, size_t n, systime_t time) {
+ (void)time;
+
+ return lcdConsoleWrite((GLCDConsole *)ip, bp, n);
+}
+
+static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
+ (void)ip;
+ (void)bp;
+ (void)n;
+ (void)time;
+
+ return 0;
+}
+
+static uint16_t getflags(void *ip) {
+ _chn_get_and_clear_flags_impl(ip);
+}
+
+static const struct GLCDConsoleVMT vmt = {
+ writes, reads, put, get,
+ putt, gett, writet, readt,
+ getflags
+};
+
+
+msg_t lcdConsoleInit(GLCDConsole *console, uint16_t x0, uint16_t y0, uint16_t width, uint16_t height, font_t font, uint16_t bkcolor, uint16_t color) {
+ const uint8_t* ptr;
+ uint16_t chi;
+ uint16_t x,y;
+
+ console->vmt = &vmt;
+ /* read font, get height */
+ console->fy = lcdGetFontHeight(font);
+
+ /* calculate the size of the console as an integer multiple of characters height*/
+ console->sx = width;
+ console->sy = (((int16_t)(height/console->fy))-1)*console->fy;
+
+ console->cx = 0;
+ console->cy = 0;
+ console->x0 = x0;
+ console->y0 = y0;
+
+ console->bkcolor = bkcolor;
+ console->color = color;
+
+ console->font = font;
+
+ lcdFillArea(x0, y0, x0+width, y0+height, console->bkcolor);
+ return RDY_OK;
+}
+
+msg_t lcdConsolePut(GLCDConsole *console, char c) {
+ uint8_t width;
+
+ if(c == '\n') {
+ /* clear the text at the end of the line */
+ if(console->cx < console->sx)
+ lcdFillArea(console->x0 + console->cx, console->y0 + console->cy,
+ console->x0 + console->sx, console->y0 + console->cy + console->fy,
+ console->bkcolor);
+ console->cx = 0;
+ console->cy += console->fy;
+ } else if(c == '\r') {
+ /* TODO: work backwards through the buffer to the start of the current line */
+ //console->cx = 0;
+ } else {
+ width = lcdMeasureChar(c, console->font);
+ if((console->cx + width) >= console->sx) {
+ /* clear the text at the end of the line */
+ lcdFillArea(console->x0 + console->cx, console->y0 + console->cy,
+ console->x0 + console->cx + width, console->y0 + console->cy + console->fy,
+ console->bkcolor);
+ console->cx = 0;
+ console->cy += console->fy;
+ }
+
+ if((console->cy > console->sy)) {
+
+ lcdVerticalScroll(console->x0, console->y0, console->x0 + console->sx,
+ console->y0 + console->sy + console->fy, console->fy);
+ /* reset the cursor */
+ console->cx = 0;
+ console->cy = console->sy;
+ }
+
+ lcdDrawChar(console->x0 + console->cx, console->y0 + console->cy, c,
+ console->font, console->color, console->bkcolor, solid);
+
+ /* update cursor */
+ console->cx += width;
+ }
+ return RDY_OK;
+}
+
+msg_t lcdConsoleWrite(GLCDConsole *console, uint8_t *bp, size_t n) {
+ size_t i;
+ for(i = 0; i < n; i++)
+ lcdConsolePut(console, bp[i]);
+
+ return RDY_OK;
+}
+
+
diff --git a/old/console.h b/old/console.h
new file mode 100644
index 00000000..f76c5adf
--- /dev/null
+++ b/old/console.h
@@ -0,0 +1,84 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef CONSOLE_H
+#define CONSOLE_H
+
+#include "glcd.h"
+
+/**
+ * @brief Structure representing a GLCD driver.
+ */
+typedef struct GLCDConsole GLCDConsole;
+
+/**
+ * @brief @p GLCDConsole specific methods.
+ */
+#define _glcd_driver_methods \
+ _base_asynchronous_channel_methods
+
+/**
+ * @extends BaseAsynchronousChannelVMT
+ *
+ * @brief @p GLCDConsole virtual methods table.
+ */
+struct GLCDConsoleVMT {
+ _glcd_driver_methods
+};
+
+/**
+ * @extends BaseAsynchronousChannel
+ *
+ * @brief GLCD Console class.
+ * @details This class extends @p BaseAsynchronousChannel by adding physical
+ * I/O queues.
+ */
+struct GLCDConsole {
+ /** @brief Virtual Methods Table.*/
+ const struct GLCDConsoleVMT *vmt;
+ _base_asynchronous_channel_data
+ /* WARNING: Do not add any data to this struct above this comment, only below */
+ /* font */
+ font_t font;
+ /* lcd area to use */
+ uint16_t x0,y0;
+ /* current cursor position, in pixels */
+ uint16_t cx,cy;
+ /* console size in pixels */
+ uint16_t sx,sy;
+ /* foreground and background colour */
+ uint16_t bkcolor, color;
+ /* font size in pixels */
+ uint8_t fy;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+msg_t lcdConsoleInit(GLCDConsole *console, uint16_t x0, uint16_t y0, uint16_t width, uint16_t height, font_t font, uint16_t bkcolor, uint16_t color);
+msg_t lcdConsolePut(GLCDConsole *console, char c);
+msg_t lcdConsoleWrite(GLCDConsole *console, uint8_t *bp, size_t n);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CONSOLE_H */
diff --git a/old/graph/graph.c b/old/graph/graph.c
new file mode 100644
index 00000000..853ab738
--- /dev/null
+++ b/old/graph/graph.c
@@ -0,0 +1,75 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "glcd.h"
+
+#define MARKSIZE 5 // half
+
+static uint16_t x, y; // origins in graph
+static uint16_t grid_X, grid_Y; //grids
+
+void graphDrawSystem(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t gridX, uint16_t gridY, uint16_t color) {
+ uint16_t i, length;
+ volatile uint16_t off;
+
+ x = x0;
+ y = y0;
+ grid_X = gridX;
+ grid_Y = gridY;
+
+ // X-Axis
+ length = x1 - x0;
+ lcdDrawLine(x0, y0, x1, y0, color);
+ lcdDrawLine(x1, y0, x1-5, y0+5, color);
+ lcdDrawLine(x1, y0, x1-5, y0-5, color);
+ for(i=1; i<(length / grid_X); i++) {
+ off = x0 + i * grid_X;
+ lcdDrawLine(off, y0-MARKSIZE, off, y0+MARKSIZE, color);
+ }
+
+ // Y-Axis
+ length = y0 - y1;
+ lcdDrawLine(x0, y0, x0, y1, color);
+ lcdDrawLine(x0, y1, x0-5, y1+5, color);
+ lcdDrawLine(x0, y1, x0+5, y1+5, color);
+ for(i=1; i<(length / grid_Y); i++) {
+ off = y0 + i * grid_Y;
+ lcdDrawLine(x0-MARKSIZE, off, x0+MARKSIZE, off, color);
+ }
+}
+
+void graphDrawDots(int coord[][2], uint16_t entries, uint16_t radius, uint16_t color) {
+ uint16_t i;
+
+ for(i = 0; i < entries; i++)
+ lcdDrawCircle(coord[i][0]+x, y-coord[i][1], radius, 1, color);
+}
+
+void graphDrawNet(int coord[][2], uint16_t entries, uint16_t radius, uint16_t lineColor, uint16_t dotColor) {
+ uint16_t i;
+
+ for(i = 0; i < entries; ++i)
+ lcdDrawLine(coord[i-1][0]+x, y-coord[i-1][1], coord[i][0]+x, y-coord[i][1], lineColor);
+ for(i = 0; i < entries; ++i)
+ if(radius != 0)
+ lcdDrawCircle(coord[i][0]+x, y-coord[i][1], radius, 1, dotColor);
+}
+
+
diff --git a/old/graph/graph.h b/old/graph/graph.h
new file mode 100644
index 00000000..f4286fc2
--- /dev/null
+++ b/old/graph/graph.h
@@ -0,0 +1,72 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef GRAPH_H
+#define GRAPH_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*
+ * Description: does draw axis arrows and grid
+ *
+ * param:
+ * - x0, y0, x1, y1: location of arrows
+ * - gridX, gridY: grid size in X and Y direction
+ * - color: color of arrows
+ *
+ * return: none
+ */
+void graphDrawSystem(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t gridX, uint16_t gridY, uint16_t color);
+
+/*
+ * Description: does draw coordinates into graph as dots
+ *
+ * param:
+ * - coord: two dimensionl array containing X and Y coordinates
+ * - entries: amount of coordinates passed (sizeof(coord)/sizeof(coord[0])
+ * - radius: size of the dots
+ * - color: color of the dots
+ *
+ * return: none
+ */
+void graphDrawDots(int coord[][2], uint16_t entries, uint16_t radius, uint16_t color);
+
+/*
+ * Description: does draw coordinates into graph connected by lines
+ *
+ * param:
+ * - coord: two dimensional array containing X and Y coordinates
+ * - entries: amount of coordinates passed (sizeof(coord)/sizeof(coord[0])
+ * - radius: if not 0, graphDrawDots() gets invoked
+ * - lineColor: color of the lines
+ * - dotColor: color of dots, if radius != 0
+ *
+ * return: none
+ */
+void graphDrawNet(int coord[][2], uint16_t entries, uint16_t radius, uint16_t lineColor, uint16_t dotColor);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/old/graph/graph.mk b/old/graph/graph.mk
new file mode 100644
index 00000000..706a9412
--- /dev/null
+++ b/old/graph/graph.mk
@@ -0,0 +1,3 @@
+LCD_GRAPH_SRC = $(LCDLIB)/graph/graph.c
+
+LCD_GRAPH_INC = $(LCDLIB)/graph
diff --git a/old/gui/gui.c b/old/gui/gui.c
new file mode 100644
index 00000000..40553d86
--- /dev/null
+++ b/old/gui/gui.c
@@ -0,0 +1,334 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "gui.h"
+
+static struct guiNode_t *firstGUI = NULL;
+uint16_t x, y; // global touchpad coordinates
+
+static uint8_t addElement(struct guiNode_t *newNode) {
+ struct guiNode_t *new;
+
+ if(firstGUI == NULL) {
+ firstGUI = chHeapAlloc(NULL, sizeof(struct guiNode_t));
+ if(firstGUI == NULL)
+ return 0;
+
+ *firstGUI = *newNode;
+ firstGUI->next = NULL;
+ } else {
+ new = firstGUI;
+ while(new->next != NULL)
+ new = new->next;
+
+ new->next = chHeapAlloc(NULL, sizeof(struct guiNode_t));
+ if(new->next == NULL)
+ return 0;
+
+ new = new->next;
+ *new = *newNode;
+ new->next = NULL;
+ }
+
+ return 1;
+}
+
+static uint8_t deleteElement(char *label) {
+ struct guiNode_t *pointer, *pointer1;
+
+ if(firstGUI != NULL) {
+ if(strcmp(firstGUI->label, label) == 0) {
+ pointer = firstGUI->next;
+ chHeapFree(firstGUI);
+ firstGUI = pointer;
+ } else {
+ pointer = firstGUI;
+
+ while(pointer->next != NULL) {
+ pointer1 = pointer->next;
+
+ if(strcmp(firstGUI->label, label) == 0) {
+ pointer->next = pointer1->next;
+ chHeapFree(pointer1);
+ break;
+ }
+
+ pointer = pointer1;
+
+ }
+ }
+
+ return 1; // successful
+ }
+
+ return 0; // not successful
+}
+
+void guiPrintElements(BaseSequentialStream *chp) {
+ struct guiNode_t *pointer = firstGUI;
+
+ chprintf(chp, "\r\n\nguiNodes:\r\n\n");
+
+ while(pointer != NULL) {
+ chprintf(chp, "x0: %d\r\n", pointer->x0);
+ chprintf(chp, "y0: %d\r\n", pointer->y0);
+ chprintf(chp, "x1: %d\r\n", pointer->x1);
+ chprintf(chp, "y1: %d\r\n", pointer->y1);
+ chprintf(chp, "label: %s\r\n", pointer->label);
+ chprintf(chp, "active: %d\r\n", *(pointer->active));
+ chprintf(chp, "state: %d\r\n", *(pointer->state));
+ chprintf(chp, "*next: 0x%x\r\n", pointer->next);
+ chprintf(chp, "\r\n\n");
+ pointer = pointer->next;
+ }
+}
+
+static inline void buttonUpdate(struct guiNode_t *node) {
+ if(x >= node->x0 && x <= node->x1 && y >= node->y0 && y <= node->y1) {
+ *(node->state) = 1;
+ } else {
+ *(node->state) = 0;
+ }
+}
+
+static inline void sliderUpdate(struct guiNode_t *node) {
+ uint16_t length = 1;
+
+ if(node->orientation == horizontal)
+ length = node->x1 - node->x0;
+ else if(node->orientation == vertical)
+ length = node->y1 - node->y0;
+
+ if(node->mode == modePassive) {
+ node->percentage = *(node->state);
+ } else if(node->mode == modeActive) {
+ if(x >= node->x0 && x <= node->x1 && y >= node->y0 && y <= node->y1) {
+ if(node->orientation == horizontal) {
+ node->percentage = (((x - node->x0) * 100) / length);
+ } else if(node->orientation == vertical) {
+ node->percentage = (((y - node->y0) * 100) / length);
+ }
+ }
+
+ *(node->state) = node->percentage;
+ }
+
+ // a bit of safety here
+ if(node->percentage > 100)
+ node->percentage = 100;
+
+ if(node->orientation == horizontal) {
+ node->value = ((((node->x1)-(node->x0)) * node->percentage) / 100);
+ if(node->oldValue > node->value || node->value == 0)
+ lcdFillArea(node->x0+1, node->y0+1, node->x1, node->y1, node->bkColor);
+ else
+ lcdDrawRect(node->x0+1, node->y0+1, node->x0+node->value, node->y1, filled, node->valueColor);
+ } else if(node->orientation == vertical) {
+ node->value = ((((node->y1)-(node->y0)) * node->percentage) / 100);
+ if(node->oldValue > node->value || node->value == 0)
+ lcdFillArea(node->x0+1, node->y0+1, node->x1, node->y1, node->bkColor);
+ else
+ lcdDrawRect(node->x0+1, node->y0+1, node->x1, node->y0+node->value, filled, node->valueColor);
+ }
+
+ node->oldValue = node->value;
+}
+
+static inline void wheelUpdate(struct guiNode_t *node) {
+ (void)node;
+}
+
+static inline void keymatrixUpdate(struct guiNode_t *node) {
+ (void)node;
+}
+
+static void guiThread(const uint16_t interval) {
+ struct guiNode_t *node;
+
+ chRegSetThreadName("GUI");
+
+ while(TRUE) {
+ for(node = firstGUI; node; node = node->next) {
+ // check if GUI element is set active
+ if(*(node->active) == active) {
+ x = tpReadX();
+ y = tpReadY();
+
+ switch(node->type) {
+ case button:
+ buttonUpdate(node);
+ break;
+ case slider:
+ sliderUpdate(node);
+ break;
+ case wheel:
+ wheelUpdate(node);
+ break;
+ case keymatrix:
+ keymatrixUpdate(node);
+ break;
+ }
+ }
+ }
+
+ chThdSleepMilliseconds(interval);
+ }
+}
+
+Thread *guiInit(uint16_t interval, tprio_t priority) {
+ Thread *tp = NULL;
+
+ tp = chThdCreateFromHeap(NULL, THD_WA_SIZE(512), priority, guiThread, interval);
+
+ return tp;
+}
+
+uint8_t guiDeleteElement(char *label) {
+ return deleteElement(label);
+}
+
+uint8_t guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, char *str, font_t font, uint16_t fontColor, uint16_t buttonColor, uint16_t shadow, char *label, uint8_t *active, uint8_t *state) {
+ struct guiNode_t *newNode;
+ uint16_t i;
+
+ newNode = chHeapAlloc(NULL, sizeof(struct guiNode_t));
+ if(newNode == NULL)
+ return 0;
+
+ newNode->type = button;
+ newNode->label = label;
+ newNode->x0 = x0;
+ newNode->y0 = y0;
+ newNode->x1 = x1;
+ newNode->y1 = y1;
+ newNode->shadow = shadow;
+ newNode->active = active;
+ newNode->state = state;
+
+ if(addElement(newNode) != 1)
+ return 0;
+
+ lcdDrawRectString(x0, y0, x1, y1, str, font, fontColor, buttonColor);
+
+ if(shadow != 0) {
+ for(i = 0; i < shadow; i++) {
+ lcdDrawLine(x0+shadow, y1+i, x1+shadow-1, y1+i, Black);
+ lcdDrawLine(x1+i, y0+shadow, x1+i, y1+shadow-1, Black);
+ }
+ }
+
+ chHeapFree(newNode);
+
+ return 1;
+}
+
+uint8_t guiDrawSlider(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t orientation, uint8_t mode, uint16_t frameColor, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value) {
+ struct guiNode_t *newNode;
+
+ newNode = chHeapAlloc(NULL, sizeof(struct guiNode_t));
+ if(newNode == NULL)
+ return 0;
+
+ newNode->type = slider;
+ newNode->label = label;
+ newNode->x0 = x0;
+ newNode->y0 = y0;
+ newNode->x1 = x1;
+ newNode->y1 = y1;
+ newNode->mode = mode;
+ newNode->bkColor = bkColor;
+ newNode->valueColor = valueColor;
+ newNode->state = value;
+ newNode->active = active;
+ newNode->orientation = orientation;
+ newNode->percentage = 0;
+
+ if(addElement(newNode) != 1)
+ return 0;
+
+ (void)bkColor;
+ (void)valueColor;
+
+ // lcdDraw functions
+ lcdDrawRect(x0, y0, x1, y1, frame, frameColor);
+
+ chHeapFree(newNode);
+
+ return 1;
+}
+
+uint8_t guiDrawWheel(uint16_t x0, uint16_t y0, uint16_t radius1, uint16_t radius2, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value) {
+ struct guiNode_t *newNode;
+
+ newNode = chHeapAlloc(NULL, sizeof(struct guiNode_t));
+ if(newNode == NULL)
+ return 0;
+
+ newNode->type = wheel;
+ newNode->label = label;
+ newNode->x0 = x0;
+ newNode->y0 = y0;
+ newNode->r1 = radius1;
+ newNode->r2 = radius2;
+ newNode->active = active;
+ newNode->state = value;
+
+ if(addElement(newNode) != 1)
+ return 0;
+
+ (void)bkColor;
+ (void)valueColor;
+ // lcdDraw functions
+
+ chHeapFree(newNode);
+
+ return 1;
+}
+
+uint8_t guiDrawKeymatrix(uint16_t x0, uint16_t y0, uint16_t size, uint16_t space, uint16_t shadow, uint16_t buttonColor, uint16_t fontColor, font_t font, char *label, uint8_t *active, uint8_t *value) {
+ struct guiNode_t *newNode;
+
+ newNode = chHeapAlloc(NULL, sizeof(struct guiNode_t));
+ if(newNode == NULL)
+ return 0;
+
+ newNode->type = keymatrix;
+ newNode->label = label;
+ newNode->x0 = x0;
+ newNode->y0 = y0;
+ newNode->shadow = shadow;
+ newNode->active = active;
+ newNode->state = value;
+
+ if(addElement(newNode) != 1)
+ return 0;
+
+ // lcdDraw functions
+ (void)size;
+ (void)space;
+ (void)buttonColor;
+ (void)fontColor;
+ (void)font;
+
+ chHeapFree(newNode);
+
+ return 1;
+}
+
diff --git a/old/gui/gui.h b/old/gui/gui.h
new file mode 100644
index 00000000..04d9a8b1
--- /dev/null
+++ b/old/gui/gui.h
@@ -0,0 +1,115 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef GUI_H
+#define GUI_H
+
+#include "ch.h"
+#include "hal.h"
+#include "glcd.h"
+#include "chprintf.h"
+#include "touchpad.h"
+#include <string.h>
+
+struct guiNode_t {
+ uint8_t type;
+ uint16_t x0;
+ uint16_t y0;
+ uint16_t x1;
+ uint16_t y1;
+ uint16_t r1;
+ uint16_t r2;
+ uint16_t shadow;
+ uint16_t bkColor;
+ uint16_t valueColor;
+ uint16_t value;
+ uint16_t oldValue;
+ uint16_t percentage;
+ uint8_t orientation;
+ uint8_t mode;
+ uint8_t *active;
+ uint8_t *state;
+ char *label;
+ struct guiNode_t *next;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {button, slider, wheel, keymatrix};
+enum {horizontal, vertical};
+enum {inactive, active};
+enum {modePassive, modeActive};
+
+/*
+ * Description: creates the GUI thread
+ *
+ * param: - interval: thread sleep in milliseconds after each GUI element update
+ * - priority: priority of the thread
+ *
+ * return: pointer to created thread
+ */
+Thread *guiInit(uint16_t interval, tprio_t priority);
+
+/*
+ * Description: prints all GUI elements structs (linked list)
+ *
+ * param: - chp: pointer to output stream
+ *
+ * return: none
+ */
+void guiPrintElements(BaseSequentialStream *chp);
+
+/*
+ * Description: deletes a GUI element from the linked list
+ *
+ * param: - label: label of the element (parameter of each guiDrawXXX function)
+ *
+ * return: 1 if successful, 0 otherwise
+ */
+uint8_t guiDeleteElement(char *label);
+
+/*
+ * Description: draws a button on the screen and keeps it's state up to date
+ *
+ * param: - x0, y0, x1, y1: start and end coordinates of the button's rectangle
+ * - str: string that gets drawn into the rectangle - button's lable
+ * - fontColor: color of the lable
+ * - buttonColor: color of the rectangle
+ * - shadow: draws a black shadow with N pixels size if != 0
+ * - active: pass pointer to variable which holds the state 'active' or 'inactive'
+ * - state: pass pointer to variable whcih will keep the state of the button (pressed / unpressed)'
+ *
+ * return: 1 if button successfully created
+ */
+uint8_t guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, char *str, font_t font, uint16_t fontColor, uint16_t buttonColor, uint16_t shadow, char *label, uint8_t *active, uint8_t *state);
+
+uint8_t guiDrawSlider(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t orientation, uint8_t mode, uint16_t frameColor, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value);
+
+uint8_t guiDrawWheel(uint16_t x0, uint16_t y0, uint16_t radius1, uint16_t radius2, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value);
+
+uint8_t guiDrawKeymatrix(uint16_t x0, uint16_t y0, uint16_t buttonSize, uint16_t space, uint16_t shadow, uint16_t buttonColor, uint16_t fontColor, font_t font, char *label, uint8_t *active, uint8_t *value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/old/gui/gui.mk b/old/gui/gui.mk
new file mode 100644
index 00000000..e25cbd73
--- /dev/null
+++ b/old/gui/gui.mk
@@ -0,0 +1,3 @@
+LCD_GUI_SRC = $(LCDLIB)/gui/gui.c
+
+LCD_GUI_INC = $(LCDLIB)/gui
diff --git a/readme1.txt b/readme1.txt
new file mode 100644
index 00000000..907c7eb4
--- /dev/null
+++ b/readme1.txt
@@ -0,0 +1,28 @@
+To include any of these functions/drivers in your project...
+
+ 1/ Specify the path to the LCDLIB. If none defined, default is $(CHIBIOS)/ext/lcd
+
+ 2/ In your project Makefile (amongst similiar lines but after the hal line) add the line...
+ include $(LCDLIB)/lcd.mk
+
+ 3/ In your project Makefile add the makefiles for any specific drivers you want e.g
+ include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk
+ include $(LCDLIB)/halext/drivers/gdispNokia6610/gdisp_lld.mk
+
+ 4/ In your project halconf.h turn on the support you want eg.
+ /**
+ * @brief Enables the Touchpad subsystem.
+ */
+ #if !defined(HAL_USE_TOUCHPAD) || defined(__DOXYGEN__)
+ #define HAL_USE_TOUCHPAD TRUE
+ #endif
+ /**
+ * @brief Enables the GDISP subsystem.
+ */
+ #if !defined(HAL_USE_GDISP) || defined(__DOXYGEN__)
+ #define HAL_USE_GDISP TRUE
+ /* Any driver specific defines required go here. The below line is an example. */
+ #define GDISP_NEED_MULTITHREAD TRUE
+ #endif
+ 5/ Do a make clean.
+
diff --git a/readme2.txt b/readme2.txt
new file mode 100644
index 00000000..0b67c9b0
--- /dev/null
+++ b/readme2.txt
@@ -0,0 +1,19 @@
+## Doxygen
+run doxygen in the toplevel directory to generate the doxygen documentation in html
+
+
+
+## Wiki
+please read the wiki pages to this project carefully, before you ask any questions:
+
+http://chibios.org/dokuwiki/doku.php?id=chibios:community
+
+
+
+## Maintainer & Contributors
+please read the contributors.txt file which contains a full history of each contribution
+
+Maintainer:
+ - Joel Bodenmann aka Tectu <joel@unormal.org>
+
+
diff --git a/src/gdisp-readme.txt b/src/gdisp-readme.txt
new file mode 100644
index 00000000..12b00e2c
--- /dev/null
+++ b/src/gdisp-readme.txt
@@ -0,0 +1,14 @@
+The new GDISP driver is an architecture independant rewrite of the GLCD interface.
+This new architecture independance should allow many new low level drivers to be easily added.
+
+GDISP allows low-level driver hardware accelerated drawing routines while providing a software emulation
+if the low level driver can not provide it. A basic low level driver now only requires 2 routines to be written.
+
+A glcd.h compatability file has been included that allow applications written to use the existing GLCD driver to
+use the GDISP driver with little or no change.
+
+It is written in the ChibiOS style with ChibiOS style includes and documentation.
+
+It is encapsulated into a "halext" structure with appropriate readme's that allow for easy inclusion in any
+ChibiOS project. This structure can be seamlessly added to as new driver types are added and it supports
+low level drivers that are neither platform or board specific (although they can be).
diff --git a/src/gdisp.c b/src/gdisp.c
new file mode 100644
index 00000000..ee2b98e4
--- /dev/null
+++ b/src/gdisp.c
@@ -0,0 +1,997 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file gdisp.c
+ * @brief GDISP Driver code.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+#include "ch.h"
+#include "hal.h"
+#include "gdisp.h"
+
+#ifndef _GDISP_C
+#define _GDISP_C
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+#ifdef GDISP_NEED_TEXT
+ #include "gdisp_fonts.h"
+#endif
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+#ifdef UNUSED
+#elif defined(__GNUC__)
+# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
+#elif defined(__LCLINT__)
+# define UNUSED(x) /*@unused@*/ x
+#else
+# define UNUSED(x) x
+#endif
+
+#if GDISP_NEED_MULTITHREAD
+ #if !CH_USE_MUTEXES
+ #error "GDISP: CH_USE_MUTEXES must be defined in chconf.h because GDISP_NEED_MULTITHREAD is defined"
+ #endif
+#endif
+
+#if GDISP_NEED_ASYNC
+ #if !CH_USE_MAILBOXES || !CH_USE_MUTEXES || !CH_USE_SEMAPHORES
+ #error "GDISP: CH_USE_MAILBOXES, CH_USE_SEMAPHORES and CH_USE_MUTEXES must be defined in chconf.h because GDISP_NEED_ASYNC is defined"
+ #endif
+#endif
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+#if GDISP_NEED_MULTITHREAD || GDISP_NEED_ASYNC
+ static Mutex gdispMutex;
+#endif
+
+#if GDISP_NEED_ASYNC
+ #define GDISP_THREAD_STACK_SIZE 512 /* Just a number - not yet a reflection of actual use */
+ #define GDISP_QUEUE_SIZE 8 /* We only allow a short queue */
+
+ static Thread * lldThread;
+ static Mailbox gdispMailbox;
+ static msg_t gdispMailboxQueue[GDISP_QUEUE_SIZE];
+ static Semaphore gdispMsgsSem;
+ static Mutex gdispMsgsMutex;
+ static gdisp_lld_msg_t gdispMsgs[GDISP_QUEUE_SIZE];
+ static WORKING_AREA(waGDISPThread, GDISP_THREAD_STACK_SIZE);
+#endif
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+#if GDISP_NEED_ASYNC
+ static msg_t GDISPThreadHandler(void *UNUSED(arg)) {
+ gdisp_lld_msg_t *pmsg;
+
+ #if CH_USE_REGISTRY
+ chRegSetThreadName("GDISPAsyncAPI");
+ #endif
+
+ while(1) {
+ /* Wait for msg with work to do. */
+ chMBFetch(&gdispMailbox, (msg_t *)&pmsg, TIME_INFINITE);
+
+ /* OK - we need to obtain the mutex in case a synchronous operation is occurring */
+ chMtxLock(&gdispMutex);
+ GDISP_LLD(msgdispatch)(pmsg);
+ chMtxUnlock();
+
+ /* Mark the message as free */
+ pmsg->action = GDISP_LLD_MSG_NOP;
+ chSemSignal(&gdispMsgsSem);
+ }
+ return 0;
+ }
+
+ static gdisp_lld_msg_t *gdispAllocMsg(gdisp_msgaction_t action) {
+ gdisp_lld_msg_t *p;
+
+ while(1) { /* To be sure, to be sure */
+
+ /* Wait for a slot */
+ chSemWait(&gdispMsgsSem);
+
+ /* Find the slot */
+ chMtxLock(&gdispMsgsMutex);
+ for(p=gdispMsgs; p < &gdispMsgs[GDISP_QUEUE_SIZE]; p++) {
+ if (p->action == GDISP_LLD_MSG_NOP) {
+ /* Allocate it */
+ p->action = action;
+ chMtxUnlock();
+ return p;
+ }
+ }
+ chMtxUnlock();
+
+ /* Oops - none found, try again */
+ chSemSignal(&gdispMsgsSem);
+ }
+ }
+#endif
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__)
+ /**
+ * @brief GDISP Driver initialization.
+ * @note This function is NOT currently implicitly invoked by @p halInit().
+ * It must be called manually.
+ *
+ * @init
+ */
+ bool_t gdispInit(void) {
+ bool_t res;
+
+ /* Initialise Mutex */
+ chMtxInit(&gdispMutex);
+
+ /* Initialise driver */
+ chMtxLock(&gdispMutex);
+ res = GDISP_LLD(init)();
+ chMtxUnlock();
+
+ return res;
+ }
+#elif GDISP_NEED_ASYNC
+ bool_t gdispInit(void) {
+ bool_t res;
+ unsigned i;
+
+ /* Mark all the Messages as free */
+ for(i=0; i < GDISP_QUEUE_SIZE; i++)
+ gdispMsgs[i].action = GDISP_LLD_MSG_NOP;
+
+ /* Initialise our Mailbox, Mutex's and Counting Semaphore.
+ * A Mutex is required as well as the Mailbox and Thread because some calls have to be synchronous.
+ * Synchronous calls get handled by the calling thread, asynchronous by our worker thread.
+ */
+ chMBInit(&gdispMailbox, gdispMailboxQueue, sizeof(gdispMailboxQueue)/sizeof(gdispMailboxQueue[0]));
+ chMtxInit(&gdispMutex);
+ chMtxInit(&gdispMsgsMutex);
+ chSemInit(&gdispMsgsSem, GDISP_QUEUE_SIZE);
+
+ lldThread = chThdCreateStatic(waGDISPThread, sizeof(waGDISPThread), NORMALPRIO, GDISPThreadHandler, NULL);
+
+ /* Initialise driver - synchronous */
+ chMtxLock(&gdispMutex);
+ res = GDISP_LLD(init)();
+ chMtxUnlock();
+
+ return res;
+ }
+#endif
+
+#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__)
+ /**
+ * @brief Test if the GDISP engine is currently drawing.
+ * @note This function will always return FALSE if
+ * GDISP_NEED_ASYNC is not defined.
+ *
+ * @init
+ */
+ bool_t gdispIsBusy(void) {
+ return FALSE;
+ }
+#elif GDISP_NEED_ASYNC
+ bool_t gdispIsBusy(void) {
+ return chMBGetUsedCountI(&gdispMailbox) != FALSE;
+ }
+#endif
+
+#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__)
+ /**
+ * @brief Clear the display to the specified color.
+ * @pre The GDISP unit must be in powerOn or powerSleep mode.
+ *
+ * @param[in] color The color to use when clearing the screen
+ *
+ * @api
+ */
+ void gdispClear(color_t color) {
+ chMtxLock(&gdispMutex);
+ GDISP_LLD(clear)(color);
+ chMtxUnlock();
+ }
+#elif GDISP_NEED_ASYNC
+ void gdispClear(color_t color) {
+ gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_CLEAR);
+ p->clear.color = color;
+ chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE);
+ }
+#endif
+
+#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__)
+ /**
+ * @brief Set a pixel in the specified color.
+ * @pre The GDISP unit must be in powerOn or powerSleep mode.
+ *
+ * @param[in] x,y The position to set the pixel.
+ * @param[in] color The color to use
+ *
+ * @api
+ */
+ void gdispDrawPixel(coord_t x, coord_t y, color_t color) {
+ chMtxLock(&gdispMutex);
+ GDISP_LLD(drawpixel)(x, y, color);
+ chMtxUnlock();
+ }
+#elif GDISP_NEED_ASYNC
+ void gdispDrawPixel(coord_t x, coord_t y, color_t color) {
+ gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_DRAWPIXEL);
+ p->drawpixel.x = x;
+ p->drawpixel.y = y;
+ p->drawpixel.color = color;
+ chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE);
+ }
+#endif
+
+#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a line.
+ * @pre The GDISP unit must be in powerOn or powerSleep mode.
+ *
+ * @param[in] x0,y0 The start position
+ * @param[in] x1,y1 The end position
+ * @param[in] color The color to use
+ *
+ * @api
+ */
+ void gdispDrawLine(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
+ chMtxLock(&gdispMutex);
+ GDISP_LLD(drawline)(x0, y0, x1, y1, color);
+ chMtxUnlock();
+ }
+#elif GDISP_NEED_ASYNC
+ void gdispDrawLine(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
+ gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_DRAWLINE);
+ p->drawline.x0 = x0;
+ p->drawline.y0 = y0;
+ p->drawline.x1 = x1;
+ p->drawline.y1 = y1;
+ p->drawline.color = color;
+ chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE);
+ }
+#endif
+
+#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__)
+ /**
+ * @brief Fill an area with a color.
+ * @pre The GDISP unit must be in powerOn or powerSleep mode.
+ *
+ * @param[in] x0,y0 The start position
+ * @param[in] cx,cy The size of the box (outside dimensions)
+ * @param[in] color The color to use
+ *
+ * @api
+ */
+ void gdispFillArea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
+ chMtxLock(&gdispMutex);
+ GDISP_LLD(fillarea)(x, y, cx, cy, color);
+ chMtxUnlock();
+ }
+#elif GDISP_NEED_ASYNC
+ void gdispFillArea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
+ gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_FILLAREA);
+ p->fillarea.x = x;
+ p->fillarea.y = y;
+ p->fillarea.cx = cx;
+ p->fillarea.cy = cy;
+ p->fillarea.color = color;
+ chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE);
+ }
+#endif
+
+#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__)
+ /**
+ * @brief Fill an area using the supplied bitmap.
+ * @pre The GDISP unit must be in powerOn or powerSleep mode.
+ * @details The bitmap is in the pixel format specified by the low level driver
+ * @note If a packed pixel format is used and the width doesn't
+ * match a whole number of bytes, the next line will start on a
+ * non-byte boundary (no end-of-line padding).
+ * @note If GDISP_NEED_ASYNC is defined then the buffer must be static
+ * or at least retained until this call has finished the blit. You can
+ * tell when all graphics drawing is finished by @p gdispIsBusy() going FALSE.
+ *
+ * @param[in] x0,y0 The start position
+ * @param[in] cx,cy The size of the filled area
+ * @param[in] buffer The bitmap in the driver's pixel format.
+ *
+ * @api
+ */
+ void gdispBlitArea(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) {
+ chMtxLock(&gdispMutex);
+ GDISP_LLD(blitarea)(x, y, cx, cy, buffer);
+ chMtxUnlock();
+ }
+#elif GDISP_NEED_ASYNC
+ void gdispBlitArea(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) {
+ gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_BLITAREA);
+ p->blitarea.x = x;
+ p->blitarea.y = y;
+ p->blitarea.cx = cx;
+ p->blitarea.cy = cy;
+ p->blitarea.buffer = buffer;
+ chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE);
+ }
+#endif
+
+#if (GDISP_NEED_CIRCLE && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a circle.
+ * @pre The GDISP unit must be in powerOn or powerSleep mode.
+ *
+ * @param[in] x0,y0 The center of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color to use
+ *
+ * @api
+ */
+ void gdispDrawCircle(coord_t x, coord_t y, coord_t radius, color_t color) {
+ chMtxLock(&gdispMutex);
+ GDISP_LLD(drawcircle)(x, y, radius, color);
+ chMtxUnlock();
+ }
+#elif GDISP_NEED_CIRCLE && GDISP_NEED_ASYNC
+ void gdispDrawCircle(coord_t x, coord_t y, coord_t radius, color_t color) {
+ gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_DRAWCIRCLE);
+ p->drawcircle.x = x;
+ p->drawcircle.y = y;
+ p->drawcircle.radius = radius;
+ p->drawcircle.color = color;
+ chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE);
+ }
+#endif
+
+#if (GDISP_NEED_CIRCLE && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a filled circle.
+ * @pre The GDISP unit must be in powerOn or powerSleep mode.
+ *
+ * @param[in] x0,y0 The center of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color to use
+ *
+ * @api
+ */
+ void gdispFillCircle(coord_t x, coord_t y, coord_t radius, color_t color) {
+ chMtxLock(&gdispMutex);
+ GDISP_LLD(fillcircle)(x, y, radius, color);
+ chMtxUnlock();
+ }
+#elif GDISP_NEED_CIRCLE && GDISP_NEED_ASYNC
+ void gdispFillCircle(coord_t x, coord_t y, coord_t radius, color_t color) {
+ gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_FILLCIRCLE);
+ p->fillcircle.x = x;
+ p->fillcircle.y = y;
+ p->fillcircle.radius = radius;
+ p->fillcircle.color = color;
+ chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE);
+ }
+#endif
+
+#if (GDISP_NEED_ELLIPSE && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw an ellipse.
+ * @pre The GDISP unit must be in powerOn or powerSleep mode.
+ *
+ * @param[in] x0,y0 The center of the ellipse
+ * @param[in] a,b The dimensions of the ellipse
+ * @param[in] color The color to use
+ *
+ * @api
+ */
+ void gdispDrawEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ chMtxLock(&gdispMutex);
+ GDISP_LLD(drawellipse)(x, y, a, b, color);
+ chMtxUnlock();
+ }
+#elif GDISP_NEED_ELLIPSE && GDISP_NEED_ASYNC
+ void gdispDrawEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_DRAWELLIPSE);
+ p->drawellipse.x = x;
+ p->drawellipse.y = y;
+ p->drawellipse.a = a;
+ p->drawellipse.b = b;
+ p->drawellipse.color = color;
+ chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE);
+ }
+#endif
+
+#if (GDISP_NEED_ELLIPSE && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a filled ellipse.
+ * @pre The GDISP unit must be in powerOn or powerSleep mode.
+ *
+ * @param[in] x0,y0 The center of the ellipse
+ * @param[in] a,b The dimensions of the ellipse
+ * @param[in] color The color to use
+ *
+ * @api
+ */
+ void gdispFillEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ chMtxLock(&gdispMutex);
+ GDISP_LLD(fillellipse)(x, y, a, b, color);
+ chMtxUnlock();
+ }
+#elif GDISP_NEED_ELLIPSE && GDISP_NEED_ASYNC
+ void gdispFillEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_FILLELLIPSE);
+ p->fillellipse.x = x;
+ p->fillellipse.y = y;
+ p->fillellipse.a = a;
+ p->fillellipse.b = b;
+ p->fillellipse.color = color;
+ chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE);
+ }
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a text character.
+ * @pre The GDISP unit must be in powerOn or powerSleep mode.
+ *
+ * @param[in] x,y The position for the text
+ * @param[in] c The character to draw
+ * @param[in] color The color to use
+ *
+ * @api
+ */
+ void gdispDrawChar(coord_t x, coord_t y, char c, font_t font, color_t color) {
+ chMtxLock(&gdispMutex);
+ GDISP_LLD(drawchar)(x, y, c, font, color);
+ chMtxUnlock();
+ }
+#elif GDISP_NEED_TEXT && GDISP_NEED_ASYNC
+ void gdispDrawChar(coord_t x, coord_t y, char c, font_t font, color_t color) {
+ gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_DRAWCHAR);
+ p->drawchar.x = x;
+ p->drawchar.y = y;
+ p->drawchar.c = c;
+ p->drawchar.font = font;
+ p->drawchar.color = color;
+ chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE);
+ }
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a text character with a filled background.
+ * @pre The GDISP unit must be in powerOn or powerSleep mode.
+ *
+ * @param[in] x,y The position for the text
+ * @param[in] c The character to draw
+ * @param[in] color The color to use
+ * @param[in] bgcolor The background color to use
+ *
+ * @api
+ */
+ void gdispFillChar(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
+ chMtxLock(&gdispMutex);
+ GDISP_LLD(fillchar)(x, y, c, font, color, bgcolor);
+ chMtxUnlock();
+ }
+#elif GDISP_NEED_TEXT && GDISP_NEED_ASYNC
+ void gdispFillChar(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
+ gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_FILLCHAR);
+ p->fillchar.x = x;
+ p->fillchar.y = y;
+ p->fillchar.c = c;
+ p->fillchar.font = font;
+ p->fillchar.color = color;
+ p->fillchar.bgcolor = bgcolor;
+ chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE);
+ }
+#endif
+
+#if (GDISP_NEED_PIXELREAD && (GDISP_NEED_MULTITHREAD || GDISP_NEED_ASYNC)) || defined(__DOXYGEN__)
+ /**
+ * @brief Get the color of a pixel.
+ * @return The color of the pixel.
+ *
+ * @param[in] x,y The position of the pixel
+ *
+ * @api
+ */
+ color_t gdispGetPixelColor(coord_t x, coord_t y) {
+ color_t c;
+
+ /* Always synchronous as it must return a value */
+ chMtxLock(&gdispMutex);
+ c = GDISP_LLD(getpixelcolor)(x, y);
+ chMtxUnlock();
+
+ return c;
+ }
+#endif
+
+#if (GDISP_NEED_SCROLL && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__)
+ /**
+ * @brief Scroll vertically a section of the screen.
+ * @note Optional.
+ * @note If lines is >= cy, it is equivelent to a area fill with bgcolor.
+ *
+ * @param[in] x, y The start of the area to be scrolled
+ * @param[in] cx, cy The size of the area to be scrolled
+ * @param[in] lines The number of lines to scroll (Can be positive or negative)
+ * @param[in] bgcolor The color to fill the newly exposed area.
+ *
+ * @api
+ */
+ void gdispVerticalScroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
+ chMtxLock(&gdispMutex);
+ GDISP_LLD(verticalscroll)(x, y, cx, cy, lines, bgcolor);
+ chMtxUnlock();
+ }
+#elif GDISP_NEED_SCROLL && GDISP_NEED_ASYNC
+ void gdispVerticalScroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
+ gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_VERTICALSCROLL);
+ p->verticalscroll.x = x;
+ p->verticalscroll.y = y;
+ p->verticalscroll.cx = cx;
+ p->verticalscroll.cy = cy;
+ p->verticalscroll.lines = lines;
+ p->verticalscroll.bgcolor = bgcolor;
+ chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE);
+ }
+#endif
+
+#if (GDISP_NEED_CONTROL && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__)
+ /**
+ * @brief Set the power mode for the display.
+ * @pre The GDISP unit must have been initialised using @p gdispInit().
+ * @note Depending on the hardware implementation this function may not
+ * support some codes. They will be ignored.
+ *
+ * @param[in] powerMode The power mode to use
+ *
+ * @api
+ */
+ void gdispControl(unsigned what, void *value) {
+ chMtxLock(&gdispMutex);
+ GDISP_LLD(control)(what, value);
+ chMtxUnlock();
+ }
+#elif GDISP_NEED_CONTROL && GDISP_NEED_ASYNC
+ void gdispControl(unsigned what, void *value) {
+ gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_CONTROL);
+ p->control.what = what;
+ p->control.value = value;
+ chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE);
+ }
+#endif
+
+#if (GDISP_NEED_QUERY && (GDISP_NEED_MULTITHREAD || GDISP_NEED_ASYNC)) || defined(__DOXYGEN__)
+ /**
+ * @brief Query a property of the display.
+ * @pre The GDISP unit must have been initialised using @p gdispInit().
+ * @note The result must be typecast to the correct type.
+ * @note An uunsupported query will return (void *)-1.
+ *
+ * @param[in] what What to query
+ *
+ * @api
+ */
+ void *gdispQuery(unsigned what) {
+ void *res;
+
+ chMtxLock(&gdispMutex);
+ res = GDISP_LLD(query)(what);
+ chMtxUnlock();
+ return res;
+ }
+#endif
+
+/*===========================================================================*/
+/* High Level Driver Routines. */
+/*===========================================================================*/
+
+/**
+ * @brief Draw a rectangular box.
+ * @pre The GDISP unit must be in powerOn or powerSleep mode.
+ *
+ * @param[in] x0,y0 The start position
+ * @param[in] cx,cy The size of the box (outside dimensions)
+ * @param[in] color The color to use
+ * @param[in] filled Should the box should be filled
+ *
+ * @api
+ */
+void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
+ /* No mutex required as we only call high level functions which have their own mutex */
+ coord_t x1, y1;
+
+ x1 = x+cx-1;
+ y1 = y+cy-1;
+
+ if (cx > 2) {
+ if (cy >= 1) {
+ gdispDrawLine(x, y, x1, y, color);
+ if (cy >= 2) {
+ gdispDrawLine(x, y1, x1, y1, color);
+ if (cy > 2) {
+ gdispDrawLine(x, y+1, x, y1-1, color);
+ gdispDrawLine(x1, y+1, x1, y1-1, color);
+ }
+ }
+ }
+ } else if (cx == 2) {
+ gdispDrawLine(x, y, x, y1, color);
+ gdispDrawLine(x1, y, x1, y1, color);
+ } else if (cx == 1) {
+ gdispDrawLine(x, y, x, y1, color);
+ }
+}
+
+#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a text string.
+ * @pre The GDISP unit must be in powerOn or powerSleep mode.
+ *
+ * @param[in] x,y The position for the text
+ * @param[in] str The string to draw
+ * @param[in] color The color to use
+ *
+ * @api
+ */
+ void gdispDrawString(coord_t x, coord_t y, const char *str, font_t font, color_t color) {
+ /* No mutex required as we only call high level functions which have their own mutex */
+ coord_t w, p;
+ char c;
+ int first;
+
+ first = 1;
+ p = font->charPadding * font->xscale;
+ while(*str) {
+ /* Get the next printable character */
+ c = *str++;
+ w = _getCharWidth(font, c) * font->xscale;
+ if (!w) continue;
+
+ /* Handle inter-character padding */
+ if (p) {
+ if (!first)
+ x += p;
+ else
+ first = 0;
+ }
+
+ /* Print the character */
+ gdispDrawChar(x, y, c, font, color);
+ x += w;
+ }
+ }
+#endif
+
+#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a text string.
+ * @pre The GDISP unit must be in powerOn or powerSleep mode.
+ *
+ * @param[in] x,y The position for the text
+ * @param[in] str The string to draw
+ * @param[in] color The color to use
+ * @param[in] bgcolor The background color to use
+ *
+ * @api
+ */
+ void gdispFillString(coord_t x, coord_t y, const char *str, font_t font, color_t color, color_t bgcolor) {
+ /* No mutex required as we only call high level functions which have their own mutex */
+ coord_t w, h, p;
+ char c;
+ int first;
+
+ first = 1;
+ h = font->height * font->yscale;
+ p = font->charPadding * font->xscale;
+ while(*str) {
+ /* Get the next printable character */
+ c = *str++;
+ w = _getCharWidth(font, c) * font->xscale;
+ if (!w) continue;
+
+ /* Handle inter-character padding */
+ if (p) {
+ if (!first) {
+ gdispFillArea(x, y, p, h, bgcolor);
+ x += p;
+ } else
+ first = 0;
+ }
+
+ /* Print the character */
+ gdispFillChar(x, y, c, font, color, bgcolor);
+ x += w;
+ }
+ }
+#endif
+
+#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a text string verticly centered within the specified box.
+ * @pre The GDISP unit must be in powerOn or powerSleep mode.
+ * @note The entire box is filled
+ *
+ * @param[in] x,y The position for the text (need to define top-right or base-line - check code)
+ * @param[in] str The string to draw
+ * @param[in] color The color to use
+ * @param[in] bgcolor The background color to use
+ * @param[in] justify Justify the text left, center or right within the box
+ *
+ * @api
+ */
+ void gdispFillStringBox(coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, font_t font, color_t color, color_t bgcolor, justify_t justify) {
+ /* No mutex required as we only call high level functions which have their own mutex */
+ coord_t w, h, p, ypos, xpos;
+ char c;
+ int first;
+ const char *rstr;
+
+ h = font->height * font->yscale;
+ p = font->charPadding * font->xscale;
+
+ /* Oops - font too large for the area */
+ if (h > cy) return;
+
+ /* See if we need to fill above the font */
+ ypos = (cy - h + 1)/2;
+ if (ypos > 0) {
+ gdispFillArea(x, y, cx, ypos, bgcolor);
+ y += ypos;
+ cy -= ypos;
+ }
+
+ /* See if we need to fill below the font */
+ ypos = cy - h;
+ if (ypos > 0) {
+ gdispFillArea(x, y+cy-ypos, cx, ypos, bgcolor);
+ cy -= ypos;
+ }
+
+ /* get the start of the printable string and the xpos */
+ switch(justify) {
+ case justifyCenter:
+ /* Get the length of the entire string */
+ w = gdispGetStringWidth(str, font);
+ if (w <= cx)
+ xpos = x + (cx - w)/2;
+ else {
+ /* Calculate how much of the string we need to get rid of */
+ ypos = (w - cx)/2;
+ xpos = 0;
+ first = 1;
+ while(*str) {
+ /* Get the next printable character */
+ c = *str++;
+ w = _getCharWidth(font, c) * font->xscale;
+ if (!w) continue;
+
+ /* Handle inter-character padding */
+ if (p) {
+ if (!first) {
+ xpos += p;
+ if (xpos > ypos) break;
+ } else
+ first = 0;
+ }
+
+ /* Print the character */
+ xpos += w;
+ if (xpos > ypos) break;
+ }
+ xpos = ypos - xpos + x;
+ }
+ break;
+ case justifyRight:
+ /* Find the end of the string */
+ for(rstr = str; *str; str++);
+ xpos = x+cx - 2;
+ first = 1;
+ for(str--; str >= rstr; str--) {
+ /* Get the next printable character */
+ c = *str;
+ w = _getCharWidth(font, c) * font->xscale;
+ if (!w) continue;
+
+ /* Handle inter-character padding */
+ if (p) {
+ if (!first) {
+ if (xpos - p < x) break;
+ xpos -= p;
+ } else
+ first = 0;
+ }
+
+ /* Print the character */
+ if (xpos - w < x) break;
+ xpos -= w;
+ }
+ str++;
+ break;
+ case justifyLeft:
+ /* Fall through */
+ default:
+ xpos = x+1;
+ break;
+ }
+
+ /* Fill any space to the left */
+ if (x < xpos)
+ gdispFillArea(x, y, xpos-x, cy, bgcolor);
+
+ /* Print characters until we run out of room */
+ first = 1;
+ while(*str) {
+ /* Get the next printable character */
+ c = *str++;
+ w = _getCharWidth(font, c) * font->xscale;
+ if (!w) continue;
+
+ /* Handle inter-character padding */
+ if (p) {
+ if (!first) {
+ if (xpos + p > x+cx) break;
+ gdispFillArea(xpos, y, p, cy, bgcolor);
+ xpos += p;
+ } else
+ first = 0;
+ }
+
+ /* Print the character */
+ if (xpos + w > x+cx) break;
+ gdispFillChar(xpos, y, c, font, color, bgcolor);
+ xpos += w;
+ }
+
+ /* Fill any space to the right */
+ if (xpos < x+cx)
+ gdispFillArea(xpos, y, x+cx-xpos, cy, bgcolor);
+ }
+#endif
+
+#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
+ /**
+ * @brief Get a metric of a font.
+ * @return The metric requested in pixels.
+ *
+ * @param[in] font The font to test
+ * @param[in] metric The metric to measure
+ *
+ * @api
+ */
+ coord_t gdispGetFontMetric(font_t font, fontmetric_t metric) {
+ /* No mutex required as we only read static data */
+ switch(metric) {
+ case fontHeight: return font->height * font->yscale;
+ case fontDescendersHeight: return font->descenderHeight * font->yscale;
+ case fontLineSpacing: return font->lineSpacing * font->yscale;
+ case fontCharPadding: return font->charPadding * font->xscale;
+ case fontMinWidth: return font->minWidth * font->xscale;
+ case fontMaxWidth: return font->maxWidth * font->xscale;
+ }
+ return 0;
+ }
+#endif
+
+#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
+ /**
+ * @brief Get the pixel width of a character.
+ * @return The width of the character in pixels. Does not include any between character padding.
+ *
+ * @param[in] c The character to draw
+ * @param[in] font The font to use
+ *
+ * @api
+ */
+ coord_t gdispGetCharWidth(char c, font_t font) {
+ /* No mutex required as we only read static data */
+ return _getCharWidth(font, c) * font->xscale;
+ }
+#endif
+
+#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
+ /**
+ * @brief Get the pixel width of a string.
+ * @return The width of the string in pixels.
+ *
+ * @param[in] str The string to measure
+ * @param[in] font The font to use
+ *
+ * @api
+ */
+ coord_t gdispGetStringWidth(const char* str, font_t font) {
+ /* No mutex required as we only read static data */
+ coord_t w, p, x;
+ char c;
+ int first;
+
+ first = 1;
+ x = 0;
+ p = font->charPadding * font->xscale;
+ while(*str) {
+ /* Get the next printable character */
+ c = *str++;
+ w = _getCharWidth(font, c) * font->xscale;
+ if (!w) continue;
+
+ /* Handle inter-character padding */
+ if (p) {
+ if (!first)
+ x += p;
+ else
+ first = 0;
+ }
+
+ /* Add the character width */
+ x += w;
+ }
+ return x;
+ }
+#endif
+
+#if (!defined(gdispPackPixels) && !defined(GDISP_PIXELFORMAT_CUSTOM)) || defined(__DOXYGEN__)
+ /**
+ * @brief Pack a pixel into a pixel buffer.
+ * @note This function performs no buffer boundary checking
+ * regardless of whether GDISP_NEED_CLIPPING has been specified.
+ *
+ * @param[in] buf The buffer to put the pixel in
+ * @param[in] cx The width of a pixel line
+ * @param[in] x, y The location of the pixel to place
+ * @param[in] color The color to put into the buffer
+ *
+ * @api
+ */
+ void gdispPackPixels(pixel_t *buf, coord_t cx, coord_t x, coord_t y, color_t color) {
+ /* No mutex required as we only read static data */
+ #if defined(GDISP_PIXELFORMAT_RGB888)
+ #error "GDISP: Packed pixels not supported yet"
+ #elif defined(GDISP_PIXELFORMAT_RGB444)
+ #error "GDISP: Packed pixels not supported yet"
+ #elif defined(GDISP_PIXELFORMAT_RGB666)
+ #error "GDISP: Packed pixels not supported yet"
+ #elif
+ #error "GDISP: Unsupported packed pixel format"
+ #endif
+ }
+#endif
+
+#endif /* HAL_USE_GDISP */
+
+#endif /* _GDISP_C */
+/** @} */
diff --git a/src/gdisp_fonts.c b/src/gdisp_fonts.c
new file mode 100644
index 00000000..25a56526
--- /dev/null
+++ b/src/gdisp_fonts.c
@@ -0,0 +1,655 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ Font tables included into gdisp.c
+*/
+#include "ch.h"
+#include "hal.h"
+#include "gdisp.h"
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+#if GDISP_NEED_TEXT
+
+#include "gdisp_fonts.h"
+
+
+/* fontSmall - for side buttons */
+#if 1
+ /* Forward Declarations of internal arrays */
+ static const uint8_t fontSmall_Widths[];
+ static const uint16_t fontSmall_Offsets[];
+ static const fontcolumn_t fontSmall_Data[];
+
+ const struct font fontSmall = { 11, 0, 14, 2, 2, 12, ' ', '~', 1, 1,
+ fontSmall_Widths,
+ fontSmall_Offsets,
+ fontSmall_Data};
+ const struct font fontSmallDouble = { 11, 0, 14, 2, 2, 12, ' ', '~', 2, 2,
+ fontSmall_Widths,
+ fontSmall_Offsets,
+ fontSmall_Data};
+ const struct font fontSmallNarrow = { 11, 0, 14, 2, 2, 12, ' ', '~', 1, 2,
+ fontSmall_Widths,
+ fontSmall_Offsets,
+ fontSmall_Data};
+
+ static const uint8_t fontSmall_Widths[] = {
+ 2, 3, 6, 8, 7, 9, 7, 3, 4, 4, 5, 7, 4, 4, 3, 6,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 4, 6, 7, 6, 7,
+ 12, 8, 7, 8, 8, 7, 7, 8, 8, 3, 5, 8, 7, 9, 8, 8,
+ 8, 8, 8, 7, 7, 8, 8, 12, 8, 8, 8, 4, 6, 4, 7, 7,
+ 4, 7, 7, 7, 7, 7, 4, 7, 7, 3, 3, 7, 3, 9, 7, 7,
+ 7, 7, 4, 6, 4, 7, 7, 9, 6, 6, 6, 5, 3, 5, 8, 0
+ };
+ static const uint16_t fontSmall_Offsets[] = {
+ 0, 2, 5, 11, 19, 26, 35, 42,
+ 45, 49, 53, 58, 65, 69, 73, 76,
+ 82, 89, 96, 103, 110, 117, 124, 131,
+ 138, 145, 152, 155, 159, 165, 172, 178,
+ 185, 197, 205, 212, 220, 228, 235, 242,
+ 250, 258, 261, 266, 274, 281, 290, 298,
+ 306, 314, 322, 330, 337, 344, 352, 360,
+ 372, 380, 388, 396, 400, 406, 410, 417,
+ 424, 428, 435, 442, 449, 456, 463, 467,
+ 474, 481, 484, 487, 494, 497, 506, 513,
+ 520, 527, 534, 538, 544, 548, 555, 562,
+ 571, 577, 583, 589, 594, 597, 602, 0
+ };
+ static const fontcolumn_t fontSmall_Data[] = {
+ /* */ 0x0000, 0x0000,
+ /* ! */ 0x0000, 0x017F, 0x017F,
+ /* " */ 0x0000, 0x0007, 0x0007, 0x0000, 0x0007, 0x0007,
+ /* # */ 0x0000, 0x0044, 0x01FF, 0x01FF, 0x0044, 0x01FF, 0x01FF, 0x0044,
+ /* $ */ 0x0000, 0x008C, 0x019E, 0x03FF, 0x03FF, 0x01E6, 0x00C4,
+ /* % */ 0x0000, 0x0082, 0x00C7, 0x0065, 0x00B7, 0x01DA, 0x014C, 0x01C6, 0x0082,
+ /* & */ 0x0000, 0x00E6, 0x01FF, 0x013F, 0x01E6, 0x01E0, 0x0120,
+ /* ' */ 0x0000, 0x0007, 0x0007,
+ /* ( */ 0x0000, 0x03FE, 0x07FF, 0x0401,
+ /* ) */ 0x0000, 0x0401, 0x07FF, 0x03FE,
+ /* * */ 0x0000, 0x000A, 0x000E, 0x000E, 0x000A,
+ /* + */ 0x0000, 0x0020, 0x0020, 0x00F8, 0x00F8, 0x0020, 0x0020,
+ /* , */ 0x0000, 0x0200, 0x0300, 0x0100,
+ /* - */ 0x0000, 0x0020, 0x0020, 0x0020,
+ /* . */ 0x0000, 0x0100, 0x0100,
+ /* / */ 0x0000, 0x0180, 0x01E0, 0x0078, 0x001F, 0x0007,
+ /* 0 */ 0x0000, 0x00FE, 0x01FF, 0x0101, 0x0101, 0x01FF, 0x00FE,
+ /* 1 */ 0x0000, 0x0002, 0x0002, 0x01FF, 0x01FF, 0x0000, 0x0000,
+ /* 2 */ 0x0000, 0x0182, 0x01C3, 0x0161, 0x0131, 0x011F, 0x010E,
+ /* 3 */ 0x0000, 0x0082, 0x0183, 0x0111, 0x0111, 0x01FF, 0x00EE,
+ /* 4 */ 0x0000, 0x0060, 0x0078, 0x005E, 0x01FF, 0x01FF, 0x0040,
+ /* 5 */ 0x0000, 0x009F, 0x019F, 0x0109, 0x0109, 0x01F9, 0x00F1,
+ /* 6 */ 0x0000, 0x00FE, 0x01FF, 0x0111, 0x0111, 0x01F3, 0x00E2,
+ /* 7 */ 0x0000, 0x0001, 0x01C1, 0x01F1, 0x003D, 0x000F, 0x0003,
+ /* 8 */ 0x0000, 0x00EE, 0x01FF, 0x0111, 0x0111, 0x01FF, 0x00EE,
+ /* 9 */ 0x0000, 0x008E, 0x019F, 0x0111, 0x0111, 0x01FF, 0x00FE,
+ /* : */ 0x0000, 0x0108, 0x0108,
+ /* ; */ 0x0000, 0x0200, 0x0308, 0x0108,
+ /* < */ 0x0000, 0x0020, 0x0070, 0x00D8, 0x018C, 0x0104,
+ /* = */ 0x0000, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050,
+ /* > */ 0x0000, 0x0104, 0x018C, 0x00D8, 0x0070, 0x0020,
+ /* ? */ 0x0000, 0x0002, 0x0003, 0x0161, 0x0171, 0x001F, 0x000E,
+ /* @ */ 0x0000, 0x0078, 0x01FE, 0x0186, 0x0333, 0x0279, 0x0249, 0x0279, 0x027B, 0x0246, 0x007E, 0x0078,
+ /* A */ 0x0180, 0x01F0, 0x007C, 0x004F, 0x004F, 0x007C, 0x01F0, 0x0180,
+ /* B */ 0x0000, 0x01FF, 0x01FF, 0x0111, 0x0111, 0x01FF, 0x00EE,
+ /* C */ 0x0000, 0x00FE, 0x01FF, 0x0101, 0x0101, 0x0101, 0x0183, 0x0082,
+ /* D */ 0x0000, 0x01FF, 0x01FF, 0x0101, 0x0101, 0x0183, 0x00FE, 0x007C,
+ /* E */ 0x0000, 0x01FF, 0x01FF, 0x0111, 0x0111, 0x0111, 0x0101,
+ /* F */ 0x0000, 0x01FF, 0x01FF, 0x0011, 0x0011, 0x0011, 0x0001,
+ /* G */ 0x0000, 0x00FE, 0x01FF, 0x0101, 0x0111, 0x0191, 0x01F3, 0x01F2,
+ /* H */ 0x0000, 0x01FF, 0x01FF, 0x0010, 0x0010, 0x0010, 0x01FF, 0x01FF,
+ /* I */ 0x0000, 0x01FF, 0x01FF,
+ /* J */ 0x00C0, 0x01C0, 0x0100, 0x01FF, 0x00FF,
+ /* K */ 0x0000, 0x01FF, 0x01FF, 0x003C, 0x0066, 0x00C3, 0x0181, 0x0100,
+ /* L */ 0x0000, 0x01FF, 0x01FF, 0x0100, 0x0100, 0x0100, 0x0100,
+ /* M */ 0x0000, 0x01FF, 0x01FF, 0x003C, 0x00F0, 0x00F0, 0x003C, 0x01FF, 0x01FF,
+ /* N */ 0x0000, 0x01FF, 0x01FF, 0x001E, 0x0038, 0x00E0, 0x01FF, 0x01FF,
+ /* O */ 0x0000, 0x00FE, 0x01FF, 0x0101, 0x0101, 0x0101, 0x01FF, 0x00FE,
+ /* P */ 0x0000, 0x01FF, 0x01FF, 0x0011, 0x0011, 0x0011, 0x001F, 0x000E,
+ /* Q */ 0x0000, 0x00FE, 0x01FF, 0x0101, 0x0141, 0x01C1, 0x03FF, 0x02FE,
+ /* R */ 0x0000, 0x01FF, 0x01FF, 0x0011, 0x0011, 0x0011, 0x01FF, 0x01EE,
+ /* S */ 0x0000, 0x008E, 0x019F, 0x0111, 0x0111, 0x01F3, 0x00E2,
+ /* T */ 0x0000, 0x0001, 0x0001, 0x01FF, 0x01FF, 0x0001, 0x0001,
+ /* U */ 0x0000, 0x00FF, 0x01FF, 0x0100, 0x0100, 0x0100, 0x01FF, 0x00FF,
+ /* V */ 0x0003, 0x001F, 0x007C, 0x01E0, 0x01E0, 0x007C, 0x001F, 0x0003,
+ /* W */ 0x0003, 0x001F, 0x007C, 0x01E0, 0x01E0, 0x007C, 0x007C, 0x01E0, 0x01E0, 0x007C, 0x001F, 0x0003,
+ /* X */ 0x0183, 0x01C7, 0x006C, 0x0038, 0x0038, 0x006C, 0x01C7, 0x0183,
+ /* Y */ 0x0003, 0x0007, 0x000C, 0x01F8, 0x01F8, 0x000C, 0x0007, 0x0003,
+ /* Z */ 0x0181, 0x01C1, 0x0161, 0x0131, 0x0119, 0x010D, 0x0107, 0x0103,
+ /* [ */ 0x0000, 0x07FF, 0x07FF, 0x0401,
+ /* \ */ 0x0000, 0x0007, 0x001F, 0x0078, 0x01E0, 0x0180,
+ /* ] */ 0x0000, 0x0401, 0x07FF, 0x07FF,
+ /* ^ */ 0x0000, 0x0002, 0x0003, 0x0001, 0x0001, 0x0003, 0x0002,
+ /* _ */ 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400,
+ /* ` */ 0x0000, 0x0001, 0x0003, 0x0002,
+ /* a */ 0x0000, 0x00C0, 0x01E8, 0x0128, 0x0128, 0x01F8, 0x01F0,
+ /* b */ 0x0000, 0x01FF, 0x01FF, 0x0108, 0x0108, 0x01F8, 0x00F0,
+ /* c */ 0x0000, 0x00F0, 0x01F8, 0x0108, 0x0108, 0x0198, 0x0090,
+ /* d */ 0x0000, 0x00F0, 0x01F8, 0x0108, 0x0108, 0x01FF, 0x01FF,
+ /* e */ 0x0000, 0x00F0, 0x01F8, 0x0128, 0x0128, 0x01B8, 0x00B0,
+ /* f */ 0x0000, 0x01FE, 0x01FF, 0x0009,
+ /* g */ 0x0000, 0x04F0, 0x05F8, 0x0508, 0x0508, 0x07F8, 0x03F8,
+ /* h */ 0x0000, 0x01FF, 0x01FF, 0x0018, 0x0008, 0x01F8, 0x01F0,
+ /* i */ 0x0000, 0x01F9, 0x01F9,
+ /* j */ 0x0000, 0x07F9, 0x07F9,
+ /* k */ 0x0000, 0x01FF, 0x01FF, 0x0070, 0x00D8, 0x0188, 0x0100,
+ /* l */ 0x0000, 0x01FF, 0x01FF,
+ /* m */ 0x0000, 0x01F8, 0x01F8, 0x0008, 0x01F8, 0x01F8, 0x0008, 0x01F8, 0x01F0,
+ /* n */ 0x0000, 0x01F8, 0x01F8, 0x0018, 0x0008, 0x01F8, 0x01F0,
+ /* o */ 0x0000, 0x00F0, 0x01F8, 0x0108, 0x0108, 0x01F8, 0x00F0,
+ /* p */ 0x0000, 0x07F8, 0x07F8, 0x0108, 0x0108, 0x01F8, 0x00F0,
+ /* q */ 0x0000, 0x00F0, 0x01F8, 0x0108, 0x0108, 0x07F8, 0x07F8,
+ /* r */ 0x0000, 0x01F8, 0x01F8, 0x0008,
+ /* s */ 0x0000, 0x0090, 0x01B8, 0x0168, 0x01D8, 0x0090,
+ /* t */ 0x0000, 0x00FE, 0x01FE, 0x0108,
+ /* u */ 0x0000, 0x00F8, 0x01F8, 0x0100, 0x0180, 0x01F8, 0x01F8,
+ /* v */ 0x0000, 0x0018, 0x0078, 0x01E0, 0x01E0, 0x0078, 0x0018,
+ /* w */ 0x0000, 0x0078, 0x01F8, 0x01E0, 0x0078, 0x0078, 0x01E0, 0x01F8, 0x0078,
+ /* x */ 0x0000, 0x0198, 0x01F8, 0x0060, 0x01F8, 0x0198,
+ /* y */ 0x0400, 0x0478, 0x07F8, 0x0380, 0x00F8, 0x0078,
+ /* z */ 0x0000, 0x0188, 0x01C8, 0x0168, 0x0138, 0x0118,
+ /* { */ 0x0000, 0x0010, 0x01FF, 0x03EF, 0x0200,
+ /* | */ 0x0000, 0x03FF, 0x03FF,
+ /* } */ 0x0000, 0x0200, 0x03EF, 0x01FF, 0x0010,
+ /* ~ */ 0x0000, 0x0004, 0x0006, 0x0002, 0x0006, 0x0004, 0x0006, 0x0002
+ };
+#endif
+
+/* fontLarger - Tahoma, 11, Bold */
+#if 1
+ /* Forward Declarations of internal arrays */
+ static const uint8_t fontLarger_Widths[];
+ static const uint16_t fontLarger_Offsets[];
+ static const fontcolumn_t fontLarger_Data[];
+
+ const struct font fontLarger = { 12, 1, 13, 2, 2, 13, ' ', '~', 1, 1,
+ fontLarger_Widths,
+ fontLarger_Offsets,
+ fontLarger_Data};
+ const struct font fontLargerDouble = { 12, 1, 13, 2, 2, 13, ' ', '~', 2, 2,
+ fontLarger_Widths,
+ fontLarger_Offsets,
+ fontLarger_Data};
+ const struct font fontLargerNarrow = { 12, 1, 13, 2, 2, 13, ' ', '~', 1, 2,
+ fontLarger_Widths,
+ fontLarger_Offsets,
+ fontLarger_Data};
+ static const uint8_t fontLarger_Widths[] = {
+ 2, 3, 5, 8, 7, 13, 8, 2, 4, 4, 7, 8, 3, 4, 3, 5,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 9, 8, 9, 6,
+ 9, 8, 7, 7, 8, 6, 5, 7, 8, 4, 5, 7, 6, 10, 7, 8,
+ 7, 8, 8, 7, 6, 7, 7, 11, 7, 6, 6, 4, 5, 4, 9, 8,
+ 5, 6, 7, 5, 7, 6, 5, 7, 7, 2, 3, 6, 2, 10, 7, 7,
+ 7, 7, 4, 5, 5, 7, 6, 10, 6, 6, 5, 6, 4, 6, 9, 0
+ };
+ static const uint16_t fontLarger_Offsets[] = {
+ 0, 2, 5, 10, 18, 25, 38, 46,
+ 48, 52, 56, 63, 71, 74, 78, 81,
+ 86, 93, 100, 107, 114, 121, 128, 135,
+ 142, 149, 156, 159, 162, 171, 179, 188,
+ 194, 203, 211, 218, 225, 233, 239, 244,
+ 251, 259, 263, 268, 275, 281, 291, 298,
+ 306, 313, 321, 329, 336, 342, 349, 356,
+ 367, 374, 380, 386, 390, 395, 399, 408,
+ 416, 421, 427, 434, 439, 446, 452, 457,
+ 464, 471, 473, 476, 482, 484, 494, 501,
+ 508, 515, 522, 526, 531, 536, 543, 549,
+ 559, 565, 571, 576, 582, 586, 592, 0
+ };
+ static const fontcolumn_t fontLarger_Data[] = {
+ /* */ 0x0000, 0x0000,
+ /* ! */ 0x0000, 0x037E, 0x037E,
+ /* " */ 0x0007, 0x0007, 0x0000, 0x0007, 0x0007,
+ /* # */ 0x00C0, 0x03D8, 0x00F8, 0x00DE, 0x03D8, 0x00F8, 0x00DE, 0x0018,
+ /* $ */ 0x0118, 0x023C, 0x0264, 0x0FFF, 0x0264, 0x03C4, 0x0188,
+ /* % */ 0x001C, 0x003E, 0x0022, 0x023E, 0x011C, 0x00C0, 0x0020, 0x0018, 0x01C4, 0x03E2, 0x0220, 0x03E0,
+ 0x01C0,
+ /* & */ 0x01CC, 0x03FE, 0x0232, 0x0272, 0x03DE, 0x018C, 0x03E0, 0x0260,
+ /* ' */ 0x0007, 0x0007,
+ /* ( */ 0x01F8, 0x07FE, 0x0E07, 0x0801,
+ /* ) */ 0x0801, 0x0E07, 0x07FE, 0x01F8,
+ /* * */ 0x0000, 0x000A, 0x0004, 0x001F, 0x001F, 0x0004, 0x000A,
+ /* + */ 0x0000, 0x0020, 0x0020, 0x0020, 0x01FC, 0x0020, 0x0020, 0x0020,
+ /* , */ 0x0000, 0x0F00, 0x0700,
+ /* - */ 0x0020, 0x0020, 0x0020, 0x0020,
+ /* . */ 0x0000, 0x0300, 0x0300,
+ /* / */ 0x0C00, 0x0380, 0x0060, 0x001C, 0x0003,
+ /* 0 */ 0x01FC, 0x03FE, 0x0202, 0x0202, 0x0202, 0x03FE, 0x01FC,
+ /* 1 */ 0x0000, 0x0204, 0x0204, 0x03FE, 0x03FE, 0x0200, 0x0200,
+ /* 2 */ 0x0204, 0x0302, 0x0382, 0x02C2, 0x0262, 0x023E, 0x021C,
+ /* 3 */ 0x0104, 0x0202, 0x0222, 0x0222, 0x0222, 0x03FE, 0x01DC,
+ /* 4 */ 0x0060, 0x0050, 0x0048, 0x0044, 0x03FE, 0x03FE, 0x0040,
+ /* 5 */ 0x0100, 0x021E, 0x021E, 0x0212, 0x0212, 0x03F2, 0x01E2,
+ /* 6 */ 0x01F8, 0x03FC, 0x0216, 0x0212, 0x0212, 0x03F2, 0x01E0,
+ /* 7 */ 0x0002, 0x0002, 0x0382, 0x03E2, 0x007A, 0x001E, 0x0006,
+ /* 8 */ 0x01DC, 0x03FE, 0x0222, 0x0222, 0x0222, 0x03FE, 0x01DC,
+ /* 9 */ 0x003C, 0x027E, 0x0242, 0x0242, 0x0342, 0x01FE, 0x00FC,
+ /* : */ 0x0000, 0x0318, 0x0318,
+ /* ; */ 0x0000, 0x0F18, 0x0718,
+ /* < */ 0x0000, 0x0060, 0x0060, 0x0090, 0x0090, 0x0108, 0x0108, 0x0204, 0x0204,
+ /* = */ 0x0000, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090,
+ /* > */ 0x0000, 0x0204, 0x0204, 0x0108, 0x0108, 0x0090, 0x0090, 0x0060, 0x0060,
+ /* ? */ 0x0004, 0x0002, 0x0362, 0x0372, 0x001E, 0x000C,
+ /* @ */ 0x01F8, 0x0204, 0x04F2, 0x05FA, 0x050A, 0x04FA, 0x05FA, 0x0104, 0x00F8,
+ /* A */ 0x0380, 0x03F0, 0x00FC, 0x008E, 0x008E, 0x00FC, 0x03F0, 0x0380,
+ /* B */ 0x03FE, 0x03FE, 0x0222, 0x0222, 0x0222, 0x03FE, 0x01DC,
+ /* C */ 0x01FC, 0x03FE, 0x0202, 0x0202, 0x0202, 0x0202, 0x018C,
+ /* D */ 0x03FE, 0x03FE, 0x0202, 0x0202, 0x0202, 0x0306, 0x01FC, 0x00F8,
+ /* E */ 0x03FE, 0x03FE, 0x0222, 0x0222, 0x0222, 0x0222,
+ /* F */ 0x03FE, 0x03FE, 0x0022, 0x0022, 0x0022,
+ /* G */ 0x01FC, 0x03FE, 0x0202, 0x0202, 0x0222, 0x03E2, 0x03EC,
+ /* H */ 0x03FE, 0x03FE, 0x0020, 0x0020, 0x0020, 0x0020, 0x03FE, 0x03FE,
+ /* I */ 0x0202, 0x03FE, 0x03FE, 0x0202,
+ /* J */ 0x0200, 0x0202, 0x0202, 0x03FE, 0x01FE,
+ /* K */ 0x03FE, 0x03FE, 0x0070, 0x00D8, 0x018C, 0x0306, 0x0202,
+ /* L */ 0x03FE, 0x03FE, 0x0200, 0x0200, 0x0200, 0x0200,
+ /* M */ 0x03FE, 0x000E, 0x001C, 0x0038, 0x0070, 0x0030, 0x0018, 0x000C, 0x03FE, 0x03FE,
+ /* N */ 0x03FE, 0x000E, 0x001C, 0x0070, 0x01E0, 0x0380, 0x03FE,
+ /* O */ 0x01FC, 0x03FE, 0x0202, 0x0202, 0x0202, 0x0202, 0x03FE, 0x01FC,
+ /* P */ 0x03FE, 0x03FE, 0x0042, 0x0042, 0x0042, 0x007E, 0x003C,
+ /* Q */ 0x01FC, 0x03FE, 0x0202, 0x0202, 0x0602, 0x0E02, 0x0BFE, 0x09FC,
+ /* R */ 0x03FE, 0x03FE, 0x0022, 0x0062, 0x00E2, 0x01BE, 0x031C, 0x0200,
+ /* S */ 0x019C, 0x023E, 0x0222, 0x0222, 0x0222, 0x03E2, 0x01CC,
+ /* T */ 0x0002, 0x0002, 0x03FE, 0x03FE, 0x0002, 0x0002,
+ /* U */ 0x01FE, 0x03FE, 0x0200, 0x0200, 0x0200, 0x03FE, 0x01FE,
+ /* V */ 0x000E, 0x007E, 0x03F0, 0x0380, 0x03F0, 0x007E, 0x000E,
+ /* W */ 0x001E, 0x00FE, 0x03E0, 0x03E0, 0x00FC, 0x000E, 0x00FC, 0x03E0, 0x03E0, 0x00FE, 0x001E,
+ /* X */ 0x0306, 0x038E, 0x00F8, 0x0070, 0x00F8, 0x038E, 0x0306,
+ /* Y */ 0x000E, 0x003E, 0x03F0, 0x03F0, 0x003E, 0x000E,
+ /* Z */ 0x0382, 0x03C2, 0x0262, 0x0232, 0x021E, 0x020E,
+ /* [ */ 0x0FFF, 0x0FFF, 0x0801, 0x0801,
+ /* \ */ 0x0003, 0x001C, 0x0060, 0x0380, 0x0C00,
+ /* ] */ 0x0801, 0x0801, 0x0FFF, 0x0FFF,
+ /* ^ */ 0x0000, 0x0010, 0x0008, 0x0004, 0x0002, 0x0002, 0x0004, 0x0008, 0x0010,
+ /* _ */ 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800,
+ /* ` */ 0x0000, 0x0000, 0x0001, 0x0003, 0x0002,
+ /* a */ 0x0180, 0x03D0, 0x0248, 0x0248, 0x03F8, 0x03F0,
+ /* b */ 0x03FF, 0x03FF, 0x0210, 0x0208, 0x0208, 0x03F8, 0x01F0,
+ /* c */ 0x01F0, 0x03F8, 0x0208, 0x0208, 0x0208,
+ /* d */ 0x01F0, 0x03F8, 0x0208, 0x0208, 0x0108, 0x03FF, 0x03FF,
+ /* e */ 0x01F0, 0x03F8, 0x0248, 0x0248, 0x0278, 0x0170,
+ /* f */ 0x0008, 0x03FE, 0x03FF, 0x0009, 0x0001,
+ /* g */ 0x01F0, 0x0BF8, 0x0A08, 0x0A08, 0x0908, 0x0FF8, 0x07F8,
+ /* h */ 0x03FF, 0x03FF, 0x0010, 0x0008, 0x0008, 0x03F8, 0x03F0,
+ /* i */ 0x03FA, 0x03FA,
+ /* j */ 0x0808, 0x0FFA, 0x07FA,
+ /* k */ 0x03FF, 0x03FF, 0x00E0, 0x01B0, 0x0318, 0x0208,
+ /* l */ 0x03FF, 0x03FF,
+ /* m */ 0x03F8, 0x03F8, 0x0008, 0x0008, 0x03F8, 0x03F0, 0x0008, 0x0008, 0x03F8, 0x03F0,
+ /* n */ 0x03F8, 0x03F8, 0x0010, 0x0008, 0x0008, 0x03F8, 0x03F0,
+ /* o */ 0x01F0, 0x03F8, 0x0208, 0x0208, 0x0208, 0x03F8, 0x01F0,
+ /* p */ 0x0FF8, 0x0FF8, 0x0210, 0x0208, 0x0208, 0x03F8, 0x01F0,
+ /* q */ 0x01F0, 0x03F8, 0x0208, 0x0208, 0x0108, 0x0FF8, 0x0FF8,
+ /* r */ 0x03F8, 0x03F8, 0x0010, 0x0018,
+ /* s */ 0x0130, 0x0278, 0x0248, 0x03C8, 0x0190,
+ /* t */ 0x0008, 0x01FE, 0x03FE, 0x0208, 0x0208,
+ /* u */ 0x01F8, 0x03F8, 0x0200, 0x0200, 0x0100, 0x03F8, 0x03F8,
+ /* v */ 0x0038, 0x00F8, 0x03C0, 0x03C0, 0x00F8, 0x0038,
+ /* w */ 0x0018, 0x00F8, 0x03E0, 0x0380, 0x00F8, 0x00F8, 0x0380, 0x03E0, 0x00F8, 0x0018,
+ /* x */ 0x0318, 0x03B8, 0x00E0, 0x00E0, 0x03B8, 0x0318,
+ /* y */ 0x0038, 0x0CF8, 0x0FC0, 0x03C0, 0x00F8, 0x0038,
+ /* z */ 0x0388, 0x03C8, 0x0268, 0x0238, 0x0218,
+ /* { */ 0x0020, 0x0020, 0x07FE, 0x0FDF, 0x0801, 0x0801,
+ /* | */ 0x0000, 0x0000, 0x0FFF, 0x0FFF,
+ /* } */ 0x0801, 0x0801, 0x0FDF, 0x07FE, 0x0020, 0x0020,
+ /* ~ */ 0x00E0, 0x0030, 0x0030, 0x0030, 0x0060, 0x00C0, 0x00C0, 0x00C0, 0x0070
+ };
+#endif
+
+/* fontUI1 - UI Font 1 Medium Bold */
+#if 1
+ /* Forward Declarations of internal arrays */
+ static const uint8_t fontUI1_Widths[];
+ static const uint16_t fontUI1_Offsets[];
+ static const fontcolumn_t fontUI1_Data[];
+
+ const struct font fontUI1 = { 13, 0, 15, 2, 3, 13, ' ', '~', 1, 1,
+ fontUI1_Widths,
+ fontUI1_Offsets,
+ fontUI1_Data};
+ const struct font fontUI1Double = { 13, 0, 15, 2, 3, 13, ' ', '~', 2, 2,
+ fontUI1_Widths,
+ fontUI1_Offsets,
+ fontUI1_Data};
+ const struct font fontUI1Narrow = { 13, 0, 15, 2, 3, 13, ' ', '~', 1, 2,
+ fontUI1_Widths,
+ fontUI1_Offsets,
+ fontUI1_Data};
+
+ static const uint8_t fontUI1_Widths[] = {
+ 3, 3, 6, 8, 7, 13, 9, 3, 5, 5, 6, 8, 3, 5, 3, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 8, 8, 8, 6,
+ 10, 8, 7, 7, 8, 7, 7, 8, 8, 5, 5, 7, 7, 9, 8, 8,
+ 7, 8, 8, 7, 8, 8, 7, 11, 7, 7, 7, 5, 7, 5, 9, 8,
+ 5, 7, 7, 6, 7, 7, 5, 7, 7, 3, 4, 7, 3, 11, 7, 7,
+ 7, 7, 6, 6, 5, 7, 7, 9, 7, 7, 6, 7, 4, 7, 8, 0
+ };
+ static const uint16_t fontUI1_Offsets[] = {
+ 0, 3, 6, 12, 20, 27, 40, 49,
+ 52, 57, 62, 68, 76, 79, 84, 87,
+ 94, 101, 108, 115, 122, 129, 136, 143,
+ 150, 157, 164, 167, 170, 178, 186, 194,
+ 200, 210, 218, 225, 232, 240, 247, 254,
+ 262, 270, 275, 280, 287, 294, 303, 311,
+ 319, 326, 334, 342, 349, 357, 365, 372,
+ 383, 390, 397, 404, 409, 416, 421, 430,
+ 438, 443, 450, 457, 463, 470, 477, 482,
+ 489, 496, 499, 503, 510, 513, 524, 531,
+ 538, 545, 552, 558, 564, 569, 576, 583,
+ 592, 599, 606, 612, 619, 623, 630, 0
+ };
+ static const fontcolumn_t fontUI1_Data[] = {
+ /* */ 0x0000, 0x0000, 0x0000,
+ /* ! */ 0x0000, 0x02FC, 0x02FC,
+ /* " */ 0x0000, 0x000E, 0x000E, 0x0000, 0x000E, 0x000E,
+ /* # */ 0x0000, 0x0080, 0x0390, 0x00F0, 0x039C, 0x00F0, 0x009C, 0x0010,
+ /* $ */ 0x0000, 0x0130, 0x0278, 0x0FC8, 0x027E, 0x03C8, 0x0190,
+ /* % */ 0x0000, 0x0038, 0x007C, 0x0044, 0x007C, 0x0338, 0x00C0, 0x0030, 0x01CC, 0x03E0, 0x0220, 0x03E0,
+ 0x01C0,
+ /* & */ 0x0000, 0x01D8, 0x03FC, 0x0224, 0x027C, 0x02D8, 0x0180, 0x0360, 0x0220,
+ /* ' */ 0x0000, 0x000E, 0x000E,
+ /* ( */ 0x0000, 0x01F0, 0x07FC, 0x0E0E, 0x0802,
+ /* ) */ 0x0000, 0x0802, 0x0E0E, 0x07FC, 0x01F0,
+ /* * */ 0x0000, 0x0014, 0x0008, 0x003E, 0x0008, 0x0014,
+ /* + */ 0x0000, 0x0040, 0x0040, 0x0040, 0x03F8, 0x0040, 0x0040, 0x0040,
+ /* , */ 0x0000, 0x0F00, 0x0700,
+ /* - */ 0x0000, 0x0040, 0x0040, 0x0040, 0x0040,
+ /* . */ 0x0000, 0x0300, 0x0300,
+ /* / */ 0x0000, 0x0C00, 0x0F00, 0x03E0, 0x00F8, 0x001E, 0x0006,
+ /* 0 */ 0x0000, 0x01F8, 0x03FC, 0x0204, 0x0204, 0x03FC, 0x01F8,
+ /* 1 */ 0x0000, 0x0000, 0x0208, 0x03FC, 0x03FC, 0x0200, 0x0000,
+ /* 2 */ 0x0000, 0x0308, 0x038C, 0x02C4, 0x0264, 0x023C, 0x0218,
+ /* 3 */ 0x0000, 0x0108, 0x030C, 0x0224, 0x0224, 0x03FC, 0x01D8,
+ /* 4 */ 0x0000, 0x00C0, 0x00A0, 0x0090, 0x03F8, 0x03FC, 0x0080,
+ /* 5 */ 0x0000, 0x0100, 0x033C, 0x023C, 0x0224, 0x03E4, 0x01C4,
+ /* 6 */ 0x0000, 0x01F0, 0x03F8, 0x022C, 0x0224, 0x03E4, 0x01C0,
+ /* 7 */ 0x0000, 0x0004, 0x0304, 0x03C4, 0x00F4, 0x003C, 0x000C,
+ /* 8 */ 0x0000, 0x01D8, 0x03FC, 0x0224, 0x0224, 0x03FC, 0x01D8,
+ /* 9 */ 0x0000, 0x0038, 0x027C, 0x0244, 0x0344, 0x01FC, 0x00F8,
+ /* : */ 0x0000, 0x0330, 0x0330,
+ /* ; */ 0x0000, 0x0F30, 0x0730,
+ /* < */ 0x0000, 0x0040, 0x00A0, 0x00A0, 0x0110, 0x0110, 0x0208, 0x0208,
+ /* = */ 0x0000, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090,
+ /* > */ 0x0000, 0x0208, 0x0208, 0x0110, 0x0110, 0x00A0, 0x00A0, 0x0040,
+ /* ? */ 0x0000, 0x0008, 0x02C4, 0x02E4, 0x003C, 0x0018,
+ /* @ */ 0x0000, 0x01F0, 0x0208, 0x04E4, 0x05F4, 0x0514, 0x05F4, 0x05F4, 0x0104, 0x00F8,
+ /* A */ 0x0000, 0x0380, 0x03F0, 0x00FC, 0x008C, 0x00FC, 0x03F0, 0x0380,
+ /* B */ 0x0000, 0x03FC, 0x03FC, 0x0224, 0x0224, 0x03FC, 0x01D8,
+ /* C */ 0x0000, 0x01F8, 0x03FC, 0x0204, 0x0204, 0x0204, 0x0108,
+ /* D */ 0x0000, 0x03FC, 0x03FC, 0x0204, 0x0204, 0x030C, 0x01F8, 0x00F0,
+ /* E */ 0x0000, 0x03FC, 0x03FC, 0x0224, 0x0224, 0x0224, 0x0224,
+ /* F */ 0x0000, 0x03FC, 0x03FC, 0x0024, 0x0024, 0x0024, 0x0024,
+ /* G */ 0x0000, 0x01F8, 0x03FC, 0x0204, 0x0204, 0x0244, 0x03C4, 0x03C8,
+ /* H */ 0x0000, 0x03FC, 0x03FC, 0x0020, 0x0020, 0x0020, 0x03FC, 0x03FC,
+ /* I */ 0x0000, 0x0204, 0x03FC, 0x03FC, 0x0204,
+ /* J */ 0x0200, 0x0204, 0x0204, 0x03FC, 0x01FC,
+ /* K */ 0x0000, 0x03FC, 0x03FC, 0x00F0, 0x0198, 0x030C, 0x0204,
+ /* L */ 0x0000, 0x03FC, 0x03FC, 0x0200, 0x0200, 0x0200, 0x0200,
+ /* M */ 0x0000, 0x03FC, 0x001C, 0x0038, 0x0070, 0x0020, 0x0010, 0x03F8, 0x03FC,
+ /* N */ 0x0000, 0x03FC, 0x0018, 0x0030, 0x0060, 0x00C0, 0x0180, 0x03FC,
+ /* O */ 0x0000, 0x01F8, 0x03FC, 0x0204, 0x0204, 0x0204, 0x03FC, 0x01F8,
+ /* P */ 0x0000, 0x03FC, 0x03FC, 0x0044, 0x0044, 0x007C, 0x0038,
+ /* Q */ 0x0000, 0x01F8, 0x03FC, 0x0204, 0x0604, 0x0E04, 0x0BFC, 0x09F8,
+ /* R */ 0x0000, 0x03FC, 0x03FC, 0x0044, 0x00C4, 0x01FC, 0x0338, 0x0200,
+ /* S */ 0x0000, 0x0138, 0x027C, 0x0264, 0x0264, 0x03E4, 0x01C8,
+ /* T */ 0x0004, 0x0004, 0x0004, 0x03FC, 0x03FC, 0x0004, 0x0004, 0x0004,
+ /* U */ 0x0000, 0x01FC, 0x03FC, 0x0200, 0x0200, 0x0200, 0x03FC, 0x01FC,
+ /* V */ 0x0000, 0x001C, 0x00FC, 0x03E0, 0x03E0, 0x00FC, 0x001C,
+ /* W */ 0x0000, 0x001C, 0x00FC, 0x03E0, 0x03C0, 0x007C, 0x007C, 0x03C0, 0x03E0, 0x00FC, 0x001C,
+ /* X */ 0x0000, 0x030C, 0x039C, 0x00F0, 0x00F0, 0x039C, 0x030C,
+ /* Y */ 0x0000, 0x000C, 0x003C, 0x03F0, 0x03F0, 0x003C, 0x000C,
+ /* Z */ 0x0000, 0x0384, 0x03C4, 0x02E4, 0x0274, 0x023C, 0x021C,
+ /* [ */ 0x0000, 0x0FFE, 0x0FFE, 0x0802, 0x0802,
+ /* \ */ 0x0000, 0x0006, 0x001E, 0x00F8, 0x03E0, 0x0F00, 0x0C00,
+ /* ] */ 0x0000, 0x0802, 0x0802, 0x0FFE, 0x0FFE,
+ /* ^ */ 0x0000, 0x0020, 0x0030, 0x0018, 0x000C, 0x000C, 0x0018, 0x0030, 0x0020,
+ /* _ */ 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800,
+ /* ` */ 0x0000, 0x0000, 0x0002, 0x0006, 0x0004,
+ /* a */ 0x0000, 0x0180, 0x03D0, 0x0250, 0x0250, 0x03F0, 0x03E0,
+ /* b */ 0x0000, 0x03FE, 0x03FE, 0x0210, 0x0210, 0x03F0, 0x01E0,
+ /* c */ 0x0000, 0x01E0, 0x03F0, 0x0210, 0x0210, 0x0210,
+ /* d */ 0x0000, 0x01E0, 0x03F0, 0x0210, 0x0210, 0x03FE, 0x03FE,
+ /* e */ 0x0000, 0x01E0, 0x03F0, 0x0250, 0x0250, 0x0270, 0x0160,
+ /* f */ 0x0010, 0x03FC, 0x03FE, 0x0012, 0x0012,
+ /* g */ 0x0000, 0x01E0, 0x0BF0, 0x0A10, 0x0A10, 0x0FF0, 0x07F0,
+ /* h */ 0x0000, 0x03FE, 0x03FE, 0x0010, 0x0010, 0x03F0, 0x03E0,
+ /* i */ 0x0000, 0x03F4, 0x03F4,
+ /* j */ 0x0800, 0x0810, 0x0FF4, 0x07F4,
+ /* k */ 0x0000, 0x03FE, 0x03FE, 0x00C0, 0x01E0, 0x0330, 0x0210,
+ /* l */ 0x0000, 0x03FE, 0x03FE,
+ /* m */ 0x0000, 0x03F0, 0x03F0, 0x0010, 0x0010, 0x03F0, 0x03E0, 0x0010, 0x0010, 0x03F0, 0x03E0,
+ /* n */ 0x0000, 0x03F0, 0x03F0, 0x0010, 0x0010, 0x03F0, 0x03E0,
+ /* o */ 0x0000, 0x01E0, 0x03F0, 0x0210, 0x0210, 0x03F0, 0x01E0,
+ /* p */ 0x0000, 0x0FF0, 0x0FF0, 0x0210, 0x0210, 0x03F0, 0x01E0,
+ /* q */ 0x0000, 0x01E0, 0x03F0, 0x0210, 0x0210, 0x0FF0, 0x0FF0,
+ /* r */ 0x0000, 0x03F0, 0x03F0, 0x0020, 0x0030, 0x0030,
+ /* s */ 0x0000, 0x0260, 0x02F0, 0x02D0, 0x03D0, 0x0190,
+ /* t */ 0x0010, 0x01FC, 0x03FC, 0x0210, 0x0210,
+ /* u */ 0x0000, 0x01F0, 0x03F0, 0x0200, 0x0200, 0x03F0, 0x03F0,
+ /* v */ 0x0000, 0x0070, 0x01F0, 0x0380, 0x0380, 0x01F0, 0x0070,
+ /* w */ 0x0000, 0x00F0, 0x03F0, 0x0300, 0x00F0, 0x00F0, 0x0300, 0x03F0, 0x00F0,
+ /* x */ 0x0000, 0x0330, 0x03F0, 0x00C0, 0x00C0, 0x03F0, 0x0330,
+ /* y */ 0x0000, 0x0030, 0x0CF0, 0x0FC0, 0x03C0, 0x00F0, 0x0030,
+ /* z */ 0x0000, 0x0310, 0x0390, 0x02D0, 0x0270, 0x0230,
+ /* { */ 0x0000, 0x0040, 0x0040, 0x07FC, 0x0FBE, 0x0802, 0x0802,
+ /* | */ 0x0000, 0x0000, 0x0FFE, 0x0FFE,
+ /* } */ 0x0000, 0x0802, 0x0802, 0x0FBE, 0x07FC, 0x0040, 0x0040,
+ /* ~ */ 0x0000, 0x01C0, 0x0020, 0x0020, 0x00C0, 0x0100, 0x0100, 0x00E0
+ };
+#endif
+
+/* fontUI1 - UI Font 2 Medium Bold */
+#if 1
+ /* Forward Declarations of internal arrays */
+ static const uint8_t fontUI2_Widths[];
+ static const uint16_t fontUI2_Offsets[];
+ static const fontcolumn_t fontUI2_Data[];
+
+ const struct font fontUI2 = { 11, 1, 13, 2, 2, 12, ' ', '~', 1, 1,
+ fontUI2_Widths,
+ fontUI2_Offsets,
+ fontUI2_Data};
+ const struct font fontUI2Double = { 11, 1, 13, 2, 2, 12, ' ', '~', 2, 2,
+ fontUI2_Widths,
+ fontUI2_Offsets,
+ fontUI2_Data};
+ const struct font fontUI2Narrow = { 11, 1, 13, 2, 2, 12, ' ', '~', 1, 2,
+ fontUI2_Widths,
+ fontUI2_Offsets,
+ fontUI2_Data};
+
+ static const uint8_t fontUI2_Widths[] = {
+ 2, 2, 5, 8, 6, 12, 8, 2, 4, 4, 6, 8, 2, 4, 2, 5,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2, 2, 8, 8, 8, 5,
+ 9, 7, 6, 6, 7, 5, 5, 7, 7, 4, 5, 6, 5, 9, 6, 7,
+ 6, 7, 7, 6, 6, 7, 6, 10, 6, 6, 6, 4, 5, 4, 7, 7,
+ 4, 6, 6, 5, 6, 6, 4, 6, 6, 2, 3, 6, 2, 10, 6, 6,
+ 6, 6, 4, 5, 4, 6, 6, 8, 6, 6, 5, 6, 4, 6, 8, 0
+ };
+ static const uint16_t fontUI2_Offsets[] = {
+ 0, 2, 4, 9, 17, 23, 35, 43,
+ 45, 49, 53, 59, 67, 69, 73, 75,
+ 80, 86, 92, 98, 104, 110, 116, 122,
+ 128, 134, 140, 142, 144, 152, 160, 168,
+ 173, 182, 189, 195, 201, 208, 213, 218,
+ 225, 232, 236, 241, 247, 252, 261, 267,
+ 274, 280, 287, 294, 300, 306, 313, 319,
+ 329, 335, 341, 347, 351, 356, 360, 367,
+ 374, 378, 384, 390, 395, 401, 407, 411,
+ 417, 423, 425, 428, 434, 436, 446, 452,
+ 458, 464, 470, 474, 479, 483, 489, 495,
+ 503, 509, 515, 520, 526, 530, 536, 0
+ };
+ static const fontcolumn_t fontUI2_Data[] = {
+ /* */ 0x0000, 0x0000,
+ /* ! */ 0x017E, 0x017E,
+ /* " */ 0x0007, 0x0007, 0x0000, 0x0007, 0x0007,
+ /* # */ 0x00C0, 0x03D8, 0x00F8, 0x00DE, 0x03D8, 0x00F8, 0x00DE, 0x0018,
+ /* $ */ 0x0098, 0x013C, 0x07E4, 0x013F, 0x01E4, 0x00C8,
+ /* % */ 0x001C, 0x003E, 0x0022, 0x003E, 0x019C, 0x0060, 0x0018, 0x00E6, 0x01F0, 0x0110, 0x01F0, 0x00E0,
+ /* & */ 0x00EC, 0x01FE, 0x0112, 0x013E, 0x016C, 0x00C0, 0x01B0, 0x0110,
+ /* ' */ 0x0007, 0x0007,
+ /* ( */ 0x00F8, 0x03FE, 0x0707, 0x0401,
+ /* ) */ 0x0401, 0x0707, 0x03FE, 0x00F8,
+ /* * */ 0x000A, 0x0004, 0x001F, 0x001F, 0x0004, 0x000A,
+ /* + */ 0x0000, 0x0020, 0x0020, 0x0020, 0x01FC, 0x0020, 0x0020, 0x0020,
+ /* , */ 0x0780, 0x0380,
+ /* - */ 0x0020, 0x0020, 0x0020, 0x0020,
+ /* . */ 0x0180, 0x0180,
+ /* / */ 0x0600, 0x0180, 0x0070, 0x000C, 0x0003,
+ /* 0 */ 0x00FC, 0x01FE, 0x0102, 0x0102, 0x01FE, 0x00FC,
+ /* 1 */ 0x0000, 0x0104, 0x01FE, 0x01FE, 0x0100, 0x0000,
+ /* 2 */ 0x0184, 0x01C6, 0x0162, 0x0132, 0x011E, 0x010C,
+ /* 3 */ 0x0084, 0x0186, 0x0112, 0x0112, 0x01FE, 0x00EC,
+ /* 4 */ 0x0060, 0x0050, 0x0048, 0x01FC, 0x01FE, 0x0040,
+ /* 5 */ 0x0080, 0x019E, 0x011E, 0x0112, 0x01F2, 0x00E2,
+ /* 6 */ 0x00FC, 0x01FE, 0x0112, 0x0112, 0x01F2, 0x00E0,
+ /* 7 */ 0x0002, 0x0002, 0x01C2, 0x01FA, 0x003E, 0x0006,
+ /* 8 */ 0x00EC, 0x01FE, 0x0112, 0x0112, 0x01FE, 0x00EC,
+ /* 9 */ 0x001C, 0x013E, 0x0122, 0x0122, 0x01FE, 0x00FC,
+ /* : */ 0x0198, 0x0198,
+ /* ; */ 0x0798, 0x0398,
+ /* < */ 0x0000, 0x0020, 0x0050, 0x0050, 0x0088, 0x0088, 0x0104, 0x0104,
+ /* = */ 0x0000, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048,
+ /* > */ 0x0000, 0x0104, 0x0104, 0x0088, 0x0088, 0x0050, 0x0050, 0x0020,
+ /* ? */ 0x0004, 0x0162, 0x0172, 0x001E, 0x000C,
+ /* @ */ 0x00F8, 0x0104, 0x0272, 0x02FA, 0x028A, 0x027A, 0x02FA, 0x0084, 0x0078,
+ /* A */ 0x01C0, 0x01F8, 0x007E, 0x0046, 0x007E, 0x01F8, 0x01C0,
+ /* B */ 0x01FE, 0x01FE, 0x0112, 0x0112, 0x01FE, 0x00EC,
+ /* C */ 0x00FC, 0x01FE, 0x0102, 0x0102, 0x0102, 0x0102,
+ /* D */ 0x01FE, 0x01FE, 0x0102, 0x0102, 0x0186, 0x00FC, 0x0078,
+ /* E */ 0x01FE, 0x01FE, 0x0112, 0x0112, 0x0112,
+ /* F */ 0x01FE, 0x01FE, 0x0012, 0x0012, 0x0012,
+ /* G */ 0x00FC, 0x01FE, 0x0102, 0x0102, 0x0122, 0x01E2, 0x01E2,
+ /* H */ 0x01FE, 0x01FE, 0x0010, 0x0010, 0x0010, 0x01FE, 0x01FE,
+ /* I */ 0x0102, 0x01FE, 0x01FE, 0x0102,
+ /* J */ 0x0100, 0x0102, 0x0102, 0x01FE, 0x00FE,
+ /* K */ 0x01FE, 0x01FE, 0x0078, 0x00CC, 0x0186, 0x0102,
+ /* L */ 0x01FE, 0x01FE, 0x0100, 0x0100, 0x0100,
+ /* M */ 0x01FE, 0x000E, 0x001C, 0x0038, 0x0030, 0x0018, 0x000C, 0x01FE, 0x01FE,
+ /* N */ 0x01FE, 0x000E, 0x001C, 0x0038, 0x0070, 0x01FE,
+ /* O */ 0x00FC, 0x01FE, 0x0102, 0x0102, 0x0102, 0x01FE, 0x00FC,
+ /* P */ 0x01FE, 0x01FE, 0x0022, 0x0022, 0x003E, 0x001C,
+ /* Q */ 0x00FC, 0x01FE, 0x0102, 0x0302, 0x0702, 0x05FE, 0x04FC,
+ /* R */ 0x01FE, 0x01FE, 0x0022, 0x0062, 0x00FE, 0x019C, 0x0100,
+ /* S */ 0x011C, 0x013E, 0x0132, 0x0132, 0x01F2, 0x00E2,
+ /* T */ 0x0002, 0x0002, 0x01FE, 0x01FE, 0x0002, 0x0002,
+ /* U */ 0x00FE, 0x01FE, 0x0100, 0x0100, 0x0100, 0x01FE, 0x00FE,
+ /* V */ 0x000E, 0x007E, 0x01F0, 0x01F0, 0x007E, 0x000E,
+ /* W */ 0x000E, 0x007E, 0x01F0, 0x01E0, 0x003E, 0x003E, 0x01E0, 0x01F0, 0x007E, 0x000E,
+ /* X */ 0x0186, 0x01CE, 0x0078, 0x0078, 0x01CE, 0x0186,
+ /* Y */ 0x0006, 0x001E, 0x01F8, 0x01F8, 0x001E, 0x0006,
+ /* Z */ 0x01C2, 0x01E2, 0x0172, 0x013A, 0x011E, 0x010E,
+ /* [ */ 0x07FF, 0x07FF, 0x0401, 0x0401,
+ /* \ */ 0x0003, 0x000C, 0x0070, 0x0180, 0x0600,
+ /* ] */ 0x0401, 0x0401, 0x07FF, 0x07FF,
+ /* ^ */ 0x0010, 0x0008, 0x0004, 0x0002, 0x0004, 0x0008, 0x0010,
+ /* _ */ 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400,
+ /* ` */ 0x0000, 0x0001, 0x0003, 0x0002,
+ /* a */ 0x00C0, 0x01E8, 0x0128, 0x0128, 0x01F8, 0x01F0,
+ /* b */ 0x01FF, 0x01FF, 0x0108, 0x0108, 0x01F8, 0x00F0,
+ /* c */ 0x00F0, 0x01F8, 0x0108, 0x0108, 0x0108,
+ /* d */ 0x00F0, 0x01F8, 0x0108, 0x0108, 0x01FF, 0x01FF,
+ /* e */ 0x00F0, 0x01F8, 0x0128, 0x0128, 0x0138, 0x0130,
+ /* f */ 0x01FE, 0x01FF, 0x0009, 0x0001,
+ /* g */ 0x00F0, 0x05F8, 0x0508, 0x0508, 0x07F8, 0x03F8,
+ /* h */ 0x01FF, 0x01FF, 0x0008, 0x0008, 0x01F8, 0x01F0,
+ /* i */ 0x01FA, 0x01FA,
+ /* j */ 0x0408, 0x07FA, 0x03FA,
+ /* k */ 0x01FF, 0x01FF, 0x0060, 0x00F0, 0x0198, 0x0108,
+ /* l */ 0x01FF, 0x01FF,
+ /* m */ 0x01F8, 0x01F8, 0x0008, 0x0008, 0x01F8, 0x01F0, 0x0008, 0x0008, 0x01F8, 0x01F0,
+ /* n */ 0x01F8, 0x01F8, 0x0008, 0x0008, 0x01F8, 0x01F0,
+ /* o */ 0x00F0, 0x01F8, 0x0108, 0x0108, 0x01F8, 0x00F0,
+ /* p */ 0x07F8, 0x07F8, 0x0108, 0x0108, 0x01F8, 0x00F0,
+ /* q */ 0x00F0, 0x01F8, 0x0108, 0x0108, 0x07F8, 0x07F8,
+ /* r */ 0x01F8, 0x01F8, 0x0010, 0x0018,
+ /* s */ 0x0130, 0x0178, 0x0168, 0x01E8, 0x00C8,
+ /* t */ 0x00FE, 0x01FE, 0x0108, 0x0108,
+ /* u */ 0x00F8, 0x01F8, 0x0100, 0x0100, 0x01F8, 0x01F8,
+ /* v */ 0x0018, 0x0078, 0x01E0, 0x01E0, 0x0078, 0x0018,
+ /* w */ 0x0078, 0x01F8, 0x01C0, 0x0078, 0x0078, 0x01C0, 0x01F8, 0x0078,
+ /* x */ 0x0198, 0x01F8, 0x0060, 0x0060, 0x01F8, 0x0198,
+ /* y */ 0x0018, 0x0678, 0x07E0, 0x01E0, 0x0078, 0x0018,
+ /* z */ 0x0188, 0x01C8, 0x0168, 0x0138, 0x0118,
+ /* { */ 0x0020, 0x0020, 0x03FE, 0x07DF, 0x0401, 0x0401,
+ /* | */ 0x0000, 0x0000, 0x07FF, 0x07FF,
+ /* } */ 0x0401, 0x0401, 0x07DF, 0x03FE, 0x0020, 0x0020,
+ /* ~ */ 0x0060, 0x0010, 0x0010, 0x0030, 0x0060, 0x0040, 0x0040, 0x0030
+ };
+#endif
+
+/*
+ fontLargeNumbers:
+ Large numbers font, height = 16 (including the decenders)
+ Characters include: 0 - 9, -, +, ., %, :, Space, Comma
+*/
+#if 1
+ /* Forward Declarations of internal arrays */
+ static const uint8_t fontLargeNumbers_Widths[];
+ static const uint16_t fontLargeNumbers_Offsets[];
+ static const fontcolumn_t fontLargeNumbers_Data[];
+
+ const struct font fontLargeNumbers = { 16, 2, 21, 1, 3, 15, '%', ':', 1, 1,
+ fontLargeNumbers_Widths,
+ fontLargeNumbers_Offsets,
+ fontLargeNumbers_Data};
+ const struct font fontLargeNumbersDouble = { 16, 2, 21, 1, 3, 15, '%', ':', 2, 2,
+ fontLargeNumbers_Widths,
+ fontLargeNumbers_Offsets,
+ fontLargeNumbers_Data};
+ const struct font fontLargeNumbersNarrow = { 16, 2, 21, 1, 3, 15, '%', ':', 1, 2,
+ fontLargeNumbers_Widths,
+ fontLargeNumbers_Offsets,
+ fontLargeNumbers_Data};
+
+ static const uint8_t fontLargeNumbers_Widths[] = {
+ 15, 0, 0, 0, 0, 0, 11, 3, 6, 3, 0, 10, 10, 10, 10, 10,
+ 10, 10, 10, 10, 10, 4, 0, 0
+ };
+ static const uint16_t fontLargeNumbers_Offsets[] = {
+ 0, 0, 0, 0, 0, 0, 15, 26,
+ 29, 35, 0, 38, 48, 58, 68, 78,
+ 88, 98, 108, 118, 128, 138, 0, 0
+ };
+ static const fontcolumn_t fontLargeNumbers_Data[] = {
+ /* % */ 0x007E, 0x00FF, 0x00C3, 0x80C3, 0xE0FF, 0x7C7E, 0x1F00, 0x07C0, 0x00F0, 0x7E3E, 0xFF0F, 0xC303,
+ 0xC300, 0xFF00, 0x7E00,
+ /* + */ 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x1FFC, 0x1FFC, 0x1FFC, 0x01C0, 0x01C0, 0x01C0, 0x01C0,
+ /* , */ 0x7000, 0x7000, 0xF000,
+ /* - */ 0x0700, 0x0700, 0x0700, 0x0700, 0x0700, 0x0700,
+ /* . */ 0x7000, 0x7000, 0x7000,
+ /* 0 */ 0x0FF8, 0x3FFE, 0x3FFE, 0x7007, 0x6003, 0x6003, 0x7007, 0x3FFE, 0x3FFE, 0x0FF8,
+ /* 1 */ 0x0000, 0x0070, 0x0038, 0x0038, 0x001C, 0x7FFF, 0x7FFF, 0x7FFF, 0x0000, 0x0000,
+ /* 2 */ 0x600C, 0x700E, 0x7C0F, 0x7E07, 0x6F03, 0x6783, 0x63C7, 0x61FF, 0x60FE, 0x603C,
+ /* 3 */ 0x180C, 0x380E, 0x780F, 0x70C3, 0x60C3, 0x60E3, 0x71FF, 0x3FFE, 0x3F3C, 0x0E00,
+ /* 4 */ 0x0F00, 0x0DC0, 0x0CE0, 0x0C38, 0x0C1E, 0x7FFF, 0x7FFF, 0x7FFF, 0x0C00, 0x0C00,
+ /* 5 */ 0x18C0, 0x38FC, 0x78FF, 0x707F, 0x6063, 0x6063, 0x70E3, 0x3FE3, 0x3FC3, 0x0F80,
+ /* 6 */ 0x0FF8, 0x3FFE, 0x3FFE, 0x70C7, 0x6063, 0x6063, 0x70E7, 0x3FEF, 0x3FC6, 0x0F04,
+ /* 7 */ 0x0003, 0x0003, 0x7803, 0x7F03, 0x7FC3, 0x07F3, 0x00FB, 0x003F, 0x000F, 0x0007,
+ /* 8 */ 0x1E1C, 0x3F3E, 0x7FFF, 0x71E7, 0x60C3, 0x60C3, 0x71E7, 0x7FFF, 0x3F3E, 0x1E1C,
+ /* 9 */ 0x1078, 0x39FE, 0x7BFE, 0x7387, 0x6303, 0x6303, 0x7187, 0x3FFE, 0x3FFE, 0x0FF8,
+ /* : */ 0x0000, 0x0E38, 0x0E38, 0x0E38
+ };
+#endif
+
+#endif /* GDISP_NEED_TEXT */
+
+#endif /* HAL_USE_GDISP */
diff --git a/src/touchpad.c b/src/touchpad.c
new file mode 100644
index 00000000..977bb31c
--- /dev/null
+++ b/src/touchpad.c
@@ -0,0 +1,261 @@
+/*
+ ChibiOS-LCD-Driver - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file touchpad.c
+ * @brief Touchpad Driver code.
+ *
+ * @addgroup TOUCHPAD
+ * @{
+ */
+#include "ch.h"
+#include "hal.h"
+#include "gdisp.h"
+#include "touchpad.h"
+
+#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+#ifdef UNUSED
+#elif defined(__GNUC__)
+# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
+#elif defined(__LCLINT__)
+# define UNUSED(x) /*@unused@*/ x
+#else
+# define UNUSED(x) x
+#endif
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+volatile static struct cal cal = {
+ 1, 1, 0, 0
+};
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+/**
+ * @brief returns the uncalibrated readout of the X direction from the controller
+ *
+ * @noapi
+ */
+static uint16_t _tpReadRealX(void) {
+ uint32_t results = 0;
+ uint16_t i, x;
+
+ for(i = 0; i < CONVERSIONS; i++) {
+ tp_lld_read_x(); /* dummy, reduce noise on SPI */
+ results += tp_lld_read_x();
+ }
+
+ // 12-bit
+ x = (((SCREEN_WIDTH-1) * (results/CONVERSIONS)) / 2048);
+
+ return x;
+}
+
+/**
+ * @brief return the uncalibrated readout of the Y-direction from the controller
+ *
+ * @noapi
+ */
+static uint16_t _tpReadRealY(void) {
+ uint32_t results = 0;
+ uint16_t i, y;
+
+ for(i = 0; i < CONVERSIONS; i++) {
+ tp_lld_read_y(); /* dummy, reduce noise on SPI */
+ results += tp_lld_read_y();
+ }
+
+ // 12-bit
+ y = (((SCREEN_HEIGHT-1) * (results/CONVERSIONS)) / 2048);
+
+ return y;
+}
+
+/**
+ * @brief draws a cross. Used for calibration.
+ *
+ * @noapi
+ */
+static void _tpDrawCross(uint16_t x, uint16_t y) {
+ gdispDrawLine(x-15, y, x-2, y, 0xffff);
+ gdispDrawLine(x+2, y, x+15, y, 0xffff);
+ gdispDrawLine(x, y-15, x, y-2, 0xffff);
+ gdispDrawLine(x, y+2, x, y+15, 0xffff);
+
+ gdispDrawLine(x-15, y+15, x-7, y+15, RGB565CONVERT(184,158,131));
+ gdispDrawLine(x-15, y+7, x-15, y+15, RGB565CONVERT(184,158,131));
+
+ gdispDrawLine(x-15, y-15, x-7, y-15, RGB565CONVERT(184,158,131));
+ gdispDrawLine(x-15, y-7, x-15, y-15, RGB565CONVERT(184,158,131));
+
+ gdispDrawLine(x+7, y+15, x+15, y+15, RGB565CONVERT(184,158,131));
+ gdispDrawLine(x+15, y+7, x+15, y+15, RGB565CONVERT(184,158,131));
+
+ gdispDrawLine(x+7, y-15, x+15, y-15, RGB565CONVERT(184,158,131));
+ gdispDrawLine(x+15, y-15, x+15, y-7, RGB565CONVERT(184,158,131));
+}
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Touchpad Driver initialization.
+ * @note This function is NOT currently implicitly invoked by @p halInit().
+ * It must be called manually.
+ *
+ * @api
+ */
+void tpInit(TOUCHPADDriver *tp) {
+ /* Initialise Mutex */
+ //MUTEX_INIT
+
+ /* Initialise driver */
+ //MUTEX_ENTER
+ tp_lld_init(tp);
+ //MUTEX_EXIT
+}
+
+/**
+ * @brief Get the X-Coordinate, relative to screen zero point.
+ *
+ * @return The X position in pixels.
+ *
+ * @api
+ */
+uint16_t tpReadX(void) {
+ uint16_t x, y;
+
+ x = cal.xm * _tpReadRealX() + cal.xn;
+ y = cal.ym * _tpReadRealY() + cal.yn;
+
+ /*
+ switch(gdispGetOrientation()) { // implement gdispGetOrientation()
+ case portrait:
+ return x;
+ case landscape:
+ return SCREEN_HEIGHT - y;
+ case portraitInv:
+ return SCREEN_WIDTH - x;
+ case landscapeInv:
+ return y;
+ }
+ */
+
+ return x;
+}
+
+/**
+ * @brief Get the X-Coordinate, relative to screen zero point.
+ *
+ * @return The Y position in pixels.
+ *
+ * @api
+ */
+uint16_t tpReadY(void) {
+ uint16_t x, y;
+
+ x = cal.xm * _tpReadRealX() + cal.xn;
+ y = cal.ym * _tpReadRealY() + cal.yn;
+
+ /*
+ switch(gdispGetOrientation()) { // implement gdispGetOrientation()
+ case portrait:
+ return y;
+ case landscape:
+ return x;
+ case portraitInv:
+ return SCREEN_HEIGHT - y;
+ case landscapeInv:
+ return SCREEN_WIDTH - x;
+ }
+ */
+
+ return y;
+}
+
+void tpCalibrate(void) {
+ uint16_t cross[2][2] = {{40,50}, {200, 280}};
+ uint16_t points[2][2];
+ uint8_t i;
+
+ //gdispSetOrientation(portrait);
+ gdispClear(Red);
+ gdispFillStringBox(0, 10, gdispGetWidth(), 30, "Calibration", &fontUI2Double, White, Red, justifyCenter);
+
+ for(i = 0; i < 2; i++) {
+ _tpDrawCross(cross[i][0], cross[i][1]);
+ while(!tpIRQ());
+ points[i][0] = _tpReadRealX();
+ points[i][1] = _tpReadRealY();
+ chThdSleepMilliseconds(100);
+ while(tpIRQ());
+ gdispFillArea(cross[i][0]-15, cross[i][1]-15, 42, 42, Red);
+ }
+
+ cal.xm = ((float)cross[1][0] - (float)cross[0][0]) / ((float)points[1][0] - (float)points[0][0]);
+ cal.ym = ((float)cross[1][1] - (float)cross[0][1]) / ((float)points[1][1] - (float)points[0][1]);
+
+ cal.xn = (float)cross[0][0] - cal.xm * (float)points[0][0];
+ cal.yn = (float)cross[0][1] - cal.ym * (float)points[0][1];
+}
+
+#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__)
+ /**
+ * @brief returns if touchpad is pressed or not
+ *
+ * @return 1 if pressed, 0 otherwise
+ *
+ * @api
+ */
+ uint8_t tpIRQ(void) {
+ return tp_lld_irq();
+ }
+#endif
+
+#if TOUCHPAD_HAS_PRESSURE || defined(__DOXYGEN__)
+ /**
+ * @brief Get the pressure.
+ *
+ * @return The pressure.
+ *
+ * @api
+ */
+ uint16_t tpReadZ(void) {
+ /* ToDo */
+ return (tp_lld_read_z());
+ }
+#endif
+
+#endif /* HAL_USE_TOUCHPAD */
+/** @} */
+
diff --git a/templates/gdispXXXXX/gdisp_lld.c b/templates/gdispXXXXX/gdisp_lld.c
new file mode 100644
index 00000000..81e96894
--- /dev/null
+++ b/templates/gdispXXXXX/gdisp_lld.c
@@ -0,0 +1,490 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file templates/gdisp_lld.c
+ * @brief GDISP Graphics Driver subsystem low level driver source template.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+#include "gdisp.h"
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+/* Include the emulation code for things we don't support */
+#include "gdisp_emulation.c"
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+#if GDISP_NEED_TEXT
+ #include "gdisp_fonts.h"
+#endif
+
+/* All the board specific code should go in these include file so the driver
+ * can be ported to another board just by creating a suitable file.
+ */
+#if defined(BOARD_YOURBOARDNAME)
+ #include "gdisp_lld_board_yourboardname.h"
+#else
+ /* Include the user supplied board definitions */
+ #include "gdisp_lld_board.h"
+#endif
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/* ---- Required Routines ---- */
+/*
+ The following 2 routines are required.
+ All other routines are optional.
+*/
+
+/**
+ * @brief Low level GDISP driver initialisation.
+ * @return TRUE if successful, FALSE on error.
+ *
+ * @notapi
+ */
+bool_t GDISP_LLD(init)(void) {
+ /* Initialise your display */
+
+ /* Initialise the GDISP structure to match */
+ GDISP.Width = SCREEN_WIDTH;
+ GDISP.Height = SCREEN_HEIGHT;
+ GDISP.Orientation = portrait;
+ GDISP.Powermode = powerOn;
+ GDISP.Backlight = 100;
+ GDISP.Contrast = 50;
+ return TRUE;
+}
+
+/**
+ * @brief Draws a pixel on the display.
+ *
+ * @param[in] x X location of the pixel
+ * @param[in] y Y location of the pixel
+ * @param[in] color The color of the pixel
+ *
+ * @notapi
+ */
+void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ if (x >= GDISP.Width || y >= GDISP.Height) return;
+ #endif
+ /* Code here */
+}
+
+/* ---- Optional Routines ---- */
+/*
+ All the below routines are optional.
+ Defining them will increase speed but everything
+ will work if they are not defined.
+ If you are not using a routine - turn it off using
+ the appropriate GDISP_HARDWARE_XXXX macro.
+ Don't bother coding for obvious similar routines if
+ there is no performance penalty as the emulation software
+ makes a good job of using similar routines.
+ eg. If fillarea() is defined there is little
+ point in defining clear() unless the
+ performance bonus is significant.
+ For good performance it is suggested to implement
+ fillarea() and blitarea().
+*/
+
+#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__)
+ /**
+ * @brief Clear the display.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] color The color of the pixel
+ *
+ * @notapi
+ */
+ void GDISP_LLD(clear)(color_t color) {
+ /* Code here */
+ }
+#endif
+
+#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a line.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x0, y0 The start of the line
+ * @param[in] x1, y1 The end of the line
+ * @param[in] color The color of the line
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ /* Need to clip to screen */
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__)
+ /**
+ * @brief Fill an area with a color.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The start filled area
+ * @param[in] cx, cy The width and height to be filled
+ * @param[in] color The color of the fill
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
+ if (x+cx > GDISP.Width) cx = GDISP.Width - x;
+ if (y+cy > GDISP.Height) cy = GDISP.Height - y;
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__)
+ /**
+ * @brief Fill an area with a bitmap.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The start filled area
+ * @param[in] cx, cy The width and height to be filled
+ * @param[in] buffer The pixels to use to fill the area.
+ *
+ * @notapi
+ */
+ void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) {
+ #if GDISP_NEED_VALIDATION
+ if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
+ if (x+cx > GDISP.Width) return;
+ if (y+cy > GDISP.Height) cy = GDISP.Height - y;
+ #endif
+ /* Code here */
+ }
+#endif
+
+/* Circular Drawing Functions */
+#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a circle.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the circle is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color of the circle
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ /* Code here */
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Create a filled circle.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the circle is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color of the circle
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ /* Code here */
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw an ellipse.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the ellipse is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the ellipse
+ * @param[in] a, b The dimensions of the ellipse
+ * @param[in] color The color of the ellipse
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ /* Code here */
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Create a filled ellipse.
+ * @note Optional - The high level driver can emulate using software.
+ * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave
+ * correctly if the ellipse is over the edges of the screen.
+ *
+ * @param[in] x, y The centre of the ellipse
+ * @param[in] a, b The dimensions of the ellipse
+ * @param[in] color The color of the ellipse
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ /* Code here */
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a character using a transparent background.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The top-left corner of the text
+ * @param[in] c The character to print
+ * @param[in] color The color of the character
+ *
+ * @notapi
+ */
+ void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) {
+ #if GDISP_NEED_VALIDATION
+ /* Code here */
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Draw a character using a filled background.
+ * @note Optional - The high level driver can emulate using software.
+ *
+ * @param[in] x, y The top-left corner of the text
+ * @param[in] c The character to print
+ * @param[in] color The color of the character
+ * @param[in] bgcolor The background color
+ *
+ * @notapi
+ */
+ void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) {
+ #if GDISP_NEED_VALIDATION
+ /* Code here */
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__)
+ /**
+ * @brief Get the color of a particular pixel.
+ * @note Optional.
+ * @note If x,y is off the screen, the result is undefined.
+ * @return The color of the specified pixel.
+ *
+ * @param[in] x, y The start of the text
+ *
+ * @notapi
+ */
+ color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) {
+ #if GDISP_NEED_VALIDATION
+ if (x >= GDISP.Width || y >= GDISP.Height) return 0;
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__)
+ /**
+ * @brief Scroll vertically a section of the screen.
+ * @note Optional.
+ * @note If x,y + cx,cy is off the screen, the result is undefined.
+ * @note If lines is >= cy, it is equivelent to a area fill with bgcolor.
+ *
+ * @param[in] x, y The start of the area to be scrolled
+ * @param[in] cx, cy The size of the area to be scrolled
+ * @param[in] lines The number of lines to scroll (Can be positive or negative)
+ * @param[in] bgcolor The color to fill the newly exposed area.
+ *
+ * @notapi
+ */
+ void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
+ #if GDISP_NEED_VALIDATION
+ if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return;
+ if (x+cx > GDISP.Width) cx = GDISP.Width - x;
+ if (y+cy > GDISP.Height) cy = GDISP.Height - y;
+ #endif
+ /* Code here */
+ }
+#endif
+
+#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__)
+ /**
+ * @brief Driver Control
+ * @detail Unsupported control codes are ignored.
+ * @note The value parameter should always be typecast to (void *).
+ * @note There are some predefined and some specific to the low level driver.
+ * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t
+ * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t
+ * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver
+ * that only supports off/on anything other
+ * than zero is on.
+ * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100.
+ * GDISP_CONTROL_LLD - Low level driver control constants start at
+ * this value.
+ *
+ * @param[in] what What to do.
+ * @param[in] value The value to use (always cast to a void *).
+ *
+ * @notapi
+ */
+ void GDISP_LLD(control)(unsigned what, void *value) {
+ switch(what) {
+ case GDISP_CONTROL_POWER:
+ if (GDISP.Powermode == (gdisp_powermode_t)value)
+ return;
+ switch((gdisp_powermode_t)value) {
+ case powerOff:
+ /* Code here */
+ break;
+ case powerOn:
+ /* Code here */
+ /* You may need this ---
+ if (GDISP.Powermode != powerSleep)
+ GDISP_LLD(init)();
+ */
+ break;
+ case powerSleep:
+ /* Code here */
+ break;
+ default:
+ return;
+ }
+ GDISP.Powermode = (gdisp_powermode_t)value;
+ return;
+ case GDISP_CONTROL_ORIENTATION:
+ if (GDISP.Orientation == (gdisp_orientation_t)value)
+ return;
+ switch((gdisp_orientation_t)value) {
+ case portrait:
+ /* Code here */
+ GDISP.Height = SCREEN_HEIGHT;
+ GDISP.Width = SCREEN_WIDTH;
+ break;
+ case landscape:
+ /* Code here */
+ GDISP.Height = SCREEN_WIDTH;
+ GDISP.Width = SCREEN_HEIGHT;
+ break;
+ case portraitInv:
+ /* Code here */
+ GDISP.Height = SCREEN_HEIGHT;
+ GDISP.Width = SCREEN_WIDTH;
+ break;
+ case landscapeInv:
+ /* Code here */
+ GDISP.Height = SCREEN_WIDTH;
+ GDISP.Width = SCREEN_HEIGHT;
+ break;
+ default:
+ return;
+ }
+ GDISP.Orientation = (gdisp_orientation_t)value;
+ return;
+/*
+ case GDISP_CONTROL_BACKLIGHT:
+ case GDISP_CONTROL_CONTRAST:
+*/
+ }
+ }
+#endif
+
+#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__)
+/**
+ * @brief Query a driver value.
+ * @detail Typecase the result to the type you want.
+ * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen
+ * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen
+ * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode
+ * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation
+ * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100)
+ * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100).
+ * GDISP_QUERY_LLD - Low level driver control constants start at
+ * this value.
+ *
+ * @param[in] what What to Query
+ *
+ * @notapi
+ */
+void *GDISP_LLD(query)(unsigned what) {
+ switch(what) {
+ case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width;
+ case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height;
+ case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode;
+ case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation;
+ case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight;
+ case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast;
+ case GDISP_QUERY_LLD+0:
+ /* Code here */
+ default: return (void *)-1;
+ }
+}
+#endif
+
+#endif /* HAL_USE_GDISP */
+/** @} */
diff --git a/templates/gdispXXXXX/gdisp_lld.mk b/templates/gdispXXXXX/gdisp_lld.mk
new file mode 100644
index 00000000..d0933492
--- /dev/null
+++ b/templates/gdispXXXXX/gdisp_lld.mk
@@ -0,0 +1,5 @@
+# List the required driver.
+HALSRC += ${CHIBIOS}/os/halext/drivers/gdispYOURDEVICE/gdisp_lld.c
+
+# Required include directories
+HALINC += ${CHIBIOS}/os/halext/drivers/gdispYOURDEVICE
diff --git a/templates/gdispXXXXX/gdisp_lld_config.h b/templates/gdispXXXXX/gdisp_lld_config.h
new file mode 100644
index 00000000..81a6826f
--- /dev/null
+++ b/templates/gdispXXXXX/gdisp_lld_config.h
@@ -0,0 +1,66 @@
+/*
+ ChibiOS/RT - Copyright (C) 2012
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS-LCD-Driver.
+
+ ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file templates/gdisp_lld_config.h
+ * @brief GDISP Graphic Driver subsystem low level driver header template.
+ *
+ * @addtogroup GDISP
+ * @{
+ */
+
+#ifndef _GDISP_LLD_CONFIG_H
+#define _GDISP_LLD_CONFIG_H
+
+#if HAL_USE_GDISP || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver hardware support. */
+/*===========================================================================*/
+
+#define GDISP_DRIVER_NAME "YourDriverName"
+#define GDISP_LLD(x) gdisp_lld_##x##_YourDriverName
+
+#define GDISP_HARDWARE_LINES FALSE
+#define GDISP_HARDWARE_CLEARS FALSE
+#define GDISP_HARDWARE_FILLS FALSE
+#define GDISP_HARDWARE_BITFILLS FALSE
+#define GDISP_HARDWARE_CIRCLES FALSE
+#define GDISP_HARDWARE_CIRCLEFILLS FALSE
+#define GDISP_HARDWARE_ELLIPSES FALSE
+#define GDISP_HARDWARE_ELLIPSEFILLS FALSE
+#define GDISP_HARDWARE_TEXT FALSE
+#define GDISP_HARDWARE_TEXTFILLS FALSE
+#define GDISP_HARDWARE_SCROLL FALSE
+#define GDISP_HARDWARE_PIXELREAD FALSE
+#define GDISP_HARDWARE_CONTROL FALSE
+#define GDISP_HARDWARE_QUERY FALSE
+
+#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE
+#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE
+
+#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
+#define GDISP_PACKED_PIXELS FALSE
+#define GDISP_PACKED_LINES FALSE
+
+#endif /* HAL_USE_GDISP */
+
+#endif /* _GDISP_LLD_CONFIG_H */
+/** @} */
diff --git a/templates/gdispXXXXX/readme.txt b/templates/gdispXXXXX/readme.txt
new file mode 100644
index 00000000..bdb66006
--- /dev/null
+++ b/templates/gdispXXXXX/readme.txt
@@ -0,0 +1,35 @@
+To use this driver template
+ 1. Copy this entire directory (including the directory itself)
+ into halext/drivers
+ 2. Rename the directory to match your hardware.
+ 3. Customise each file in the directory including the .mk file
+ and this file. An example for this file is below...
+ 4. Keep any board specific code in a file you create called
+ gdisp_lld_board_yourboardname.h and adjust gdisp.c to match.
+ This enables someone porting to a new board to add another
+ suitable boad definition without worrying about the rest of
+ the driver. See the gdispNokia6610 driver as an example.
+
+------------------------------------------------------------------
+To use this driver:
+
+1. Add in your halconf.h:
+ a) #define HAL_USE_GDISP TRUE
+ b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD
+ c) One (only) of:
+ #define LCD_USE_GPIO
+ #define LCD_USE_SPI
+ #define LCD_USE_FSMC
+ d) All of the following (with appropriate values):
+ #define SCREEN_WIDTH 128
+ #define SCREEN_HEIGHT 128
+ e) If you are not using a known board then create a gdisp_lld_board.h file
+ and ensure it is on your include path.
+ Use the gdisp_lld_board_example.h file as a basis.
+ Currently known boards are:
+ XXXXXXXXX
+
+
+2. To your makefile add the following lines:
+ include $(CHIBIOS)/os/halext/halext.mk
+ include $(CHIBIOS)/os/halext/drivers/gdispXXXXX/gdisp_lld.mk
diff --git a/templates/readme.txt b/templates/readme.txt
new file mode 100644
index 00000000..a2c5b7ef
--- /dev/null
+++ b/templates/readme.txt
@@ -0,0 +1,4 @@
+The following low level driver templates are available:
+
+GDISP:
+ gdispXXXXX - Generalised GDISP driver