1 | /*
|
---|
2 | * TOPPERS/ASP Kernel
|
---|
3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
4 | * Advanced Standard Profile Kernel
|
---|
5 | *
|
---|
6 | * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
|
---|
7 | * Toyohashi Univ. of Technology, JAPAN
|
---|
8 | * Copyright (C) 2004-2010 by Embedded and Real-Time Systems Laboratory
|
---|
9 | * Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
10 | * Copyright (C) 2015-2019 by TOPPERS PROJECT Educational Working Group.
|
---|
11 | *
|
---|
12 | * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
13 | * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
14 | * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
15 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
16 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
17 | * スコード中に含まれていること.
|
---|
18 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
19 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
20 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
21 | * の無保証規定を掲載すること.
|
---|
22 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
23 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
24 | * と.
|
---|
25 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
26 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
27 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
28 | * 報告すること.
|
---|
29 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
30 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
31 | * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
32 | * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
33 | * 免責すること.
|
---|
34 | *
|
---|
35 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
36 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
37 | * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
38 | * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
39 | * の責任を負わない.
|
---|
40 | *
|
---|
41 | * $Id$
|
---|
42 | */
|
---|
43 |
|
---|
44 | /*
|
---|
45 | * Written by Limor Fried/Ladyada for Adafruit Industries.
|
---|
46 | * MIT license, all text above must be included in any redistribution
|
---|
47 | * http://opensource.org/licenses/mit-license.php
|
---|
48 | */
|
---|
49 |
|
---|
50 | /*
|
---|
51 | * ADAFRUIT ST7735 1.8",1.44"LCD制御プログラムのヘッダファイル
|
---|
52 | */
|
---|
53 |
|
---|
54 | #ifndef _ADAFRUIT_ST7735_H_
|
---|
55 | #define _ADAFRUIT_ST7735_H_
|
---|
56 |
|
---|
57 | #ifdef __cplusplus
|
---|
58 | extern "C" {
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | #include "device.h"
|
---|
62 | #include "pinmode.h"
|
---|
63 | #include "spi.h"
|
---|
64 |
|
---|
65 | /*
|
---|
66 | * LCDカラーモード定義
|
---|
67 | */
|
---|
68 | #define CM_ARGB8888 0x00000000 /* ARGB8888 color mode */
|
---|
69 | #define CM_RGB888 0x00000001 /* RGB888 color mode */
|
---|
70 | #define CM_RGB565 0x00000002 /* RGB565 color mode */
|
---|
71 |
|
---|
72 | // some flags for initR() :(
|
---|
73 | #define INITR_GREENTAB 0x0
|
---|
74 | #define INITR_REDTAB 0x1
|
---|
75 | #define INITR_BLACKTAB 0x2
|
---|
76 |
|
---|
77 | #define INITR_18GREENTAB INITR_GREENTAB
|
---|
78 | #define INITR_18REDTAB INITR_REDTAB
|
---|
79 | #define INITR_18BLACKTAB INITR_BLACKTAB
|
---|
80 | #define INITR_144GREENTAB 0x1
|
---|
81 |
|
---|
82 | #define ST7735_TFTWIDTH 128
|
---|
83 | // for 1.44" display
|
---|
84 | #define ST7735_TFTHEIGHT_144 128
|
---|
85 | // for 1.8" display
|
---|
86 | #define ST7735_TFTHEIGHT_18 160
|
---|
87 |
|
---|
88 | #define ST7735_NOP 0x00
|
---|
89 | #define ST7735_SWRESET 0x01
|
---|
90 | #define ST7735_RDDID 0x04
|
---|
91 | #define ST7735_RDDST 0x09
|
---|
92 |
|
---|
93 | #define ST7735_SLPIN 0x10
|
---|
94 | #define ST7735_SLPOUT 0x11
|
---|
95 | #define ST7735_PTLON 0x12
|
---|
96 | #define ST7735_NORON 0x13
|
---|
97 |
|
---|
98 | #define ST7735_INVOFF 0x20
|
---|
99 | #define ST7735_INVON 0x21
|
---|
100 | #define ST7735_DISPOFF 0x28
|
---|
101 | #define ST7735_DISPON 0x29
|
---|
102 | #define ST7735_CASET 0x2A
|
---|
103 | #define ST7735_RASET 0x2B
|
---|
104 | #define ST7735_RAMWR 0x2C
|
---|
105 | #define ST7735_RAMRD 0x2E
|
---|
106 |
|
---|
107 | #define ST7735_PTLAR 0x30
|
---|
108 | #define ST7735_COLMOD 0x3A
|
---|
109 | #define ST7735_MADCTL 0x36
|
---|
110 |
|
---|
111 | #define ST7735_FRMCTR1 0xB1
|
---|
112 | #define ST7735_FRMCTR2 0xB2
|
---|
113 | #define ST7735_FRMCTR3 0xB3
|
---|
114 | #define ST7735_INVCTR 0xB4
|
---|
115 | #define ST7735_DISSET5 0xB6
|
---|
116 |
|
---|
117 | #define ST7735_PWCTR1 0xC0
|
---|
118 | #define ST7735_PWCTR2 0xC1
|
---|
119 | #define ST7735_PWCTR3 0xC2
|
---|
120 | #define ST7735_PWCTR4 0xC3
|
---|
121 | #define ST7735_PWCTR5 0xC4
|
---|
122 | #define ST7735_VMCTR1 0xC5
|
---|
123 |
|
---|
124 | #define ST7735_RDID1 0xDA
|
---|
125 | #define ST7735_RDID2 0xDB
|
---|
126 | #define ST7735_RDID3 0xDC
|
---|
127 | #define ST7735_RDID4 0xDD
|
---|
128 |
|
---|
129 | #define ST7735_PWCTR6 0xFC
|
---|
130 |
|
---|
131 | #define ST7735_GMCTRP1 0xE0
|
---|
132 | #define ST7735_GMCTRN1 0xE1
|
---|
133 |
|
---|
134 | // Color definitions
|
---|
135 | #define ST7735_BLACK 0x0000
|
---|
136 | #define ST7735_BLUE 0x001F
|
---|
137 | #define ST7735_RED 0xF800
|
---|
138 | #define ST7735_GREEN 0x07E0
|
---|
139 | #define ST7735_CYAN 0x07FF
|
---|
140 | #define ST7735_MAGENTA 0xF81F
|
---|
141 | #define ST7735_YELLOW 0xFFE0
|
---|
142 | #define ST7735_WHITE 0xFFFF
|
---|
143 |
|
---|
144 |
|
---|
145 | #ifndef TOPPERS_MACRO_ONLY
|
---|
146 |
|
---|
147 | /*
|
---|
148 | * カラーの属性を定義
|
---|
149 | */
|
---|
150 | typedef uint16_t color_t;
|
---|
151 |
|
---|
152 | /*
|
---|
153 | * LCDハンドラ構造体定義
|
---|
154 | */
|
---|
155 | typedef struct
|
---|
156 | {
|
---|
157 | SPI_Handle_t *hspi; /* spiハンドラ */
|
---|
158 | uint16_t _width; /* 幅ピクセル数 */
|
---|
159 | uint16_t _height; /* 高さピクセル数 */
|
---|
160 | uint8_t colstart;
|
---|
161 | uint8_t rowstart;
|
---|
162 | uint8_t tabcolor; /* some displays need this changed */
|
---|
163 | uint8_t dummy;
|
---|
164 | ID spi_lock;
|
---|
165 | uint8_t cs_pin;
|
---|
166 | uint8_t rs_pin;
|
---|
167 | uint8_t rst_pin;
|
---|
168 | uint8_t cs2_pin;
|
---|
169 | }LCD_Handler_t;
|
---|
170 |
|
---|
171 | /*
|
---|
172 | * 描画構造体
|
---|
173 | */
|
---|
174 | typedef struct
|
---|
175 | {
|
---|
176 | LCD_Handler_t *hlcd;
|
---|
177 | color_t TextColor;
|
---|
178 | color_t BackColor;
|
---|
179 | void *pFont;
|
---|
180 | }LCD_DrawProp_t;
|
---|
181 |
|
---|
182 | typedef struct
|
---|
183 | {
|
---|
184 | int16_t X;
|
---|
185 | int16_t Y;
|
---|
186 | }Point, * pPoint;
|
---|
187 |
|
---|
188 | /*
|
---|
189 | * 関数のプロトタイプ宣言
|
---|
190 | */
|
---|
191 | extern ER lcd_writecommand(LCD_Handler_t *hlcd, uint8_t c);
|
---|
192 | extern ER lcd_writedata(LCD_Handler_t *hlcd, uint8_t *p, uint32_t len);
|
---|
193 | extern ER lcd_writedata2(LCD_Handler_t *hlcd, uint16_t c, int cnt);
|
---|
194 | extern ER lcd_writedata3(LCD_Handler_t *hlcd, uint8_t *pbmp, uint16_t width, uint16_t height);
|
---|
195 |
|
---|
196 | extern void lcd_initB(LCD_Handler_t *hlcd);
|
---|
197 | extern void lcd_initR(LCD_Handler_t *hlcd, uint8_t options);
|
---|
198 | extern void lcd_setAddrWindow(LCD_Handler_t *hlcd, uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1);
|
---|
199 | extern void lcd_fillRect(LCD_Handler_t *hlcd, int16_t x, int16_t y, int16_t w, int16_t h, color_t color);
|
---|
200 | extern void lcd_pushColor(LCD_Handler_t *hlcd, color_t color);
|
---|
201 | extern void lcd_drawPixel(LCD_Handler_t *hlcd, int16_t x, int16_t y, color_t color);
|
---|
202 | extern void lcd_drawFastVLine(LCD_Handler_t *hlcd, int16_t x, int16_t y, int16_t h, color_t color);
|
---|
203 | extern void lcd_drawFastHLine(LCD_Handler_t *hlcd, int16_t x, int16_t y, int16_t w, color_t color);
|
---|
204 | extern void lcd_drawImageHLine(LCD_Handler_t *hlcd, int16_t x, int16_t y, uint16_t w, color_t *pcolor);
|
---|
205 | extern void lcd_drawBitmap(LCD_Handler_t *hlcd, uint16_t x0, uint16_t y0, uint8_t *pbmp);
|
---|
206 | extern void lcd_invertDisplay(LCD_Handler_t *hlcd, bool_t i);
|
---|
207 |
|
---|
208 | extern void lcd_fillScreen(LCD_DrawProp_t *pDrawProp);
|
---|
209 | extern void lcd_drawRect(LCD_DrawProp_t *pDrawProp, int16_t x, int16_t y, int16_t w, int16_t h);
|
---|
210 | extern void lcd_DrawCircle(LCD_DrawProp_t *pDrawProp, uint16_t x0, uint16_t y0, uint16_t Radius);
|
---|
211 | extern void lcd_drawLine(LCD_DrawProp_t *pDrawProp, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
---|
212 | extern void lcd_drawPolygon(LCD_DrawProp_t *pDrawProp, pPoint Points, uint16_t PointCount);
|
---|
213 |
|
---|
214 | #endif /* TOPPERS_MACRO_ONLY */
|
---|
215 |
|
---|
216 | #ifdef __cplusplus
|
---|
217 | }
|
---|
218 | #endif
|
---|
219 |
|
---|
220 | #endif /* _ADAFRUIT_ST7735_H_ */
|
---|
221 |
|
---|