upm  0.3.2
Sensor/Actuator repository for libmraa (v0.7.2)
eboled.h
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2015 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #pragma once
25 
26 #include <string>
27 #include <mraa/spi.hpp>
28 #include <mraa/gpio.hpp>
29 #include "lcd.h"
30 #include "ssd.h"
31 
32 #define EBOLED_DEFAULT_SPI_BUS 0
33 #define EBOLED_DEFAULT_CD 36
34 #define EBOLED_DEFAULT_RESET 48
35 
36 namespace upm
37 {
61  class EBOLED : public LCD
62  {
63  // SSD commands
64  typedef enum {
65  CMD_SETLOWCOLUMN = 0x00,
66  CMD_EXTERNALVCC = 0x01,
67  CMD_SWITCHCAPVCC = 0x02,
68  CMD_SETHIGHCOLUMN = 0x10,
69  CMD_MEMORYADDRMODE = 0x20,
70  CMD_SETCOLUMNADDRESS = 0x21,
71  CMD_SETPAGEADDRESS = 0x22,
72  CMD_SETSTARTLINE = 0x40, // 0x40 - 0x7f
73  CMD_SETCONTRAST = 0x81,
74  CMD_CHARGEPUMP = 0x8d,
75  CMD_SEGREMAP = 0xa0,
76  CMD_DISPLAYALLONRESUME = 0xa4,
77  CMD_DISPLAYALLON = 0xa5,
78  CMD_NORMALDISPLAY = 0xa6,
79  CMD_INVERTDISPLAY = 0xa7,
80  CMD_SETMULTIPLEX = 0xa8,
81  CMD_DISPLAYOFF = 0xae,
82  CMD_DISPLAYON = 0xaf,
83  CMD_SETPAGESTARTADDR = 0xb0, // 0xb0-0xb7
84  CMD_COMSCANINC = 0xc0,
85  CMD_COMSCANDEC = 0xc8,
86  CMD_SETDISPLAYOFFSET = 0xd3,
87  CMD_SETDISPLAYCLOCKDIV = 0xd5,
88  CMD_SETPRECHARGE = 0xd9,
89  CMD_SETCOMPINS = 0xda,
90  CMD_SETVCOMDESELECT = 0xdb
91  } SSD_CMDS_T;
92 
93  public:
103  EBOLED(int spi=EBOLED_DEFAULT_SPI_BUS, int CD=EBOLED_DEFAULT_CD,
104  int reset=EBOLED_DEFAULT_RESET);
105 
109  ~EBOLED();
110 
119  mraa_result_t draw(uint8_t* data, int bytes);
120 
128  mraa_result_t write(std::string msg);
129 
138  mraa_result_t setCursor(int row, int column);
139 
145  mraa_result_t clear();
146 
152  mraa_result_t home();
153 
154  protected:
155  mraa_result_t command(uint8_t cmd);
156  mraa_result_t data(uint8_t data);
157  mraa_result_t writeChar(uint8_t value);
158  mraa_result_t setAddressingMode(displayAddressingMode mode);
159 
160  private:
161  mraa::Gpio m_gpioCD; // command(0)/data(1)
162  mraa::Gpio m_gpioRST; // reset pin
163 
164  mraa::Spi m_spi;
165  };
166 }
Definition: a110x.h:29
~EBOLED()
Definition: eboled.cxx:92
Definition: lcd.h:36
mraa_result_t home()
Definition: eboled.cxx:161
mraa_result_t write(std::string msg)
Definition: eboled.cxx:116
API for EBOLED spi controlled OLED display.
Definition: eboled.h:61
mraa_result_t draw(uint8_t *data, int bytes)
Definition: eboled.cxx:97
mraa_result_t clear()
Definition: eboled.cxx:142
mraa_result_t setCursor(int row, int column)
Definition: eboled.cxx:127
EBOLED(int spi=EBOLED_DEFAULT_SPI_BUS, int CD=EBOLED_DEFAULT_CD, int reset=EBOLED_DEFAULT_RESET)
Definition: eboled.cxx:32