Driver for a 128x64 pixels graphic LCD panel based on a KS0723 driver from Samsung.

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LcdKs0723.h Source File

LcdKs0723.h

00001 /* mbed Samsung LCD Library, for a samsung KS0723 based 128x64 black/white lcd panel.
00002  * Copyright (c) 2011, Jeroen Hilgers
00003  *
00004  * I based the interface on the LCD libraries by Simon Ford, to obtain compatibility
00005  * between different displays. I used TextLCD as an example to implement the 
00006  * : public Steam part of this library.
00007  *
00008  *
00009  * Permission is hereby granted, free of charge, to any person obtaining a copy
00010  * of this software and associated documentation files (the "Software"), to deal
00011  * in the Software without restriction, including without limitation the rights
00012  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013  * copies of the Software, and to permit persons to whom the Software is
00014  * furnished to do so, subject to the following conditions:
00015  *
00016  * The above copyright notice and this permission notice shall be included in
00017  * all copies or substantial portions of the Software.
00018  *
00019  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025  * THE SOFTWARE.
00026  */
00027 
00028 
00029 #ifndef MBED_SAMSUNG_LCD_H
00030 #define MBED_SAMSUNG_LCD_H
00031 
00032 #include "mbed.h"
00033 
00034 /** LcdKs0723 class. Provides an interface compatible with
00035  ** other display libraries by Simon Ford on www.mbed.org.
00036  *
00037  * Example:
00038  * @code
00039  * #include "mbed.h"
00040  * #include "LcdKs0723.h"
00041  *
00042  * LcdKs0723 lcd(p28, p10, p27, p19, p25, p15, p24, p16, p23, p17, p22, p18);
00043  *
00044  * int main() 
00045  * {
00046  *    lcd.printf("KS0723 LCD Display driver.\n");
00047  *    lcd.printf("Float: %1.3f\n", 1.375f);
00048  *    lcd.printf("Hex: 0x%04X\n", 0xB12);
00049  *    while(1) 
00050  *   {
00051  *   }
00052  * }
00053  * @endcode
00054  */
00055 
00056 class LcdKs0723 : public Stream 
00057 {
00058   public:
00059     /** Create a LcdKs0723 interface
00060      *
00061      * @param reset Reset line
00062      * @param rs    RS line
00063      * @param write Write line
00064      * @param read  Read line
00065      * @param d0-d7 Data lines
00066      */  
00067     LcdKs0723(PinName reset, PinName rs, PinName write, PinName read, PinName d0, PinName d1,
00068                PinName d2, PinName d3, PinName d4, PinName d5, PinName d6, PinName d7);
00069                
00070 #if DOXYGEN_ONLY
00071     /** Write a character to the LCD
00072      *
00073      * @param c The character to write to the display
00074      */
00075     int putc(int c);
00076 
00077     /** Write a formated string to the LCD
00078      *
00079      * @param format A printf-style format string, followed by the
00080      *               variables to use in formating the string.
00081      */
00082     int printf(const char* format, ...);
00083 #endif               
00084 
00085     /** Locate to a screen column and row
00086      *
00087      * @param column  The horizontal position from the left, indexed from 0
00088      * @param row     The vertical position from the top, indexed from 0
00089      */
00090     void locate(int column, int row);
00091 
00092     /** Clear the screen and locate to 0,0 */
00093     void cls();
00094 
00095   private:
00096      DigitalOut mReset, mRs, mWrite, mRead;
00097      BusInOut mData;
00098      int mRow;
00099      int mCol;
00100      
00101      uint8_t ReadData (void);
00102      void WriteData (uint8_t value);
00103      uint8_t ReadStatus(void);
00104      void WriteControl(uint8_t value);
00105      
00106      // Character definition.
00107      static const uint8_t mFont5x7[];
00108      
00109   protected:
00110      // Stream implementation functions.
00111      virtual int _putc(int value);
00112      virtual int _getc() {return -1;}     
00113 };
00114 
00115 #endif