-
Notifications
You must be signed in to change notification settings - Fork 443
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
Trying to use ds1307 with ssd1306 oled #74
Comments
Code of ssd1306 driver does not use i2cdev library which is the core of all i2c drivers in this repo. |
How do i port to use i2cdev? |
See https://github.com/TaraHoleInIt/tarablessd1306/blob/master/ifaces/default_if_i2c.c #ifdef CONFIG_USE_I2CDEV_LIB
#include <i2cdev.h>
#endif
...
#ifdef CONFIG_USE_I2CDEV_LIB
static i2c_dev_t dev;
#endif
...
bool SSD1306_I2CMasterInitDefault( void ) {
#ifdef CONFIG_USE_I2CDEV_LIB
ESP_ERROR_CHECK_NONFATAL( i2cdev_init(), return false );
memset (&dev, 0, sizeof( i2c_dev_t ) );
dev.port = 0;
dev.addr = I2CAddress;
dev.cfg.sda_io_num = SDAPin;
dev.cfg.sda_pullup_en = GPIO_PULLUP_ENABLE;
dev.cfg.scl_io_num = SCLPin;
dev.cfg.scl_pullup_en = GPIO_PULLUP_ENABLE;
dev.cfg.master.clk_speed = I2CDisplaySpeed;
ESP_ERROR_CHECK_NONFATAL( i2c_dev_create_mutex(dev), return false );
#else
...
#endif
return true;
}
...
static bool I2CDefaultWriteBytes( int Address, bool IsCommand, const uint8_t* Data, size_t DataLength ) {
#ifdef CONFIG_USE_I2CDEV_LIB
NullCheck( Data, return false );
ESP_ERROR_CHECK_NONFATAL( i2c_dev_take_mutex( &dev ), return false );
ESP_ERROR_CHECK_NONFATAL( i2c_dev_write_reg( &dev, ( IsCommand == true ) ? SSD1306_I2C_COMMAND_MODE: SSD1306_I2C_DATA_MODE, Data, DataLength ),
do { i2c_dev_give_mutex( &dev ); return false; } while (0) );
ESP_ERROR_CHECK_NONFATAL( i2c_dev_give_mutex( &dev ); return false );
#else
...
#endif
return true;
} |
Of course, you will need the appropriate changes to the Kconfig of ssd1306 driver and its makefiles. |
Cool, Thanks for the help. I will close the issue. |
@VedantParanjape is this issue solved? now I'm facing the same problem but instead of ds1307, I'm using qmc5883l with ssd1306 OLED. if you got a solution please help me out with this. |
I don't remember, but I ditched that OLED library use u8g2 instead and it works fine with this driver. |
@VedantParanjape thank you for your quick response, Using any library is ok with me. Finally I need to integrate qmc5883l magneto meter and ssd1306oled. |
|
thank you so much
…On Thu, Apr 29, 2021 at 1:22 PM Vedant Paranjape ***@***.***> wrote:
@VedantParanjape <https://github.com/VedantParanjape> thank you for your
quick response,
Using any library is ok with me. Finally I need to integrate qmc5883l
magneto meter and ssd1306oled.
Is that ok to share sample working code. I really got stuck since am new
to esp-idf.
https://github.com/VedantParanjape/esp-2fa
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#74 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKZYDWTFG4XVBOMEPGFLZJTTLEF2JANCNFSM4MILWMBQ>
.
|
@VedantParanjape this issue is solved and thank you so much for your time and help. |
Welcome :) |
Спасибо! у меня в итоге заработало!
default_if_i2c.c// i2c.
#include "i2cdev.h"
#include <esp_err.h>
#include <esp_idf_lib_helpers.h>
#include <esp_log.h>
static i2c_dev_t dev;
#define SSD1360_DEVICE_ADDRESS 0x3C
...
esp_err_t SSD1306_I2CMasterInitDefault(i2c_port_t port, gpio_num_t sda_gpio,
gpio_num_t scl_gpio) {
ESP_ERROR_CHECK_NONFATAL(i2cdev_init(), return false);
memset(&dev, 0, sizeof(i2c_dev_t));
dev.port = port;
dev.addr = SSD1360_DEVICE_ADDRESS;
dev.cfg.sda_io_num = sda_gpio;
dev.cfg.scl_io_num = scl_gpio;
dev.cfg.sda_pullup_en = GPIO_PULLUP_ENABLE;
dev.cfg.scl_pullup_en = GPIO_PULLUP_ENABLE;
dev.cfg.master.clk_speed = 100000;
ESP_ERROR_CHECK_NONFATAL(i2c_dev_create_mutex(&dev), return false);
return true;
}
...
bool SSD1306_I2CMasterAttachDisplayDefault(struct SSD1306_Device *DisplayHandle,
int Width, int Height, int RSTPin) {
NullCheck(DisplayHandle, return false);
return SSD1306_Init_I2C(DisplayHandle, Width, Height, SSD1360_DEVICE_ADDRESS,
RSTPin, I2CDefaultWriteCommand, I2CDefaultWriteData,
I2CDefaultReset);
}
...
static bool I2CDefaultWriteBytes(int Address, bool IsCommand,
const uint8_t *Data, size_t DataLength) {
NullCheck(Data, return false);
ESP_ERROR_CHECK_NONFATAL(i2c_dev_take_mutex(&dev), return false);
ESP_ERROR_CHECK_NONFATAL(
i2c_dev_write_reg(&dev,
(IsCommand == true) ? SSD1306_I2C_COMMAND_MODE
: SSD1306_I2C_DATA_MODE,
Data, DataLength),
do {
i2c_dev_give_mutex(&dev);
return false;
} while (0));
ESP_ERROR_CHECK_NONFATAL(i2c_dev_give_mutex(&dev), return false);
return true;
} ssd1306_default_if.hesp_err_t SSD1306_I2CMasterInitDefault(i2c_port_t port, gpio_num_t sda_gpio,
gpio_num_t scl_gpio);
bool SSD1306_I2CMasterAttachDisplayDefault(struct SSD1306_Device *DisplayHandle,
int Width, int Height, int RSTPin); Taskvoid clear() {
SSD1306_Clear(&I2Cdspl, SSD_COLOR_BLACK);
SSD1306_Update(&I2Cdspl);
}
void displayTask(void *pvParam) {
i2cdev_init();
SSD1306_I2CMasterInitDefault(I2C_NUM_0, (gpio_num_t)19, (gpio_num_t)23);
SSD1306_I2CMasterAttachDisplayDefault(&I2Cdisplay, displayWidth, displayHeight, displaylPin);
SetupDemo(&I2Cdisplay, &Font_droid_sans_fallback_24x28);
SayHello(&I2Cdspl, "Hello world!");
while (true) {
clear();
SayHello(&I2Cdisplay, "Hello world!");
vTaskDelay(1500 / portTICK_PERIOD_MS);
clear();
SayHello(&I2Cdisplay, "---");
vTaskDelay(1500 / portTICK_PERIOD_MS);
}
} |
English please ! |
Devcie type
Framework version
Describe the bug
I am using https://github.com/TaraHoleInIt/tarablessd1306 to drive the oled. When i try to use both in the same code, ESP crashes.
Error Log from serial monitor
Code:
The text was updated successfully, but these errors were encountered: