commit
1176b9738c
109 changed files with 2698 additions and 3101 deletions
23
Doxyfile
23
Doxyfile
|
@ -1,23 +0,0 @@
|
|||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = "ChibiOS-LCD-Driver"
|
||||
PROJECT_NUMBER = 0.0.1
|
||||
PROJECT_BRIEF = "Library for interfacing GLCDs with Touchpad to ChibiOS"
|
||||
OUTPUT_LANGUAGE = English
|
||||
TAB_SIZE = 2
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
INPUT =
|
||||
RECURSIVE = YES
|
||||
GENERATE_LATEX = NO
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_DYNAMIC_SECTIONS = YES
|
||||
GENERATE_TREEVIEW = YES
|
||||
DISABLE_INDEX = YES
|
||||
TREEVIEW_WIDTH = 300
|
||||
SEARCHENGINE = YES
|
||||
CLASS_DIAGRAMS = YES
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = YES
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
|
1747
Doxygenfile
Normal file
1747
Doxygenfile
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,14 +0,0 @@
|
|||
This file is a complete history of persons who contributed to the GLCD Library.
|
||||
|
||||
At this point we want to thank all of these people for their work.
|
||||
|
||||
|
||||
Date NickName RealName Contribution
|
||||
==== ======== ======== ============
|
||||
|
||||
30.07.2012 inmarket Andrew Hannam halext implementation
|
||||
- dxli Dongxu Li lcdDrawEllipse() filled option
|
||||
- benwilliam - fastMath & lcdDrawEllipse()
|
||||
- Badger Thomas Saunders console implementation, FSMC
|
||||
- Abhishek Abhishek Kakkar font rendering, S6D1121 GPIO
|
||||
|
24
demos/README
24
demos/README
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
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 are a few demos, showing how to use the library.
|
||||
|
||||
Please note that this are not compilable projects.
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2012
|
||||
ChibiOS-LCD-Driver - Copyright (C) 2012
|
||||
Joel Bodenmann aka Tectu <joel@unormal.org>
|
||||
|
||||
This file is part of ChibiOS-LCD-Driver.
|
||||
|
@ -20,32 +20,28 @@
|
|||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "glcd.h"
|
||||
#include "test.h"
|
||||
#include "gdisp.h"
|
||||
#include "chprintf.h"
|
||||
#include "console.h"
|
||||
|
||||
static GLCDDriver GLCDD1;
|
||||
static GLCDConsole CON1;
|
||||
|
||||
int main(void) {
|
||||
halInit();
|
||||
chSysInit();
|
||||
|
||||
// init LCD and clear it
|
||||
lcdInit(&GLCDD1);
|
||||
lcdClear(Black);
|
||||
gdispInit();
|
||||
gdispClear(Lime);
|
||||
|
||||
// init console
|
||||
lcdConsoleInit(&CON1, 0, 0, lcdGetWidth(), lcdGetHeight(), font_Small, Black, White);
|
||||
lcdConsoleInit(&CON1, 0, 0, gdispGetWidth(), gdispGetHeight(), &fontLarger, Black, White);
|
||||
|
||||
|
||||
chprintf((BaseSequentialStream *)&CON1, "Hello the time is %d\nGoodbye.", chTimeNow());
|
||||
|
||||
// use test thread for console output
|
||||
TestThread((BaseSequentialStream*)&CON1);
|
||||
|
||||
while (TRUE) {
|
||||
|
||||
chThdSleepMilliseconds(200);
|
||||
|
||||
chThdSleepMilliseconds(100);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
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 "hal.h"
|
||||
#include "glcd.h"
|
||||
|
||||
static GLCDDriver GLCDD1;
|
||||
|
||||
int main(void) {
|
||||
halInit();
|
||||
chSysInit();
|
||||
|
||||
lcdInit(&GLCDD1);
|
||||
lcdClear(Black);
|
||||
lcdDrawString(100, 100, "Hello World", White, Black);
|
||||
|
||||
lcdMoveCursor(10,10,White, Black);
|
||||
chprintf((BaseSequentialStream *)&GLCDD1, "chTimeNow: %d", chTimeNow());
|
||||
|
||||
lcdDrawCircle(150, 150, 10, filled, Green);
|
||||
lcdDrawLine(0, 0, lcdGetWidth(), lcdGetHeight(), Yellow);
|
||||
|
||||
while (TRUE) {
|
||||
|
||||
chThdSleepMilliseconds(200);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
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 "hal.h"
|
||||
#include "gui.h"
|
||||
#include "glcd.h"
|
||||
#include "touchpad.h"
|
||||
|
||||
// GLCD driver object
|
||||
static GLCDDriver GLCDD1;
|
||||
|
||||
int main(void) {
|
||||
uint8_t setActive, setState, clearActive, clearState;
|
||||
|
||||
halInit();
|
||||
chSysInit();
|
||||
|
||||
// Initializes the LCD
|
||||
lcdInit(&GLCDD1);
|
||||
|
||||
// Initializes the touchpad
|
||||
tpInit(&SPID1);
|
||||
|
||||
// clear the entire LCD screen
|
||||
lcdClear(Black);
|
||||
|
||||
// Initializes the GUI thread
|
||||
// 10ms interval
|
||||
// HIGHPRIO thread priority level
|
||||
guiInit(10, HIGHPRIO);
|
||||
|
||||
// set the following buttons to active
|
||||
// buttons wouldn't have any effect if you set these variables to 'inactive'
|
||||
setActive = active;
|
||||
clearActive = active;
|
||||
|
||||
// draw a button to set, and one to clear the LED
|
||||
guiDrawButton(10, 10, 60, 60, "Set", font_Larger, Black, Yellow, 6, "SetButton", &setActive, &setState);
|
||||
guiDrawButton(70, 10, 120, 60, "Clear", font_Larger, Black, Red, 6, "ClearButton", &clearActive, &clearState);
|
||||
|
||||
// you can delete a GUI element at any time from the GUI. You have to pass the GUI element name here.
|
||||
// please note that you have to redraw the screen to delete the element yourself.
|
||||
// guiDeleteElement("SetButton");
|
||||
// guiDeleteElement("ClearButton");
|
||||
|
||||
while (TRUE) {
|
||||
|
||||
// check if button 'set' is pressed
|
||||
if(setState)
|
||||
palSetPad(GPIOD, GPIOD_LED3);
|
||||
|
||||
// check if button 'clear' is pressed
|
||||
if(clearState)
|
||||
palClearPad(GPIOD, GPIOD_LED3);
|
||||
|
||||
chThdSleepMilliseconds(200);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2012
|
||||
ChibiOS-LCD-Driver - Copyright (C) 2012
|
||||
Joel Bodenmann aka Tectu <joel@unormal.org>
|
||||
|
||||
This file is part of ChibiOS-LCD-Driver.
|
||||
|
@ -18,18 +18,22 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XPT2046_LLD_H
|
||||
#define XPT2046_LLD_H
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "gdisp.h"
|
||||
|
||||
#include "glcd.h"
|
||||
#include "touchpad.h"
|
||||
int main(void) {
|
||||
halInit();
|
||||
chSysInit();
|
||||
|
||||
#ifdef TOUCHPAD_USE_XPT2046
|
||||
gdispInit();
|
||||
gdispClear(Black);
|
||||
|
||||
uint16_t lld_tpReadX(void);
|
||||
uint16_t lld_tpReadY(void);
|
||||
uint16_t lld_tpReadZ(void);
|
||||
// gdispDrawXXX(...);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
while (TRUE) {
|
||||
|
||||
chThdSleepMilliseconds(100);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
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 "hal.h"
|
||||
#include "glcd.h"
|
||||
|
||||
static GLCDDriver GLCDD1;
|
||||
|
||||
int main(void) {
|
||||
halInit();
|
||||
chSysInit();
|
||||
|
||||
lcdInit(&GLCDD1);
|
||||
lcdClear(Black);
|
||||
lcdDrawString(100, 100, "Hello World", White, Black);
|
||||
|
||||
// wait two seconds to see current LCD content
|
||||
chThdSleepSeconds(2);
|
||||
|
||||
// brings LCD to sleep mode
|
||||
lcdSetPowerMode(sleepOn);
|
||||
|
||||
// wait two seconds to see current LCD content
|
||||
chThdSleepSeconds(2);
|
||||
|
||||
// brings LCD back from sleep mode
|
||||
// content displayed before gets displayed again
|
||||
lcdSetPowerMode(sleepOff);
|
||||
|
||||
while (TRUE) {
|
||||
|
||||
chThdSleepMilliseconds(200);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
4
demos/readme.txt
Normal file
4
demos/readme.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
This folder contains a few demos which explain how to use the library.
|
||||
|
||||
Only the main files are contained. No compile-able projects
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2012
|
||||
ChibiOS-LCD-Driver - Copyright (C) 2012
|
||||
Joel Bodenmann aka Tectu <joel@unormal.org>
|
||||
|
||||
This file is part of ChibiOS-LCD-Driver.
|
||||
|
@ -18,18 +18,29 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ADS7843_LLD_H
|
||||
#define ADS7843_LLD_H
|
||||
|
||||
#include "glcd.h"
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "gdisp.h"
|
||||
#include "touchpad.h"
|
||||
|
||||
#ifdef TOUCHPAD_USE_ADS7843
|
||||
TOUCHPADDriver TOUCHPADD1 = {
|
||||
&SPID1,
|
||||
};
|
||||
|
||||
uint16_t lld_tpReadX(void);
|
||||
uint16_t lld_tpReadY(void);
|
||||
uint16_t lld_tpReadZ(void);
|
||||
int main(void) {
|
||||
halInit();
|
||||
chSysInit();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
gdispInit();
|
||||
gdispClear(Lime);
|
||||
|
||||
tpInit(&TOUCHPADD1);
|
||||
tpCalibrate();
|
||||
|
||||
gdispClear(Lime);
|
||||
|
||||
while (TRUE) {
|
||||
gdispDrawFillCircle(tpReadX(), tpReadY(), 3, Black);
|
||||
}
|
||||
}
|
||||
|
20
docs/console.txt
Normal file
20
docs/console.txt
Normal file
|
@ -0,0 +1,20 @@
|
|||
The console module acts as a BaseSequentialStream at a user defined area of the LCD.
|
||||
|
||||
Requirements:
|
||||
The console code requires a lld that has vertical scroll implemented.
|
||||
It is also necessary to enable the scroll code:
|
||||
|
||||
#define GDISP_NEED_SCROLL TRUE
|
||||
|
||||
Usage:
|
||||
|
||||
#include "console.h"
|
||||
|
||||
/* Define a console object */
|
||||
GLCDConsole CON1;
|
||||
|
||||
/* initialise the console to take up the entire screen */
|
||||
lcdConsoleInit(&CON1, 0, 0, 320, 240, &fontLarger, Black, White);
|
||||
|
||||
/* print something */
|
||||
chprintf((BaseSequentialStream *)&CON1, "Hello the time is %d\nGoodbye.", chTimeNow());
|
25
docs/contributors.txt
Normal file
25
docs/contributors.txt
Normal file
|
@ -0,0 +1,25 @@
|
|||
This file is a complete history of persons who contributed to the GLCD Library.
|
||||
|
||||
At this point we want to thank all of these people for their work.
|
||||
|
||||
|
||||
NickName RealName Contribution
|
||||
======== ======== ============
|
||||
|
||||
inmarket Andrew Hannam GDISP (restructorizing the entire library)
|
||||
VMT
|
||||
ASYNC and MULTITHREAD implementation
|
||||
|
||||
Badger Thomas Saunders console implementation
|
||||
FSMC for STM32F1 and F4
|
||||
lld orientation fixed for S6F1121 and SSD1289
|
||||
|
||||
Abhishek Abhishek Kumar S6D1121 GPIO
|
||||
font rendering
|
||||
touchpad noise filtering & optimizations
|
||||
|
||||
benwilliam - lcdDrawEllipse()
|
||||
fastMath
|
||||
|
||||
dxli Dongxu Li lcdDrawEllipse() filled option
|
||||
|
106
docs/files.txt
Normal file
106
docs/files.txt
Normal file
|
@ -0,0 +1,106 @@
|
|||
This is a tree of the toplevel directory of the GLCD library.
|
||||
The maintainer is supposed to keep it up to date at any new release.
|
||||
|
||||
├── demos
|
||||
│ ├── lcd
|
||||
│ │ └── main.c
|
||||
│ ├── readme.txt
|
||||
│ └── touchpad
|
||||
│ └── main.c
|
||||
├── docs
|
||||
│ ├── contributors.txt
|
||||
│ ├── files.txt
|
||||
│ ├── readme.txt
|
||||
│ ├── releases.txt
|
||||
│ └── usage.txt
|
||||
├── Doxygenfile
|
||||
├── drivers
|
||||
│ ├── gdisp
|
||||
│ │ ├── gdispNokia6610
|
||||
│ │ │ ├── gdisp_lld_board_example.h
|
||||
│ │ │ ├── gdisp_lld_board_olimexsam7ex256.h
|
||||
│ │ │ ├── gdisp_lld.c
|
||||
│ │ │ ├── gdisp_lld_config.h
|
||||
│ │ │ ├── gdisp_lld.mk
|
||||
│ │ │ ├── GE12.h
|
||||
│ │ │ ├── GE8.h
|
||||
│ │ │ └── readme.txt
|
||||
│ │ ├── gdispS6d1121
|
||||
│ │ │ ├── gdisp_lld.c
|
||||
│ │ │ ├── gdisp_lld_config.h
|
||||
│ │ │ ├── gdisp_lld.mk
|
||||
│ │ │ ├── readme.txt
|
||||
│ │ │ └── s6d1121_lld.c.h
|
||||
│ │ ├── gdispSsd1289
|
||||
│ │ │ ├── gdisp_lld.c
|
||||
│ │ │ ├── gdisp_lld_config.h
|
||||
│ │ │ ├── gdisp_lld.mk
|
||||
│ │ │ ├── readme.txt
|
||||
│ │ │ └── ssd1289_lld.c.h
|
||||
│ │ ├── gdispTestStub
|
||||
│ │ │ ├── gdisp_lld.c
|
||||
│ │ │ ├── gdisp_lld_config.h
|
||||
│ │ │ ├── gdisp_lld.mk
|
||||
│ │ │ └── readme.txt
|
||||
│ │ └── gdispVMT
|
||||
│ │ ├── gdisp_lld.c
|
||||
│ │ ├── gdisp_lld_config.h
|
||||
│ │ ├── gdisp_lld_driver1.c
|
||||
│ │ ├── gdisp_lld_driver2.c
|
||||
│ │ ├── gdisp_lld.mk
|
||||
│ │ └── readme.txt
|
||||
│ └── touchpad
|
||||
│ ├── touchpadADS7843
|
||||
│ │ ├── readme.txt
|
||||
│ │ ├── touchpad_lld.c
|
||||
│ │ ├── touchpad_lld_config.h
|
||||
│ │ └── touchpad_lld.mk
|
||||
│ └── touchpadXPT2046
|
||||
│ ├── readme.txt
|
||||
│ ├── touchpad_lld.c
|
||||
│ ├── touchpad_lld_config.h
|
||||
│ └── touchpad_lld.mk
|
||||
├── include
|
||||
│ ├── console.h
|
||||
│ ├── gdisp_emulation.c
|
||||
│ ├── gdisp_fonts.h
|
||||
│ ├── gdisp.h
|
||||
│ ├── gdisp_lld.h
|
||||
│ ├── gdisp_lld_msgs.h
|
||||
│ ├── glcd.h
|
||||
│ ├── touchpad.h
|
||||
│ └── touchpad_lld.h
|
||||
├── lcd.mk
|
||||
├── license.txt
|
||||
├── old
|
||||
│ ├── graph
|
||||
│ │ ├── graph.c
|
||||
│ │ ├── graph.h
|
||||
│ │ └── graph.mk
|
||||
│ └── gui
|
||||
│ ├── gui.c
|
||||
│ ├── gui.h
|
||||
│ └── gui.mk
|
||||
├── readme.txt
|
||||
├── src
|
||||
│ ├── console.c
|
||||
│ ├── gdisp.c
|
||||
│ ├── gdisp_fonts.c
|
||||
│ ├── gdisp-readme.txt
|
||||
│ └── touchpad.c
|
||||
├── templates
|
||||
│ ├── gdispXXXXX
|
||||
│ │ ├── gdisp_lld.c
|
||||
│ │ ├── gdisp_lld_config.h
|
||||
│ │ ├── gdisp_lld.mk
|
||||
│ │ └── readme.txt
|
||||
│ ├── readme.txt
|
||||
│ └── touchpadXXXXX
|
||||
│ ├── touchpad_lld.c
|
||||
│ ├── touchpad_lld_config.h
|
||||
│ └── touchpad_lld.mk
|
||||
└── tools
|
||||
└── readme.txt
|
||||
|
||||
23 directories, 77 files
|
||||
|
2
docs/readme.txt
Normal file
2
docs/readme.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
This folder contains documentation about this GLCD library.
|
||||
|
7
docs/releases.txt
Normal file
7
docs/releases.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
*****************************************************************************
|
||||
*** Releases ***
|
||||
*****************************************************************************
|
||||
|
||||
*** 0.1.0 ***
|
||||
FIX: removed gdisp and touchpad prefix of driver directories
|
||||
|
|
@ -5,17 +5,20 @@ To include any of these functions/drivers in your project...
|
|||
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
|
||||
3/ Add $(LCDSRC) and $(LCDINC) to your SRCS and INCDIR of your projects Makefile
|
||||
|
||||
4/ In your project halconf.h turn on the support you want eg.
|
||||
4/ In your project Makefile add the makefiles for any specific drivers you want e.g
|
||||
include $(LCDLIB)/halext/drivers/touchpad/XPT2046/touchpad_lld.mk
|
||||
include $(LCDLIB)/halext/drivers/gdisp/Nokia6610/gdisp_lld.mk
|
||||
|
||||
5/ 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.
|
||||
*/
|
||||
|
@ -24,5 +27,6 @@ To include any of these functions/drivers in your project...
|
|||
/* Any driver specific defines required go here. The below line is an example. */
|
||||
#define GDISP_NEED_MULTITHREAD TRUE
|
||||
#endif
|
||||
5/ Do a make clean.
|
||||
|
||||
6/ Do a make clean.
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
LCD_DRIVERS_SRC = $(LCDLIB)/drivers/lcd/ssd1289_lld.c \
|
||||
$(LCDLIB)/drivers/lcd/s6d1121_lld.c \
|
||||
$(LCDLIB)/drivers/touchpad/ads7843_lld.c \
|
||||
$(LCDLIB)/drivers/touchpad/xpt2046_lld.c \
|
||||
|
||||
LCD_DRIVERS_INC = $(LCDLIB)/drivers/lcd \
|
||||
$(LCDLIB)/drivers/touchpad \
|
||||
|
5
drivers/gdisp/Nokia6610/gdisp_lld.mk
Normal file
5
drivers/gdisp/Nokia6610/gdisp_lld.mk
Normal file
|
@ -0,0 +1,5 @@
|
|||
# List the required driver.
|
||||
LCDSRC += $(LCDLIB)/drivers/gdisp/Nokia6610/gdisp_lld.c
|
||||
|
||||
# Required include directories
|
||||
LCDINC += $(LCDLIB)/drivers/gdisp/Nokia6610
|
|
@ -561,7 +561,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
|
|||
lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines);
|
||||
lld_lcdWriteStreamStart();
|
||||
gap = cx*abslines;
|
||||
for(i = 0; i < gap; i++) lld_lcdWriteData(color);
|
||||
for(i = 0; i < gap; i++) lld_lcdWriteData(bgcolor);
|
||||
lld_lcdWriteStreamStop();
|
||||
lld_lcdResetViewPort();
|
||||
}
|
5
drivers/gdisp/S6D1121/gdisp_lld.mk
Normal file
5
drivers/gdisp/S6D1121/gdisp_lld.mk
Normal file
|
@ -0,0 +1,5 @@
|
|||
# List the required driver.
|
||||
LCDSRC += $(LCDLIB)/drivers/gdisp/S6D1121/gdisp_lld.c
|
||||
|
||||
# Required include directories
|
||||
LCDINC += $(LCDLIB)/drivers/gdisp/S6D1121
|
|
@ -48,7 +48,7 @@
|
|||
#define GDISP_HARDWARE_ELLIPSEFILLS FALSE
|
||||
#define GDISP_HARDWARE_TEXT FALSE
|
||||
#define GDISP_HARDWARE_TEXTFILLS FALSE
|
||||
#define GDISP_HARDWARE_SCROLL FALSE
|
||||
#define GDISP_HARDWARE_SCROLL TRUE
|
||||
#define GDISP_HARDWARE_PIXELREAD FALSE
|
||||
#define GDISP_HARDWARE_CONTROL TRUE
|
||||
#define GDISP_HARDWARE_QUERY FALSE
|
|
@ -478,7 +478,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
|
|||
lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines);
|
||||
lld_lcdWriteStreamStart();
|
||||
gap = cx*abslines;
|
||||
for(i = 0; i < gap; i++) lld_lcdWriteData(color);
|
||||
for(i = 0; i < gap; i++) lld_lcdWriteData(bgcolor);
|
||||
lld_lcdWriteStreamStop();
|
||||
lld_lcdResetViewPort();
|
||||
}
|
5
drivers/gdisp/SSD1289/gdisp_lld.mk
Normal file
5
drivers/gdisp/SSD1289/gdisp_lld.mk
Normal file
|
@ -0,0 +1,5 @@
|
|||
# List the required driver.
|
||||
LCDSRC += $(LCDLIB)/drivers/gdisp/SSD1289/gdisp_lld.c
|
||||
|
||||
# Required include directories
|
||||
LCDINC += $(LCDLIB)/drivers/gdisp/SSD1289
|
5
drivers/gdisp/TestStub/gdisp_lld.mk
Normal file
5
drivers/gdisp/TestStub/gdisp_lld.mk
Normal file
|
@ -0,0 +1,5 @@
|
|||
# List the required driver.
|
||||
LCDSRC += $(LCDLIB)/drivers/gdisp/TestStub/gdisp_lld.c
|
||||
|
||||
# Required include directories
|
||||
LCDINC += $(LCDLIB)/drivers/gdisp/TestStub
|
7
drivers/gdisp/VMT/gdisp_lld.mk
Normal file
7
drivers/gdisp/VMT/gdisp_lld.mk
Normal file
|
@ -0,0 +1,7 @@
|
|||
# List the required driver.
|
||||
LCDSRC += $(LCDLIB)/drivers/gdisp/VMT/gdisp_lld.c \
|
||||
$(LCDLIB)/drivers/gdisp/VMT/gdisp_lld_driver1.c \
|
||||
$(LCDLIB)//drivers/gdisp/VMT/gdisp_lld_driver2.c
|
||||
|
||||
# Required include directories
|
||||
LCDINC += $(LCDLIB)/drivers/gdisp/VMT
|
|
@ -1,543 +0,0 @@
|
|||
/*
|
||||
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 "hal.h"
|
||||
|
||||
#include "s6d1121_lld.h"
|
||||
#include "chprintf.h"
|
||||
|
||||
#ifdef LCD_USE_S6D1121
|
||||
|
||||
static uint8_t orientation;
|
||||
extern uint16_t lcd_width, lcd_height;
|
||||
|
||||
/* 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));
|
||||
|
||||
static uint16_t buf[((SCREEN_HEIGHT > SCREEN_WIDTH ) ? SCREEN_HEIGHT : SCREEN_WIDTH)];
|
||||
|
||||
#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;
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef STM32F4XX
|
||||
// change pin mode back to digital output
|
||||
LCD_DATA_PORT->CRH = 0x33333333;
|
||||
LCD_DATA_PORT->CRL = 0x33333333;
|
||||
#else
|
||||
#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;
|
||||
}
|
||||
|
||||
void lld_lcdWriteIndex(uint16_t lcdReg) {
|
||||
LCD_RS_LOW;
|
||||
|
||||
lld_lcdwrite(lcdReg);
|
||||
|
||||
LCD_RS_HIGH;
|
||||
}
|
||||
|
||||
void lld_lcdWriteData(uint16_t lcdData) {
|
||||
lld_lcdwrite(lcdData);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
__inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
|
||||
uint16_t i;
|
||||
|
||||
for(i = 0; i < size; i++) {
|
||||
lld_lcdwrite(buffer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
__inline void lld_lcdReadStreamStart(void) {
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
__inline void lld_lcdReadStreamStop(void) {
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
__inline void lld_lcdReadStream(uint16_t *buffer, size_t 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;
|
||||
}
|
||||
|
||||
__inline void lld_lcdWriteStreamStart(void) {
|
||||
LCD_REG = 0x0022;
|
||||
}
|
||||
|
||||
__inline void lld_lcdWriteStreamStop(void) {
|
||||
|
||||
}
|
||||
|
||||
__inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
|
||||
uint16_t i;
|
||||
for(i = 0; i < size; i++)
|
||||
LCD_RAM = buffer[i];
|
||||
}
|
||||
|
||||
__inline void lld_lcdReadStreamStart(void) {
|
||||
LCD_REG = 0x0022;
|
||||
}
|
||||
|
||||
__inline void lld_lcdReadStreamStop(void) {
|
||||
|
||||
}
|
||||
|
||||
__inline void lld_lcdReadStream(uint16_t *buffer, size_t size) {
|
||||
uint16_t i;
|
||||
/* throw away first value read */
|
||||
volatile uint16_t dummy = LCD_RAM;
|
||||
|
||||
for(i = 0; i < size; i++) {
|
||||
buffer[i] = LCD_RAM;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void lld_lcdSetPowerMode(uint8_t powerMode) {
|
||||
/* TODO: implement */
|
||||
}
|
||||
|
||||
void lld_lcdInit(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_lcdResetWindow();
|
||||
}
|
||||
|
||||
void lld_lcdSetCursor(uint16_t x, uint16_t y) {
|
||||
/* R20h - 8 bit
|
||||
* R21h - 9 bit
|
||||
*/
|
||||
switch(lcdGetOrientation()) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void lld_lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) {
|
||||
uint32_t index = 0, area;
|
||||
|
||||
area = ((x1-x0)*(y1-y0));
|
||||
|
||||
lld_lcdSetWindow(x0, y0, x1, y1);
|
||||
|
||||
lld_lcdWriteStreamStart();
|
||||
|
||||
for(index = 0; index < area; index++)
|
||||
lld_lcdWriteData(color);
|
||||
|
||||
lld_lcdWriteStreamStop();
|
||||
|
||||
lld_lcdResetWindow();
|
||||
}
|
||||
|
||||
// Do not use now, will be fixed in future
|
||||
void lld_lcdSetOrientation(uint8_t newOrientation) {
|
||||
orientation = newOrientation;
|
||||
|
||||
switch(orientation) {
|
||||
case portrait:
|
||||
lld_lcdWriteReg(0x0001,0x0127);
|
||||
lld_lcdWriteReg(0x03, 0b0011);
|
||||
lcd_height = SCREEN_HEIGHT;
|
||||
lcd_width = SCREEN_WIDTH;
|
||||
break;
|
||||
case landscape:
|
||||
lld_lcdWriteReg(0x0001,0x0027);
|
||||
lld_lcdWriteReg(0x0003, 0b1011);
|
||||
lcd_height = SCREEN_WIDTH;
|
||||
lcd_width = SCREEN_HEIGHT;
|
||||
break;
|
||||
case portraitInv:
|
||||
lld_lcdWriteReg(0x0001,0x0127);
|
||||
lld_lcdWriteReg(0x0003, 0b0000);
|
||||
lcd_height = SCREEN_HEIGHT;
|
||||
lcd_width = SCREEN_WIDTH;
|
||||
break;
|
||||
case landscapeInv:
|
||||
lld_lcdWriteReg(0x0001,0x0027);
|
||||
lld_lcdWriteReg(0x0003, 0b1000);
|
||||
lcd_height = SCREEN_WIDTH;
|
||||
lcd_width = SCREEN_HEIGHT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lld_lcdResetWindow(void) {
|
||||
switch(lcdGetOrientation()) {
|
||||
case portrait:
|
||||
case portraitInv:
|
||||
lld_lcdSetWindow(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
break;
|
||||
case landscape:
|
||||
case landscapeInv:
|
||||
lld_lcdSetWindow(0, 0, SCREEN_HEIGHT, SCREEN_WIDTH);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lld_lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||
/* HSA / HEA are 8 bit
|
||||
* VSA / VEA are 9 bit
|
||||
* use masks 0x00FF and 0x01FF to enforce this
|
||||
*/
|
||||
switch(lcdGetOrientation()) {
|
||||
case portrait:
|
||||
lld_lcdWriteReg(0x46, (((x1-1) & 0x00FF) << 8) | (x0 & 0x00FF));
|
||||
lld_lcdWriteReg(0x48, y0 & 0x01FF);
|
||||
lld_lcdWriteReg(0x47, (y1-1) & 0x01FF);
|
||||
break;
|
||||
case landscape:
|
||||
lld_lcdWriteReg(0x46, (((y1-1) & 0x00FF) << 8) | (y1 & 0x00FF));
|
||||
lld_lcdWriteReg(0x48, x0 & 0x01FF);
|
||||
lld_lcdWriteReg(0x47, (x1-1) & 0x01FF);
|
||||
break;
|
||||
case portraitInv:
|
||||
lld_lcdWriteReg(0x46, (((SCREEN_WIDTH-x0-1) & 0x00FF) << 8) | ((SCREEN_WIDTH - x1) & 0x00FF));
|
||||
lld_lcdWriteReg(0x48, (SCREEN_HEIGHT-y1) & 0x01FF);
|
||||
lld_lcdWriteReg(0x47, (SCREEN_HEIGHT-y0-1) & 0x01FF);
|
||||
break;
|
||||
case landscapeInv:
|
||||
lld_lcdWriteReg(0x46, (((SCREEN_WIDTH - y0 - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - y1) & 0x00FF));
|
||||
lld_lcdWriteReg(0x48, (SCREEN_HEIGHT - x1) & 0x01FF);
|
||||
lld_lcdWriteReg(0x47, (SCREEN_HEIGHT - x0 - 1) & 0x01FF);
|
||||
break;
|
||||
}
|
||||
|
||||
lld_lcdSetCursor(x0, y0);
|
||||
}
|
||||
|
||||
void lld_lcdClear(uint16_t color) {
|
||||
uint32_t index = 0;
|
||||
lld_lcdSetCursor(0, 0);
|
||||
lld_lcdWriteStreamStart();
|
||||
|
||||
for(index = 0; index < SCREEN_WIDTH * SCREEN_HEIGHT; index++)
|
||||
lld_lcdWriteData(color);
|
||||
|
||||
lld_lcdWriteStreamStop();
|
||||
}
|
||||
|
||||
// Do not use!
|
||||
uint16_t lld_lcdGetPixelColor(uint16_t x, uint16_t y) {
|
||||
uint16_t dummy;
|
||||
|
||||
lld_lcdSetCursor(x,y);
|
||||
lld_lcdWriteStreamStart();
|
||||
|
||||
dummy = lld_lcdReadData();
|
||||
dummy = lld_lcdReadData();
|
||||
|
||||
lld_lcdWriteStreamStop();
|
||||
|
||||
return dummy;
|
||||
}
|
||||
|
||||
void lld_lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) {
|
||||
lld_lcdSetCursor(x, y);
|
||||
lld_lcdWriteReg(0x0022, color);
|
||||
}
|
||||
|
||||
uint16_t lld_lcdGetOrientation(void) {
|
||||
return orientation;
|
||||
}
|
||||
|
||||
uint16_t lld_lcdGetHeight(void) {
|
||||
return lcd_height;
|
||||
}
|
||||
|
||||
uint16_t lld_lcdGetWidth(void) {
|
||||
return lcd_width;
|
||||
}
|
||||
|
||||
/* a positive lines value shifts the screen up, negative down */
|
||||
/* TODO: test this */
|
||||
void lld_lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines) {
|
||||
uint16_t row0, row1;
|
||||
uint16_t i;
|
||||
|
||||
for(i = 0; i < ((y1-y0) - abs(lines)); i++) {
|
||||
if(lines > 0) {
|
||||
row0 = y0 + i + lines;
|
||||
row1 = y0 + i;
|
||||
} else {
|
||||
row0 = (y1 - i - 1) + lines;
|
||||
row1 = (y1 - i - 1);
|
||||
}
|
||||
|
||||
/* read row0 into the buffer and then write at row1*/
|
||||
lld_lcdSetWindow(x0, row0, x1, row0);
|
||||
lld_lcdReadStreamStart();
|
||||
lld_lcdReadStream(buf, x1-x0);
|
||||
lld_lcdReadStreamStop();
|
||||
|
||||
lld_lcdSetWindow(x0, row1, x1, row1);
|
||||
lld_lcdWriteStreamStart();
|
||||
lld_lcdWriteStream(buf, x1-x0);
|
||||
lld_lcdWriteStreamStop();
|
||||
}
|
||||
|
||||
lld_lcdResetWindow();
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
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
|
||||
|
||||
#include "glcd.h"
|
||||
|
||||
#ifdef LCD_USE_S6D1121
|
||||
|
||||
// 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
void lld_lcdInit(void);
|
||||
void lld_lcdSetCursor(uint16_t x, uint16_t y);
|
||||
void lld_lcdSetOrientation(uint8_t newOrientation);
|
||||
void lld_lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
||||
void lld_lcdClear(uint16_t color);
|
||||
void lld_lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color);
|
||||
uint16_t lld_lcdGetPixelColor(uint16_t x, uint16_t y);
|
||||
uint16_t lld_lcdGetOrientation(void);
|
||||
uint16_t lld_lcdGetHeight(void);
|
||||
uint16_t lld_lcdGetWidth(void);
|
||||
void lld_lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,469 +0,0 @@
|
|||
/*
|
||||
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 "ssd1289_lld.h"
|
||||
|
||||
#ifdef LCD_USE_SSD1289
|
||||
|
||||
uint8_t orientation;
|
||||
uint16_t DeviceCode;
|
||||
extern uint16_t lcd_width, lcd_height;
|
||||
|
||||
static uint16_t buf[((SCREEN_HEIGHT > SCREEN_WIDTH ) ? SCREEN_HEIGHT : SCREEN_WIDTH)];
|
||||
|
||||
#ifdef LCD_USE_GPIO
|
||||
|
||||
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 lcdRAM;
|
||||
|
||||
Clr_CS;
|
||||
lld_lcdWriteIndex(lcdReg);
|
||||
lcdRAM = lld_lcdReadData();
|
||||
|
||||
Set_CS;
|
||||
|
||||
return lcdRAM;
|
||||
}
|
||||
|
||||
__inline void lld_lcdWriteStreamStart(void) {
|
||||
Clr_CS;
|
||||
|
||||
lld_lcdWriteIndex(0x0022);
|
||||
}
|
||||
|
||||
__inline void lld_lcdWriteStreamStop(void) {
|
||||
Set_CS;
|
||||
}
|
||||
|
||||
__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;
|
||||
}
|
||||
}
|
||||
|
||||
__inline void lld_lcdReadStreamStart(void) {
|
||||
Clr_CS
|
||||
|
||||
lld_lcdWriteIndex(0x0022);
|
||||
}
|
||||
|
||||
__inline void lld_lcdReadStreamStop(void) {
|
||||
Set_CS;
|
||||
}
|
||||
|
||||
__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();
|
||||
}
|
||||
|
||||
#endif // LCD_USE_GPIO
|
||||
|
||||
#ifdef LCD_USE_SPI
|
||||
/* TODO */
|
||||
#endif // LCD_USE_SPI
|
||||
|
||||
#ifdef 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;
|
||||
volatile uint16_t dummy = LCD_RAM;
|
||||
return (LCD_RAM);
|
||||
}
|
||||
|
||||
__inline void lld_lcdWriteStreamStart(void) {
|
||||
LCD_REG = 0x0022;
|
||||
}
|
||||
|
||||
__inline void lld_lcdWriteStreamStop(void) {
|
||||
|
||||
}
|
||||
|
||||
__inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
|
||||
uint16_t i;
|
||||
for(i = 0; i < size; i++)
|
||||
LCD_RAM = buffer[i];
|
||||
}
|
||||
|
||||
__inline void lld_lcdReadStreamStart(void) {
|
||||
LCD_REG = 0x0022;
|
||||
}
|
||||
|
||||
__inline void lld_lcdReadStreamStop(void) {
|
||||
|
||||
}
|
||||
|
||||
__inline void lld_lcdReadStream(uint16_t *buffer, size_t size) {
|
||||
uint16_t i;
|
||||
/* throw away first value read */
|
||||
volatile uint16_t dummy = LCD_RAM;
|
||||
|
||||
for(i = 0; i < size; i++) {
|
||||
buffer[i] = LCD_RAM;
|
||||
}
|
||||
}
|
||||
#endif // LCD_USE_FSMC
|
||||
|
||||
static __inline void lld_lcdDelay(uint16_t us) {
|
||||
chThdSleepMicroseconds(us);
|
||||
}
|
||||
|
||||
void lld_lcdSetPowerMode(uint8_t powerMode) {
|
||||
switch(powerMode) {
|
||||
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
|
||||
lld_lcdInit();
|
||||
break;
|
||||
case sleepOn:
|
||||
lld_lcdWriteReg(0x0010, 0x0001); // enter sleep mode
|
||||
break;
|
||||
case sleepOff:
|
||||
lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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(lcdGetOrientation()) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void lld_lcdSetOrientation(uint8_t newOrientation) {
|
||||
orientation = newOrientation;
|
||||
|
||||
switch(orientation) {
|
||||
case portrait:
|
||||
lld_lcdWriteReg(0x0001, 0x2B3F);
|
||||
/* ID = 11 AM = 0 */
|
||||
lld_lcdWriteReg(0x0011, 0x6070);
|
||||
lcd_height = SCREEN_HEIGHT;
|
||||
lcd_width = SCREEN_WIDTH;
|
||||
break;
|
||||
case landscape:
|
||||
lld_lcdWriteReg(0x0001, 0x293F);
|
||||
/* ID = 11 AM = 1 */
|
||||
lld_lcdWriteReg(0x0011, 0x6078);
|
||||
lcd_height = SCREEN_WIDTH;
|
||||
lcd_width = SCREEN_HEIGHT;
|
||||
break;
|
||||
case portraitInv:
|
||||
lld_lcdWriteReg(0x0001, 0x2B3F);
|
||||
/* ID = 01 AM = 0 */
|
||||
lld_lcdWriteReg(0x0011, 0x6040);
|
||||
lcd_height = SCREEN_HEIGHT;
|
||||
lcd_width = SCREEN_WIDTH;
|
||||
break;
|
||||
case landscapeInv:
|
||||
lld_lcdWriteReg(0x0001, 0x293F);
|
||||
/* ID = 01 AM = 1 */
|
||||
lld_lcdWriteReg(0x0011, 0x6048);
|
||||
lcd_height = SCREEN_WIDTH;
|
||||
lcd_width = SCREEN_HEIGHT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lld_lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||
lld_lcdSetCursor(x0, y0);
|
||||
|
||||
/* 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(lcdGetOrientation()) {
|
||||
case portrait:
|
||||
lld_lcdWriteReg(0x44, (((x1-1) << 8) & 0xFF00 ) | (x0 & 0x00FF));
|
||||
lld_lcdWriteReg(0x45, y0 & 0x01FF);
|
||||
lld_lcdWriteReg(0x46, (y1-1) & 0x01FF);
|
||||
break;
|
||||
case landscape:
|
||||
lld_lcdWriteReg(0x44, (((y1-1) << 8) & 0xFF00) | (y1 & 0x00FF));
|
||||
lld_lcdWriteReg(0x45, x0 & 0x01FF);
|
||||
lld_lcdWriteReg(0x46, (x1-1) & 0x01FF);
|
||||
break;
|
||||
case portraitInv:
|
||||
lld_lcdWriteReg(0x44, (((SCREEN_WIDTH-x0-1) & 0x00FF) << 8) | ((SCREEN_WIDTH - x1) & 0x00FF));
|
||||
lld_lcdWriteReg(0x45, (SCREEN_HEIGHT-y1) & 0x01FF);
|
||||
lld_lcdWriteReg(0x46, (SCREEN_HEIGHT-y0-1) & 0x01FF);
|
||||
break;
|
||||
case landscapeInv:
|
||||
lld_lcdWriteReg(0x44, (((SCREEN_WIDTH - y0 - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - y1) & 0x00FF));
|
||||
lld_lcdWriteReg(0x45, (SCREEN_HEIGHT - x1) & 0x01FF);
|
||||
lld_lcdWriteReg(0x46, (SCREEN_HEIGHT - x0 - 1) & 0x01FF);
|
||||
break;
|
||||
}
|
||||
|
||||
lld_lcdSetCursor(x0, y0);
|
||||
}
|
||||
|
||||
void lld_lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) {
|
||||
uint32_t index = 0, area;
|
||||
|
||||
area = ((x1-x0)*(y1-y0));
|
||||
|
||||
lld_lcdSetWindow(x0, y0, x1, y1);
|
||||
lld_lcdWriteStreamStart();
|
||||
|
||||
for(index = 0; index < area; index++)
|
||||
lld_lcdWriteData(color);
|
||||
|
||||
lld_lcdWriteStreamStop();
|
||||
}
|
||||
|
||||
void lld_lcdClear(uint16_t color) {
|
||||
uint32_t index = 0;
|
||||
|
||||
lld_lcdSetCursor(0, 0);
|
||||
lld_lcdWriteStreamStart();
|
||||
|
||||
for(index = 0; index < SCREEN_WIDTH * SCREEN_HEIGHT; index++)
|
||||
lld_lcdWriteData(color);
|
||||
|
||||
lld_lcdWriteStreamStop();
|
||||
}
|
||||
|
||||
uint16_t lld_lcdGetPixelColor(uint16_t x, uint16_t y) {
|
||||
uint16_t dummy;
|
||||
|
||||
lld_lcdSetCursor(x,y);
|
||||
lld_lcdWriteStreamStart();
|
||||
|
||||
dummy = lld_lcdReadData();
|
||||
dummy = lld_lcdReadData();
|
||||
|
||||
lld_lcdWriteStreamStop();
|
||||
|
||||
return dummy;
|
||||
}
|
||||
|
||||
void lld_lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) {
|
||||
lld_lcdSetCursor(x, y);
|
||||
lld_lcdWriteReg(0x0022, color);
|
||||
}
|
||||
|
||||
void lld_lcdInit(void) {
|
||||
#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);
|
||||
}
|
||||
|
||||
uint16_t lld_lcdGetOrientation(void) {
|
||||
return orientation;
|
||||
}
|
||||
|
||||
uint16_t lld_lcdGetHeight(void) {
|
||||
return lcd_height;
|
||||
}
|
||||
|
||||
uint16_t lld_lcdGetWidth(void) {
|
||||
return lcd_width;
|
||||
}
|
||||
|
||||
/* a positive lines value shifts the screen up, negative down */
|
||||
void lld_lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines) {
|
||||
uint16_t row0, row1;
|
||||
uint16_t i;
|
||||
|
||||
lld_lcdSetWindow(x0, y0, x1, y1);
|
||||
|
||||
for(i = 0; i < ((y1-y0) - abs(lines)); i++) {
|
||||
if(lines > 0) {
|
||||
row0 = y0 + i + lines;
|
||||
row1 = y0 + i;
|
||||
} else {
|
||||
row0 = (y1 - i - 1) + lines;
|
||||
row1 = (y1 - i - 1);
|
||||
}
|
||||
|
||||
/* read row0 into the buffer and then write at row1*/
|
||||
lld_lcdSetWindow(x0, row0, x1, row0);
|
||||
lld_lcdReadStreamStart();
|
||||
lld_lcdReadStream(buf, x1-x0);
|
||||
lld_lcdReadStreamStop();
|
||||
|
||||
lld_lcdSetWindow(x0, row1, x1, row1);
|
||||
lld_lcdWriteStreamStart();
|
||||
lld_lcdWriteStream(buf, x1-x0);
|
||||
lld_lcdWriteStreamStop();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,182 +0,0 @@
|
|||
/*
|
||||
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
|
||||
|
||||
#include "glcd.h"
|
||||
|
||||
#ifdef LCD_USE_SSD1289
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void lld_lcdInit(void);
|
||||
void lld_lcdWriteStreamStart(void);
|
||||
void lld_lcdWriteStreamStop(void);
|
||||
void lld_lcdWriteStream(uint16_t *buffer, uint16_t size);
|
||||
void lld_lcdSetCursor(uint16_t x, uint16_t y);
|
||||
void lld_lcdSetOrientation(uint8_t newOrientation);
|
||||
void lld_lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
||||
void lld_lcdClear(uint16_t color);
|
||||
void lld_lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color);
|
||||
void lld_lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
||||
void lld_lcdSetPowerMode(uint8_t powerMode);
|
||||
uint16_t lld_lcdGetPixelColor(uint16_t x, uint16_t y);
|
||||
uint16_t lld_lcdGetOrientation(void);
|
||||
uint16_t lld_lcdGetHeight(void);
|
||||
uint16_t lld_lcdGetWidth(void);
|
||||
void lld_lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef 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);
|
||||
#endif
|
||||
|
||||
#ifdef LCD_USE_SPI
|
||||
/* TODO */
|
||||
#endif
|
||||
|
||||
#ifdef 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
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
248
drivers/touchpad/ADS7843/touchpad_lld.c
Normal file
248
drivers/touchpad/ADS7843/touchpad_lld.c
Normal file
|
@ -0,0 +1,248 @@
|
|||
/*
|
||||
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. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#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. */
|
||||
/*===========================================================================*/
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Local copy of the current touchpad driver */
|
||||
static const TOUCHPADDriver *tpDriver;
|
||||
|
||||
static uint16_t sampleBuf[7];
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver interrupt handlers. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver exported functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/* ---- Required Routines ---- */
|
||||
|
||||
/**
|
||||
* @brief Low level Touchpad driver initialization.
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
void tp_lld_init(const TOUCHPADDriver *tp) {
|
||||
tpDriver = tp;
|
||||
|
||||
if(tpDriver->direct_init)
|
||||
spiStart(tpDriver->spip, tpDriver->spicfg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reads a conversion from the touchpad
|
||||
*
|
||||
* @param[in] cmd The command bits to send to the touchpad
|
||||
*
|
||||
* @return The read value 12-bit right-justified
|
||||
*
|
||||
* @note This function only reads data, it is assumed that the pins are
|
||||
* configured properly and the bus has been acquired beforehand
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
uint16_t tp_lld_read_value(uint8_t cmd) {
|
||||
static uint8_t txbuf[3] = {0};
|
||||
static uint8_t rxbuf[3] = {0};
|
||||
uint16_t ret;
|
||||
|
||||
txbuf[0] = cmd;
|
||||
|
||||
spiExchange(tpDriver->spip, 3, txbuf, rxbuf);
|
||||
|
||||
ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 7-point median filtering code for touchpad samples
|
||||
*
|
||||
* @note This is an internally used routine only.
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static void tp_lld_filter(void) {
|
||||
uint16_t temp;
|
||||
int i,j;
|
||||
|
||||
for(i = 0; i < 4; i++) {
|
||||
for(j=i; j < 7; j++) {
|
||||
if(sampleBuf[i] > sampleBuf[j]) {
|
||||
/* Swap the values */
|
||||
temp = sampleBuf[i];
|
||||
sampleBuf[i] = sampleBuf[j];
|
||||
sampleBuf[j] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads out the X direction.
|
||||
*
|
||||
* @note The samples are median filtered for greater noise reduction
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
uint16_t tp_lld_read_x(void) {
|
||||
int i;
|
||||
|
||||
#if defined(SPI_USE_MUTUAL_EXCLUSION)
|
||||
spiAcquireBus(tpDriver->spip);
|
||||
#endif
|
||||
|
||||
TOUCHPAD_SPI_PROLOGUE();
|
||||
palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad);
|
||||
|
||||
/* Discard the first conversion - very noisy and keep the ADC on hereafter
|
||||
* till we are done with the sampling. Note that PENIRQ is disabled.
|
||||
*/
|
||||
tp_lld_read_value(0xD1);
|
||||
|
||||
for(i = 0; i < 7; i++) {
|
||||
sampleBuf[i]=tp_lld_read_value(0xD1);
|
||||
}
|
||||
|
||||
/* Switch on PENIRQ once again - perform a dummy read */
|
||||
tp_lld_read_value(0xD0);
|
||||
|
||||
palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad);
|
||||
TOUCHPAD_SPI_EPILOGUE();
|
||||
|
||||
#if defined(SPI_USE_MUTUAL_EXCLUSION)
|
||||
spiReleaseBus(tpDriver->spip);
|
||||
#endif
|
||||
|
||||
/* Find the median - use selection sort */
|
||||
tp_lld_filter();
|
||||
|
||||
return sampleBuf[3];
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Reads out the Y direction.
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
uint16_t tp_lld_read_y(void) {
|
||||
int i;
|
||||
|
||||
#if defined(SPI_USE_MUTUAL_EXCLUSION)
|
||||
spiAcquireBus(tpDriver->spip);
|
||||
#endif
|
||||
|
||||
TOUCHPAD_SPI_PROLOGUE();
|
||||
palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad);
|
||||
|
||||
/* Discard the first conversion - very noisy and keep the ADC on hereafter
|
||||
* till we are done with the sampling. Note that PENIRQ is disabled.
|
||||
*/
|
||||
tp_lld_read_value(0x91);
|
||||
|
||||
for(i = 0; i < 7; i++) {
|
||||
sampleBuf[i] = tp_lld_read_value(0x91);
|
||||
}
|
||||
|
||||
/* Switch on PENIRQ once again - perform a dummy read */
|
||||
tp_lld_read_value(0x90);
|
||||
|
||||
palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad);
|
||||
TOUCHPAD_SPI_EPILOGUE();
|
||||
|
||||
#ifdef SPI_USE_MUTUAL_EXCLUSION
|
||||
spiReleaseBus(tpDriver->spip);
|
||||
#endif
|
||||
|
||||
/* Find the median - use selection sort */
|
||||
tp_lld_filter();
|
||||
|
||||
return sampleBuf[3];
|
||||
}
|
||||
|
||||
/* ---- 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(tpDriver->tpIRQPort, tpDriver->tpIRQPin));
|
||||
}
|
||||
#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 */
|
||||
/** @} */
|
||||
|
6
drivers/touchpad/ADS7843/touchpad_lld.mk
Normal file
6
drivers/touchpad/ADS7843/touchpad_lld.mk
Normal file
|
@ -0,0 +1,6 @@
|
|||
# List the required driver.
|
||||
LCDSRC += $(LCDLIB)/drivers/touchpad/ADS7843/touchpad_lld.c
|
||||
|
||||
# Required include directories
|
||||
LCDINC += $(LCDLIB)/drivers/touchpad/ADS7843
|
||||
|
248
drivers/touchpad/XPT2046/touchpad_lld.c
Normal file
248
drivers/touchpad/XPT2046/touchpad_lld.c
Normal file
|
@ -0,0 +1,248 @@
|
|||
/*
|
||||
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. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#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. */
|
||||
/*===========================================================================*/
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Local copy of the current touchpad driver */
|
||||
static const TOUCHPADDriver *tpDriver;
|
||||
|
||||
static uint16_t sampleBuf[7];
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver interrupt handlers. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver exported functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/* ---- Required Routines ---- */
|
||||
|
||||
/**
|
||||
* @brief Low level Touchpad driver initialization.
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
void tp_lld_init(const TOUCHPADDriver *tp) {
|
||||
tpDriver = tp;
|
||||
|
||||
if(tpDriver->direct_init)
|
||||
spiStart(tpDriver->spip, tpDriver->spicfg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reads a conversion from the touchpad
|
||||
*
|
||||
* @param[in] cmd The command bits to send to the touchpad
|
||||
*
|
||||
* @return The read value 12-bit right-justified
|
||||
*
|
||||
* @note This function only reads data, it is assumed that the pins are
|
||||
* configured properly and the bus has been acquired beforehand
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
uint16_t tp_lld_read_value(uint8_t cmd) {
|
||||
static uint8_t txbuf[3] = {0};
|
||||
static uint8_t rxbuf[3] = {0};
|
||||
uint16_t ret;
|
||||
|
||||
txbuf[0] = cmd;
|
||||
|
||||
spiExchange(tpDriver->spip, 3, txbuf, rxbuf);
|
||||
|
||||
ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 7-point median filtering code for touchpad samples
|
||||
*
|
||||
* @note This is an internally used routine only.
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static void tp_lld_filter(void) {
|
||||
uint16_t temp;
|
||||
int i,j;
|
||||
|
||||
for(i = 0; i < 4; i++) {
|
||||
for(j=i; j < 7; j++) {
|
||||
if(sampleBuf[i] > sampleBuf[j]) {
|
||||
/* Swap the values */
|
||||
temp = sampleBuf[i];
|
||||
sampleBuf[i] = sampleBuf[j];
|
||||
sampleBuf[j] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads out the X direction.
|
||||
*
|
||||
* @note The samples are median filtered for greater noise reduction
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
uint16_t tp_lld_read_x(void) {
|
||||
int i;
|
||||
|
||||
#if defined(SPI_USE_MUTUAL_EXCLUSION)
|
||||
spiAcquireBus(tpDriver->spip);
|
||||
#endif
|
||||
|
||||
TOUCHPAD_SPI_PROLOGUE();
|
||||
palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad);
|
||||
|
||||
/* Discard the first conversion - very noisy and keep the ADC on hereafter
|
||||
* till we are done with the sampling. Note that PENIRQ is disabled.
|
||||
*/
|
||||
tp_lld_read_value(0xD1);
|
||||
|
||||
for(i = 0; i < 7; i++) {
|
||||
sampleBuf[i]=tp_lld_read_value(0xD1);
|
||||
}
|
||||
|
||||
/* Switch on PENIRQ once again - perform a dummy read */
|
||||
tp_lld_read_value(0xD0);
|
||||
|
||||
palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad);
|
||||
TOUCHPAD_SPI_EPILOGUE();
|
||||
|
||||
#if defined(SPI_USE_MUTUAL_EXCLUSION)
|
||||
spiReleaseBus(tpDriver->spip);
|
||||
#endif
|
||||
|
||||
/* Find the median - use selection sort */
|
||||
tp_lld_filter();
|
||||
|
||||
return sampleBuf[3];
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Reads out the Y direction.
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
uint16_t tp_lld_read_y(void) {
|
||||
int i;
|
||||
|
||||
#if defined(SPI_USE_MUTUAL_EXCLUSION)
|
||||
spiAcquireBus(tpDriver->spip);
|
||||
#endif
|
||||
|
||||
TOUCHPAD_SPI_PROLOGUE();
|
||||
palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad);
|
||||
|
||||
/* Discard the first conversion - very noisy and keep the ADC on hereafter
|
||||
* till we are done with the sampling. Note that PENIRQ is disabled.
|
||||
*/
|
||||
tp_lld_read_value(0x91);
|
||||
|
||||
for(i = 0; i < 7; i++) {
|
||||
sampleBuf[i] = tp_lld_read_value(0x91);
|
||||
}
|
||||
|
||||
/* Switch on PENIRQ once again - perform a dummy read */
|
||||
tp_lld_read_value(0x90);
|
||||
|
||||
palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad);
|
||||
TOUCHPAD_SPI_EPILOGUE();
|
||||
|
||||
#ifdef SPI_USE_MUTUAL_EXCLUSION
|
||||
spiReleaseBus(tpDriver->spip);
|
||||
#endif
|
||||
|
||||
/* Find the median - use selection sort */
|
||||
tp_lld_filter();
|
||||
|
||||
return sampleBuf[3];
|
||||
}
|
||||
|
||||
/* ---- 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(tpDriver->tpIRQPort, tpDriver->tpIRQPin));
|
||||
}
|
||||
#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 */
|
||||
/** @} */
|
||||
|
6
drivers/touchpad/XPT2046/touchpad_lld.mk
Normal file
6
drivers/touchpad/XPT2046/touchpad_lld.mk
Normal file
|
@ -0,0 +1,6 @@
|
|||
# List the required driver.
|
||||
LCDSRC += $(LCDLIB)/drivers/touchpad/XPT2046/touchpad_lld.c
|
||||
|
||||
# Required include directories
|
||||
LCDINC += $(LCDLIB)/drivers/touchpad/XPT2046
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
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 "xpt2046_lld.h"
|
||||
|
||||
#ifdef TOUCHPAD_USE_XPT2046
|
||||
|
||||
__inline uint16_t lld_tpReadX(void) {
|
||||
uint8_t txbuf[1];
|
||||
uint8_t rxbuf[2];
|
||||
uint16_t x;
|
||||
|
||||
txbuf[0] = 0xd0;
|
||||
TP_CS_LOW;
|
||||
spiSend(&SPID1, 1, txbuf);
|
||||
spiReceive(&SPID1, 2, rxbuf);
|
||||
TP_CS_HIGH;
|
||||
|
||||
x = rxbuf[0] << 4;
|
||||
x |= rxbuf[1] >> 4;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
__inline uint16_t lld_tpReadY(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;
|
||||
}
|
||||
|
||||
__inline uint16_t lld_tpReadZ(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
431
glcd/glcd.c
431
glcd/glcd.c
|
@ -1,431 +0,0 @@
|
|||
/*
|
||||
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 "hal.h"
|
||||
|
||||
#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
|
||||
|
||||
/* Hack 1: Manually load the low level driver capabilities first so we can
|
||||
* control what we implement with hardware scrolling and pixel read.
|
||||
*/
|
||||
#include "gdisp_lld_config.h"
|
||||
|
||||
/* Hack 2: Force on the bits of functionality that glcd needs. */
|
||||
#define HAL_USE_GDISP TRUE
|
||||
#define GDISP_NEED_VALIDATION FALSE /* The original glcd didn't so we don't here either */
|
||||
#define GDISP_NEED_CIRCLE TRUE
|
||||
#define GDISP_NEED_ELLIPSE TRUE
|
||||
#define GDISP_NEED_TEXT TRUE
|
||||
#define GDISP_NEED_SCROLL GDISP_HARDWARE_SCROLL
|
||||
#define GDISP_NEED_PIXELREAD GDISP_HARDWARE_PIXELREAD
|
||||
#define GDISP_NEED_CONTROL TRUE
|
||||
#define GDISP_NEED_MULTITHREAD FALSE /* We implement multi-thread here */
|
||||
|
||||
/* Now load the low level driver and font structure definitions */
|
||||
#include "gdisp_lld.h"
|
||||
#include "gdisp_fonts.h"
|
||||
|
||||
/* Hack 3: GLCD only supports RGB565. Anything else would require significant API changes. */
|
||||
#ifndef GDISP_PIXELFORMAT_RGB565
|
||||
#error "GLCD only support drivers with RGB565 pixel format"
|
||||
#endif
|
||||
|
||||
/* Now load the glcd headers */
|
||||
#include "glcd.h"
|
||||
#include "glcdWorker.h"
|
||||
|
||||
/* Hack 4: Include the emulation code and font tables.
|
||||
* We have to include it here rather than compiling
|
||||
* the files as we need to pass our control defines
|
||||
* as they are not being defined by the application.
|
||||
* We need to turn off the inclusion of gdisp.h due
|
||||
* to conflicting type defines etc.
|
||||
*/
|
||||
#define _GDISP_H // Prevent gdisp.h from being included
|
||||
#include "gdisp_emulation.c"
|
||||
#include "gdisp_fonts.c"
|
||||
|
||||
#define EMSG(a) struct a *emsg = (struct a*)msg
|
||||
|
||||
static Thread *workerThread = NULL;
|
||||
|
||||
static WORKING_AREA(waGLCDWorkerThread, GLCD_WORKER_SIZE);
|
||||
static msg_t ThreadGLCDWorker(void *arg) {
|
||||
(void)arg;
|
||||
Thread *p;
|
||||
|
||||
chRegSetThreadName("GLCDWorker");
|
||||
|
||||
while(TRUE) {
|
||||
/* Wait for msg with work to do. */
|
||||
p = chMsgWait();
|
||||
struct glcd_msg_base *msg = (struct glcd_msg_base*)chMsgGet(p);
|
||||
glcd_result_t result = GLCD_PROGRESS;
|
||||
|
||||
/* do work here */
|
||||
switch(msg->action) {
|
||||
case GLCD_SET_POWERMODE: {
|
||||
EMSG(glcd_msg_powermode);
|
||||
gdisp_lld_control(GDISP_CONTROL_POWER, (void *)(int)emsg->powermode);
|
||||
result = GLCD_DONE;
|
||||
break;
|
||||
}
|
||||
|
||||
case GLCD_SET_ORIENTATION: {
|
||||
EMSG(glcd_msg_orientation);
|
||||
gdisp_lld_control(GDISP_CONTROL_ORIENTATION, (void *)(int)emsg->newOrientation);
|
||||
result = GLCD_DONE;
|
||||
break;
|
||||
}
|
||||
case GLCD_FILL_AREA: {
|
||||
EMSG(glcd_msg_fill_area);
|
||||
gdisp_lld_fillarea(emsg->x0, emsg->y0, emsg->x1-emsg->x0+1,emsg->y1-emsg->y0+1,emsg->color);
|
||||
result = GLCD_DONE;
|
||||
break;
|
||||
}
|
||||
|
||||
case GLCD_WRITE_AREA: {
|
||||
EMSG(glcd_msg_write_area);
|
||||
gdisp_lld_blitarea(emsg->x0, emsg->y0, emsg->x1-emsg->x0+1, emsg->y1-emsg->y0+1, emsg->buffer);
|
||||
result = GLCD_DONE;
|
||||
break;
|
||||
}
|
||||
|
||||
case GLCD_CLEAR: {
|
||||
EMSG(glcd_msg_clear);
|
||||
gdisp_lld_clear(emsg->color);
|
||||
result = GLCD_DONE;
|
||||
break;
|
||||
}
|
||||
|
||||
case GLCD_GET_PIXEL_COLOR: {
|
||||
/* Hack 5: This may now fail if the low level driver doesn't
|
||||
* support it. Previously this support was required
|
||||
* in the driver by GLCD
|
||||
*/
|
||||
#if GDISP_HARDWARE_READPIXEL
|
||||
((struct glcd_msg_get_pixel_color *)emsg)->color =
|
||||
gdisp_lld_getpixelcolor(emsg->x, emsg->y);
|
||||
result = GLCD_DONE;
|
||||
#else
|
||||
EMSG(glcd_msg_get_pixel_color);
|
||||
((struct glcd_msg_get_pixel_color *)emsg)->color = 0;
|
||||
result = GLCD_FAILED;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
case GLCD_DRAW_PIXEL: {
|
||||
EMSG(glcd_msg_draw_pixel);
|
||||
gdisp_lld_drawpixel(emsg->x, emsg->y, emsg->color);
|
||||
result = GLCD_DONE;
|
||||
break;
|
||||
}
|
||||
|
||||
case GLCD_VERTICAL_SCROLL: {
|
||||
/* Hack 6: This may now fail if the low level driver doesn't
|
||||
* support it. Previously this support was required
|
||||
* in the driver by GLCD
|
||||
*/
|
||||
#if GDISP_HARDWARE_SCROLL
|
||||
EMSG(glcd_msg_vertical_scroll);
|
||||
gdisp_lld_verticalscroll(emsg->x0, emsg->y0, emsg->x1-emsg->x0+1, emsg->y1-emsg->y0+1, emsg->lines, 0);
|
||||
result = GLCD_DONE;
|
||||
#else
|
||||
result = GLCD_FAILED;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
case GLCD_DRAW_CHAR: {
|
||||
EMSG(glcd_msg_draw_char);
|
||||
if (emsg->tpText)
|
||||
gdisp_lld_drawchar(emsg->cx, emsg->cy, emsg->c, emsg->font, emsg->color);
|
||||
else
|
||||
gdisp_lld_fillchar(emsg->cx, emsg->cy, emsg->c, emsg->font, emsg->color, emsg->bkcolor);
|
||||
/* We can't normally access a high level function here but in this case it is safe
|
||||
* because the routine only accesses const data members (multi-thread safe).
|
||||
*/
|
||||
emsg->ret_width = lcdMeasureChar(emsg->c, emsg->font);
|
||||
result = GLCD_DONE;
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
result = GLCD_FAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Done, release msg again. */
|
||||
chMsgRelease(p, (msg_t)result);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void lcdInit(GLCDDriver *UNUSED(glcdp)) {
|
||||
workerThread = chThdCreateStatic(waGLCDWorkerThread, sizeof(waGLCDWorkerThread), NORMALPRIO, ThreadGLCDWorker, NULL);
|
||||
|
||||
gdisp_lld_init();
|
||||
}
|
||||
|
||||
uint16_t lcdGetHeight(void) {
|
||||
return GDISP.Height;
|
||||
}
|
||||
|
||||
uint16_t lcdGetWidth(void) {
|
||||
return GDISP.Width;
|
||||
}
|
||||
|
||||
uint16_t lcdGetOrientation(void) {
|
||||
return GDISP.Orientation;
|
||||
}
|
||||
|
||||
glcd_result_t lcdSetPowerMode(uint8_t powerMode) {
|
||||
struct glcd_msg_powermode msg;
|
||||
|
||||
msg.action = GLCD_SET_POWERMODE;
|
||||
msg.powermode = powerMode;
|
||||
|
||||
return (glcd_result_t)chMsgSend(workerThread, (msg_t)&msg);
|
||||
}
|
||||
|
||||
glcd_result_t lcdSetOrientation(uint8_t newOrientation) {
|
||||
struct glcd_msg_orientation msg;
|
||||
|
||||
msg.action = GLCD_SET_ORIENTATION;
|
||||
msg.newOrientation = newOrientation;
|
||||
|
||||
return (glcd_result_t)chMsgSend(workerThread, (msg_t)&msg);
|
||||
}
|
||||
|
||||
glcd_result_t lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) {
|
||||
struct glcd_msg_fill_area msg;
|
||||
|
||||
msg.action = GLCD_FILL_AREA;
|
||||
msg.x0 = x0;
|
||||
msg.y0 = y0;
|
||||
msg.x1 = x1;
|
||||
msg.y1 = y1;
|
||||
msg.color = color;
|
||||
|
||||
return (glcd_result_t)chMsgSend(workerThread, (msg_t)&msg);
|
||||
}
|
||||
|
||||
glcd_result_t lcdWriteArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t *buffer, size_t n) {
|
||||
struct glcd_msg_write_area msg;
|
||||
|
||||
msg.action = GLCD_WRITE_AREA;
|
||||
msg.x0 = x0;
|
||||
msg.y0 = y0;
|
||||
msg.x1 = x1;
|
||||
msg.y1 = y1;
|
||||
msg.buffer = buffer;
|
||||
msg.size = n;
|
||||
|
||||
return (glcd_result_t)chMsgSend(workerThread, (msg_t)&msg);
|
||||
}
|
||||
|
||||
glcd_result_t lcdClear(uint16_t color) {
|
||||
struct glcd_msg_clear msg;
|
||||
|
||||
msg.action = GLCD_CLEAR;
|
||||
msg.color = color;
|
||||
|
||||
return (glcd_result_t)chMsgSend(workerThread, (msg_t)&msg);
|
||||
}
|
||||
|
||||
uint16_t lcdGetPixelColor(uint16_t x, uint16_t y) {
|
||||
struct glcd_msg_get_pixel_color msg;
|
||||
|
||||
msg.action = GLCD_GET_PIXEL_COLOR;
|
||||
msg.x = x;
|
||||
msg.y = y;
|
||||
|
||||
chMsgSend(workerThread, (msg_t)&msg);
|
||||
|
||||
return msg.color;
|
||||
}
|
||||
|
||||
glcd_result_t lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) {
|
||||
struct glcd_msg_draw_pixel msg;
|
||||
|
||||
msg.action = GLCD_DRAW_PIXEL;
|
||||
msg.x = x;
|
||||
msg.y = y;
|
||||
msg.color = color;
|
||||
|
||||
return (glcd_result_t)chMsgSend(workerThread, (msg_t)&msg);
|
||||
}
|
||||
|
||||
glcd_result_t lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines) {
|
||||
struct glcd_msg_vertical_scroll msg;
|
||||
|
||||
msg.action = GLCD_VERTICAL_SCROLL;
|
||||
msg.x0 = x0;
|
||||
msg.y0 = y0;
|
||||
msg.x1 = x1;
|
||||
msg.y1 = y1;
|
||||
msg.lines = lines;
|
||||
|
||||
return (glcd_result_t)chMsgSend(workerThread, (msg_t)&msg);
|
||||
}
|
||||
|
||||
void lcdDrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) {
|
||||
struct glcd_msg_draw_line msg;
|
||||
|
||||
msg.action = GLCD_DRAW_LINE;
|
||||
msg.x0 = x0;
|
||||
msg.y0 = y0;
|
||||
msg.x1 = x1;
|
||||
msg.y1 = y1;
|
||||
msg.color = color;
|
||||
|
||||
chMsgSend(workerThread, (msg_t)&msg);
|
||||
}
|
||||
|
||||
uint16_t lcdDrawChar(uint16_t cx, uint16_t cy, char c, font_t font, uint16_t color, uint16_t bkcolor, bool_t tpText) {
|
||||
struct glcd_msg_draw_char msg;
|
||||
|
||||
msg.action = GLCD_DRAW_CHAR;
|
||||
msg.cx = cx;
|
||||
msg.cy = cy;
|
||||
msg.c = c;
|
||||
msg.font = font;
|
||||
msg.color = color;
|
||||
msg.bkcolor = bkcolor;
|
||||
msg.tpText = tpText;
|
||||
msg.ret_width = 0;
|
||||
|
||||
chMsgSend(workerThread, (msg_t)&msg);
|
||||
|
||||
return msg.ret_width;
|
||||
}
|
||||
|
||||
void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color) {
|
||||
struct glcd_msg_draw_circle msg;
|
||||
|
||||
msg.action = GLCD_DRAW_CIRCLE;
|
||||
msg.x = x;
|
||||
msg.y = y;
|
||||
msg.radius = radius;
|
||||
msg.filled = filled;
|
||||
msg.color = color;
|
||||
|
||||
chMsgSend(workerThread, (msg_t)&msg);
|
||||
}
|
||||
|
||||
void lcdDrawEllipse(uint16_t x, uint16_t y, uint16_t a, uint16_t b, uint8_t filled, uint16_t color) {
|
||||
struct glcd_msg_draw_ellipse msg;
|
||||
|
||||
msg.action = GLCD_DRAW_ELLIPSE;
|
||||
msg.x = x;
|
||||
msg.y = y;
|
||||
msg.a = a;
|
||||
msg.b = b;
|
||||
msg.filled = filled;
|
||||
msg.color = color;
|
||||
|
||||
chMsgSend(workerThread, (msg_t)&msg);
|
||||
}
|
||||
|
||||
/* WARNING: No boundary checks! Unpredictable behaviour if text exceeds boundary */
|
||||
void lcdDrawString(uint16_t x, uint16_t y, const char *str, font_t font, uint16_t color, uint16_t bkcolor, bool_t tpText) {
|
||||
uint16_t cx = x, cy = y;
|
||||
|
||||
while (*str) {
|
||||
cx += lcdDrawChar(cx, cy, *str++, font, color, bkcolor, tpText);
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t lcdMeasureChar(char c, font_t font) {
|
||||
return (_getCharWidth(font, c)+font->charPadding) * font->xscale;
|
||||
}
|
||||
|
||||
uint16_t lcdMeasureString(const char *str, font_t font) {
|
||||
uint16_t result = 0;
|
||||
|
||||
/* Measure each char width, add it, return the result */
|
||||
while (*str)
|
||||
result += lcdMeasureChar(*str++, font);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
uint16_t lcdGetFontHeight(font_t font) {
|
||||
return font->height;
|
||||
}
|
||||
|
||||
uint16_t lcdBGR2RGB(uint16_t color) {
|
||||
uint16_t r, g, b, rgb;
|
||||
|
||||
b = ( color>>0 ) & 0x1f;
|
||||
g = ( color>>5 ) & 0x3f;
|
||||
r = ( color>>11 ) & 0x1f;
|
||||
|
||||
rgb = (b<<11) + (g<<5) + (r<<0);
|
||||
|
||||
return( rgb );
|
||||
}
|
||||
|
||||
void lcdDrawRect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t filled, uint16_t color) {
|
||||
uint16_t TempX;
|
||||
uint16_t TempY;
|
||||
|
||||
if (x0 > x1) {
|
||||
TempX = x1;
|
||||
x1 = x0;
|
||||
x0 = TempX;
|
||||
}
|
||||
if (y0 > y1) {
|
||||
TempY = y1;
|
||||
y1 = y0;
|
||||
y0 = TempY;
|
||||
}
|
||||
if(filled) {
|
||||
lcdFillArea(x0, y0, x1+1, y1+1, color);
|
||||
} else {
|
||||
lcdDrawLine(x0, y0, x1, y0, color);
|
||||
lcdDrawLine(x0, y1, x1, y1, color);
|
||||
lcdDrawLine(x0, y0, x0, y1, color);
|
||||
lcdDrawLine(x1, y0, x1, y1+1, color);
|
||||
}
|
||||
}
|
||||
|
||||
void lcdDrawRectString(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, const char* str, font_t font, uint16_t fontColor, uint16_t bkColor) {
|
||||
uint16_t off_left, off_up;
|
||||
|
||||
off_left = ((x1-x0)-lcdMeasureString(str, font))/2;
|
||||
off_up = ((y1-y0) - lcdGetFontHeight(font)) / 2;
|
||||
|
||||
lcdDrawRect(x0, y0, x1, y1, filled, bkColor);
|
||||
/* Abhishek: default to solid text for this? */
|
||||
lcdDrawString(x0+off_left, y0+off_up, str, font, fontColor, bkColor, solid);
|
||||
}
|
148
glcd/glcd.h
148
glcd/glcd.h
|
@ -1,148 +0,0 @@
|
|||
/*
|
||||
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 GLCD_H
|
||||
#define GLCD_H
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
#define PORTRAIT (lcdGetOrientation() == portrait || lcdGetOrientation() == portraitInv)
|
||||
#define LANDSCAPE (lcdGetOrientation() == landscape || lcdGetOrientation() == landscapeInv)
|
||||
|
||||
/* New 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;
|
||||
|
||||
/* Old font names */
|
||||
#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)
|
||||
|
||||
/* LCD color - Note that GLCD only supports 16 bit color in the API */
|
||||
#define White 0xFFFF
|
||||
#define Black 0x0000
|
||||
#define Grey 0xF7DE
|
||||
#define Blue 0x001F
|
||||
#define Blue2 0x051F
|
||||
#define Red 0xF800
|
||||
#define Magenta 0xF81F
|
||||
#define Green 0x07E0
|
||||
#define Cyan 0x7FFF
|
||||
#define Yellow 0xFFE0
|
||||
|
||||
#define RGB565CONVERT(red, green, blue) \
|
||||
(uint16_t)( (( red >> 3 ) << 11 ) | (( green >> 2 ) << 5 ) | ( blue >> 3 ))
|
||||
|
||||
#ifndef _GDISP_LLD_H
|
||||
/* Don't double define these at the low level driver */
|
||||
typedef const struct font *font_t;
|
||||
enum orientation {portrait, landscape, portraitInv, landscapeInv};
|
||||
enum powermode {powerOff, powerSleep, powerOn};
|
||||
#define sleepOn powerSleep
|
||||
#define sleepOff powerOn
|
||||
#endif
|
||||
|
||||
enum filled {frame, filled};
|
||||
enum transparency {solid, transparent};
|
||||
|
||||
/**
|
||||
* @brief Structure representing a GLCD driver.
|
||||
*/
|
||||
typedef struct GLCDDriver GLCDDriver;
|
||||
|
||||
struct GLCDDriver {
|
||||
};
|
||||
|
||||
enum glcd_result { GLCD_DONE,
|
||||
GLCD_FAILED,
|
||||
GLCD_PROGRESS,
|
||||
};
|
||||
|
||||
typedef enum glcd_result glcd_result_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Core functions */
|
||||
void lcdInit(GLCDDriver *GLCDD1);
|
||||
glcd_result_t lcdClear(uint16_t color);
|
||||
glcd_result_t lcdSetOrientation(uint8_t newOrientation);
|
||||
glcd_result_t lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
||||
glcd_result_t lcdWriteArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t *buffer, size_t n);
|
||||
glcd_result_t lcdSetPowerMode(uint8_t powerMode);
|
||||
|
||||
/* Drawing functions */
|
||||
glcd_result_t lcdDrawPixel(uint16_t x, uint16_t y, uint16_t point);
|
||||
void lcdDrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
||||
void lcdDrawRect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t filled, uint16_t color);
|
||||
void lcdDrawRectString(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, const char* str, font_t font, uint16_t fontColor, uint16_t bkColor);
|
||||
void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color);
|
||||
void lcdDrawEllipse(uint16_t x, uint16_t y, uint16_t a, uint16_t b, uint8_t filled, uint16_t color);
|
||||
|
||||
/* Text Rendering Functions */
|
||||
uint16_t lcdDrawChar(uint16_t cx, uint16_t cy, char c, font_t font, uint16_t color, uint16_t bkcolor, bool_t tpText);
|
||||
void lcdDrawString(uint16_t x, uint16_t y, const char *str, font_t font, uint16_t color, uint16_t bkcolor, bool_t tpText);
|
||||
|
||||
/* Character measuring functions */
|
||||
uint16_t lcdMeasureChar(char c, font_t font);
|
||||
uint16_t lcdMeasureString(const char* str, font_t font);
|
||||
uint16_t lcdGetFontHeight(font_t font);
|
||||
|
||||
/* Size and orientation related */
|
||||
uint16_t lcdGetHeight(void);
|
||||
uint16_t lcdGetWidth(void);
|
||||
uint16_t lcdGetOrientation(void);
|
||||
|
||||
/* BGR->RGB and pixel readback */
|
||||
uint16_t lcdBGR2RGB(uint16_t color);
|
||||
uint16_t lcdGetPixelColor(uint16_t x, uint16_t y);
|
||||
|
||||
/* Scrolling function */
|
||||
glcd_result_t lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,5 +0,0 @@
|
|||
LCD_GLCD_SRC = $(LCDLIB)/glcd/glcd.c \
|
||||
$(LCDLIB)/glcd/console.c
|
||||
|
||||
LCD_GLCD_INC = $(LCDLIB)/glcd \
|
||||
${CHIBIOS}/os/halext/include ${CHIBIOS}/os/halext/src
|
|
@ -1,170 +0,0 @@
|
|||
/*
|
||||
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 GLCD_WORKER_H
|
||||
#define GLCD_WORKER_H
|
||||
|
||||
#include "glcd.h"
|
||||
|
||||
#define GLCD_WORKER_SIZE 512
|
||||
|
||||
enum glcd_action { GLCD_SET_POWERMODE,
|
||||
GLCD_SET_ORIENTATION,
|
||||
GLCD_FILL_AREA,
|
||||
GLCD_WRITE_AREA,
|
||||
GLCD_CLEAR,
|
||||
GLCD_GET_PIXEL_COLOR,
|
||||
GLCD_DRAW_PIXEL,
|
||||
GLCD_VERTICAL_SCROLL,
|
||||
GLCD_DRAW_CHAR,
|
||||
GLCD_DRAW_LINE,
|
||||
GLCD_DRAW_CIRCLE,
|
||||
GLCD_DRAW_ELLIPSE,
|
||||
};
|
||||
|
||||
#define _glcd_msg_base \
|
||||
enum glcd_action action;
|
||||
|
||||
struct glcd_msg_base {
|
||||
_glcd_msg_base
|
||||
};
|
||||
|
||||
struct glcd_msg_powermode {
|
||||
_glcd_msg_base
|
||||
|
||||
uint8_t powermode;
|
||||
};
|
||||
|
||||
struct glcd_msg_orientation {
|
||||
_glcd_msg_base
|
||||
|
||||
uint8_t newOrientation;
|
||||
};
|
||||
|
||||
struct glcd_msg_set_window {
|
||||
_glcd_msg_base
|
||||
|
||||
uint16_t x0;
|
||||
uint16_t y0;
|
||||
uint16_t x1;
|
||||
uint16_t y1;
|
||||
};
|
||||
|
||||
struct glcd_msg_fill_area {
|
||||
_glcd_msg_base
|
||||
|
||||
uint16_t x0;
|
||||
uint16_t y0;
|
||||
uint16_t x1;
|
||||
uint16_t y1;
|
||||
uint16_t color;
|
||||
};
|
||||
|
||||
struct glcd_msg_write_area {
|
||||
_glcd_msg_base
|
||||
|
||||
uint16_t x0;
|
||||
uint16_t y0;
|
||||
uint16_t x1;
|
||||
uint16_t y1;
|
||||
uint16_t *buffer;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
struct glcd_msg_clear {
|
||||
_glcd_msg_base
|
||||
|
||||
uint16_t color;
|
||||
};
|
||||
|
||||
struct glcd_msg_get_pixel_color {
|
||||
_glcd_msg_base
|
||||
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
uint16_t color;
|
||||
};
|
||||
|
||||
struct glcd_msg_draw_pixel {
|
||||
_glcd_msg_base
|
||||
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
uint16_t color;
|
||||
};
|
||||
|
||||
struct glcd_msg_vertical_scroll {
|
||||
_glcd_msg_base
|
||||
|
||||
uint16_t x0;
|
||||
uint16_t y0;
|
||||
uint16_t x1;
|
||||
uint16_t y1;
|
||||
int16_t lines;
|
||||
};
|
||||
|
||||
struct glcd_msg_draw_line {
|
||||
_glcd_msg_base
|
||||
|
||||
uint16_t x0;
|
||||
uint16_t y0;
|
||||
uint16_t x1;
|
||||
uint16_t y1;
|
||||
int16_t color;
|
||||
};
|
||||
|
||||
struct glcd_msg_draw_circle {
|
||||
_glcd_msg_base
|
||||
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
uint16_t radius;
|
||||
uint16_t y1;
|
||||
uint8_t filled;
|
||||
int16_t color;
|
||||
};
|
||||
|
||||
struct glcd_msg_draw_ellipse {
|
||||
_glcd_msg_base
|
||||
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
uint16_t a;
|
||||
uint16_t b;
|
||||
uint16_t y1;
|
||||
uint8_t filled;
|
||||
int16_t color;
|
||||
};
|
||||
|
||||
struct glcd_msg_draw_char {
|
||||
_glcd_msg_base;
|
||||
|
||||
uint16_t cx;
|
||||
uint16_t cy;
|
||||
uint16_t color;
|
||||
uint16_t bkcolor;
|
||||
uint16_t ret_width;
|
||||
char c;
|
||||
font_t font;
|
||||
bool_t tpText;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
GLCD now uses the GDISP low level drivers and fonts.
|
||||
|
||||
To update your make to use this new version:
|
||||
Add the low level driver yo want to use to your make file. eg.
|
||||
include $(CHIBIOS)/os/halext/drivers/gdispTestStub/gdisp_lld.mk
|
||||
|
||||
There some restrictions that GLCD places on your use of new features and on the capabilities
|
||||
of the low level driver.
|
||||
|
||||
They are:
|
||||
1/ GLCD requires a driver that supports RGB565 pixel format. This is a
|
||||
limitation of the GLCD API. To update the API would create compatability
|
||||
issues with existing applications.
|
||||
2/ If you want to use the GLCD scroll or the GLCD read-pixel calls then your
|
||||
low level driver must support them. If it doesn't these calls will
|
||||
fail.
|
||||
3/ You cannot reduce the code size like in GDISP by defining macros to
|
||||
compile out code that you are not using.
|
||||
4/ Some of the new features of GDISP like right or center justified text are not
|
||||
supported as there is no equivelant API in GDISP.
|
||||
5/ There is no mechanism to send hardware specific commands to the low level driver
|
||||
such as commands to control the back-light.
|
||||
|
||||
What it does do that GDISP currently doesn't:
|
||||
1/ Asynchronous multi-thread support.
|
47
glcdconf.h
47
glcdconf.h
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
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 GLCDCONF_H
|
||||
#define GLCDCONF_H
|
||||
|
||||
#define SCREEN_WIDTH 240
|
||||
#define SCREEN_HEIGHT 320
|
||||
|
||||
/***** LCD CONTROLLER *****/
|
||||
#define LCD_USE_SSD1289
|
||||
// #define LCD_USE_S6D1121
|
||||
|
||||
|
||||
/***** LCD INTERFACE *****/
|
||||
#define LCD_USE_GPIO
|
||||
// #define LCD_USE_SPI
|
||||
// #define LCD_USE_FSMC
|
||||
|
||||
|
||||
/***** TOUCHPAD CONTROLLER *****/
|
||||
// #define TOUCHPAD_USE_ADS7843
|
||||
#define TOUCHPAD_USE_XPT2046
|
||||
|
||||
|
||||
/***** GUI OPTIONS *****/
|
||||
#define GUI_USE_ANIMATIONS
|
||||
|
||||
#endif
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# List the required driver.
|
||||
HALSRC += $(LCDLIB)/halext/drivers/gdispNokia6610/gdisp_lld.c
|
||||
|
||||
# Required include directories
|
||||
HALINC += $(LCDLIB)/halext/drivers/gdispNokia6610
|
|
@ -1,5 +0,0 @@
|
|||
# List the required driver.
|
||||
HALSRC += $(LCDLIB)/halext/drivers/gdispS6d1121/gdisp_lld.c
|
||||
|
||||
# Required include directories
|
||||
HALINC += $(LCDLIB)/halext/drivers/gdispS6d1121
|
|
@ -1,5 +0,0 @@
|
|||
# List the required driver.
|
||||
HALSRC += $(LCDLIB)/halext/drivers/gdispSsd1289/gdisp_lld.c
|
||||
|
||||
# Required include directories
|
||||
HALINC += $(LCDLIB)/halext/drivers/gdispSsd1289
|
|
@ -1,5 +0,0 @@
|
|||
# List the required driver.
|
||||
HALSRC += $(LCDLIB)/halext/drivers/gdispTestStub/gdisp_lld.c
|
||||
|
||||
# Required include directories
|
||||
HALINC += $(LCDLIB)/halext/drivers/gdispTestStub
|
|
@ -1,7 +0,0 @@
|
|||
# List the required driver.
|
||||
HALSRC += ${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
|
||||
HALINC += ${CHIBIOS}/os/halext/drivers/gdispVMT
|
|
@ -1,152 +0,0 @@
|
|||
/*
|
||||
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. */
|
||||
/*===========================================================================*/
|
||||
static const SPIConfig spicfg = {
|
||||
NULL,
|
||||
TP_CS_PORT,
|
||||
TP_CS,
|
||||
SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0,
|
||||
};
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 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, &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 */
|
||||
/** @} */
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
# List the required driver.
|
||||
HALSRC += $(LCDLIB)/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c
|
||||
|
||||
# Required include directories
|
||||
HALINC += $(LCDLIB)/halext/drivers/touchpad/touchpadADS7843
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
# List the required driver.
|
||||
HALSRC += $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c
|
||||
|
||||
# Required include directories
|
||||
HALINC += $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
# List of all the ChibiOS/RT META files, there is no need to remove the files
|
||||
# from this list, you can disable parts of the kernel by editing halconf.h.
|
||||
|
||||
HALSRC += $(LCDLIB)/halext/src/gdisp.c \
|
||||
$(LCDLIB)/halext/src/gdisp_fonts.c \
|
||||
$(LCDLIB)/halext/src/touchpad.c
|
||||
|
||||
# Required include directories
|
||||
HALINC += $(LCDLIB)/halext/include
|
|
@ -1,5 +0,0 @@
|
|||
# List the required driver.
|
||||
HALSRC += ${CHIBIOS}/os/halext/drivers/gdispYOURDEVICE/gdisp_lld.c
|
||||
|
||||
# Required include directories
|
||||
HALINC += ${CHIBIOS}/os/halext/drivers/gdispYOURDEVICE
|
|
@ -21,7 +21,10 @@
|
|||
#ifndef CONSOLE_H
|
||||
#define CONSOLE_H
|
||||
|
||||
#include "glcd.h"
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
#include "gdisp.h"
|
||||
|
||||
/**
|
||||
* @brief Structure representing a GLCD driver.
|
||||
|
@ -58,13 +61,13 @@ struct GLCDConsole {
|
|||
/* font */
|
||||
font_t font;
|
||||
/* lcd area to use */
|
||||
uint16_t x0,y0;
|
||||
coord_t x0,y0;
|
||||
/* current cursor position, in pixels */
|
||||
uint16_t cx,cy;
|
||||
coord_t cx,cy;
|
||||
/* console size in pixels */
|
||||
uint16_t sx,sy;
|
||||
coord_t sx,sy;
|
||||
/* foreground and background colour */
|
||||
uint16_t bkcolor, color;
|
||||
pixel_t bkcolor, color;
|
||||
/* font size in pixels */
|
||||
uint8_t fy;
|
||||
};
|
||||
|
@ -73,9 +76,9 @@ struct GLCDConsole {
|
|||
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 lcdConsoleInit(GLCDConsole *console, coord_t x0, coord_t y0, coord_t width, coord_t height, font_t font, pixel_t bkcolor, pixel_t color);
|
||||
msg_t lcdConsolePut(GLCDConsole *console, char c);
|
||||
msg_t lcdConsoleWrite(GLCDConsole *console, uint8_t *bp, size_t n);
|
||||
msg_t lcdConsoleWrite(GLCDConsole *console, char *bp, size_t n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
|
@ -70,7 +70,7 @@ struct cal {
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void tpInit(TOUCHPADDriver *tp);
|
||||
void tpInit(const TOUCHPADDriver *tp);
|
||||
uint16_t tpReadX(void);
|
||||
uint16_t tpReadY(void);
|
||||
|
|
@ -49,37 +49,76 @@
|
|||
#define TOUCHPAD_HAS_PRESSURE FALSE
|
||||
#endif
|
||||
|
||||
#ifndef TOUCHPAD_SPI_PROLOGUE
|
||||
#define TOUCHPAD_SPI_PROLOGUE()
|
||||
#endif
|
||||
|
||||
#ifndef TOUCHPAD_SPI_EPILOGUE
|
||||
#define TOUCHPAD_SPI_EPILOGUE()
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
typedef struct TOUCHPADDriver TOUCHPADDriver;
|
||||
typedef struct _TOUCHPADDriver TOUCHPADDriver;
|
||||
|
||||
/**
|
||||
* @brief Structure representing a Touchpad driver.
|
||||
*/
|
||||
struct TOUCHPADDriver {
|
||||
/*
|
||||
* @brief Pointer to SPI driver.
|
||||
* @note SPI driver must be enabled in mcu- and halconf.h
|
||||
*/
|
||||
SPIDriver *spid;
|
||||
struct _TOUCHPADDriver {
|
||||
/*
|
||||
* @brief Pointer to SPI driver.
|
||||
* @note SPI driver must be enabled in mcuconf.h and halconf.h
|
||||
*/
|
||||
SPIDriver *spip;
|
||||
|
||||
/*
|
||||
* @brief Pointer to the SPI configuration structure.
|
||||
* @note The lowest possible speed ~ 1-2MHz is to be used, otherwise
|
||||
* will result in a lot of noise
|
||||
*/
|
||||
const SPIConfig *spicfg;
|
||||
|
||||
/*
|
||||
* @brief Touchscreen controller TPIRQ pin GPIO port
|
||||
*/
|
||||
ioportid_t tpIRQPort;
|
||||
|
||||
/*
|
||||
* @brief Touchscreen controller TPIRQ GPIO pin
|
||||
* @note The interface is polled as of now, interrupt support is
|
||||
* to be implemented in the future.
|
||||
*/
|
||||
ioportmask_t tpIRQPin;
|
||||
|
||||
/*
|
||||
* @brief Initialize the SPI with the configuration struct given or not
|
||||
* If TRUE, spiStart is called by the init, otherwise not
|
||||
* @note This is provided in such a case when SPI port is being shared
|
||||
* across multiple peripherals, so not to disturb the SPI bus.
|
||||
* You can use TOUCHPAD_SPI_PROLOGUE() and TOUCHPAD_SPI_EPILOGUE()
|
||||
* macros to change the SPI configuration or speed before and
|
||||
* after using the touchpad. An example case would be sharing the
|
||||
* bus with a fast flash memory chip.
|
||||
*/
|
||||
bool_t direct_init;
|
||||
};
|
||||
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if !defined(__DOXYGEN__)
|
||||
extern TOUCHPADDriver Touchpad;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Core functions */
|
||||
void tp_lld_init(TOUCHPADDriver *tp);
|
||||
void tp_lld_init(const TOUCHPADDriver *tp);
|
||||
|
||||
uint16_t tp_lld_read_value(uint8_t cmd);
|
||||
uint16_t tp_lld_read_x(void);
|
||||
uint16_t tp_lld_read_y(void);
|
||||
|
30
lcd.mk
30
lcd.mk
|
@ -3,29 +3,9 @@ ifeq ($(LCDLIB),)
|
|||
LCDLIB = $(CHIBIOS)/ext/lcd
|
||||
endif
|
||||
|
||||
LCDSRC += $(LCDLIB)/src/gdisp.c \
|
||||
$(LCDLIB)/src/gdisp_fonts.c \
|
||||
$(LCDLIB)/src/touchpad.c \
|
||||
$(LCDLIB)/src/console.c
|
||||
|
||||
include $(LCDLIB)/halext/halext.mk
|
||||
|
||||
|
||||
|
||||
# this is used for the old structure - will get removed soon
|
||||
|
||||
#include $(LCDLIB)/drivers/drivers.mk
|
||||
#include $(LCDLIB)/glcd/glcd.mk
|
||||
#include $(LCDLIB)/touchpad/touchpad.mk
|
||||
#include $(LCDLIB)/graph/graph.mk
|
||||
#include $(LCDLIB)/gui/gui.mk
|
||||
|
||||
#LCDSRC = $(LCD_DRIVERS_SRC) \
|
||||
# $(LCD_GLCD_SRC) \
|
||||
# $(LCD_TOUCHPAD_SRC) \
|
||||
# $(LCD_GRAPH_SRC) \
|
||||
# $(LCD_GUI_SRC)
|
||||
|
||||
#LCDINC = $(LCDLIB) \
|
||||
# $(LCD_DRIVERS_INC) \
|
||||
# $(LCD_GLCD_INC) \
|
||||
# $(LCD_TOUCHPAD_INC) \
|
||||
# $(LCD_GRAPH_INC) \
|
||||
# $(LCD_GUI_INC)
|
||||
|
||||
LCDINC += $(LCDLIB)/include
|
||||
|
|
|
@ -19,14 +19,17 @@
|
|||
*/
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
#include "glcd.h"
|
||||
#include "gdisp.h"
|
||||
#include "gdisp_fonts.h"
|
||||
#include "console.h"
|
||||
|
||||
#if defined(GDISP_NEED_SCROLL)
|
||||
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
@ -90,14 +93,14 @@ static const struct GLCDConsoleVMT vmt = {
|
|||
};
|
||||
|
||||
|
||||
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 lcdConsoleInit(GLCDConsole *console, coord_t x0, coord_t y0, coord_t width, coord_t height, font_t font, pixel_t bkcolor, pixel_t color) {
|
||||
const uint8_t* ptr;
|
||||
uint16_t chi;
|
||||
uint16_t x,y;
|
||||
|
||||
console->vmt = &vmt;
|
||||
/* read font, get height */
|
||||
console->fy = lcdGetFontHeight(font);
|
||||
console->fy = font->height;
|
||||
|
||||
/* calculate the size of the console as an integer multiple of characters height*/
|
||||
console->sx = width;
|
||||
|
@ -113,7 +116,7 @@ msg_t lcdConsoleInit(GLCDConsole *console, uint16_t x0, uint16_t y0, uint16_t wi
|
|||
|
||||
console->font = font;
|
||||
|
||||
lcdFillArea(x0, y0, x0+width, y0+height, console->bkcolor);
|
||||
gdispFillArea(x0, y0, x0 + width, y0 + height, console->bkcolor);
|
||||
return RDY_OK;
|
||||
}
|
||||
|
||||
|
@ -123,7 +126,7 @@ msg_t lcdConsolePut(GLCDConsole *console, char c) {
|
|||
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,
|
||||
gdispFillArea(console->x0 + console->cx, console->y0 + console->cy,
|
||||
console->x0 + console->sx, console->y0 + console->cy + console->fy,
|
||||
console->bkcolor);
|
||||
console->cx = 0;
|
||||
|
@ -132,10 +135,10 @@ msg_t lcdConsolePut(GLCDConsole *console, char c) {
|
|||
/* TODO: work backwards through the buffer to the start of the current line */
|
||||
//console->cx = 0;
|
||||
} else {
|
||||
width = lcdMeasureChar(c, console->font);
|
||||
width = _getCharWidth(console->font, c);
|
||||
if((console->cx + width) >= console->sx) {
|
||||
/* clear the text at the end of the line */
|
||||
lcdFillArea(console->x0 + console->cx, console->y0 + console->cy,
|
||||
gdispFillArea(console->x0 + console->cx, console->y0 + console->cy,
|
||||
console->x0 + console->cx + width, console->y0 + console->cy + console->fy,
|
||||
console->bkcolor);
|
||||
console->cx = 0;
|
||||
|
@ -143,16 +146,16 @@ msg_t lcdConsolePut(GLCDConsole *console, char c) {
|
|||
}
|
||||
|
||||
if((console->cy > console->sy)) {
|
||||
|
||||
lcdVerticalScroll(console->x0, console->y0, console->x0 + console->sx,
|
||||
console->y0 + console->sy + console->fy, console->fy);
|
||||
/* scroll the screen */
|
||||
gdispVerticalScroll(console->x0, console->y0, console->x0 + console->sx,
|
||||
console->y0 + console->sy + console->fy, console->fy, console->bkcolor);
|
||||
/* 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);
|
||||
gdispDrawChar(console->x0 + console->cx, console->y0 + console->cy, c,
|
||||
console->font, console->color);
|
||||
|
||||
/* update cursor */
|
||||
console->cx += width;
|
||||
|
@ -160,7 +163,7 @@ msg_t lcdConsolePut(GLCDConsole *console, char c) {
|
|||
return RDY_OK;
|
||||
}
|
||||
|
||||
msg_t lcdConsoleWrite(GLCDConsole *console, uint8_t *bp, size_t n) {
|
||||
msg_t lcdConsoleWrite(GLCDConsole *console, char *bp, size_t n) {
|
||||
size_t i;
|
||||
for(i = 0; i < n; i++)
|
||||
lcdConsolePut(console, bp[i]);
|
||||
|
@ -169,3 +172,4 @@ msg_t lcdConsoleWrite(GLCDConsole *console, uint8_t *bp, size_t n) {
|
|||
}
|
||||
|
||||
|
||||
#endif /* GDISP_NEED_SCROLL */
|
|
@ -1,10 +1,10 @@
|
|||
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.
|
||||
The new GDISP driver is an architecture independent rewrite of the GLCD interface.
|
||||
This new architecture independence 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
|
||||
A glcd.h compatibility 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.
|
|
@ -69,13 +69,13 @@ static uint16_t _tpReadRealX(void) {
|
|||
uint32_t results = 0;
|
||||
uint16_t i, x;
|
||||
|
||||
/* Median filtering is already done in LLD */
|
||||
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);
|
||||
/* Take the average of the readings */
|
||||
x = results / CONVERSIONS;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
@ -89,13 +89,13 @@ static uint16_t _tpReadRealY(void) {
|
|||
uint32_t results = 0;
|
||||
uint16_t i, y;
|
||||
|
||||
/* Median filtering is already done in LLD */
|
||||
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);
|
||||
/* Take the average of the readings */
|
||||
y = results / CONVERSIONS;
|
||||
|
||||
return y;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ static void _tpDrawCross(uint16_t x, uint16_t y) {
|
|||
*
|
||||
* @api
|
||||
*/
|
||||
void tpInit(TOUCHPADDriver *tp) {
|
||||
void tpInit(const TOUCHPADDriver *tp) {
|
||||
/* Initialise Mutex */
|
||||
//MUTEX_INIT
|
||||
|
||||
|
@ -210,7 +210,7 @@ void tpCalibrate(void) {
|
|||
|
||||
//gdispSetOrientation(portrait);
|
||||
gdispClear(Red);
|
||||
gdispDrawString(40, 10, "Calibration", &fontUI1Double, White);
|
||||
gdispFillStringBox(0, 10, gdispGetWidth(), 30, "Calibration", &fontUI2Double, White, Red, justifyCenter);
|
||||
|
||||
for(i = 0; i < 2; i++) {
|
||||
_tpDrawCross(cross[i][0], cross[i][1]);
|
5
templates/gdispXXXXX/gdisp_lld.mk
Normal file
5
templates/gdispXXXXX/gdisp_lld.mk
Normal file
|
@ -0,0 +1,5 @@
|
|||
# List the required driver.
|
||||
LCDSRC += $(LCDLIB)/drivers/gdisp/gdispYOURDEVICE/gdisp_lld.c
|
||||
|
||||
# Required include directories
|
||||
LCDINC += $(LCDLIB)/drivers/gdisp/gdispYOURDEVICE
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue