Code formatted, minor fixes (#466)

This commit is contained in:
Ruslan V. Uss 2017-10-19 00:25:48 +05:00 committed by Johan Kanflo
parent 8a474d749d
commit 5fa48d0298
28 changed files with 623 additions and 608 deletions

View file

@ -1,4 +1,4 @@
# Driver for SSD1306 OLED LCD
# Driver for SSD1306/SH1106 OLED LCD
This driver is written for usage with the ESP8266 and FreeRTOS ([esp-open-rtos](https://github.com/SuperHouse/esp-open-rtos)).
@ -11,34 +11,38 @@ This driver is written for usage with the ESP8266 and FreeRTOS ([esp-open-rtos](
## Supported connection interfaces
Currently supported two of them: I2C and SPI4.
I2C, SPI3 and SPI4.
## Usage
If Reset pin is accesible in your display module, connect it to the RESET pin of ESP8266.
If you don't do this, display RAM may be glitchy after the power lost/restore.
If you don't, display RAM could be glitchy after the power cycle.
### I2C protocol
Before using the SSD1306 LCD module the function `i2c_init(SCL_PIN, SDA_PIN)` needs to be
called to setup the I2C interface and then you must call `ssd1306_init()`.
Before using the OLED module you need to call the function `i2c_init(BUS, SCL_PIN, SDA_PIN, I2C_FREQ_400K)`
to configure the I2C interface and then you should call `ssd1306_init()`.
#### Example
```C
#define SCL_PIN 5
#define SDA_PIN 4
#define I2C_BUS 0
...
static const ssd1306_t device = {
.protocol = SSD1306_PROTO_I2C,
.width = 128,
.height = 64
.protocol = SSD1306_PROTO_I2C,
.screen = SSD1306_SCREEN, // or SH1106_SCREEN
.i2c_dev.bus = I2C_BUS,
.i2c_dev.addr = SSD1306_I2C_ADDR_0,
.width = 128,
.height = 64
};
...
i2c_init(SCL_PIN, SDA_PIN);
i2c_init(I2C_BUS, SCL_PIN, SDA_PIN, I2C_FREQ_400K);
if (ssd1306_init(&device)) {
// An error occured, while performing SSD1306 init (E.g device not found etc.)
@ -47,14 +51,15 @@ if (ssd1306_init(&device)) {
// rest of the code
```
### SPI4 protocol
### SPI3 and SPI4 protocols
This protocol MUCH faster than I2C but uses 2 additional GPIO pins (beside of HSPI CLK
and HSPI MOSI): Data/Command pin and Chip Select pin.
These protocols are MUCH faster than I2C, but use 2 additional GPIO pins
(besides the **HSPI CLK** and **HSPI MOSI**): **Chip Select** and **Data/Command** (in case of SPI4).
No additional function calls are required before `ssd1306_init()`.
#### Example
#### SPI4 Example
```C
#define CS_PIN 5
@ -64,10 +69,35 @@ No additional function calls are required before `ssd1306_init()`.
static const ssd1306_t device = {
.protocol = SSD1306_PROTO_SPI4,
.cs_pin = CS_PIN,
.dc_pin = DC_PIN,
.width = 128,
.height = 64
.screen = SSD1306_SCREEN,
.cs_pin = CS_PIN,
.dc_pin = DC_PIN,
.width = 128,
.height = 64
};
...
if (ssd1306_init(&device)) {
// An error occured, while performing SSD1306 init
}
// rest of the code
```
#### SPI3 example
```C
#define CS_PIN 5
...
static const ssd1306_t device = {
.protocol = SSD1306_PROTO_SPI3,
.screen = SSD1306_SCREEN,
.cs_pin = CS_PIN,
.width = 128,
.height = 64
};
...