Contiki 2.6

hal_lcd.h

00001 /*******************************************************************************
00002  *
00003  *  hal_lcd.h
00004  *
00005  *  Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *    Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  *
00014  *    Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in the
00016  *    documentation and/or other materials provided with the
00017  *    distribution.
00018  *
00019  *    Neither the name of Texas Instruments Incorporated nor the names of
00020  *    its contributors may be used to endorse or promote products derived
00021  *    from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00026  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00027  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00028  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00029  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00030  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00031  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00032  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00033  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034  *
00035  ******************************************************************************/
00036 
00037 #ifndef HAL_LCD_H
00038 #define HAL_LCD_H
00039 
00040 #ifndef MIN
00041 #    define MIN(n, m)   (((n) < (m)) ? (n) : (m))
00042 #endif
00043 
00044 #ifndef MAX
00045 #    define MAX(n, m)   (((n) < (m)) ? (m) : (n))
00046 #endif
00047 
00048 #ifndef ABS
00049 #    define ABS(n)     (((n) < 0) ? -(n) : (n))
00050 #endif
00051 
00052 #define LCD_BACKLT_OUT      P8OUT
00053 #define LCD_BACKLT_DIR      P8DIR
00054 #define LCD_BACKLT_SEL      P8SEL
00055 #define LCD_BACKLIGHT_PIN   BIT3
00056 #define LCD_CS_RST_DIR      P9DIR
00057 #define LCD_CS_RST_OUT      P9OUT
00058 #define LCD_CS_PIN          BIT6
00059 #define LCD_RESET_PIN       BIT7
00060 #define LCD_SPI_SEL                     P9SEL
00061 #define LCD_SPI_DIR                     P9DIR
00062 #define LCD_MOSI_PIN            BIT1
00063 #define LCD_MISO_PIN            BIT2
00064 #define LCD_CLK_PIN             BIT3
00065 
00066 #define LCD_ROW                 110
00067 #define LCD_COL                 138
00068 #define LCD_Size                3505
00069 #define LCD_MEM_Size            110 * 17
00070 #define LCD_Max_Column_Offset   0x10
00071 
00072 #define LCD_Last_Pixel          3505
00073 
00074 #define LCD_MEM_Row             0x11
00075 #define LCD_Row                 0x20
00076 
00077 // Grayscale level definitions
00078 #define PIXEL_OFF               0
00079 #define PIXEL_LIGHT             1
00080 #define PIXEL_DARK              2
00081 #define PIXEL_ON                3
00082 
00083 #define INVERT_TEXT             BIT0
00084 #define OVERWRITE_TEXT          BIT2
00085 #define GRAYSCALE_TEXT                  BIT1
00086 
00087 /*-------------------------------------------------------------
00088  *                  Function Prototypes
00089  * ------------------------------------------------------------*/
00090 extern void halLcdInit(void);
00091 extern void halLcdShutDown(void);
00092 extern void halLcdBackLightInit(void);
00093 extern void halLcdSetBackLight(unsigned char BackLightLevel);
00094 extern unsigned int halLcdGetBackLight(void);
00095 extern void halLcdShutDownBackLight(void);
00096 
00097 extern void halLcdSendCommand(unsigned char Data[]);
00098 extern void halLcdSetContrast(unsigned char ContrastLevel);
00099 extern unsigned char halLcdGetContrast(void);
00100 extern void halLcdStandby(void);
00101 extern void halLcdActive(void);
00102 
00103 //Move to specified LCD address
00104 extern void halLcdSetAddress(int Address);
00105 
00106 //Draw at current segment location
00107 extern void halLcdDrawCurrentBlock(unsigned int Value);
00108 extern void halLcdDrawCurrentLine(const unsigned int *value, int length);
00109 
00110 //Draw at specified location by calling
00111 //LCD_Set_Address(Address) & LCD_Draw_Current_Block( value )
00112 extern void halLcdDrawBlock(unsigned int Address, unsigned int Value);
00113 
00114 //Read value from LCD CGRAM
00115 extern int halLcdReadBlock(unsigned int Address);
00116 
00117 //Clear LCD Screen
00118 extern void halLcdClearScreen(void);
00119 
00120 //Invert black to white and vice versa
00121 extern void halLcdReverse(void);
00122 
00123 // Draw a Pixel @ (x,y) with GrayScale level
00124 extern void halLcdPixel(int x,  int y, unsigned char GrayScale);
00125 
00126 //Draw Line from (x1,y1) to (x2,y2) with GrayScale level
00127 extern void halLcdLine(int x1,  int y1,  int x2,  int y2, unsigned char GrayScale);
00128 extern void halLcdHLine(int x1, int x2, int y, unsigned char GrayScale);
00129 extern void halLcdVLine(int x1, int x2, int y, unsigned char GrayScale);
00130 
00131 extern void halLcdCircle(int x, int y, int Radius, int GrayScale);
00132 
00133 extern void halLcdImage(const unsigned int Image[], int Columns, int Rows, int x, int y);
00134 extern void halLcdClearImage(int Columns, int Rows,  int x, int y);
00135 
00136 //Print String of Length starting at current LCD location
00137 extern void halLcdPrint(char String[], unsigned char TextStyle);
00138 
00139 //Print String of Length starting at (x,y)
00140 extern void halLcdPrintXY(char String[], int x, int y, unsigned char TextStyle);
00141 
00142 //Print String of Length starting at (x,y)
00143 extern void halLcdPrintLine(char String[], unsigned char Line, unsigned char TextStyle);
00144 extern void halLcdPrintLineCol(char String[], unsigned char Line, unsigned char Col,
00145                                unsigned char TextStyle);
00146 
00147 extern void halLcdCursor(void);
00148 extern void halLcdCursorOff(void);
00149 
00150 //Scroll a single row of pixels
00151 extern void halLcdScrollRow(int y);
00152 
00153 //Scroll a number of consecutive rows from yStart to yEnd
00154 extern void halLcdHScroll(int yStart, int yEnd);
00155 
00156 //Scroll a line of text
00157 extern void halLcdScrollLine(int Line);
00158 
00159 #endif /* HAL_LCD_H */