Error Message Meaning


#include <Arduino.h>
//#define SCREEN_WIDTH 128 // OLED display width, in pixels
//#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#include <U8g2lib.h>
static const unsigned char image_cards_hearts_bits[] U8X8_PROGMEM = {0x00,0x00,0x00,0x00,0x1c,0x1c,0x3e,0x3e,0x7f,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xfe,0x3f,0xfc,0x1f,0xf8,0x0f,0xf0,0x07,0xe0,0x03,0xc0,0x01,0x80,0x00,0x00,0x00};

//#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
//#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32

U8G2_SSD1306_128X64_NONAME_F_HW_I2C U8g2(U8G2_R0,/*reset*/U8X8_PIN_NONE);
//#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
//#endif
#define u8g2
void setup(void) {
  u8g2.begin();
}
void loop(void){
//static const unsigned char image_cards_hearts_bits[] U8X8_PROGMEM = {0x00,0x00,0x00,0x00,0x1c,0x1c,0x3e,0x3e,0x7f,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xfe,0x3f,0xfc,0x1f,0xf8,0x0f,0xf0,0x07,0xe0,0x03,0xc0,0x01,0x80,0x00,0x00,0x00};
u8g2.clearBuffer();
u8g2.setFontMode(1);
u8g2.setBitmapMode(1);
u8g2.drawFrame(27, 18, 77, 20);
u8g2.setFont(u8g2_font_4x6_tr);
u8g2.drawStr(32, 30, "HANY F. MANKARIOS");
u8g2.drawXBM(57, 42, 15, 16, image_cards_hearts_bits);
u8g2.sendBuffer();
delay(1000);
}

always get error: expected primary-expression before '.' token at line u8g2.sendBuffer();

#define u8g2

u8g2 has no value defined for it so when the code is compiled

    u8g2.begin();

becomes

    .begin();

Hence the error

1 Like

Case matters.

Declared as U8g2

Referenced as u8g2

As yes, as @UKHeliBob pointed out, lose the #define u8g2. Good catch!

Nice job that was a hard one to see.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.