U8glib and LCD --> very strange problem

Hi to all.

Yesterday a college of mine want's to add some changes to the working code so i need to make some small ( non LCD ) changes. The code is installed on 6 devices and working without problems, for last 5 months.

So, i made some changes, burn the code to new arduino but the display isnt working.
I tested with some older codes and the situation is the same, LCD is powered ON but there's no text on it.

Nothing, i started the demo code and on my big surprise, hello world and other examples are working fine. Heee ?

I would understand that there is a SW problem but like i wrote, this code is running successfully on 6 other devices and am 100% sure i didnt change anything in the LCD part. To be sure i tested some old code and this one isnt working too.

I can share part of the code, if someone can take a look...
Suggestions ?

Arnix

Hi,
What version of the IDE are you using?
Have you tried an earlier version to compile and load?

Tom... :slight_smile:

Your best bet would be to share ALL of the code. Sometimes problems are in places where one least expects them.

I can share part of the code, if someone can take a look...

It would be better if you shared all of it or a small but complete program that demonstrates the problem.

Which Arduino board are you using ?

Am using :
-IDE 1.8.2 ( linux ubuntu )

  • mega 2560

I didnt try with older IDE versions but if the demo code is working then i guess this should not be a problem.

I remember that i played with gnd pin before, but like i wrote, demo is working so, this also could not be a problem. Am gonna try with older IDE versions in the meantime.5
EDITED : - the same problem on older 1.6.5 IDE

Code:

  • gonna try to share all of the code, but am not sure if this will be possible.

Arnix

This is stripped code but this is also the whole code that has anything to do with LCD.
I changed the vars and names to english so there my be some typo...

#include <U8glib.h>
//#include "U8glib.h"
#include <EEPROM.h>
#include <Keypad.h>

U8GLIB_ST7920_128X64 u8g(13, 11, 12, U8G_PIN_NONE);

void u8g_prepare(void) {
  u8g.setFont(u8g_font_6x10);
  u8g.setFontRefHeightExtendedText();
  u8g.setDefaultForegroundColor();
  u8g.setFontPosTop();
}

void greetingMsg(void) {
  //-------- SA FRAMEOM
  u8g.drawFrame(3, 3, 122, 38);

  u8g.setFont(u8g_font_6x12);
  u8g.drawStr(15, 13, "Insert coin");
  u8g.setFont(u8g_font_10x20);

  String str = String(rest) + " Eur";
  const char *srest = str.c_str();
  u8g.drawStr( 23, 28, srest  );
  u8g.setFont(u8g_font_6x12);

  str = "Inserted: " + String(allIN) + "eur";
  const char *ssetup = str.c_str();
  u8g.drawStr( 8, 38, ssetup);

  u8g.drawCircle(11, 52, 9);
  u8g.drawCircle(30, 52, 9);
  u8g.drawCircle(49, 52, 9);

  u8g.setFont(u8g_font_6x12);
  u8g.drawStr( 5, 56, "10");
  u8g.drawStr( 25, 56, "20");
  u8g.drawStr( 44, 56, "50");

  u8g.drawStr( 70, 50, Input);
}


void enought(void) {
  //--------  with FRAME
  u8g.drawFrame(3, 3, 122, 38);

  u8g.setFont(u8g_font_6x12);
  u8g.drawStr(15, 13, "Insert coins");
  u8g.setFont(u8g_font_10x20);

  u8g.drawStr( 4, 28, "Door open");
  u8g.setFont(u8g_font_6x12);

  String  str = "Inserted: " + String(allIN) + "eur";
  const char *ssetup = str.c_str();
  u8g.drawStr( 8, 38, ssetup);

  u8g.drawCircle(11, 52, 9);
  u8g.drawCircle(30, 52, 9);
  u8g.drawCircle(49, 52, 9);

  u8g.setFont(u8g_font_6x12);
  u8g.drawStr( 5, 56, "10");
  u8g.drawStr( 25, 56, "20");
  u8g.drawStr( 44, 56, "50");
  u8g.drawStr( 70, 50, Input);
}


// -------------------------------- SETUP ----------------------------------
void setup(void) {
  Serial.begin(9600);

  // 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) {
  u8g_prepare();

  // INSERTED
  if (String(rest) == "0.00" ) {
    rest = needed;
    alltogether = 0;
    u8g.firstPage();
    do {
      dovoljno();
    } while ( u8g.nextPage() );
    otvoriRelay();
  } else if (rest < 0) {
    allIN = allIN - needed;
    rest = needed - allIN;
    otvoriRelay();
  }
  else {
    u8g.firstPage();
    do {
      greetingMsg();
    } while ( u8g.nextPage() );
  }
}

void ispisKoda(char Input[Password_Lenght]) {
  //-------- with FRAME
  u8g.drawFrame(3, 3, 122, 38);

  u8g.setFont(u8g_font_6x12);
  u8g.drawStr(15, 13, "Inserted code");
  u8g.setFont(u8g_font_10x20);

  String str = String(rest) + " Eur";
  const char *srest = str.c_str();
  u8g.drawStr( 23, 28, srest  );
  u8g.setFont(u8g_font_6x12);

  str = "Inserted: " + String(allIN) + "eur";
  const char *ssetup = str.c_str();
  u8g.drawStr( 8, 38, ssetup);

  u8g.drawCircle(11, 52, 9);
  u8g.drawCircle(30, 52, 9);
  u8g.drawCircle(49, 52, 9);

  u8g.setFont(u8g_font_6x12);
  u8g.drawStr( 5, 56, "10");
  u8g.drawStr( 25, 56, "20");
  u8g.drawStr( 44, 56, "50");
  u8g.drawStr( 70, 50, Input);
}

}
void clearData() {
  while (data_count != 0) {
    Input[data_count--] = 0;
  }
  return;
}


String giveInput(int lenght) {
  bool setup = false;
  int count = 0;
  String input = "";
  clearData() ;
  u8g.firstPage();
  do {
    greetingMsg();
  } while ( u8g.nextPage() );
  while (!setup) {
    char key = keypad.getKey();
    if (key) {
      input += key;
      Input[count] = key;
      count++;
      u8g.firstPage();
      do {
        greetingMsg();
      } while ( u8g.nextPage() );

    }
    if (count == lenght - 1)
    {
      clearData() ;
       u8g.firstPage();
       do {
        greetingMsg();
      } while ( u8g.nextPage() );
      return input;
    }
  }
}