Prep for v1.0.0
[hackover2013-badge-firmware.git] / drivers / displays / tft / hw / ILI9328.c
1 /**************************************************************************/
2 /*!
3 @file ILI9328.c
4 @author K. Townsend (microBuilder.eu)
5
6 @section DESCRIPTION
7
8 Driver for ILI9328 240x320 pixel TFT LCD displays.
9
10 This driver uses an 8-bit interface and a 16-bit RGB565 colour palette.
11
12 @section LICENSE
13
14 Software License Agreement (BSD License)
15
16 Copyright (c) 2010, microBuilder SARL
17 All rights reserved.
18
19 Redistribution and use in source and binary forms, with or without
20 modification, are permitted provided that the following conditions are met:
21 1. Redistributions of source code must retain the above copyright
22 notice, this list of conditions and the following disclaimer.
23 2. Redistributions in binary form must reproduce the above copyright
24 notice, this list of conditions and the following disclaimer in the
25 documentation and/or other materials provided with the distribution.
26 3. Neither the name of the copyright holders nor the
27 names of its contributors may be used to endorse or promote products
28 derived from this software without specific prior written permission.
29
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
31 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
34 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 */
41 /**************************************************************************/
42 #include "ILI9328.h"
43 #include "core/systick/systick.h"
44 #include "drivers/displays/tft/touchscreen.h"
45
46 // Uncomment this to use faster inline methods, but requires more flash
47 #define ILI9238_USE_INLINE_METHODS (1)
48
49 static volatile lcdOrientation_t lcdOrientation = LCD_ORIENTATION_PORTRAIT;
50 static lcdProperties_t ili9328Properties = { 240, 320, TRUE, TRUE, TRUE };
51
52 /*************************************************/
53 /* Private Methods */
54 /*************************************************/
55
56 /**************************************************************************/
57 /*!
58 @brief Causes a brief delay (10 ticks per unit)
59 */
60 /**************************************************************************/
61 #if !defined ILI9238_USE_INLINE_METHODS
62 void ili9328Delay(unsigned int t)
63 {
64 unsigned char t1;
65 while(t--)
66 for ( t1=10; t1 > 0; t1-- )
67 {
68 __asm("nop");
69 }
70 }
71 #else
72 static inline void ili9328Delay(unsigned int t) { unsigned char t1; while(t--) for ( t1=10; t1 > 0; t1-- ) { __asm("nop"); } }
73 #endif
74
75 /**************************************************************************/
76 /*!
77 @brief Writes the supplied 16-bit command using an 8-bit interface
78 */
79 /**************************************************************************/
80 #if !defined ILI9238_USE_INLINE_METHODS
81 void ili9328WriteCmd(uint16_t command)
82 {
83 // Compiled with -Os on GCC 4.4 this works out to 25 cycles
84 // (versus 36 compiled with no optimisations). I'm not sure it
85 // can be improved further, so that means 25 cycles/350nS for
86 // continuous writes (cmd, data, data, data, ...) or ~150 cycles/
87 // ~2.1uS for a random pixel (Set X [cmd+data], Set Y [cmd+data],
88 // Set color [cmd+data]) (times assumes 72MHz clock).
89
90 CLR_CS_CD_SET_RD_WR; // Saves 18 commands compared to "CLR_CS; CLR_CD; SET_RD; SET_WR;"
91 ILI9328_GPIO2DATA_DATA = (command >> (8 - ILI9328_DATA_OFFSET));
92 CLR_WR;
93 SET_WR;
94 ILI9328_GPIO2DATA_DATA = command << ILI9328_DATA_OFFSET;
95 CLR_WR;
96 SET_WR_CS; // Saves 7 commands compared to "SET_WR; SET_CS;"
97 }
98 #else
99 static inline void ili9328WriteCmd(uint16_t command) { CLR_CS_CD_SET_RD_WR; ILI9328_GPIO2DATA_DATA = (command >> (8 - ILI9328_DATA_OFFSET)); CLR_WR; SET_WR; ILI9328_GPIO2DATA_DATA = command << ILI9328_DATA_OFFSET; CLR_WR; SET_WR_CS; }
100 #endif
101
102 /**************************************************************************/
103 /*!
104 @brief Writes the supplied 16-bit data using an 8-bit interface
105 */
106 /**************************************************************************/
107 #if !defined ILI9238_USE_INLINE_METHODS
108 void ili9328WriteData(uint16_t data)
109 {
110 CLR_CS_SET_CD_RD_WR; // Saves 18 commands compared to SET_CD; SET_RD; SET_WR; CLR_CS"
111 ILI9328_GPIO2DATA_DATA = (data >> (8 - ILI9328_DATA_OFFSET));
112 CLR_WR;
113 SET_WR;
114 ILI9328_GPIO2DATA_DATA = data << ILI9328_DATA_OFFSET;
115 CLR_WR;
116 SET_WR_CS; // Saves 7 commands compared to "SET_WR, SET_CS;"
117 }
118 #else
119 static inline void ili9328WriteData(uint16_t data) { CLR_CS_SET_CD_RD_WR; ILI9328_GPIO2DATA_DATA = (data >> (8 - ILI9328_DATA_OFFSET)); CLR_WR; SET_WR; ILI9328_GPIO2DATA_DATA = data << ILI9328_DATA_OFFSET; CLR_WR; SET_WR_CS; }
120 #endif
121
122 /**************************************************************************/
123 /*!
124 @brief Reads a 16-bit value from the 8-bit data bus
125 */
126 /**************************************************************************/
127 uint16_t ili9328ReadData(void)
128 {
129 // ToDo: Optimise this method!
130
131 uint16_t high, low;
132 high = low = 0;
133 uint16_t d;
134
135 SET_CD_RD_WR; // Saves 14 commands compared to "SET_CD; SET_RD; SET_WR"
136 CLR_CS;
137
138 // set inputs
139 ILI9328_GPIO2DATA_SETINPUT;
140 CLR_RD;
141 ili9328Delay(100);
142 high = ILI9328_GPIO2DATA_DATA;
143 high >>= ILI9328_DATA_OFFSET;
144 high &= 0xFF;
145 SET_RD;
146
147 CLR_RD;
148 ili9328Delay(100);
149 low = ILI9328_GPIO2DATA_DATA;
150 low >>= ILI9328_DATA_OFFSET;
151 low &=0xFF;
152 SET_RD;
153
154 SET_CS;
155 ILI9328_GPIO2DATA_SETOUTPUT;
156
157 d = high;
158 d <<= 8;
159 d |= low;
160
161 return d;
162 }
163
164 /**************************************************************************/
165 /*!
166 @brief Reads a 16-bit value
167 */
168 /**************************************************************************/
169 uint16_t ili9328Read(uint16_t addr)
170 {
171 ili9328WriteCmd(addr);
172 return ili9328ReadData();
173 }
174
175 /**************************************************************************/
176 /*!
177 @brief Sends a 16-bit command + 16-bit data
178 */
179 /**************************************************************************/
180 void ili9328Command(uint16_t command, uint16_t data)
181 {
182 ili9328WriteCmd(command);
183 ili9328WriteData(data);
184 }
185
186 /**************************************************************************/
187 /*!
188 @brief Returns the 16-bit (4-hexdigit) controller code
189 */
190 /**************************************************************************/
191 uint16_t ili9328Type(void)
192 {
193 ili9328WriteCmd(ILI9328_COMMANDS_DRIVERCODEREAD);
194 return ili9328ReadData();
195 }
196
197 /**************************************************************************/
198 /*!
199 @brief Sets the cursor to the specified X/Y position
200 */
201 /**************************************************************************/
202 #if !defined ILI9238_USE_INLINE_METHODS
203 void ili9328SetCursor(uint16_t x, uint16_t y)
204 {
205 uint16_t al, ah;
206
207 if (lcdOrientation == LCD_ORIENTATION_LANDSCAPE)
208 {
209 al = y;
210 ah = x;
211 }
212 else
213 {
214 al = x;
215 ah = y;
216 }
217
218 ili9328Command(ILI9328_COMMANDS_HORIZONTALGRAMADDRESSSET, al);
219 ili9328Command(ILI9328_COMMANDS_VERTICALGRAMADDRESSSET, ah);
220 }
221 #else
222 static inline void ili9328SetCursor(uint16_t x, uint16_t y) { uint16_t al, ah; if (lcdOrientation == LCD_ORIENTATION_LANDSCAPE) { al = y; ah = x; } else { al = x; ah = y; }; ili9328WriteCmd(ILI9328_COMMANDS_HORIZONTALGRAMADDRESSSET); ili9328WriteData(al); ili9328WriteCmd(ILI9328_COMMANDS_VERTICALGRAMADDRESSSET); ili9328WriteData(ah); }
223 #endif
224
225 /**************************************************************************/
226 /*!
227 @brief Sends the initialisation sequence to the display controller
228 */
229 /**************************************************************************/
230 void ili9328InitDisplay(void)
231 {
232 // Clear data line
233 GPIO_GPIO2DATA &= ~ILI9328_DATA_MASK;
234
235 SET_RD;
236 SET_WR;
237 SET_CS;
238 SET_CD;
239
240 // Reset display
241 CLR_RESET;
242 ili9328Delay(100);
243 SET_RESET;
244 ili9328Delay(1000);
245
246 ili9328Command(ILI9328_COMMANDS_DRIVEROUTPUTCONTROL1, 0x0100); // Driver Output Control Register (R01h)
247 ili9328Command(ILI9328_COMMANDS_LCDDRIVINGCONTROL, 0x0700); // LCD Driving Waveform Control (R02h)
248 ili9328Command(ILI9328_COMMANDS_ENTRYMODE, 0x1030); // Entry Mode (R03h)
249 ili9328Command(ILI9328_COMMANDS_DISPLAYCONTROL2, 0x0302);
250 ili9328Command(ILI9328_COMMANDS_DISPLAYCONTROL3, 0x0000);
251 ili9328Command(ILI9328_COMMANDS_DISPLAYCONTROL4, 0x0000); // Fmark On
252 ili9328Command(ILI9328_COMMANDS_POWERCONTROL1, 0x0000); // Power Control 1 (R10h)
253 ili9328Command(ILI9328_COMMANDS_POWERCONTROL2, 0x0007); // Power Control 2 (R11h)
254 ili9328Command(ILI9328_COMMANDS_POWERCONTROL3, 0x0000); // Power Control 3 (R12h)
255 ili9328Command(ILI9328_COMMANDS_POWERCONTROL4, 0x0000); // Power Control 4 (R13h)
256 ili9328Delay(1000);
257 ili9328Command(ILI9328_COMMANDS_POWERCONTROL1, 0x14B0); // Power Control 1 (R10h)
258 ili9328Delay(500);
259 ili9328Command(ILI9328_COMMANDS_POWERCONTROL2, 0x0007); // Power Control 2 (R11h)
260 ili9328Delay(500);
261 ili9328Command(ILI9328_COMMANDS_POWERCONTROL3, 0x008E); // Power Control 3 (R12h)
262 ili9328Command(ILI9328_COMMANDS_POWERCONTROL4, 0x0C00); // Power Control 4 (R13h)
263 ili9328Command(ILI9328_COMMANDS_POWERCONTROL7, 0x0015); // NVM read data 2 (R29h)
264 ili9328Delay(500);
265 ili9328Command(ILI9328_COMMANDS_GAMMACONTROL1, 0x0000); // Gamma Control 1
266 ili9328Command(ILI9328_COMMANDS_GAMMACONTROL2, 0x0107); // Gamma Control 2
267 ili9328Command(ILI9328_COMMANDS_GAMMACONTROL3, 0x0000); // Gamma Control 3
268 ili9328Command(ILI9328_COMMANDS_GAMMACONTROL4, 0x0203); // Gamma Control 4
269 ili9328Command(ILI9328_COMMANDS_GAMMACONTROL5, 0x0402); // Gamma Control 5
270 ili9328Command(ILI9328_COMMANDS_GAMMACONTROL6, 0x0000); // Gamma Control 6
271 ili9328Command(ILI9328_COMMANDS_GAMMACONTROL7, 0x0207); // Gamma Control 7
272 ili9328Command(ILI9328_COMMANDS_GAMMACONTROL8, 0x0000); // Gamma Control 8
273 ili9328Command(ILI9328_COMMANDS_GAMMACONTROL9, 0x0203); // Gamma Control 9
274 ili9328Command(ILI9328_COMMANDS_GAMMACONTROL10, 0x0403); // Gamma Control 10
275 ili9328Command(ILI9328_COMMANDS_HORIZONTALADDRESSSTARTPOSITION, 0x0000); // Window Horizontal RAM Address Start (R50h)
276 ili9328Command(ILI9328_COMMANDS_HORIZONTALADDRESSENDPOSITION, ili9328Properties.width - 1); // Window Horizontal RAM Address End (R51h)
277 ili9328Command(ILI9328_COMMANDS_VERTICALADDRESSSTARTPOSITION, 0X0000); // Window Vertical RAM Address Start (R52h)
278 ili9328Command(ILI9328_COMMANDS_VERTICALADDRESSENDPOSITION, ili9328Properties.height - 1); // Window Vertical RAM Address End (R53h)
279 ili9328Command(ILI9328_COMMANDS_DRIVEROUTPUTCONTROL2, 0xa700); // Driver Output Control (R60h)
280 ili9328Command(ILI9328_COMMANDS_BASEIMAGEDISPLAYCONTROL, 0x0003); // Driver Output Control (R61h) - enable VLE
281 ili9328Command(ILI9328_COMMANDS_PANELINTERFACECONTROL1, 0X0010); // Panel Interface Control 1 (R90h)
282
283 // Display On
284 ili9328Command(ILI9328_COMMANDS_DISPLAYCONTROL1, 0x0133); // Display Control (R07h)
285 ili9328Delay(500);
286 ili9328WriteCmd(ILI9328_COMMANDS_WRITEDATATOGRAM);
287 }
288
289 /**************************************************************************/
290 /*!
291 @brief Sets the cursor to the home position (0,0)
292 */
293 /**************************************************************************/
294 void ili9328Home(void)
295 {
296 ili9328SetCursor(0, 0);
297 ili9328WriteCmd(ILI9328_COMMANDS_WRITEDATATOGRAM); // Write Data to GRAM (R22h)
298 }
299
300 /**************************************************************************/
301 /*!
302 @brief Sets the window confines
303 */
304 /**************************************************************************/
305 void ili9328SetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
306 {
307 ili9328Command(ILI9328_COMMANDS_HORIZONTALADDRESSSTARTPOSITION, x0);
308 ili9328Command(ILI9328_COMMANDS_HORIZONTALADDRESSENDPOSITION, x1);
309 ili9328Command(ILI9328_COMMANDS_VERTICALADDRESSSTARTPOSITION, y0);
310 ili9328Command(ILI9328_COMMANDS_VERTICALADDRESSENDPOSITION, y1);
311 ili9328SetCursor(x0, y0);
312 }
313
314 /*************************************************/
315 /* Public Methods */
316 /*************************************************/
317
318 /**************************************************************************/
319 /*!
320 @brief Configures any pins or HW and initialises the LCD controller
321 */
322 /**************************************************************************/
323 void lcdInit(void)
324 {
325 // Set control line pins to output
326 gpioSetDir(ILI9328_CS_PORT, ILI9328_CS_PIN, 1);
327 gpioSetDir(ILI9328_CD_PORT, ILI9328_CD_PIN, 1);
328 gpioSetDir(ILI9328_WR_PORT, ILI9328_WR_PIN, 1);
329 gpioSetDir(ILI9328_RD_PORT, ILI9328_RD_PIN, 1);
330
331 // Set data port pins to output
332 ILI9328_GPIO2DATA_SETOUTPUT;
333
334 // Disable pullups
335 ILI9328_DISABLEPULLUPS();
336
337 // Set backlight pin to output and turn it on
338 gpioSetDir(ILI9328_BL_PORT, ILI9328_BL_PIN, 1); // set to output
339 lcdBacklight(TRUE);
340
341 // Set reset pin to output
342 gpioSetDir(ILI9328_RES_PORT, ILI9328_RES_PIN, 1); // Set to output
343 gpioSetValue(ILI9328_RES_PORT, ILI9328_RES_PIN, 0); // Low to reset
344 systickDelay(50);
345 gpioSetValue(ILI9328_RES_PORT, ILI9328_RES_PIN, 1); // High to exit
346
347 // Initialize the display
348 ili9328InitDisplay();
349
350 systickDelay(50);
351
352 // Set lcd to default orientation
353 lcdSetOrientation(lcdOrientation);
354
355 // Fill black
356 lcdFillRGB(COLOR_BLACK);
357
358 // Initialise the touch screen (and calibrate if necessary)
359 tsInit();
360 }
361
362 /**************************************************************************/
363 /*!
364 @brief Enables or disables the LCD backlight
365 */
366 /**************************************************************************/
367 void lcdBacklight(bool state)
368 {
369 // Set the backlight
370 gpioSetValue(ILI9328_BL_PORT, ILI9328_BL_PIN, state ? 0 : 1);
371 }
372
373 /**************************************************************************/
374 /*!
375 @brief Renders a simple test pattern on the LCD
376 */
377 /**************************************************************************/
378 void lcdTest(void)
379 {
380 uint32_t i,j;
381 ili9328Home();
382
383 for(i=0;i<320;i++)
384 {
385 for(j=0;j<240;j++)
386 {
387 if(i>279)ili9328WriteData(COLOR_WHITE);
388 else if(i>239)ili9328WriteData(COLOR_BLUE);
389 else if(i>199)ili9328WriteData(COLOR_GREEN);
390 else if(i>159)ili9328WriteData(COLOR_CYAN);
391 else if(i>119)ili9328WriteData(COLOR_RED);
392 else if(i>79)ili9328WriteData(COLOR_MAGENTA);
393 else if(i>39)ili9328WriteData(COLOR_YELLOW);
394 else ili9328WriteData(COLOR_BLACK);
395 }
396 }
397 }
398
399 /**************************************************************************/
400 /*!
401 @brief Fills the LCD with the specified 16-bit color
402 */
403 /**************************************************************************/
404 void lcdFillRGB(uint16_t data)
405 {
406 unsigned int i;
407 ili9328Home();
408
409 uint32_t pixels = 320*240;
410 for ( i=0; i < pixels; i++ )
411 {
412 ili9328WriteData(data);
413 }
414 }
415
416 /**************************************************************************/
417 /*!
418 @brief Draws a single pixel at the specified X/Y location
419 */
420 /**************************************************************************/
421 void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color)
422 {
423 ili9328SetCursor(x, y);
424 ili9328WriteCmd(ILI9328_COMMANDS_WRITEDATATOGRAM); // Write Data to GRAM (R22h)
425 ili9328WriteData(color);
426 }
427
428 /**************************************************************************/
429 /*!
430 @brief Draws an array of consecutive RGB565 pixels (much
431 faster than addressing each pixel individually)
432 */
433 /**************************************************************************/
434 void lcdDrawPixels(uint16_t x, uint16_t y, uint16_t *data, uint32_t len)
435 {
436 uint32_t i = 0;
437 ili9328SetCursor(x, y);
438 ili9328WriteCmd(ILI9328_COMMANDS_WRITEDATATOGRAM);
439 do
440 {
441 ili9328WriteData(data[i]);
442 i++;
443 } while (i<len);
444 }
445
446 /**************************************************************************/
447 /*!
448 @brief Optimised routine to draw a horizontal line faster than
449 setting individual pixels
450 */
451 /**************************************************************************/
452 void lcdDrawHLine(uint16_t x0, uint16_t x1, uint16_t y, uint16_t color)
453 {
454 // Allows for slightly better performance than setting individual pixels
455 uint16_t x, pixels;
456
457 if (x1 < x0)
458 {
459 // Switch x1 and x0
460 x = x1;
461 x1 = x0;
462 x0 = x;
463 }
464
465 // Check limits
466 if (x1 >= lcdGetWidth())
467 {
468 x1 = lcdGetWidth() - 1;
469 }
470 if (x0 >= lcdGetWidth())
471 {
472 x0 = lcdGetWidth() - 1;
473 }
474
475 ili9328SetCursor(x0, y);
476 ili9328WriteCmd(ILI9328_COMMANDS_WRITEDATATOGRAM); // Write Data to GRAM (R22h)
477 for (pixels = 0; pixels < x1 - x0 + 1; pixels++)
478 {
479 ili9328WriteData(color);
480 }
481 }
482
483 /**************************************************************************/
484 /*!
485 @brief Optimised routine to draw a vertical line faster than
486 setting individual pixels
487 */
488 /**************************************************************************/
489 void lcdDrawVLine(uint16_t x, uint16_t y0, uint16_t y1, uint16_t color)
490 {
491 lcdOrientation_t oldOrientation = lcdOrientation;
492
493 if (oldOrientation == LCD_ORIENTATION_PORTRAIT)
494 {
495 lcdSetOrientation(LCD_ORIENTATION_LANDSCAPE);
496 lcdDrawHLine(y0, y1, lcdGetHeight() - (x + 1), color);
497 }
498 else
499 {
500 lcdSetOrientation(LCD_ORIENTATION_PORTRAIT);
501 lcdDrawHLine(lcdGetWidth() - (y0 + 1), lcdGetWidth() - (y1 + 1), x, color);
502 }
503
504 // Switch orientation back
505 lcdSetOrientation(oldOrientation);
506 }
507
508 /**************************************************************************/
509 /*!
510 @brief Gets the 16-bit color of the pixel at the specified location
511 */
512 /**************************************************************************/
513 uint16_t lcdGetPixel(uint16_t x, uint16_t y)
514 {
515 ili9328SetCursor(x, y);
516 ili9328WriteCmd(ILI9328_COMMANDS_WRITEDATATOGRAM);
517 // prefetch
518 ili9328ReadData();
519
520 // Eeek ... why does this need to be done twice for a proper value?!?
521 ili9328SetCursor(x, y);
522 ili9328WriteCmd(ILI9328_COMMANDS_WRITEDATATOGRAM);
523 return ili9328ReadData();
524 }
525
526 /**************************************************************************/
527 /*!
528 @brief Sets the LCD orientation to horizontal and vertical
529 */
530 /**************************************************************************/
531 void lcdSetOrientation(lcdOrientation_t orientation)
532 {
533 uint16_t entryMode = 0x1030;
534 uint16_t outputControl = 0x0100;
535
536 switch (orientation)
537 {
538 case LCD_ORIENTATION_PORTRAIT:
539 entryMode = 0x1030;
540 outputControl = 0x0100;
541 break;
542 case LCD_ORIENTATION_LANDSCAPE:
543 entryMode = 0x1028;
544 outputControl = 0x0000;
545 break;
546 }
547
548 ili9328Command(ILI9328_COMMANDS_ENTRYMODE, entryMode);
549 ili9328Command(ILI9328_COMMANDS_DRIVEROUTPUTCONTROL1, outputControl);
550 lcdOrientation = orientation;
551
552 ili9328SetCursor(0, 0);
553 }
554
555 /**************************************************************************/
556 /*!
557 @brief Gets the current screen orientation (horizontal or vertical)
558 */
559 /**************************************************************************/
560 lcdOrientation_t lcdGetOrientation(void)
561 {
562 return lcdOrientation;
563 }
564
565 /**************************************************************************/
566 /*!
567 @brief Gets the width in pixels of the LCD screen (varies depending
568 on the current screen orientation)
569 */
570 /**************************************************************************/
571 uint16_t lcdGetWidth(void)
572 {
573 switch (lcdOrientation)
574 {
575 case LCD_ORIENTATION_PORTRAIT:
576 return ili9328Properties.width;
577 break;
578 case LCD_ORIENTATION_LANDSCAPE:
579 default:
580 return ili9328Properties.height;
581 }
582 }
583
584 /**************************************************************************/
585 /*!
586 @brief Gets the height in pixels of the LCD screen (varies depending
587 on the current screen orientation)
588 */
589 /**************************************************************************/
590 uint16_t lcdGetHeight(void)
591 {
592 switch (lcdOrientation)
593 {
594 case LCD_ORIENTATION_PORTRAIT:
595 return ili9328Properties.height;
596 break;
597 case LCD_ORIENTATION_LANDSCAPE:
598 default:
599 return ili9328Properties.width;
600 }
601 }
602
603 /**************************************************************************/
604 /*!
605 @brief Scrolls the contents of the LCD screen vertically the
606 specified number of pixels using a HW optimised routine
607 */
608 /**************************************************************************/
609 void lcdScroll(int16_t pixels, uint16_t fillColor)
610 {
611 int16_t y = pixels;
612 while (y < 0)
613 y += 320;
614 while (y >= 320)
615 y -= 320;
616 ili9328WriteCmd(ILI9328_COMMANDS_VERTICALSCROLLCONTROL);
617 ili9328WriteData(y);
618 }
619
620 /**************************************************************************/
621 /*!
622 @brief Gets the controller's 16-bit (4 hexdigit) ID
623 */
624 /**************************************************************************/
625 uint16_t lcdGetControllerID(void)
626 {
627 return ili9328Type();
628 }
629
630 /**************************************************************************/
631 /*!
632 @brief Returns the LCDs 'lcdProperties_t' that describes the LCDs
633 generic capabilities and dimensions
634 */
635 /**************************************************************************/
636 lcdProperties_t lcdGetProperties(void)
637 {
638 return ili9328Properties;
639 }
This page took 0.112847 seconds and 5 git commands to generate.