From 6557987cfdec4b55ee89faa676d8b4c969095942 Mon Sep 17 00:00:00 2001 From: Daniel Kulp Date: Tue, 19 Sep 2023 14:13:39 -0400 Subject: [PATCH] Fix C compile of oled files --- src/oled/I2C.h | 10 +++++++++- src/oled/SSD1306_OLED.c | 8 +++----- src/oled/SSD1306_OLED.h | 9 +++++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/oled/I2C.h b/src/oled/I2C.h index 392fb69d0..63fd797ed 100644 --- a/src/oled/I2C.h +++ b/src/oled/I2C.h @@ -31,6 +31,10 @@ SOFTWARE. #include +#ifdef __cplusplus +extern "C" { +#endif + /* No. of bytes per transaction */ #define I2C_ONE_BYTE 1 #define I2C_TWO_BYTES 2 @@ -57,9 +61,13 @@ extern int i2c_read(int fd, unsigned char *read_data); extern int i2c_read_register(int fd, unsigned char read_addr, unsigned char *read_data); extern int i2c_read_registers(int fd, int num, unsigned char starting_addr, unsigned char *buff_Ptr); -extern void config_i2c_struct(char *i2c_dev_path, unsigned char slave_addr, I2C_DevicePtr i2c_dev); +extern void config_i2c_struct(const char *i2c_dev_path, unsigned char slave_addr, I2C_DevicePtr i2c_dev); extern int i2c_multiple_writes(int fd, int num, unsigned char *Ptr_buff); extern int i2c_write_register(int fd, unsigned char reg_addr_or_cntrl, unsigned char val); /* Exposed I2C-x Specific Functions */ extern int init_i2c_dev2(const char *i2cPath, unsigned char slave_address); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/src/oled/SSD1306_OLED.c b/src/oled/SSD1306_OLED.c index 8a1863bd4..3f4e4636a 100644 --- a/src/oled/SSD1306_OLED.c +++ b/src/oled/SSD1306_OLED.c @@ -57,16 +57,14 @@ int LED_DISPLAY_TYPE = LED_DISPLAY_TYPE_SSD1306; /* static Variables */ static unsigned char _rotation = 0,textsize = 0; -static short _width = LED_DISPLAY_WIDTH; -static short _height = LED_DISPLAY_HEIGHT; +static short _width = 128; +static short _height = 64; static short cursor_x = 0, cursor_y = 0, textcolor = 0, textbgcolor = 0; static bool _cp437 = false, wrap = true; - - /* static struct objects */ -static const GFXfont *gfxFont = nullptr; +static const GFXfont *gfxFont = 0; void setTextFont(const GFXfont *font) { gfxFont = font; diff --git a/src/oled/SSD1306_OLED.h b/src/oled/SSD1306_OLED.h index b7d6bd9a1..28404b693 100644 --- a/src/oled/SSD1306_OLED.h +++ b/src/oled/SSD1306_OLED.h @@ -32,6 +32,11 @@ SOFTWARE. /* Lib's */ #include + +#ifdef __cplusplus +extern "C" { +#endif + #include "gfxfont.h" /* Find Min and Max - MACROS */ @@ -178,3 +183,7 @@ extern short printNumber_I(int n, int base); extern short printNumber_I_ln(int n, int base); extern short printFloat(double number, unsigned char digits); extern short printFloat_ln(double num, int digits); + +#ifdef __cplusplus +} +#endif \ No newline at end of file