Guest User

Untitled

a guest
Jul 4th, 2012
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.10 KB | None | 0 0
  1. /*********************************************************************
  2. This is a library for our Monochrome Nokia 5110 LCD Displays
  3.  
  4.   Pick one up today in the adafruit shop!
  5.   ------> http://www.adafruit.com/products/338
  6.  
  7. These displays use SPI to communicate, 4 or 5 pins are required to  
  8. interface
  9.  
  10. Adafruit invests time and resources providing this open source code,
  11. please support Adafruit and open-source hardware by purchasing
  12. products from Adafruit!
  13.  
  14. Written by Limor Fried/Ladyada  for Adafruit Industries.  
  15. BSD license, check license.txt for more information
  16. All text above, and the splash screen must be included in any redistribution
  17. *********************************************************************/
  18.  
  19. #if defined(ARDUINO) && ARDUINO >= 100
  20.   #include "Arduino.h"
  21. #else
  22.   #include "WProgram.h"
  23. #endif
  24.  
  25. #define BLACK 1
  26. #define WHITE 0
  27.  
  28. #define LCDWIDTH 84
  29. #define LCDHEIGHT 48
  30.  
  31. #define PCD8544_POWERDOWN 0x04
  32. #define PCD8544_ENTRYMODE 0x02
  33. #define PCD8544_EXTENDEDINSTRUCTION 0x01
  34.  
  35. #define PCD8544_DISPLAYBLANK 0x0
  36. #define PCD8544_DISPLAYNORMAL 0x4
  37. #define PCD8544_DISPLAYALLON 0x1
  38. #define PCD8544_DISPLAYINVERTED 0x5
  39.  
  40. // H = 0
  41. #define PCD8544_FUNCTIONSET 0x20
  42. #define PCD8544_DISPLAYCONTROL 0x08
  43. #define PCD8544_SETYADDR 0x40
  44. #define PCD8544_SETXADDR 0x80
  45.  
  46. // H = 1
  47. #define PCD8544_SETTEMP 0x04
  48. #define PCD8544_SETBIAS 0x10
  49. #define PCD8544_SETVOP 0x80
  50.  
  51. class Adafruit_PCD8544 : public Adafruit_GFX {
  52.  public:
  53.   Adafruit_PCD8544(int8_t SCLK, int8_t DIN, int8_t DC, int8_t CS, int8_t RST);
  54.   Adafruit_PCD8544(int8_t SCLK, int8_t DIN, int8_t DC, int8_t RST);
  55.  
  56.   void begin(uint8_t contrast = 40);
  57.  
  58.   void command(uint8_t c);
  59.   void data(uint8_t c);
  60.  
  61.   void setContrast(uint8_t val);
  62.   void clearDisplay(void);
  63.   void display();
  64.  
  65.   void drawPixel(int16_t x, int16_t y, uint16_t color);
  66.   uint8_t getPixel(int8_t x, int8_t y);
  67.  
  68.  private:
  69.   int8_t _din, _sclk, _dc, _rst, _cs;
  70.   volatile uint8_t *mosiport, *clkport, *csport, *dcport;
  71.   uint8_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
  72.  
  73.   void slowSPIwrite(uint8_t c);
  74.   void fastSPIwrite(uint8_t c);
  75. };
Advertisement
Add Comment
Please, Sign In to add comment