Advertisement
JohnWasser

PCD8544.h w/inverse text

Jun 2nd, 2011
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.11 KB | None | 0 0
  1. /*
  2.  * PCD8544 - Interface with Philips PCD8544 (or compatible) LCDs.
  3.  *
  4.  * Copyright (c) 2010 Carlos Rodrigues <cefrodrigues@gmail.com>
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a copy
  7.  * of this software and associated documentation files (the "Software"), to deal
  8.  * in the Software without restriction, including without limitation the rights
  9.  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10.  * copies of the Software, and to permit persons to whom the Software is
  11.  * furnished to do so, subject to the following conditions:
  12.  *
  13.  * The above copyright notice and this permission notice shall be included in
  14.  * all copies or substantial portions of the Software.
  15.  *
  16.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19.  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21.  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22.  * THE SOFTWARE.
  23.  */
  24.  
  25.  
  26. #ifndef PCD8544_H
  27. #define PCD8544_H
  28.  
  29.  
  30. #include <WProgram.h>
  31.  
  32.  
  33. // Chip variants supported...
  34. #define CHIP_PCD8544 0
  35. #define CHIP_ST7576  1
  36.  
  37.  
  38. class PCD8544: public Print {
  39.     public:
  40.         // All the pins can be changed from the default values...
  41.         PCD8544(unsigned char sclk  = 3,   /* clock       (display pin 2) */
  42.                 unsigned char sdin  = 4,   /* data-in     (display pin 3) */
  43.                 unsigned char dc    = 5,   /* data select (display pin 4) */
  44.                 unsigned char reset = 6,   /* reset       (display pin 8) */
  45.                 unsigned char sce   = 7);  /* enable      (display pin 5) */
  46.  
  47.         // Display initialization (dimensions in pixels)...
  48.         void begin(unsigned char width=84, unsigned char height=48, unsigned char model=CHIP_PCD8544);
  49.         void stop();
  50.  
  51.         // Erase everything on the display...
  52.         void clear();
  53.         void clearLine();  // ...or just the current line
  54.        
  55.         // Control the display's power state...
  56.         void setPower(bool on);
  57.  
  58.         // For compatibility with the LiquidCrystal library...
  59.         void display();
  60.         void noDisplay();
  61.    
  62.         // Activate white-on-black mode (whole display)...
  63.         void setInverseText(bool inverse);
  64.  
  65.  
  66.         // Activate white-on-black mode (whole display)...
  67.         void setInverse(bool inverse);
  68.  
  69.         // Place the cursor at the start of the current line...
  70.         void home();
  71.  
  72.         // Place the cursor at position (column, line)...
  73.         void setCursor(unsigned char column, unsigned char line);
  74.  
  75.         // Assign a user-defined glyph (5x8) to an ASCII character (0-31)...
  76.         void createChar(unsigned char chr, const unsigned char *glyph);
  77.  
  78.         // Write an ASCII character at the current cursor position (7-bit)...
  79.         virtual void write(unsigned char chr);
  80.  
  81.         // Draw a bitmap at the current cursor position...
  82.         void drawBitmap(const unsigned char *data, unsigned char columns, unsigned char lines);
  83.  
  84.         // Draw a chart element at the current cursor position...
  85.         void drawColumn(unsigned char lines, unsigned char value);
  86.  
  87.     private:
  88.         unsigned char pin_sclk;
  89.         unsigned char pin_sdin;
  90.         unsigned char pin_dc;
  91.         unsigned char pin_reset;
  92.         unsigned char pin_sce;
  93.  
  94.         // The size of the display, in pixels...
  95.         unsigned char width;
  96.         unsigned char height;
  97.  
  98.         // Current cursor position...
  99.         unsigned char column;
  100.         unsigned char line;
  101.    
  102.         // Flag for drawing inverse (white on black) text
  103.         bool inverseText;
  104.  
  105.         // User-defined glyphs (below the ASCII space character)...
  106.         const unsigned char *custom[' '];
  107.  
  108.         // Send a command or data to the display...
  109.         void send(unsigned char type, unsigned char data);
  110. };
  111.  
  112.  
  113. #endif  /* PCD8544_H */
  114.  
  115.  
  116. /* vim: set expandtab ts=4 sw=4: */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement