1 /* Arduino SSD1306Ascii Library
2 * Copyright (C) 2015 by William Greiman
4 * This file is part of the Arduino SSD1306Ascii Library
6 * This Library is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This Library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with the Arduino SSD1306Ascii Library. If not, see
18 * <http://www.gnu.org/licenses/>.
21 * @file SSD1306AsciiWire.h
22 * @brief Class for I2C displays using Wire.
24 #ifndef SSD1306AsciiWire_h
25 #define SSD1306AsciiWire_h
27 #include "SSD1306Ascii.h"
29 * @class SSD1306AsciiWire
30 * @brief Class for I2C displays using Wire.
32 class SSD1306AsciiWire
: public SSD1306Ascii
{
35 * @brief Initialize the display controller.
37 * @param[in] dev A device initialization structure.
38 * @param[in] i2cAddr The I2C address of the display controller.
40 void begin(const DevType
* dev
, uint8_t i2cAddr
) {
43 #endif // OPTIMIZE_I2C
48 * @brief Initialize the display controller.
50 * @param[in] dev A device initialization structure.
51 * @param[in] i2cAddr The I2C address of the display controller.
52 * @param[in] rst The display controller reset pin.
54 void begin(const DevType
* dev
, uint8_t i2cAddr
, uint8_t rst
) {
59 * @brief Set the I2C clock rate to 400 kHz.
60 * Deprecated use Wire.setClock(400000L)
62 void set400kHz() __attribute__((deprecated("use Wire.setClock(400000L)"))) {
63 Wire
.setClock(400000L);
67 void writeDisplay(uint8_t b
, uint8_t mode
) {
69 if (m_nData
> 16 || (m_nData
&& mode
== SSD1306_MODE_CMD
)) {
70 Wire
.endTransmission();
74 Wire
.beginTransmission(m_i2cAddr
);
75 Wire
.write(mode
== SSD1306_MODE_CMD
? 0X00 : 0X40);
78 if (mode
== SSD1306_MODE_RAM_BUF
) {
81 Wire
.endTransmission();
85 Wire
.beginTransmission(m_i2cAddr
);
86 Wire
.write(mode
== SSD1306_MODE_CMD
? 0X00: 0X40);
88 Wire
.endTransmission();
89 #endif // OPTIMIZE_I2C
96 #endif // OPTIMIZE_I2C
98 #endif // SSD1306AsciiWire_h