OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [CORTEX_LM3Sxxxx_IAR_Keil/] [formike128x128x16.c] - Blame information for rev 581

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 581 jeremybenn
//*****************************************************************************
2
//
3
// formike128x128x16.c - Display driver for the Formike Electronic
4
//                       KWH015C04-F01 CSTN panel with an ST7637 controller.
5
//
6
// Copyright (c) 2008 Luminary Micro, Inc.  All rights reserved.
7
// 
8
// Software License Agreement
9
// 
10
// Luminary Micro, Inc. (LMI) is supplying this software for use solely and
11
// exclusively on LMI's microcontroller products.
12
// 
13
// The software is owned by LMI and/or its suppliers, and is protected under
14
// applicable copyright laws.  All rights are reserved.  You may not combine
15
// this software with "viral" open-source software in order to form a larger
16
// program.  Any use in violation of the foregoing restrictions may subject
17
// the user to criminal sanctions under applicable laws, as well as to civil
18
// liability for the breach of the terms and conditions of this license.
19
// 
20
// THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
21
// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
22
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
23
// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
24
// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
25
// 
26
// This is part of revision 2523 of the Stellaris Peripheral Driver Library.
27
//
28
//*****************************************************************************
29
 
30
//*****************************************************************************
31
//
32
//! \addtogroup ek_lm3s3748_api
33
//! @{
34
//
35
//*****************************************************************************
36
 
37
#include "hw_gpio.h"
38
#include "hw_memmap.h"
39
#include "hw_types.h"
40
#include "gpio.h"
41
#include "sysctl.h"
42
#include "rom.h"
43
#include "grlib.h"
44
#include "formike128x128x16.h"
45
#include <string.h>
46
 
47
//*****************************************************************************
48
//
49
// Defines for the pins that are used to communicate with the ST7637.
50
//
51
//*****************************************************************************
52
#define LCD_A0_BASE            GPIO_PORTB_BASE
53
#define LCD_A0_PIN             GPIO_PIN_2
54
#define LCD_WR_BASE            GPIO_PORTC_BASE
55
#define LCD_WR_PIN             GPIO_PIN_4
56
#define LCD_RD_BASE            GPIO_PORTC_BASE
57
#define LCD_RD_PIN             GPIO_PIN_5
58
#define LCD_BL_BASE            GPIO_PORTF_BASE
59
#define LCD_BL_PIN             GPIO_PIN_1
60
#define LCD_DATA_BASE          GPIO_PORTG_BASE
61
 
62
//*****************************************************************************
63
//
64
// Translates a 24-bit RGB color to a display driver-specific color.
65
//
66
// \param c is the 24-bit RGB color.  The least-significant byte is the blue
67
// channel, the next byte is the green channel, and the third byte is the red
68
// channel.
69
//
70
// This macro translates a 24-bit RGB color into a value that can be written
71
// into the display's frame buffer in order to reproduce that color, or the
72
// closest possible approximation of that color.
73
//
74
// \return Returns the display-driver specific color.
75
//
76
//*****************************************************************************
77
#define DPYCOLORTRANSLATE(c)    ((((c) & 0x00ff0000) >> 19) |               \
78
                                 ((((c) & 0x0000ff00) >> 5) & 0x000007e0) | \
79
                                 ((((c) & 0x000000ff) << 8) & 0x0000f800))
80
 
81
//*****************************************************************************
82
//
83
// Writes a data word to the ST7637.
84
//
85
//*****************************************************************************
86
static void
87
WriteData(unsigned char ucData)
88
{
89
    //
90
    // Write the data to the data bus.
91
    //
92
    HWREG(LCD_DATA_BASE + GPIO_O_DATA + (0xff << 2)) = ucData;
93
 
94
    //
95
    // Assert the write enable signal.
96
    //
97
    HWREG(LCD_WR_BASE + GPIO_O_DATA + (LCD_WR_PIN << 2)) = 0;
98
 
99
    //
100
    // Deassert the write enable signal.
101
    //
102
    HWREG(LCD_WR_BASE + GPIO_O_DATA + (LCD_WR_PIN << 2)) = LCD_WR_PIN;
103
}
104
 
105
//*****************************************************************************
106
//
107
// Writes a command to the ST7637.
108
//
109
//*****************************************************************************
110
static void
111
WriteCommand(unsigned char ucData)
112
{
113
    //
114
    // Write the command to the data bus.
115
    //
116
    HWREG(LCD_DATA_BASE + GPIO_O_DATA + (0xff << 2)) = ucData;
117
 
118
    //
119
    // Set the A0 signal low, indicating a command.
120
    //
121
    HWREG(LCD_A0_BASE + GPIO_O_DATA + (LCD_A0_PIN << 2)) = 0;
122
 
123
    //
124
    // Assert the write enable signal.
125
    //
126
    HWREG(LCD_WR_BASE + GPIO_O_DATA + (LCD_WR_PIN << 2)) = 0;
127
 
128
    //
129
    // Deassert the write enable signal.
130
    //
131
    HWREG(LCD_WR_BASE + GPIO_O_DATA + (LCD_WR_PIN << 2)) = LCD_WR_PIN;
132
 
133
    //
134
    // Set the A0 signal high, indicating that following writes are data.
135
    //
136
    HWREG(LCD_A0_BASE + GPIO_O_DATA + (LCD_A0_PIN << 2)) = LCD_A0_PIN;
137
}
138
 
139
//*****************************************************************************
140
//
141
//! Initializes the display driver.
142
//!
143
//! This function initializes the ST7637 display controller on the panel,
144
//! preparing it to display data.
145
//!
146
//! \return None.
147
//
148
//*****************************************************************************
149
void
150
Formike128x128x16Init(void)
151
{
152
    unsigned long ulClockMS, ulCount;
153
 
154
    //
155
    // Get the value to pass to SysCtlDelay() in order to delay for 1 ms.
156
    //
157
    ulClockMS = SysCtlClockGet() / (3 * 1000);
158
 
159
    //
160
    // Enable the GPIO peripherals used to interface to the ST7637.
161
    //
162
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
163
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
164
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
165
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
166
 
167
    //
168
    // Configure the pins that connect to the LCD as GPIO outputs.
169
    //
170
    GPIOPinTypeGPIOOutput(LCD_A0_BASE, LCD_A0_PIN);
171
    GPIOPinTypeGPIOOutput(LCD_WR_BASE, LCD_WR_PIN);
172
    GPIOPinTypeGPIOOutput(LCD_RD_BASE, LCD_RD_PIN);
173
    GPIOPinTypeGPIOOutput(LCD_BL_BASE, LCD_BL_PIN);
174
    GPIOPinTypeGPIOOutput(LCD_DATA_BASE, 0xff);
175
 
176
    //
177
    // Set the LCD control pins to their default values.
178
    //
179
    GPIOPinWrite(LCD_A0_BASE, LCD_A0_PIN, LCD_A0_PIN);
180
    GPIOPinWrite(LCD_WR_BASE, LCD_WR_PIN | LCD_RD_PIN,
181
                     LCD_WR_PIN | LCD_RD_PIN);
182
    GPIOPinWrite(LCD_BL_BASE, LCD_BL_PIN, 0);
183
    GPIOPinWrite(LCD_DATA_BASE, 0xff, 0x00);
184
 
185
    //
186
    // Perform a software reset of the ST7637.
187
    //
188
    WriteCommand(0x01);
189
 
190
    //
191
    // Delay for 120ms.
192
    //
193
    SysCtlDelay(ulClockMS * 120);
194
 
195
    //
196
    // Disable auto-load of mask rom data.
197
    //
198
    WriteCommand(0xD7);
199
    WriteData(0xBF);
200
 
201
    //
202
    // Set the OTP control mode to read.
203
    //
204
    WriteCommand(0xE0);
205
    WriteData(0x00);
206
 
207
    //
208
    // Delay for 10ms.
209
    //
210
    SysCtlDelay(ulClockMS * 10);
211
 
212
    //
213
    // Start the OTP read.
214
    //
215
    WriteCommand(0xE3);
216
 
217
    //
218
    // Delay for 20ms.
219
    //
220
    SysCtlDelay(ulClockMS * 20);
221
 
222
    //
223
    // Cancel the OTP read (it should have finished by now).
224
    //
225
    WriteCommand(0xE1);
226
 
227
    //
228
    // Turn off the display.
229
    //
230
    WriteCommand(0x28);
231
 
232
    //
233
    // Exit sleep mode.
234
    //
235
    WriteCommand(0x11);
236
 
237
    //
238
    // Delay for 50ms.
239
    //
240
    SysCtlDelay(ulClockMS * 50);
241
 
242
    //
243
    // Program the LCD supply voltage V0 to 14V.
244
    //
245
    WriteCommand(0xC0);
246
    WriteData(0x04);
247
    WriteData(0x01);
248
 
249
    //
250
    // Select an LCD bias voltage ratio of 1/12.
251
    //
252
    WriteCommand(0xC3);
253
    WriteData(0x00);
254
 
255
    //
256
    // Enable the x8 booster circuit.
257
    //
258
    WriteCommand(0xC4);
259
    WriteData(0x07);
260
 
261
    //
262
    // Invert the column scan direction for the panel.
263
    //
264
    WriteCommand(0xB7);
265
    WriteData(0xC0);
266
 
267
    //
268
    // Select 16bpp, 5-6-5 data input mode.
269
    //
270
    WriteCommand(0x3A);
271
    WriteData(0x05);
272
 
273
    //
274
    // Select the memory scanning direction.  The scanning mode does not matter
275
    // for this driver since the row/column selects will constrain the writes
276
    // to the desired area of the display.
277
    //
278
    WriteCommand(0x36);
279
    WriteData(0x00);
280
 
281
    //
282
    // Turn on the display.
283
    //
284
    WriteCommand(0x29);
285
 
286
    //
287
    // Clear the contents of the display buffer.
288
    //
289
    WriteCommand(0x2A);
290
    WriteData(0x00);
291
    WriteData(0x7F);
292
    WriteCommand(0x2B);
293
    WriteData(0x01);
294
    WriteData(0x80);
295
    WriteCommand(0x2c);
296
    for(ulCount = 0; ulCount < (128 * 128); ulCount++)
297
    {
298
        WriteData(0x00);
299
        WriteData(0x00);
300
    }
301
 
302
    //
303
    // Enable normal operation of the LCD.
304
    //
305
    WriteCommand(0x13);
306
}
307
 
308
//*****************************************************************************
309
//
310
//! Turns on the backlight.
311
//!
312
//! This function turns on the backlight on the display.
313
//!
314
//! \return None.
315
//
316
//*****************************************************************************
317
void
318
Formike128x128x16BacklightOn(void)
319
{
320
    //
321
    // Assert the signal that turns on the backlight.
322
    //
323
    HWREG(LCD_BL_BASE + GPIO_O_DATA + (LCD_BL_PIN << 2)) = LCD_BL_PIN;
324
}
325
 
326
//*****************************************************************************
327
//
328
//! Turns off the backlight.
329
//!
330
//! This function turns off the backlight on the display.
331
//!
332
//! \return None.
333
//
334
//*****************************************************************************
335
void
336
Formike128x128x16BacklightOff(void)
337
{
338
    //
339
    // Deassert the signal that turns on the backlight.
340
    //
341
    HWREG(LCD_BL_BASE + GPIO_O_DATA + (LCD_BL_PIN << 2)) = 0;
342
}
343
 
344
//*****************************************************************************
345
//
346
//! Draws a pixel on the screen.
347
//!
348
//! \param pvDisplayData is a pointer to the driver-specific data for this
349
//! display driver.
350
//! \param lX is the X coordinate of the pixel.
351
//! \param lY is the Y coordinate of the pixel.
352
//! \param ulValue is the color of the pixel.
353
//!
354
//! This function sets the given pixel to a particular color.  The coordinates
355
//! of the pixel are assumed to be within the extents of the display.
356
//!
357
//! \return None.
358
//
359
//*****************************************************************************
360
static void
361
Formike128x128x16PixelDraw(void *pvDisplayData, long lX, long lY,
362
                           unsigned long ulValue)
363
{
364
    //
365
    // Set the X address of the display cursor.
366
    //
367
    WriteCommand(0x2a);
368
    WriteData(lX);
369
    WriteData(lX);
370
 
371
    //
372
    // Set the Y address of the display cursor.
373
    //
374
    WriteCommand(0x2b);
375
    WriteData(lY + 1);
376
    WriteData(lY + 1);
377
 
378
    //
379
    // Write the pixel value.
380
    //
381
    WriteCommand(0x2c);
382
    WriteData(ulValue >> 8);
383
    WriteData(ulValue);
384
}
385
 
386
//*****************************************************************************
387
//
388
//! Draws a horizontal sequence of pixels on the screen.
389
//!
390
//! \param pvDisplayData is a pointer to the driver-specific data for this
391
//! display driver.
392
//! \param lX is the X coordinate of the first pixel.
393
//! \param lY is the Y coordinate of the first pixel.
394
//! \param lX0 is sub-pixel offset within the pixel data, which is valid for 1
395
//! or 4 bit per pixel formats.
396
//! \param lCount is the number of pixels to draw.
397
//! \param lBPP is the number of bits per pixel; must be 1, 4, or 8.
398
//! \param pucData is a pointer to the pixel data.  For 1 and 4 bit per pixel
399
//! formats, the most significant bit(s) represent the left-most pixel.
400
//! \param pucPalette is a pointer to the palette used to draw the pixels.
401
//!
402
//! This function draws a horizontal sequence of pixels on the screen, using
403
//! the supplied palette.  For 1 bit per pixel format, the palette contains
404
//! pre-translated colors; for 4 and 8 bit per pixel formats, the palette
405
//! contains 24-bit RGB values that must be translated before being written to
406
//! the display.
407
//!
408
//! \return None.
409
//
410
//*****************************************************************************
411
static void
412
Formike128x128x16PixelDrawMultiple(void *pvDisplayData, long lX, long lY,
413
                                   long lX0, long lCount, long lBPP,
414
                                   const unsigned char *pucData,
415
                                   const unsigned char *pucPalette)
416
{
417
    unsigned long ulByte;
418
 
419
    //
420
    // Set the extent of the line along the X axis.
421
    //
422
    WriteCommand(0x2a);
423
    WriteData(lX);
424
    WriteData(lX + lCount - 1);
425
 
426
    //
427
    // Set the Y address of the display cursor.
428
    //
429
    WriteCommand(0x2b);
430
    WriteData(lY + 1);
431
    WriteData(lY + 1);
432
 
433
    //
434
    // Write the data RAM write command.
435
    //
436
    WriteCommand(0x2c);
437
 
438
    //
439
    // Determine how to interpret the pixel data based on the number of bits
440
    // per pixel.
441
    //
442
    switch(lBPP)
443
    {
444
        //
445
        // The pixel data is in 1 bit per pixel format.
446
        //
447
        case 1:
448
        {
449
            //
450
            // Loop while there are more pixels to draw.
451
            //
452
            while(lCount)
453
            {
454
                //
455
                // Get the next byte of image data.
456
                //
457
                ulByte = *pucData++;
458
 
459
                //
460
                // Loop through the pixels in this byte of image data.
461
                //
462
                for(; (lX0 < 8) && lCount; lX0++, lCount--)
463
                {
464
                    //
465
                    // Draw this pixel in the appropriate color.
466
                    //
467
                    lBPP = ((unsigned long *)pucPalette)[(ulByte >>
468
                                                          (7 - lX0)) & 1];
469
                    WriteData(lBPP >> 8);
470
                    WriteData(lBPP);
471
                }
472
 
473
                //
474
                // Start at the beginning of the next byte of image data.
475
                //
476
                lX0 = 0;
477
            }
478
 
479
            //
480
            // The image data has been drawn.
481
            //
482
            break;
483
        }
484
 
485
        //
486
        // The pixel data is in 4 bit per pixel format.
487
        //
488
        case 4:
489
        {
490
            //
491
            // Loop while there are more pixels to draw.  "Duff's device" is
492
            // used to jump into the middle of the loop if the first nibble of
493
            // the pixel data should not be used.  Duff's device makes use of
494
            // the fact that a case statement is legal anywhere within a
495
            // sub-block of a switch statement.  See
496
            // http://en.wikipedia.org/wiki/Duff's_device for detailed
497
            // information about Duff's device.
498
            //
499
            switch(lX0 & 1)
500
            {
501
                case 0:
502
                    while(lCount)
503
                    {
504
                        //
505
                        // Get the upper nibble of the next byte of pixel data
506
                        // and extract the corresponding entry from the
507
                        // palette.
508
                        //
509
                        ulByte = (*pucData >> 4) * 3;
510
                        ulByte = (*(unsigned long *)(pucPalette + ulByte) &
511
                                  0x00ffffff);
512
 
513
                        //
514
                        // Translate this palette entry and write it to the
515
                        // screen.
516
                        //
517
                        ulByte = DPYCOLORTRANSLATE(ulByte);
518
                        WriteData(ulByte >> 8);
519
                        WriteData(ulByte);
520
 
521
                        //
522
                        // Decrement the count of pixels to draw.
523
                        //
524
                        lCount--;
525
 
526
                        //
527
                        // See if there is another pixel to draw.
528
                        //
529
                        if(lCount)
530
                        {
531
                case 1:
532
                            //
533
                            // Get the lower nibble of the next byte of pixel
534
                            // data and extract the corresponding entry from
535
                            // the palette.
536
                            //
537
                            ulByte = (*pucData++ & 15) * 3;
538
                            ulByte = (*(unsigned long *)(pucPalette + ulByte) &
539
                                      0x00ffffff);
540
 
541
                            //
542
                            // Translate this palette entry and write it to the
543
                            // screen.
544
                            //
545
                            ulByte = DPYCOLORTRANSLATE(ulByte);
546
                            WriteData(ulByte >> 8);
547
                            WriteData(ulByte);
548
 
549
                            //
550
                            // Decrement the count of pixels to draw.
551
                            //
552
                            lCount--;
553
                        }
554
                    }
555
            }
556
 
557
            //
558
            // The image data has been drawn.
559
            //
560
            break;
561
        }
562
 
563
        //
564
        // The pixel data is in 8 bit per pixel format.
565
        //
566
        case 8:
567
        {
568
            //
569
            // Loop while there are more pixels to draw.
570
            //
571
            while(lCount--)
572
            {
573
                //
574
                // Get the next byte of pixel data and extract the
575
                // corresponding entry from the palette.
576
                //
577
                ulByte = *pucData++ * 3;
578
                ulByte = *(unsigned long *)(pucPalette + ulByte) & 0x00ffffff;
579
 
580
                //
581
                // Translate this palette entry and write it to the screen.
582
                //
583
                ulByte = DPYCOLORTRANSLATE(ulByte);
584
                WriteData(ulByte >> 8);
585
                WriteData(ulByte);
586
            }
587
 
588
            //
589
            // The image data has been drawn.
590
            //
591
            break;
592
        }
593
    }
594
}
595
 
596
//*****************************************************************************
597
//
598
//! Flushes any cached drawing operations.
599
//!
600
//! \param pvDisplayData is a pointer to the driver-specific data for this
601
//! display driver.
602
//!
603
//! This functions flushes any cached drawing operations to the display.  This
604
//! is useful when a local frame buffer is used for drawing operations, and the
605
//! flush would copy the local frame buffer to the display.  For the ST7637
606
//! driver, the flush is a no operation.
607
//!
608
//! \return None.
609
//
610
//*****************************************************************************
611
static void
612
Formike128x128x16Flush(void *pvDisplayData)
613
{
614
    //
615
    // There is nothing to be done.
616
    //
617
}
618
 
619
//*****************************************************************************
620
//
621
//! Draws a horizontal line.
622
//!
623
//! \param pvDisplayData is a pointer to the driver-specific data for this
624
//! display driver.
625
//! \param lX1 is the X coordinate of the start of the line.
626
//! \param lX2 is the X coordinate of the end of the line.
627
//! \param lY is the Y coordinate of the line.
628
//! \param ulValue is the color of the line.
629
//!
630
//! This function draws a horizontal line on the display.  The coordinates of
631
//! the line are assumed to be within the extents of the display.
632
//!
633
//! \return None.
634
//
635
//*****************************************************************************
636
static void
637
Formike128x128x16LineDrawH(void *pvDisplayData, long lX1, long lX2, long lY,
638
                           unsigned long ulValue)
639
{
640
    //
641
    // Set the extent of the line along the X axis.
642
    //
643
    WriteCommand(0x2a);
644
    WriteData(lX1);
645
    WriteData(lX2);
646
 
647
    //
648
    // Set the Y address of the display cursor.
649
    //
650
    WriteCommand(0x2b);
651
    WriteData(lY + 1);
652
    WriteData(lY + 1);
653
 
654
    //
655
    // Write the data RAM write command.
656
    //
657
    WriteCommand(0x2c);
658
 
659
    //
660
    // Loop through the pixels of this horizontal line.
661
    //
662
    while(lX1++ <= lX2)
663
    {
664
        //
665
        // Write the pixel value.
666
        //
667
        WriteData(ulValue >> 8);
668
        WriteData(ulValue);
669
    }
670
}
671
 
672
//*****************************************************************************
673
//
674
//! Draws a vertical line.
675
//!
676
//! \param pvDisplayData is a pointer to the driver-specific data for this
677
//! display driver.
678
//! \param lX is the X coordinate of the line.
679
//! \param lY1 is the Y coordinate of the start of the line.
680
//! \param lY2 is the Y coordinate of the end of the line.
681
//! \param ulValue is the color of the line.
682
//!
683
//! This function draws a vertical line on the display.  The coordinates of the
684
//! line are assumed to be within the extents of the display.
685
//!
686
//! \return None.
687
//
688
//*****************************************************************************
689
static void
690
Formike128x128x16LineDrawV(void *pvDisplayData, long lX, long lY1, long lY2,
691
                           unsigned long ulValue)
692
{
693
    //
694
    // Set the X address of the display cursor.
695
    //
696
    WriteCommand(0x2a);
697
    WriteData(lX);
698
    WriteData(lX);
699
 
700
    //
701
    // Set the extent of the line along the Y axis.
702
    //
703
    WriteCommand(0x2b);
704
    WriteData(lY1 + 1);
705
    WriteData(lY2 + 1);
706
 
707
    //
708
    // Write the data RAM write command.
709
    //
710
    WriteCommand(0x2c);
711
 
712
    //
713
    // Loop through the pixels of this vertical line.
714
    //
715
    while(lY1++ <= lY2)
716
    {
717
        //
718
        // Write the pixel value.
719
        //
720
        WriteData(ulValue >> 8);
721
        WriteData(ulValue);
722
    }
723
}
724
 
725
//*****************************************************************************
726
//
727
//! Fills a rectangle.
728
//!
729
//! \param pvDisplayData is a pointer to the driver-specific data for this
730
//! display driver.
731
//! \param pRect is a pointer to the structure describing the rectangle.
732
//! \param ulValue is the color of the rectangle.
733
//!
734
//! This function fills a rectangle on the display.  The coordinates of the
735
//! rectangle are assumed to be within the extents of the display, and the
736
//! rectangle specification is fully inclusive (i.e. both sXMin and sXMax are
737
//! drawn, along with sYMin and sYMax).
738
//!
739
//! \return None.
740
//
741
//*****************************************************************************
742
static void
743
Formike128x128x16RectFill(void *pvDisplayData, const tRectangle *pRect,
744
                          unsigned long ulValue)
745
{
746
    long lCount;
747
 
748
    //
749
    // Set the extent of the rectangle along the X axis.
750
    //
751
    WriteCommand(0x2a);
752
    WriteData(pRect->sXMin);
753
    WriteData(pRect->sXMax);
754
 
755
    //
756
    // Set the extent of the rectangle along the Y axis.
757
    //
758
    WriteCommand(0x2b);
759
    WriteData(pRect->sYMin + 1);
760
    WriteData(pRect->sYMax + 1);
761
 
762
    //
763
    // Write the data RAM write command.
764
    //
765
    WriteCommand(0x2c);
766
 
767
    //
768
    // Loop through the pixels in this rectangle.
769
    //
770
    for(lCount = ((pRect->sXMax - pRect->sXMin + 1) *
771
                  (pRect->sYMax - pRect->sYMin + 1)); lCount > 0; lCount--)
772
    {
773
        //
774
        // Write the pixel value.
775
        //
776
        WriteData(ulValue >> 8);
777
        WriteData(ulValue);
778
    }
779
}
780
 
