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-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-19 22:17:10 +00:00
|
|
|
enum powermode {poweroff, poweron, standby};
|
2012-06-12 12:36:06 +00:00
|
|
|
|
|
|
|
// For text rendering only
|
|
|
|
extern uint16_t bgcolor, fgcolor;
|
|
|
|
extern uint16_t cx, cy;
|
2012-06-14 10:16:34 +00:00
|
|
|
extern const uint8_t* font;
|
2012-06-12 12:36:06 +00:00
|
|
|
|
|
|
|
// A few macros
|
|
|
|
#define lcdGotoXY(x,y) { cx=x; cy=y; }
|
|
|
|
#define lcdGetCurFontHeight() (font[FONT_TABLE_HEIGHT_IDX])
|
|
|
|
|
2012-06-19 21:48:19 +00:00
|
|
|
/**
|
|
|
|
* @brief Structure representing a GLCD driver.
|
|
|
|
*/
|
|
|
|
typedef struct GLCDDriver GLCDDriver;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief @p GLCDDriver specific methods.
|
|
|
|
*/
|
|
|
|
#define _glcd_driver_methods \
|
|
|
|
_base_asynchronous_channel_methods
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @extends BaseAsynchronousChannelVMT
|
|
|
|
*
|
|
|
|
* @brief @p GLCDDriver virtual methods table.
|
|
|
|
*/
|
|
|
|
struct GLCDDriverVMT {
|
|
|
|
_glcd_driver_methods
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @extends BaseAsynchronousChannel
|
|
|
|
*
|
|
|
|
* @brief GLCD driver class.
|
|
|
|
* @details This class extends @p BaseAsynchronousChannel by adding physical
|
|
|
|
* I/O queues.
|
|
|
|
*/
|
|
|
|
struct GLCDDriver {
|
|
|
|
/** @brief Virtual Methods Table.*/
|
|
|
|
const struct GLCDDriverVMT *vmt;
|
|
|
|
_base_asynchronous_channel_data
|
2012-06-19 22:35:16 +00:00
|
|
|
/* WARNING: Do not add any data to this struct above this comment, only below */
|
2012-06-19 21:48:19 +00:00
|
|
|
};
|
|
|
|
|
2012-06-19 19:05:01 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2012-06-19 21:48:19 +00:00
|
|
|
void lcdInit(GLCDDriver *);
|
2012-06-12 12:36:06 +00:00
|
|
|
|
|
|
|
void lcdClear(uint16_t color);
|
|
|
|
void lcdSetOrientation(uint8_t newOrientation);
|
|
|
|
void lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
|
|
|
void lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
2012-06-19 22:17:10 +00:00
|
|
|
void lcdSetPowerMode(uint8_t powerMode);
|
2012-06-12 12:36:06 +00:00
|
|
|
|
|
|
|
void 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, uint16_t fontColor, uint16_t bkColor);
|
|
|
|
void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color);
|
|
|
|
|
2012-06-13 20:34:17 +00:00
|
|
|
void lcdSetFontTransparency(uint8_t transparency);
|
2012-06-14 10:16:34 +00:00
|
|
|
void lcdSetFont(const uint8_t *newFont);
|
2012-06-19 21:48:19 +00:00
|
|
|
void lcdMoveCursor(uint16_t x, uint16_t y, uint16_t color, uint16_t bkcolor);
|
|
|
|
msg_t lcdDrawChar(char c);
|
|
|
|
size_t lcdWriteString(const char *str, size_t n);
|
|
|
|
size_t lcdPutString(const char *str);
|
2012-06-13 13:44:38 +00:00
|
|
|
void lcdDrawString(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bkcolor);
|
2012-06-12 12:36:06 +00:00
|
|
|
void lcdLineBreak(void);
|
|
|
|
|
|
|
|
uint16_t lcdMeasureChar(char c);
|
|
|
|
uint16_t lcdMeasureString(const char* str);
|
|
|
|
|
|
|
|
uint16_t lcdGetHeight(void);
|
|
|
|
uint16_t lcdGetWidth(void);
|
|
|
|
uint16_t lcdGetOrientation(void);
|
|
|
|
|
|
|
|
uint16_t lcdBGR2RGB(uint16_t color);
|
|
|
|
uint16_t lcdGetPixelColor(uint16_t x, uint16_t y);
|
|
|
|
|
2012-06-19 19:05:01 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-06-12 12:36:06 +00:00
|
|
|
#endif
|