ERM19264_UC1609  1.8.0
Arduino Eco-system Library for ERM19264 LCD driven by UC1609 controller.
ERM19264_UC1609.h
Go to the documentation of this file.
1 
8 #ifndef ERM19264_UC1609_H
9 #define ERM19264_UC1609_H
10 
11 #if (ARDUINO >=100)
12  #include "Arduino.h"
13 #else
14  #include "WProgram.h"
15 #endif
16 
17 #include "ERM19264_graphics.h"
18 #include <SPI.h>
19 
30 #define FOREGROUND 0
31 #define BACKGROUND 1
32 #define COLORINVERSE 2
34 // UC1909 Write registers
35 #define UC1609_SYSTEM_RESET 0xE2
37 #define UC1609_POWER_CONTROL 0x28
38 #define UC1609_PC_SET 0x06
40 #define UC1609_ADDRESS_CONTROL 0x88
41 #define UC1609_ADDRESS_SET 0x02
43 #define UC1609_SET_PAGEADD 0xB0
44 #define UC1609_SET_COLADD_LSB 0x00
45 #define UC1609_SET_COLADD_MSB 0x10
47 #define UC1609_TEMP_COMP_REG 0x27
48 #define UC1609_TEMP_COMP_SET 0x00
50 #define UC1609_FRAMERATE_REG 0xA0
51 #define UC1609_FRAMERATE_SET 0x01
53 #define UC1609_BIAS_RATIO 0xE8
54 #define UC1609_BIAS_RATIO_SET 0x03
56 #define UC1609_GN_PM 0x81
57 #define UC1609_DEFAULT_GN_PM 0x49
59 #define UC1609_LCD_CONTROL 0xC0
60 #define UC1609_DISPLAY_ON 0xAE
61 #define UC1609_ALL_PIXEL_ON 0xA4
62 #define UC1609_INVERSE_DISPLAY 0xA6
63 #define UC1609_SCROLL 0x40
65 // Rotate
66 #define UC1609_ROTATION_FLIP_TWO 0x06
67 #define UC1609_ROTATION_NORMAL 0x04
68 #define UC1609_ROTATION_FLIP_ONE 0x02
69 #define UC1609_ROTATION_FLIP_THREE 0x00
71 // Delays
72 #define UC1609_RESET_DELAY 3
73 #define UC1609_RESET_DELAY2 0
74 #define UC1609_INIT_DELAY 100
75 #define UC1609_INIT_DELAY2 3
76 #define UC1609_HIGHFREQ_DELAY 0
78 // GPIO abstraction
79 #define UC1609_CS_SetHigh digitalWrite(_LCD_CS, HIGH)
80 #define UC1609_CS_SetLow digitalWrite(_LCD_CS, LOW)
81 #define UC1609_CD_SetHigh digitalWrite(_LCD_CD, HIGH)
82 #define UC1609_CD_SetLow digitalWrite(_LCD_CD, LOW)
83 #define UC1609_RST_SetHigh digitalWrite(_LCD_RST, HIGH)
84 #define UC1609_RST_SetLow digitalWrite(_LCD_RST, LOW)
85 #define UC1609_SCLK_SetHigh digitalWrite(_LCD_SCLK, HIGH)
86 #define UC1609_SCLK_SetLow digitalWrite(_LCD_SCLK, LOW)
87 #define UC1609_SDA_SetHigh digitalWrite(_LCD_DIN, HIGH)
88 #define UC1609_SDA_SetLow digitalWrite(_LCD_DIN, LOW)
89 
90 // SPI HW setup
91 #define UC_SPI_FREQ 8000000
92 #define UC_SPI_DIRECTION MSBFIRST
93 #define UC_SPI_UC1609_MODE SPI_MODE0
94 #define UC_SPI_CLOCK_DIV SPI_CLOCK_DIV8
96 //There is a pre-defined macro SPI_HAS_TRANSACTION in SPI library for checking
97  //whether the firmware of the Arduino board supports SPI.beginTransaction().
98 #ifdef SPI_HAS_TRANSACTION
99  #define UC_SPI_TRANSACTION_START SPI.beginTransaction(SPISettings(UC_SPI_FREQ, UC_SPI_DIRECTION, UC_SPI_UC1609_MODE));
100  #define UC_SPI_TRANSACTION_END SPI.endTransaction();
101 #else // SPI transactions likewise not present in MCU or lib
102  #define UC_SPI_TRANSACTION_START SPI.setClockDivider(UC_SPI_CLOCK_DIV); // 72/8 = 9Mhz
103  #define UC_SPI_TRANSACTION_END // Blank
104 #endif
105 
109 {
110  public :
111  ERM19264_UC1609_Screen(uint8_t* mybuffer, uint8_t w, uint8_t h, int16_t x, int16_t y) ;
113 
114  uint8_t* screenBuffer;
115  uint8_t width;
116  uint8_t height;
117  int16_t xoffset;
118  int16_t yoffset;
119  private:
120 };
121 
124  public:
125  ERM19264_UC1609(int16_t lcdwidth , int16_t lcdheight, int8_t cd, int8_t rst, int8_t cs, int8_t sclk, int8_t din);
126  ERM19264_UC1609(int16_t lcdwidth , int16_t lcdheight, int8_t cd, int8_t rst, int8_t cs);
127 
128  ~ERM19264_UC1609(){};
129 
130  virtual void drawPixel(int16_t x, int16_t y, uint8_t colour) override;
131  void LCDupdate(void);
132  void LCDclearBuffer(void);
133  void LCDBuffer(int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t* data);
134 
135  void LCDbegin(uint8_t VbiasPot = UC1609_DEFAULT_GN_PM , uint8_t AddressSet =UC1609_ADDRESS_SET);
136  void LCDinit(void);
137  void LCDEnable(uint8_t on);
138  void LCDFillScreen(uint8_t pixel, uint8_t mircodelay);
139  void LCDFillPage(uint8_t pixels);
140  void LCDGotoXY(uint8_t column , uint8_t page);
141  void LCDrotate(uint8_t rotatevalue);
142  void LCDInvertDisplay(uint8_t on);
143  void LCDallpixelsOn(uint8_t bits);
144  void LCDscroll(uint8_t bits);
145  void LCDReset(void);
146  LCD_Return_Codes_e LCDBitmap(int16_t x, int16_t y, uint8_t w, uint8_t h, const uint8_t* data);
147  void LCDPowerDown(void);
148 
149  uint16_t LCDLibVerNumGet(void);
150  uint16_t LCDHighFreqDelayGet(void);
151  void LCDHighFreqDelaySet(uint16_t);
152  uint8_t LCDGetConstrast(void);
153  uint8_t LCDGetAddressCtrl(void);
156  private:
157 
158  void send_data(uint8_t data);
159  void send_command(uint8_t command, uint8_t value);
160  bool isHardwareSPI(void);
161  void CustomshiftOut(uint8_t bitOrder, uint8_t val);
162 
163  int8_t _LCD_CS;
164  int8_t _LCD_CD;
165  int8_t _LCD_RST;
166  int8_t _LCD_SCLK;
167  int8_t _LCD_DIN;
169  uint8_t _VbiasPOT= 0x49;
170  uint8_t _AddressCtrl= 0x02;
172  const uint16_t _LibVersionNum = 180;
174  uint8_t _widthScreen = 192;
175  uint8_t _heightScreen = 64;
177 };
178 
179 #endif
#define UC1609_DEFAULT_GN_PM
Definition: ERM19264_UC1609.h:57
#define UC1609_ADDRESS_SET
Definition: ERM19264_UC1609.h:41
#define UC1609_HIGHFREQ_DELAY
Definition: ERM19264_UC1609.h:76
ERM19264 LCD driven by UC1609 controller, header file for the graphics based functions.
LCD_Return_Codes_e
Definition: ERM19264_graphics.h:33
class to hold screen data , multiple screens can be made for the shared buffer. Buffer must be same s...
Definition: ERM19264_UC1609.h:109
int16_t xoffset
Definition: ERM19264_UC1609.h:117
uint8_t height
Definition: ERM19264_UC1609.h:116
uint8_t * screenBuffer
Definition: ERM19264_UC1609.h:112
int16_t yoffset
Definition: ERM19264_UC1609.h:118
ERM19264_UC1609_Screen(uint8_t *mybuffer, uint8_t w, uint8_t h, int16_t x, int16_t y)
init the screen/sharedBuffer object
Definition: ERM19264_UC1609.cpp:18
uint8_t width
Definition: ERM19264_UC1609.h:115
class to drive the ERM19264_UC1609 LCD
Definition: ERM19264_UC1609.h:123
int8_t _LCD_CD
Definition: ERM19264_UC1609.h:164
uint8_t _VbiasPOT
Definition: ERM19264_UC1609.h:169
void LCDPowerDown(void)
Powerdown procedure for LCD see datasheet P40.
Definition: ERM19264_UC1609.cpp:169
void LCDReset(void)
Resets LCD in a four wire setup called at start and should also be called in a controlled power down ...
Definition: ERM19264_UC1609.cpp:158
bool isHardwareSPI(void)
Checks if software SPI is on.
Definition: ERM19264_UC1609.cpp:365
void LCDGotoXY(uint8_t column, uint8_t page)
Goes to X Y position.
Definition: ERM19264_UC1609.cpp:297
void LCDBuffer(int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t *data)
Draw a data array to the screen.
Definition: ERM19264_UC1609.cpp:435
void LCDInvertDisplay(uint8_t on)
invert the display
Definition: ERM19264_UC1609.cpp:233
uint16_t _HighFreqDelay
Definition: ERM19264_UC1609.h:171
int8_t _LCD_CS
Definition: ERM19264_UC1609.h:163
void LCDrotate(uint8_t rotatevalue)
Rotates the display.
Definition: ERM19264_UC1609.cpp:212
uint8_t _widthScreen
Definition: ERM19264_UC1609.h:174
int8_t _LCD_SCLK
Definition: ERM19264_UC1609.h:166
uint16_t LCDHighFreqDelayGet(void)
Freq delay used in SW SPI getter, uS delay used in SW SPI method.
Definition: ERM19264_UC1609.cpp:537
void LCDallpixelsOn(uint8_t bits)
turns on all Pixels
Definition: ERM19264_UC1609.cpp:247
ERM19264_UC1609_Screen * ActiveBuffer
Definition: ERM19264_UC1609.h:154
int8_t _LCD_DIN
Definition: ERM19264_UC1609.h:167
void LCDEnable(uint8_t on)
Turns On Display.
Definition: ERM19264_UC1609.cpp:181
uint16_t LCDLibVerNumGet(void)
Library version number getter.
Definition: ERM19264_UC1609.cpp:531
uint8_t _AddressCtrl
Definition: ERM19264_UC1609.h:170
ERM19264_UC1609(int16_t lcdwidth, int16_t lcdheight, int8_t cd, int8_t rst, int8_t cs, int8_t sclk, int8_t din)
init the LCD class object
Definition: ERM19264_UC1609.cpp:61
int8_t _LCD_RST
Definition: ERM19264_UC1609.h:165
virtual void drawPixel(int16_t x, int16_t y, uint8_t colour) override
Draws a Pixel to the screen , overrides the graphics library.
Definition: ERM19264_UC1609.cpp:477
void CustomshiftOut(uint8_t bitOrder, uint8_t val)
used in software SPI mode to shift out data
Definition: ERM19264_UC1609.cpp:375
void LCDFillPage(uint8_t pixels)
Fill the chosen page at cursor with a datapattern.
Definition: ERM19264_UC1609.cpp:279
uint8_t _heightScreen
Definition: ERM19264_UC1609.h:175
void send_command(uint8_t command, uint8_t value)
Sends a command to the display.
Definition: ERM19264_UC1609.cpp:147
void LCDupdate(void)
updates the LCD i.e. writes the shared buffer to the active screen pointed to by ActiveBuffer
Definition: ERM19264_UC1609.cpp:412
void LCDbegin(uint8_t VbiasPot=UC1609_DEFAULT_GN_PM, uint8_t AddressSet=UC1609_ADDRESS_SET)
begin Method initialise LCD Sets pinmodes and SPI setup
Definition: ERM19264_UC1609.cpp:81
void LCDHighFreqDelaySet(uint16_t)
Freq delay used in SW SPI setter, uS delay used in SW SPI method.
Definition: ERM19264_UC1609.cpp:543
void LCDclearBuffer(void)
clears the buffer of the active screen pointed to by ActiveBuffer
Definition: ERM19264_UC1609.cpp:421
const uint16_t _LibVersionNum
Definition: ERM19264_UC1609.h:172
LCD_Return_Codes_e LCDBitmap(int16_t x, int16_t y, uint8_t w, uint8_t h, const uint8_t *data)
Draw a bitmap in PROGMEM to the screen.
Definition: ERM19264_UC1609.cpp:315
void LCDFillScreen(uint8_t pixel, uint8_t mircodelay)
Fill the screen NOT the buffer with a datapattern.
Definition: ERM19264_UC1609.cpp:261
void LCDscroll(uint8_t bits)
Scroll the displayed image up by SL rows.
Definition: ERM19264_UC1609.cpp:197
uint8_t LCDGetConstrast(void)
Getter for _VbiasPOT contrast member.
Definition: ERM19264_UC1609.cpp:518
uint8_t LCDGetAddressCtrl(void)
Getter for _AddressCtrl Display RAM address control member.
Definition: ERM19264_UC1609.cpp:524
void send_data(uint8_t data)
Send data byte with SPI to UC1609.
Definition: ERM19264_UC1609.cpp:396
void LCDinit(void)
Called from LCDbegin carries out Power on sequence and register init Can be used to reset LCD to defa...
Definition: ERM19264_UC1609.cpp:112
Graphics class to hold graphic related functions.
Definition: ERM19264_graphics.h:64