781
//*****************************************************************************
782
//
783
//! Translates a 24-bit RGB color to a display driver-specific color.
784
//!
785
//! \param pvDisplayData is a pointer to the driver-specific data for this
786
//! display driver.
787
//! \param ulValue is the 24-bit RGB color.  The least-significant byte is the
788
//! blue channel, the next byte is the green channel, and the third byte is the
789
//! red channel.
790
//!
791
//! This function translates a 24-bit RGB color into a value that can be
792
//! written into the display's frame buffer in order to reproduce that color,
793
//! or the closest possible approximation of that color.
794
//!
795
//! \return Returns the display-driver specific color.
796
//
797
//*****************************************************************************
798
static unsigned long
799
Formike128x128x16ColorTranslate(void *pvDisplayData, unsigned long ulValue)
800
{
801
    //
802
    // Translate from a 24-bit RGB color to a 5-6-5 RGB color.
803
    //
804
    return(DPYCOLORTRANSLATE(ulValue));
805
}
806
 
807
//*****************************************************************************
808
//
809
//! The display structure that describes the driver for the Formike Electronic
810
//! KWH015C04-F01 CSTN panel with an ST7637 controller.
811
//
812
//*****************************************************************************
813
const tDisplay g_sFormike128x128x16 =
814
{
815
    sizeof(tDisplay),
816
    0,
817
    128,
818
    128,
819
    Formike128x128x16PixelDraw,
820
    Formike128x128x16PixelDrawMultiple,
821
    Formike128x128x16LineDrawH,
822
    Formike128x128x16LineDrawV,
823
    Formike128x128x16RectFill,
824
    Formike128x128x16ColorTranslate,
825
    Formike128x128x16Flush
826
};
827
 
828
//*****************************************************************************
829
//
830
// Close the Doxygen group.
831
//! @}
832
//
833
//*****************************************************************************
834
 
835
 
836
 
837
 
838
 
839
 
840
 
841
 
842
 
843
 
844
 
845
 
846
 
847
 
848
 
849
 
850
/* FreeRTOS.org demo wrappers.  These are required so the prototypes for the
851
functions are the same as for the display drivers used by other evaluation
852
kits. */
853
 
854
static tContext sContext;
855
 
856
void vFormike128x128x16Clear( void )
857
{
858
const tRectangle xRectangle = { 0, 0, 127, 127 };
859
 
860
    GrContextForegroundSet( &sContext, ClrBlack );
861
    GrRectFill( &sContext, &xRectangle );
862
        GrContextForegroundSet(&sContext, ClrWhite);
863
}
864
/*-----------------------------------------------------------*/
865
 
866
void vFormike128x128x16StringDraw( const char *pcString, unsigned long lX, unsigned long lY, unsigned char ucColor )
867
{
868
        GrContextForegroundSet(&sContext, ClrWhite);
869
        GrStringDraw( &sContext, pcString, strlen( pcString ), lX, lY, false );
870
}
871
/*-----------------------------------------------------------*/
872
 
873
void vFormike128x128x16Init( unsigned long ul )
874
{
875
tRectangle rectScreen;
876
 
877
        ( void ) ul;
878
 
879
    Formike128x128x16Init();
880
    Formike128x128x16BacklightOn();
881
    GrContextInit(&sContext, &g_sFormike128x128x16);
882
    GrContextFontSet(&sContext, &g_sFontCmss12);
883
    rectScreen.sXMin = 0;
884
 
885
        /* Fill the screen with a black rectangle. */
886
    rectScreen.sYMin = 0;
887
    rectScreen.sXMax = g_sFormike128x128x16.usWidth - 1;
888
    rectScreen.sYMax = g_sFormike128x128x16.usHeight - 1;
889
    GrContextForegroundSet(&sContext, ClrBlack);
890
    GrRectFill(&sContext, &rectScreen);
891
}
892
/*-----------------------------------------------------------*/
893
 
894
void vFormike128x128x16ImageDraw( const unsigned char *pucImage, unsigned long ulX, unsigned long ulY, unsigned long ulWidth, unsigned long ulHeight )
895
{
896
        GrImageDraw( &sContext, pucImage, ( long ) ulX, ( long ) ulY);
897
 
898
}
899
 
900
 
901
 
902
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.