Driver and example for SSD1306 128x64 I2C display (#254)
This commit is contained in:
parent
e71919410d
commit
5b12ba54dc
9 changed files with 644 additions and 0 deletions
65
examples/ssd1306_i2c/ssd1306_i2c.c
Normal file
65
examples/ssd1306_i2c/ssd1306_i2c.c
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#include "espressif/esp_common.h"
|
||||
#include "esp/uart.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "i2c/i2c.h"
|
||||
#include "ssd1306/ssd1306.h"
|
||||
|
||||
#include "image.xbm"
|
||||
|
||||
/* Change this according to you schematics */
|
||||
#define SCL_PIN GPIO_ID_PIN((14))
|
||||
#define SDA_PIN GPIO_ID_PIN((12))
|
||||
|
||||
/* Local frame buffer */
|
||||
static uint8_t buffer[SSD1306_ROWS * SSD1306_COLS / 8];
|
||||
|
||||
static void ssd1306_task(void *pvParameters)
|
||||
{
|
||||
printf("%s: Started user interface task\n", __FUNCTION__);
|
||||
vTaskDelay(1000/portTICK_RATE_MS);
|
||||
|
||||
|
||||
if (ssd1306_load_xbm(image_bits, buffer))
|
||||
goto error_loop;
|
||||
|
||||
ssd1306_set_whole_display_lighting(false);
|
||||
while (1) {
|
||||
vTaskDelay(2000 / portTICK_RATE_MS);
|
||||
printf("%s: steel alive\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
error_loop:
|
||||
printf("%s: error while loading framebuffer into SSD1306\n", __func__);
|
||||
for(;;){
|
||||
vTaskDelay(2000 / portTICK_RATE_MS);
|
||||
printf("%s: error loop\n", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
void user_init(void)
|
||||
{
|
||||
// Setup HW
|
||||
uart_set_baud(0, 115200);
|
||||
|
||||
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
||||
|
||||
i2c_init(SCL_PIN, SDA_PIN);
|
||||
|
||||
if (ssd1306_init()){
|
||||
for (;;) {
|
||||
printf("%s: failed to init SSD1306 lcd\n", __func__);
|
||||
vTaskDelay(1000/portTICK_RATE_MS);
|
||||
}
|
||||
}
|
||||
|
||||
ssd1306_set_whole_display_lighting(true);
|
||||
vTaskDelay(1000/portTICK_RATE_MS);
|
||||
// Create user interface task
|
||||
xTaskCreate(ssd1306_task, "ssd1306_task", 256, NULL, 2, NULL);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue