-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_SSD1306_i2c.c
59 lines (46 loc) · 1.47 KB
/
test_SSD1306_i2c.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <driver/gpio.h>
#include <driver/spi_master.h>
#include <esp_log.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <stdio.h>
#include <string.h>
#include <u8g2.h>
#include "sdkconfig.h"
#include "u8g2_esp32_hal.h"
// SDA - GPIO21
#define PIN_SDA 21
// SCL - GPIO22
#define PIN_SCL 22
static const char *TAG = "ssd1306";
void task_test_SSD1306i2c(void *ignore) {
u8g2_esp32_hal_t u8g2_esp32_hal = U8G2_ESP32_HAL_DEFAULT;
u8g2_esp32_hal.sda = PIN_SDA;
u8g2_esp32_hal.scl = PIN_SCL;
u8g2_esp32_hal_init(u8g2_esp32_hal);
u8g2_t u8g2; // a structure which will contain all the data for one display
u8g2_Setup_ssd1306_i2c_128x32_univision_f(
&u8g2,
U8G2_R0,
//u8x8_byte_sw_i2c,
u8g2_esp32_i2c_byte_cb,
u8g2_esp32_gpio_and_delay_cb); // init u8g2 structure
u8x8_SetI2CAddress(&u8g2.u8x8,0x78);
ESP_LOGI(TAG, "u8g2_InitDisplay");
u8g2_InitDisplay(&u8g2); // send init sequence to the display, display is in sleep mode after this,
ESP_LOGI(TAG, "u8g2_SetPowerSave");
u8g2_SetPowerSave(&u8g2, 0); // wake up display
ESP_LOGI(TAG, "u8g2_ClearBuffer");
u8g2_ClearBuffer(&u8g2);
ESP_LOGI(TAG, "u8g2_DrawBox");
u8g2_DrawBox(&u8g2, 0, 26, 80,6);
u8g2_DrawFrame(&u8g2, 0,26,100,6);
ESP_LOGI(TAG, "u8g2_SetFont");
u8g2_SetFont(&u8g2, u8g2_font_ncenB14_tr);
ESP_LOGI(TAG, "u8g2_DrawStr");
u8g2_DrawStr(&u8g2, 2,17,"Hi nkolban!");
ESP_LOGI(TAG, "u8g2_SendBuffer");
u8g2_SendBuffer(&u8g2);
ESP_LOGI(TAG, "All done!");
vTaskDelete(NULL);
}