1 | /*
|
---|
2 | * TOPPERS BASE PLATFORM MIDDLEWARE
|
---|
3 | *
|
---|
4 | * Copyright (C) 2017-2019 by TOPPERS PROJECT
|
---|
5 | * Educational Working Group.
|
---|
6 | *
|
---|
7 | * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
8 | * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
9 | * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
10 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
11 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
12 | * スコード中に含まれていること.
|
---|
13 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
14 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
15 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
16 | * の無保証規定を掲載すること.
|
---|
17 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
18 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
19 | * と.
|
---|
20 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
21 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
22 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
23 | * 報告すること.
|
---|
24 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
25 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
26 | * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
27 | * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
28 | * 免責すること.
|
---|
29 | *
|
---|
30 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
31 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
32 | * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
33 | * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
34 | * の責任を負わない.
|
---|
35 | *
|
---|
36 | * $Id$
|
---|
37 | */
|
---|
38 |
|
---|
39 | /*
|
---|
40 | * Written by Limor Fried/Ladyada for Adafruit Industries.
|
---|
41 | * MIT license, all text above must be included in any redistribution
|
---|
42 | * http://opensource.org/licenses/mit-license.php
|
---|
43 | */
|
---|
44 |
|
---|
45 | /*
|
---|
46 | * ADAFRUIT ILI9341 2.8"LCD制御プログラムのヘッダファイル
|
---|
47 | */
|
---|
48 |
|
---|
49 | #ifndef _ADAFRUIT_ILI9341_H_
|
---|
50 | #define _ADAFRUIT_ILI9341_H_
|
---|
51 |
|
---|
52 | #ifdef __cplusplus
|
---|
53 | extern "C" {
|
---|
54 | #endif
|
---|
55 |
|
---|
56 | #include "device.h"
|
---|
57 | #include "pinmode.h"
|
---|
58 | #include "spi.h"
|
---|
59 |
|
---|
60 | /*
|
---|
61 | * LCDカラーモード定義
|
---|
62 | */
|
---|
63 | #define CM_ARGB8888 0x00000000 /* ARGB8888 color mode */
|
---|
64 | #define CM_RGB888 0x00000001 /* RGB888 color mode */
|
---|
65 | #define CM_RGB565 0x00000002 /* RGB565 color mode */
|
---|
66 |
|
---|
67 |
|
---|
68 |
|
---|
69 | #define ILI9341_TFTWIDTH 240
|
---|
70 | #define ILI9341_TFTHEIGHT 320
|
---|
71 |
|
---|
72 | #define ILI9341_NOP 0x00
|
---|
73 | #define ILI9341_SWRESET 0x01
|
---|
74 | #define ILI9341_RDDID 0x04
|
---|
75 | #define ILI9341_RDDST 0x09
|
---|
76 |
|
---|
77 | #define ILI9341_SLPIN 0x10
|
---|
78 | #define ILI9341_SLPOUT 0x11
|
---|
79 | #define ILI9341_PTLON 0x12
|
---|
80 | #define ILI9341_NORON 0x13
|
---|
81 |
|
---|
82 | #define ILI9341_RDMODE 0x0A
|
---|
83 | #define ILI9341_RDMADCTL 0x0B
|
---|
84 | #define ILI9341_RDPIXFMT 0x0C
|
---|
85 | #define ILI9341_RDIMGFMT 0x0A
|
---|
86 | #define ILI9341_RDSELFDIAG 0x0F
|
---|
87 |
|
---|
88 | #define ILI9341_INVOFF 0x20
|
---|
89 | #define ILI9341_INVON 0x21
|
---|
90 | #define ILI9341_GAMMASET 0x26
|
---|
91 | #define ILI9341_DISPOFF 0x28
|
---|
92 | #define ILI9341_DISPON 0x29
|
---|
93 |
|
---|
94 | #define ILI9341_CASET 0x2A
|
---|
95 | #define ILI9341_PASET 0x2B
|
---|
96 | #define ILI9341_RAMWR 0x2C
|
---|
97 | #define ILI9341_RAMRD 0x2E
|
---|
98 |
|
---|
99 | #define ILI9341_PTLAR 0x30
|
---|
100 | #define ILI9341_MADCTL 0x36
|
---|
101 | #define ILI9341_PIXFMT 0x3A
|
---|
102 |
|
---|
103 | #define ILI9341_FRMCTR1 0xB1
|
---|
104 | #define ILI9341_FRMCTR2 0xB2
|
---|
105 | #define ILI9341_FRMCTR3 0xB3
|
---|
106 | #define ILI9341_INVCTR 0xB4
|
---|
107 | #define ILI9341_DFUNCTR 0xB6
|
---|
108 |
|
---|
109 | #define ILI9341_PWCTR1 0xC0
|
---|
110 | #define ILI9341_PWCTR2 0xC1
|
---|
111 | #define ILI9341_PWCTR3 0xC2
|
---|
112 | #define ILI9341_PWCTR4 0xC3
|
---|
113 | #define ILI9341_PWCTR5 0xC4
|
---|
114 | #define ILI9341_VMCTR1 0xC5
|
---|
115 | #define ILI9341_VMCTR2 0xC7
|
---|
116 |
|
---|
117 | #define ILI9341_RDID1 0xDA
|
---|
118 | #define ILI9341_RDID2 0xDB
|
---|
119 | #define ILI9341_RDID3 0xDC
|
---|
120 | #define ILI9341_RDID4 0xDD
|
---|
121 |
|
---|
122 | #define ILI9341_GMCTRP1 0xE0
|
---|
123 | #define ILI9341_GMCTRN1 0xE1
|
---|
124 |
|
---|
125 | // Color definitions
|
---|
126 | #define ILI9341_BLACK 0x0000
|
---|
127 | #define ILI9341_BLUE 0x001F
|
---|
128 | #define ILI9341_RED 0xF800
|
---|
129 | #define ILI9341_GREEN 0x07E0
|
---|
130 | #define ILI9341_CYAN 0x07FF
|
---|
131 | #define ILI9341_MAGENTA 0xF81F
|
---|
132 | #define ILI9341_YELLOW 0xFFE0
|
---|
133 | #define ILI9341_WHITE 0xFFFF
|
---|
134 |
|
---|
135 |
|
---|
136 | #ifndef TOPPERS_MACRO_ONLY
|
---|
137 |
|
---|
138 | /*
|
---|
139 | * カラーの属性を定義
|
---|
140 | */
|
---|
141 | typedef uint16_t color_t;
|
---|
142 |
|
---|
143 | /*
|
---|
144 | * LCDハンドラ構造体定義
|
---|
145 | */
|
---|
146 | typedef struct
|
---|
147 | {
|
---|
148 | SPI_Handle_t *hspi; /* spiハンドラ */
|
---|
149 | uint16_t _width; /* 幅ピクセル数 */
|
---|
150 | uint16_t _height; /* 高さピクセル数 */
|
---|
151 | uint16_t colstart;
|
---|
152 | uint16_t rowstart;
|
---|
153 | uint8_t rotation; /* LCD回転設定 */
|
---|
154 | uint8_t cs_pin;
|
---|
155 | uint8_t dc_pin;
|
---|
156 | uint8_t rst_pin;
|
---|
157 | ID spi_lock;
|
---|
158 | }LCD_Handler_t;
|
---|
159 |
|
---|
160 | /*
|
---|
161 | * 描画構造体
|
---|
162 | */
|
---|
163 | typedef struct
|
---|
164 | {
|
---|
165 | LCD_Handler_t *hlcd;
|
---|
166 | color_t TextColor;
|
---|
167 | color_t BackColor;
|
---|
168 | void *pFont;
|
---|
169 | }LCD_DrawProp_t;
|
---|
170 |
|
---|
171 | typedef struct
|
---|
172 | {
|
---|
173 | int16_t X;
|
---|
174 | int16_t Y;
|
---|
175 | }Point, * pPoint;
|
---|
176 |
|
---|
177 | /*
|
---|
178 | * 関数のプロトタイプ宣言
|
---|
179 | */
|
---|
180 | extern ER lcd_writecommand(LCD_Handler_t *hlcd, uint8_t c);
|
---|
181 | extern ER lcd_writedata(LCD_Handler_t *hlcd, uint8_t c);
|
---|
182 | extern ER lcd_writedata2(LCD_Handler_t *hlcd, uint16_t c, int cnt);
|
---|
183 | extern ER lcd_writedata3(LCD_Handler_t *hlcd, uint8_t *pbmp, uint16_t width, uint16_t height);
|
---|
184 |
|
---|
185 | extern void lcd_init(LCD_Handler_t *hlcd, uint8_t rotation);
|
---|
186 | extern void lcd_setAddrWindow(LCD_Handler_t *hlcd, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
---|
187 | extern void lcd_fillRect(LCD_Handler_t *hlcd, int16_t x, int16_t y, int16_t w, int16_t h, color_t color);
|
---|
188 | extern void lcd_pushColor(LCD_Handler_t *hlcd, color_t color);
|
---|
189 | extern void lcd_drawPixel(LCD_Handler_t *hlcd, int16_t x, int16_t y, color_t color);
|
---|
190 | extern void lcd_drawFastVLine(LCD_Handler_t *hlcd, int16_t x, int16_t y, int16_t h, color_t color);
|
---|
191 | extern void lcd_drawFastHLine(LCD_Handler_t *hlcd, int16_t x, int16_t y, int16_t w, color_t color);
|
---|
192 | extern void lcd_drawImageHLine(LCD_Handler_t *hlcd, int16_t x, int16_t y, uint16_t w, color_t *pcolor);
|
---|
193 | extern void lcd_drawBitmap(LCD_Handler_t *hlcd, uint16_t x0, uint16_t y0, uint8_t *pbmp);
|
---|
194 | extern void lcd_setRotation(LCD_Handler_t *hlcd, uint8_t m);
|
---|
195 | extern void lcd_invertDisplay(LCD_Handler_t *hlcd, bool_t i);
|
---|
196 |
|
---|
197 | extern void lcd_fillScreen(LCD_DrawProp_t *pDrawProp);
|
---|
198 | extern void lcd_drawRect(LCD_DrawProp_t *pDrawProp, int16_t x, int16_t y, int16_t w, int16_t h);
|
---|
199 | extern void lcd_DrawCircle(LCD_DrawProp_t *pDrawProp, uint16_t x0, uint16_t y0, uint16_t Radius);
|
---|
200 | extern void lcd_drawLine(LCD_DrawProp_t *pDrawProp, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
---|
201 | extern void lcd_drawPolygon(LCD_DrawProp_t *pDrawProp, pPoint Points, uint16_t PointCount);
|
---|
202 |
|
---|
203 | #endif /* TOPPERS_MACRO_ONLY */
|
---|
204 |
|
---|
205 | #ifdef __cplusplus
|
---|
206 | }
|
---|
207 | #endif
|
---|
208 |
|
---|
209 | #endif /* _ADAFRUIT_ILI9341_H_ */
|
---|
210 |
|
---|