Contiki 3.x
hal_lcd.h
1 /*******************************************************************************
2  *
3  * hal_lcd.h
4  *
5  * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the
17  * distribution.
18  *
19  * Neither the name of Texas Instruments Incorporated nor the names of
20  * its contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  *
35  ******************************************************************************/
36 
37 #ifndef HAL_LCD_H
38 #define HAL_LCD_H
39 
40 #define LCD_BACKLT_OUT P8OUT
41 #define LCD_BACKLT_DIR P8DIR
42 #define LCD_BACKLT_SEL P8SEL
43 #define LCD_BACKLIGHT_PIN BIT3
44 #define LCD_CS_RST_DIR P9DIR
45 #define LCD_CS_RST_OUT P9OUT
46 #define LCD_CS_PIN BIT6
47 #define LCD_RESET_PIN BIT7
48 #define LCD_SPI_SEL P9SEL
49 #define LCD_SPI_DIR P9DIR
50 #define LCD_MOSI_PIN BIT1
51 #define LCD_MISO_PIN BIT2
52 #define LCD_CLK_PIN BIT3
53 
54 #define LCD_ROW 110
55 #define LCD_COL 138
56 #define LCD_Size 3505
57 #define LCD_MEM_Size 110 * 17
58 #define LCD_Max_Column_Offset 0x10
59 
60 #define LCD_Last_Pixel 3505
61 
62 #define LCD_MEM_Row 0x11
63 #define LCD_Row 0x20
64 
65 // Grayscale level definitions
66 #define PIXEL_OFF 0
67 #define PIXEL_LIGHT 1
68 #define PIXEL_DARK 2
69 #define PIXEL_ON 3
70 
71 #define INVERT_TEXT BIT0
72 #define OVERWRITE_TEXT BIT2
73 #define GRAYSCALE_TEXT BIT1
74 
75 /*-------------------------------------------------------------
76  * Function Prototypes
77  * ------------------------------------------------------------*/
78 extern void halLcdInit(void);
79 extern void halLcdShutDown(void);
80 extern void halLcdBackLightInit(void);
81 extern void halLcdSetBackLight(unsigned char BackLightLevel);
82 extern unsigned int halLcdGetBackLight(void);
83 extern void halLcdShutDownBackLight(void);
84 
85 extern void halLcdSendCommand(unsigned char Data[]);
86 extern void halLcdSetContrast(unsigned char ContrastLevel);
87 extern unsigned char halLcdGetContrast(void);
88 extern void halLcdStandby(void);
89 extern void halLcdActive(void);
90 
91 //Move to specified LCD address
92 extern void halLcdSetAddress(int Address);
93 
94 //Draw at current segment location
95 extern void halLcdDrawCurrentBlock(unsigned int Value);
96 extern void halLcdDrawCurrentLine(const unsigned int *value, int length);
97 
98 //Draw at specified location by calling
99 //LCD_Set_Address(Address) & LCD_Draw_Current_Block( value )
100 extern void halLcdDrawBlock(unsigned int Address, unsigned int Value);
101 
102 //Read value from LCD CGRAM
103 extern int halLcdReadBlock(unsigned int Address);
104 
105 //Clear LCD Screen
106 extern void halLcdClearScreen(void);
107 
108 //Invert black to white and vice versa
109 extern void halLcdReverse(void);
110 
111 // Draw a Pixel @ (x,y) with GrayScale level
112 extern void halLcdPixel(int x, int y, unsigned char GrayScale);
113 
114 //Draw Line from (x1,y1) to (x2,y2) with GrayScale level
115 extern void halLcdLine(int x1, int y1, int x2, int y2, unsigned char GrayScale);
116 extern void halLcdHLine(int x1, int x2, int y, unsigned char GrayScale);
117 extern void halLcdVLine(int x1, int x2, int y, unsigned char GrayScale);
118 
119 extern void halLcdCircle(int x, int y, int Radius, int GrayScale);
120 
121 extern void halLcdImage(const unsigned int Image[], int Columns, int Rows, int x, int y);
122 extern void halLcdClearImage(int Columns, int Rows, int x, int y);
123 
124 //Print String of Length starting at current LCD location
125 extern void halLcdPrint(char String[], unsigned char TextStyle);
126 
127 //Print String of Length starting at (x,y)
128 extern void halLcdPrintXY(char String[], int x, int y, unsigned char TextStyle);
129 
130 //Print String of Length starting at (x,y)
131 extern void halLcdPrintLine(char String[], unsigned char Line, unsigned char TextStyle);
132 extern void halLcdPrintLineCol(char String[], unsigned char Line, unsigned char Col,
133  unsigned char TextStyle);
134 
135 extern void halLcdCursor(void);
136 extern void halLcdCursorOff(void);
137 
138 //Scroll a single row of pixels
139 extern void halLcdScrollRow(int y);
140 
141 //Scroll a number of consecutive rows from yStart to yEnd
142 extern void halLcdHScroll(int yStart, int yEnd);
143 
144 //Scroll a line of text
145 extern void halLcdScrollLine(int Line);
146 
147 #endif /* HAL_LCD_H */