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 SSD1306AsciiAvrI2c.h
22 * @brief Class for I2C displays using AvrI2c.
24 #ifndef SSD1306AsciiAvrI2c_h
25 #define SSD1306AsciiAvrI2c_h
26 #include "utility/AvrI2c.h"
27 #include "SSD1306Ascii.h"
29 * @class SSD1306AsciiAvrI2c
30 * @brief Class for I2C displays on AVR.
32 * Uses the AvrI2c class that is smaller and faster than the
35 class SSD1306AsciiAvrI2c
: public SSD1306Ascii
{
38 * @brief Initialize the display controller.
40 * @param[in] dev A device initialization structure.
41 * @param[in] i2cAddr The I2C address of the display controller.
43 void begin(const DevType
* dev
, uint8_t i2cAddr
) {
47 m_i2c
.begin(AVRI2C_FASTMODE
);
51 * @brief Initialize the display controller.
53 * @param[in] dev A device initialization structure.
54 * @param[in] i2cAddr The I2C address of the display controller.
55 * @param[in] rst The display controller reset pin.
57 void begin(const DevType
* dev
, uint8_t i2cAddr
, uint8_t rst
) {
62 * @brief Set the I2C bit rate.
64 * @param[in] frequency Desired frequency in Hz.
65 * Valid range for a 16 MHz board is about 40 kHz to 444,000 kHz.
67 void setI2cClock(uint32_t frequency
) {m_i2c
.setClock(frequency
);}
70 void writeDisplay(uint8_t b
, uint8_t mode
) {
71 if ((m_nData
&& mode
== SSD1306_MODE_CMD
)) {
76 m_i2c
.start((m_i2cAddr
<< 1) | I2C_WRITE
);
77 m_i2c
.write(mode
== SSD1306_MODE_CMD
? 0X00 : 0X40);
80 if (mode
== SSD1306_MODE_RAM_BUF
) {
93 #endif // SSD1306AsciiAvrI2c_h