2016-10-28 12:08:37 +00:00
|
|
|
#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__);
|
2016-11-05 10:04:03 +00:00
|
|
|
vTaskDelay(1000/portTICK_PERIOD_MS);
|
2016-10-28 12:08:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (ssd1306_load_xbm(image_bits, buffer))
|
|
|
|
goto error_loop;
|
|
|
|
|
|
|
|
ssd1306_set_whole_display_lighting(false);
|
|
|
|
while (1) {
|
2016-11-05 10:04:03 +00:00
|
|
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
2016-10-28 12:08:37 +00:00
|
|
|
printf("%s: steel alive\n", __FUNCTION__);
|
|
|
|
}
|
|
|
|
|
|
|
|
error_loop:
|
|
|
|
printf("%s: error while loading framebuffer into SSD1306\n", __func__);
|
|
|
|
for(;;){
|
2016-11-05 10:04:03 +00:00
|
|
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
2016-10-28 12:08:37 +00:00
|
|
|
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__);
|
2016-11-05 10:04:03 +00:00
|
|
|
vTaskDelay(1000/portTICK_PERIOD_MS);
|
2016-10-28 12:08:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ssd1306_set_whole_display_lighting(true);
|
2016-11-05 10:04:03 +00:00
|
|
|
vTaskDelay(1000/portTICK_PERIOD_MS);
|
2016-10-28 12:08:37 +00:00
|
|
|
// Create user interface task
|
|
|
|
xTaskCreate(ssd1306_task, "ssd1306_task", 256, NULL, 2, NULL);
|
|
|
|
}
|