carb-sync/twinmax/display.h

68 lines
2.7 KiB
C
Raw Normal View History

#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);
#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
class Display {
public:
2020-05-31 13:36:49 +00:00
Display(const uint8_t resetPin=-1);
void begin();
void clear();
2020-05-31 13:36:49 +00:00
void progress(const uint8_t progress);
protected:
void send_command(const uint8_t c);
void send_commands(const uint8_t *cc, const uint8_t n);
private:
const uint8_t _width { 128 };
const uint8_t _height { 32 };
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 };
};
#endif