Compiler can't find what's there

I have this code to drive a 2.7" OLED 12864 display module SKU: FIT0328 LCD. This is very much work in progress - I know that the function calls are not correct but the immediate problem starts before that >:(

#include "U8g2.h"

U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9

void draw(void) {
 // graphic commands to redraw the complete screen should be placed here  
 u8g.setFont(u8g_font_unifont);
 //u8g.setFont(u8g_font_osb21);
 u8g.drawStr(0, 22, "Hello World!");
}

void setup(void) {

 // flip screen, if required
 // u8g.setRot180();

 // set SPI backup if required
 //u8g.setHardwareBackup(u8g_backup_avr_spi);

 // assign default color value
 if (u8g.getMode() == U8G_MODE_R3G3B2)
 u8g.setColorIndex(255);     // white
 else if (u8g.getMode() == U8G_MODE_GRAY2BIT)
 u8g.setColorIndex(3);         // max intensity
 else if (u8g.getMode() == U8G_MODE_BW)
 u8g.setColorIndex(1);         // pixel on
}

void loop(void) {
 // picture loop
 u8g.firstPage();
 do {
 draw();
 } while (u8g.nextPage());

 // rebuild the picture after some delay
 delay(500);
}

The Arduino IDE shows the U8g2 library present


but the compiler can't find it.

What have I got wrong?
Thanks

The header filename doesn’t always match the library name. If you take a look at any of the example sketches under File > Examples > U8g2 you will see this:

#include <U8g2lib.h>

pert:
If you take a look at any of the example sketches under File > Examples > U8g2

Now that is something I would never have looked for - the library comes in and brings examples with it. Pity it did not also bring an appropriate circuit diagram(I still haven’t found one for this LCD PCB).

Back to the tutorial code, using #include <U8g2lib.h> got past the first hurdle but straight (Kerrashh!) into the second one
Wrong Type.png

This is where in-line commenting comes into its own. There is no indication what
U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);
is, so there is not much point in looking in U8g2 for its equivalent - even if I knew where to look although I suspect that what I need is somewhere in here.

Let’s assume that the equivalent I seek is something like this
U8G2_SSD1325_NHD_128X64_2_2ND_4W_HW_SPI(rotation, cs, dc [, reset])
Then … I don’t know what rotation, cs, dc [, reset] refer to.

This is where that datasheet becomes essential. I’m so desperate to get one I have a couple of my suppliers looking for one. There must be one but I haven’t been able to find it in two days of searching.

This is where in-line commenting comes into its own. There is no indication what
U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);
is, so there is not much point in looking in U8g2 for its equivalent - even if I knew where to look although I suspect that what I need is somewhere in here.

That Library includes support for a great many displays, and the author has created extensive documentation at the link you provided, it might be worthwhile reading it.

If all that documentation was included as 'in-line comments' I suspect the library would be close to unreadable.

vagulus:
This is where that datasheet becomes essential. I'm so desperate to get one I have a couple of my suppliers looking for one. There must be one but I haven't been able to find it in two days of searching.

I know its easy to get carried away buying stuff on eBay, but it is always worthwhile checking that you have a datasheet before you buy.

srnet:
I know its easy to get carried away buying stuff on eBay, but it is always worthwhile checking that you have a datasheet before you buy.

I didn’t get it on eBay, I purchased it from an eminently reputable retailer here in Perth. I have just eMailed the manufacturer asking for a datasheet - we’ll see what happens there. The last time I tried that trick I had to work through the Chinese Embassy in Canberra to get the retailer to find someone who could communicate in English. :confused:

It gets worse. Working from the DFRobot tutorial page I get this code

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

U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);


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

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

which compiles and uploads okay but nothing happens. I’ve just queried that too! ::slight_smile:

100119-LCD_Test_Wiring-478x640.png

  1. remove the purple wire from "reset" and connect the purple line instead to pin 8
  2. Use U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=/ 13, / data=/ 11, / cs=/ 10, / dc=/ 9, / reset=*/ 8 );

Further problems:
a) I have not checked your wiring. Your picture is not good enough for thus.
b) A breadboard like this may work or may not work. It is always a great source for connection errors
c) I can not image that this display works with 5V GPIO lines. I do not see any level shifters on the PCB. But ok, it says so on the product page...

Oliver

olikraus:
a) I have not checked your wiring. Your picture is not good enough for thus.

Herewith
180120-DFRobotOLED-Circuit-640x560.png

well, then, does it work?

olikraus:
well, then, does it work?

No.

That's why I am seeking help :confused:

We do not have a description of the pins of your display.
Here are some more thinks you should check:

  • Do the pins fit to your wiring
  • Is the an electrical connection between arduino and your glcd? As I said before, these breadboards are NOT reliable.

Oliver

It turns out to be library problems. I went to the Arduino IDE (I use Visual Studio/Visual Micro because I can read it) and checked libraries - the U8g2 library had disappeared! How that happens, I don't know, but it did.

I downloaded it again and reinstalled it.

It works!

I am still trying to get a datasheet for the LCD I have. Even the manufacturer is playing hard to get.

Tell me - once the library is installed in the Arduino setup, can the ZIP be deleted?
If it can't, where do I put it so it can stay there forever.
I just installed the libraries with the ZIPs in the Downloads folder. I don't want to keep them there forever.