u8g2 icon indicating copy to clipboard operation
u8g2 copied to clipboard

ST7588 demo compilation error

Open bbd666 opened this issue 10 months ago • 1 comments

Hello I am currently testing the "hello world" demo with a ST7588I LCD and a ARDUINO NANO. SDA connected to pin D6 SCL connected to pin D5 Reset connected to pin D4

Here is the code :

#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>

const int clk=7;
const int data=6;
const int reset=5;

U8G2_ST7588_JLX12864_1_SW_I2C(U8G2_R0, clk, data,reset);

void setup(void) {
  u8g2.begin();
}

void loop(void) {
  u8g2.firstPage();
  do {
    u8g2.setFont(u8g2_font_ncenB14_tr);
    u8g2.drawStr(0,24,"Hello World!");
  } while ( u8g2.nextPage() );
}

Here is the compilation error returned :

C:\Users...\sketch_jun16a\sketch_jun16a.ino:9:38: error: expected ')' before ',' token U8G2_ST7588_JLX12864_1_SW_I2C(U8G2_R0, clk, data,reset); ^ C:\Users...\sketch_jun16a\sketch_jun16a.ino:9:40: error: conflicting declaration 'U8G2_ST7588_JLX12864_1_SW_I2C clk' U8G2_ST7588_JLX12864_1_SW_I2C(U8G2_R0, clk, data,reset); ^~~ C:\Users...\sketch_jun16a.ino:5:11: note: previous declaration as 'const int clk' const int clk=7; ^~~ C:\Users...\sketch_jun16a\sketch_jun16a.ino:9:45: error: conflicting declaration 'U8G2_ST7588_JLX12864_1_SW_I2C data' U8G2_ST7588_JLX12864_1_SW_I2C(U8G2_R0, clk, data,reset); ^~~~ C:\Users...\sketch_jun16a\sketch_jun16a.ino:6:11: note: previous declaration as 'const int data' const int data=6; ^~~~ C:\Users...\sketch_jun16a\sketch_jun16a.ino:9:55: error: expected initializer before ')' token U8G2_ST7588_JLX12864_1_SW_I2C(U8G2_R0, clk, data,reset); ^ C:\Users...\sketch_jun16a\sketch_jun16a.ino: In function 'void setup()': C:\Users...\sketch_jun16a\sketch_jun16a.ino:12:3: error: 'u8g2' was not declared in this scope u8g2.begin(); ^~~~ C:\Users...\sketch_jun16a\sketch_jun16a.ino:12:3: note: suggested alternative: 'U8G2' u8g2.begin(); ^~~~ U8G2 C:\Users...\sketch_jun16a\sketch_jun16a.ino: In function 'void loop()': C:\Users...\sketch_jun16a\sketch_jun16a.ino:16:3: error: 'u8g2' was not declared in this scope u8g2.firstPage(); ^~~~ C:\Users...\sketch_jun16a\sketch_jun16a.ino:16:3: note: suggested alternative: 'U8G2' u8g2.firstPage(); ^~~~ U8G2 exit status 1

Compilation error: expected ')' before ',' token

bbd666 avatar Jun 16 '25 08:06 bbd666

The documentation refers to the constructor name: U8G2_ST7588_JLX12864_1_SW_I2C(U8G2_R0, clk, data,reset);

However you need to create an object by calling this constructor, this will look like this: U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, clk, data,reset);

The name of the object can be anything, but the rest of the program uses u8g2, so you probably want to create the "u8g2" object.

#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>

const int clk=7;
const int data=6;
const int reset=5;

U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, clk, data,reset);

void setup(void) {
  u8g2.begin();
}

void loop(void) {
  u8g2.firstPage();
  do {
    u8g2.setFont(u8g2_font_ncenB14_tr);
    u8g2.drawStr(0,24,"Hello World!");
  } while ( u8g2.nextPage() );
}

olikraus avatar Jun 16 '25 18:06 olikraus