2020-05-30 17:10:34 +00:00
|
|
|
#ifndef _DISPLAY_H_DEF_
|
|
|
|
#define _DISPLAY_H_DEF_
|
|
|
|
|
2020-05-31 13:36:49 +00:00
|
|
|
#include <Wire.h>
|
|
|
|
|
|
|
|
#define WIRE_MAX 32
|
|
|
|
#define TRANSACTION_START _wire->setClock(400000UL);
|
|
|
|
#define TRANSACTION_END _wire->setClock(100000UL);
|
|
|
|
|
|
|
|
|
2020-05-30 17:14:56 +00:00
|
|
|
#define DSP_MEMORYMODE 0x20 ///< See datasheet
|
|
|
|
#define DSP_COLUMNADDR 0x21 ///< See datasheet
|
|
|
|
#define DSP_PAGEADDR 0x22 ///< See datasheet
|
|
|
|
#define DSP_SETCONTRAST 0x81 ///< See datasheet
|
|
|
|
#define DSP_CHARGEPUMP 0x8D ///< See datasheet
|
|
|
|
#define DSP_SEGREMAP 0xA0 ///< See datasheet
|
|
|
|
#define DSP_DISPLAYALLON_RESUME 0xA4 ///< See datasheet
|
|
|
|
#define DSP_DISPLAYALLON 0xA5 ///< Not currently used
|
|
|
|
#define DSP_NORMALDISPLAY 0xA6 ///< See datasheet
|
|
|
|
#define DSP_INVERTDISPLAY 0xA7 ///< See datasheet
|
|
|
|
#define DSP_SETMULTIPLEX 0xA8 ///< See datasheet
|
|
|
|
#define DSP_DISPLAYOFF 0xAE ///< See datasheet
|
|
|
|
#define DSP_DISPLAYON 0xAF ///< See datasheet
|
|
|
|
#define DSP_COMSCANINC 0xC0 ///< Not currently used
|
|
|
|
#define DSP_COMSCANDEC 0xC8 ///< See datasheet
|
|
|
|
#define DSP_SETDISPLAYOFFSET 0xD3 ///< See datasheet
|
|
|
|
#define DSP_SETDISPLAYCLOCKDIV 0xD5 ///< See datasheet
|
|
|
|
#define DSP_SETPRECHARGE 0xD9 ///< See datasheet
|
|
|
|
#define DSP_SETCOMPINS 0xDA ///< See datasheet
|
|
|
|
#define DSP_SETVCOMDETECT 0xDB ///< See datasheet
|
|
|
|
|
|
|
|
#define DSP_SETLOWCOLUMN 0x00 ///< Not currently used
|
|
|
|
#define DSP_SETHIGHCOLUMN 0x10 ///< Not currently used
|
|
|
|
#define DSP_SETSTARTLINE 0x40 ///< See datasheet
|
|
|
|
|
|
|
|
#define DSP_EXTERNALVCC 0x01 ///< External display voltage source
|
|
|
|
#define DSP_SWITCHCAPVCC 0x02 ///< Gen. display voltage from 3.3V
|
|
|
|
|
|
|
|
#define DSP_RIGHT_HORIZONTAL_SCROLL 0x26 ///< Init rt scroll
|
|
|
|
#define DSP_LEFT_HORIZONTAL_SCROLL 0x27 ///< Init left scroll
|
|
|
|
#define DSP_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29 ///< Init diag scroll
|
|
|
|
#define DSP_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A ///< Init diag scroll
|
|
|
|
#define DSP_DEACTIVATE_SCROLL 0x2E ///< Stop scroll
|
|
|
|
#define DSP_ACTIVATE_SCROLL 0x2F ///< Start scroll
|
|
|
|
#define DSP_SET_VERTICAL_SCROLL_AREA 0xA3 ///< Set scroll range
|
|
|
|
|
2020-05-30 17:10:34 +00:00
|
|
|
class Display {
|
|
|
|
public:
|
2020-05-31 13:36:49 +00:00
|
|
|
Display(const uint8_t resetPin=-1);
|
2020-05-30 17:10:34 +00:00
|
|
|
void begin();
|
2020-05-30 17:29:36 +00:00
|
|
|
void clear();
|
2020-05-31 20:13:05 +00:00
|
|
|
void setTitle(const String title);
|
|
|
|
void setPixel(int16_t x, int16_t y, const bool white=true);
|
|
|
|
void progress(const short progress, const uint8_t startLine, const uint8_t endLine, const bool absolute=true);
|
|
|
|
void apply();
|
2020-05-30 17:10:34 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void send_command(const uint8_t c);
|
|
|
|
void send_commands(const uint8_t *cc, const uint8_t n);
|
|
|
|
private:
|
2020-05-31 20:13:05 +00:00
|
|
|
const static int16_t _width { 128 };
|
|
|
|
const static int16_t _height { 32 };
|
|
|
|
uint8_t* _buffer { nullptr };
|
2020-05-30 17:10:34 +00:00
|
|
|
const uint8_t _comPin { 0x02 };
|
|
|
|
const uint8_t _i2caddr { 0x3C };
|
|
|
|
const uint8_t _contrast { 0x8F };
|
2020-05-31 13:36:49 +00:00
|
|
|
uint8_t _rstPin { -1 };
|
|
|
|
TwoWire* _wire { nullptr };
|
2020-05-30 17:10:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|