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 #ifndef MIN
41 # define MIN(n, m) (((n) < (m)) ? (n) : (m))
42 #endif
43 
44 #ifndef MAX
45 # define MAX(n, m) (((n) < (m)) ? (m) : (n))
46 #endif
47 
48 #ifndef ABS
49 # define ABS(n) (((n) < 0) ? -(n) : (n))
50 #endif
51 
52 #define LCD_BACKLT_OUT P8OUT
53 #define LCD_BACKLT_DIR P8DIR
54 #define LCD_BACKLT_SEL P8SEL
55 #define LCD_BACKLIGHT_PIN BIT3
56 #define LCD_CS_RST_DIR P9DIR
57 #define LCD_CS_RST_OUT P9OUT
58 #define LCD_CS_PIN BIT6
59 #define LCD_RESET_PIN BIT7
60 #define LCD_SPI_SEL P9SEL
61 #define LCD_SPI_DIR P9DIR
62 #define LCD_MOSI_PIN BIT1
63 #define LCD_MISO_PIN BIT2
64 #define LCD_CLK_PIN BIT3
65 
66 #define LCD_ROW 110
67 #define LCD_COL 138
68 #define LCD_Size 3505
69 #define LCD_MEM_Size 110 * 17
70 #define LCD_Max_Column_Offset 0x10
71 
72 #define LCD_Last_Pixel 3505
73 
74 #define LCD_MEM_Row 0x11
75 #define LCD_Row 0x20
76 
77 // Grayscale level definitions
78 #define PIXEL_OFF 0
79 #define PIXEL_LIGHT 1
80 #define PIXEL_DARK 2
81 #define PIXEL_ON 3
82 
83 #define INVERT_TEXT BIT0
84 #define OVERWRITE_TEXT BIT2
85 #define GRAYSCALE_TEXT BIT1
86 
87 /*-------------------------------------------------------------
88  * Function Prototypes
89  * ------------------------------------------------------------*/
90 extern void halLcdInit(void);
91 extern void halLcdShutDown(void);
92 extern void halLcdBackLightInit(void);
93 extern void halLcdSetBackLight(unsigned char BackLightLevel);
94 extern unsigned int halLcdGetBackLight(void);
95 extern void halLcdShutDownBackLight(void);
96 
97 extern void halLcdSendCommand(unsigned char Data[]);
98 extern void halLcdSetContrast(unsigned char ContrastLevel);
99 extern unsigned char halLcdGetContrast(void);
100 extern void halLcdStandby(void);
101 extern void halLcdActive(void);
102 
103 //Move to specified LCD address
104 extern void halLcdSetAddress(int Address);
105 
106 //Draw at current segment location
107 extern void halLcdDrawCurrentBlock(unsigned int Value);
108 extern void halLcdDrawCurrentLine(const unsigned int *value, int length);
109 
110 //Draw at specified location by calling
111 //LCD_Set_Address(Address) & LCD_Draw_Current_Block( value )
112 extern void halLcdDrawBlock(unsigned int Address, unsigned int Value);
113 
114 //Read value from LCD CGRAM
115 extern int halLcdReadBlock(unsigned int Address);
116 
117 //Clear LCD Screen
118 extern void halLcdClearScreen(void);
119 
120 //Invert black to white and vice versa
121 extern void halLcdReverse(void);
122 
123 // Draw a Pixel @ (x,y) with GrayScale level
124 extern void halLcdPixel(int x, int y, unsigned char GrayScale);
125 
126 //Draw Line from (x1,y1) to (x2,y2) with GrayScale level
127 extern void halLcdLine(int x1, int y1, int x2, int y2, unsigned char GrayScale);
128 extern void halLcdHLine(int x1, int x2, int y, unsigned char GrayScale);
129 extern void halLcdVLine(int x1, int x2, int y, unsigned char GrayScale);
130 
131 extern void halLcdCircle(int x, int y, int Radius, int GrayScale);
132 
133 extern void halLcdImage(const unsigned int Image[], int Columns, int Rows, int x, int y);
134 extern void halLcdClearImage(int Columns, int Rows, int x, int y);
135 
136 //Print String of Length starting at current LCD location
137 extern void halLcdPrint(char String[], unsigned char TextStyle);
138 
139 //Print String of Length starting at (x,y)
140 extern void halLcdPrintXY(char String[], int x, int y, unsigned char TextStyle);
141 
142 //Print String of Length starting at (x,y)
143 extern void halLcdPrintLine(char String[], unsigned char Line, unsigned char TextStyle);
144 extern void halLcdPrintLineCol(char String[], unsigned char Line, unsigned char Col,
145  unsigned char TextStyle);
146 
147 extern void halLcdCursor(void);
148 extern void halLcdCursorOff(void);
149 
150 //Scroll a single row of pixels
151 extern void halLcdScrollRow(int y);
152 
153 //Scroll a number of consecutive rows from yStart to yEnd
154 extern void halLcdHScroll(int yStart, int yEnd);
155 
156 //Scroll a line of text
157 extern void halLcdScrollLine(int Line);
158 
159 #endif /* HAL_LCD_H */