2012-08-02 20:15:55 +00:00
|
|
|
/*
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
|
2012-06-12 12:36:06 +00:00
|
|
|
#ifndef GLCD_H
|
|
|
|
#define GLCD_H
|
|
|
|
|
|
|
|
#include "ch.h"
|
|
|
|
#include "hal.h"
|
2012-06-13 19:09:26 +00:00
|
|
|
#include "fonts.h"
|
2012-07-23 17:54:10 +00:00
|
|
|
#include "fastMath.h"
|
2012-06-25 12:57:42 +00:00
|
|
|
|
2012-06-25 17:51:35 +00:00
|
|
|
#if !defined(LCD_USE_FSMC) && !defined(LCD_USE_GPIO) && !defined(LCD_USE_SPI)
|
2012-06-25 12:57:42 +00:00
|
|
|
#include "glcdconf.h"
|
|
|
|
#endif
|
|
|
|
|
2012-06-16 23:35:21 +00:00
|
|
|
#include "ssd1289_lld.h"
|
|
|
|
#include "s6d1121_lld.h"
|
2012-06-12 12:36:06 +00:00
|
|
|
|
|
|
|
#define PORTRAIT (lcdGetOrientation() == portrait || lcdGetOrientation() == portraitInv)
|
|
|
|
#define LANDSCAPE (lcdGetOrientation() == landscape || lcdGetOrientation() == landscapeInv)
|
|
|
|
|
|
|
|
/* LCD color */
|
|
|
|
#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 ))
|
|
|
|
|
|
|
|
enum orientation {portrait, landscape, portraitInv, landscapeInv};
|
|
|
|
enum filled {frame, filled};
|
2012-06-13 20:34:17 +00:00
|
|
|
enum transparency {solid, transparent};
|
2012-06-23 12:04:56 +00:00
|
|
|
enum powermode {powerOff, powerOn, sleepOn, sleepOff};
|
2012-06-12 12:36:06 +00:00
|
|
|
|
2012-06-25 17:51:35 +00:00
|
|
|
typedef const uint8_t* font_t;
|
2012-06-12 12:36:06 +00:00
|
|
|
|
|
|
|
// A few macros
|
2012-06-25 17:51:35 +00:00
|
|
|
#define lcdGetFontHeight(font) (font[FONT_TABLE_HEIGHT_IDX])
|
2012-06-12 12:36:06 +00:00
|
|
|
|
2012-06-19 21:48:19 +00:00
|
|
|
/**
|
|
|
|
* @brief Structure representing a GLCD driver.
|
|
|
|
*/
|
|
|
|
typedef struct GLCDDriver GLCDDriver;
|
|
|
|
|
|
|
|
struct GLCDDriver {
|
|
|
|
};
|
|
|
|
|
2012-07-25 17:37:46 +00:00
|
|
|
enum glcd_result { GLCD_DONE,
|
|
|
|
GLCD_FAILED,
|
|
|
|
GLCD_PROGRESS,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum glcd_result glcd_result_t;
|
|
|
|
|
2012-06-19 19:05:01 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-06-25 17:51:35 +00:00
|
|
|
/* Core functions */
|
2012-06-27 21:34:36 +00:00
|
|
|
void lcdInit(GLCDDriver *GLCDD1);
|
2012-07-24 16:17:32 +00:00
|
|
|
glcd_result_t lcdClear(uint16_t color);
|
|
|
|
glcd_result_t lcdSetOrientation(uint8_t newOrientation);
|
|
|
|
glcd_result_t lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
|
|
|
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);
|
2012-06-12 12:36:06 +00:00
|
|
|
|
2012-06-25 17:51:35 +00:00
|
|
|
/* Drawing functions */
|
2012-07-24 16:17:32 +00:00
|
|
|
glcd_result_t lcdDrawPixel(uint16_t x, uint16_t y, uint16_t point);
|
2012-06-12 12:36:06 +00:00
|
|
|
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);
|
2012-06-25 17:51:35 +00:00
|
|
|
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);
|
2012-06-12 12:36:06 +00:00
|
|
|
void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color);
|
2012-07-12 12:54:33 +00:00
|
|
|
void lcdDrawEllipse(uint16_t x, uint16_t y, uint16_t a, uint16_t b, uint8_t filled, uint16_t color);
|
2012-06-12 12:36:06 +00:00
|
|
|
|
2012-06-25 17:51:35 +00:00
|
|
|
/* Text Rendering Functions */
|
2012-07-17 00:30:18 +00:00
|
|
|
uint16_t lcdDrawChar(uint16_t cx, uint16_t cy, char c, font_t font, uint16_t color, uint16_t bkcolor, bool_t tpText);
|
2012-06-25 17:51:35 +00:00
|
|
|
void lcdDrawString(uint16_t x, uint16_t y, const char *str, font_t font, uint16_t color, uint16_t bkcolor, bool_t tpText);
|
2012-06-12 12:36:06 +00:00
|
|
|
|
2012-06-25 17:51:35 +00:00
|
|
|
/* Character measuring functions */
|
|
|
|
uint16_t lcdMeasureChar(char c, font_t font);
|
|
|
|
uint16_t lcdMeasureString(const char* str, font_t font);
|
2012-06-12 12:36:06 +00:00
|
|
|
|
2012-06-25 17:51:35 +00:00
|
|
|
/* Size and orientation related */
|
2012-06-12 12:36:06 +00:00
|
|
|
uint16_t lcdGetHeight(void);
|
|
|
|
uint16_t lcdGetWidth(void);
|
|
|
|
uint16_t lcdGetOrientation(void);
|
|
|
|
|
2012-06-25 17:51:35 +00:00
|
|
|
/* BGR->RGB and pixel readback */
|
2012-06-12 12:36:06 +00:00
|
|
|
uint16_t lcdBGR2RGB(uint16_t color);
|
|
|
|
uint16_t lcdGetPixelColor(uint16_t x, uint16_t y);
|
|
|
|
|
2012-06-25 17:51:35 +00:00
|
|
|
/* Scrolling function */
|
2012-07-25 02:00:30 +00:00
|
|
|
glcd_result_t lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines);
|
2012-06-25 12:57:42 +00:00
|
|
|
|
2012-06-19 19:05:01 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-06-12 12:36:06 +00:00
|
|
|
#endif
|