Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heltec - Makerhawk ESP32 Wifi #8

Open
gameofyou opened this issue May 31, 2020 · 2 comments
Open

Heltec - Makerhawk ESP32 Wifi #8

gameofyou opened this issue May 31, 2020 · 2 comments

Comments

@gameofyou
Copy link

gameofyou commented May 31, 2020

Just adding this comment to your project because from my google search there appears to be a number of people who have searched for an esp-idf based solution to driving this type of display which has been integrated into this board. Heltec themselves however only provide ardinuo based code. It is however very simple to get running, the key thing is a reset needs to be sent to the OLED display for it to start working.

diff --git a/main/main.c b/main/main.c
index 2f35dd2..c1f1776 100644
--- a/main/main.c
+++ b/main/main.c
@@ -11,8 +11,9 @@
 #include "ssd1366.h"
 #include "font8x8_basic.h"
 
-#define SDA_PIN GPIO_NUM_15
-#define SCL_PIN GPIO_NUM_2
+#define SDA_PIN GPIO_NUM_4
+#define SCL_PIN GPIO_NUM_15
+#define RST_PIN GPIO_NUM_16
 
 #define tag "SSD1306"
 
@@ -24,7 +25,7 @@ void i2c_master_init()
                .scl_io_num = SCL_PIN,
                .sda_pullup_en = GPIO_PULLUP_ENABLE,
                .scl_pullup_en = GPIO_PULLUP_ENABLE,
-               .master.clk_speed = 1000000
+               .master.clk_speed = 700000
        };
        i2c_param_config(I2C_NUM_0, &i2c_config);
        i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0);
@@ -35,6 +36,11 @@ void ssd1306_init() {
 
        i2c_cmd_handle_t cmd = i2c_cmd_link_create();
 
+        gpio_set_direction(RST_PIN,GPIO_MODE_OUTPUT);
+        gpio_set_level(RST_PIN, 0);
+        vTaskDelay( pdMS_TO_TICKS( 100 ) );
+        gpio_set_level(RST_PIN, 1);
+
        i2c_master_start(cmd);
        i2c_master_write_byte(cmd, (OLED_I2C_ADDRESS << 1) | I2C_MASTER_WRITE, true);
        i2c_master_write_byte(cmd, OLED_CONTROL_BYTE_CMD_STREAM, true);
@arturfreitas
Copy link

That was extremely useful! Thanks a lot.

@jonesy2
Copy link

jonesy2 commented Jul 28, 2020

You can do this in hardware if you're running out of pins - a 100nF cap to GND and a 10k res to VCC on the reset pin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants