Clear screen in U8glib

Hi to all,

I’m using a MEGA with a T6963C driver based GLCD. After a lot of tests following differents ideas in the forum, I’m stuck.

My code is very simple, a 240x128 LOGO (it displays OK, a clear screen (NOT WORK!!) and 8 24x24 buttons in the lower (they display OK but over the LOGO)

Please, any suggestion?

Thanks and regards

#include "U8glib.h"

// setup u8g object

// 8Bit Com: D0..D7:       8, 9, 10, 11, 4, 5, 6, 7,    cs=13,      cd=10, wr=11, rd=12, reset=14
U8GLIB_T6963_240X128 u8g(2,  3,  4,  5,  6,  7,  8,  9,    13,         10,    11,    12,       14);   

#include "D:\ARDUINO-IDE\3-APC-MEGA\1-APC-MEGA\APC-MEGA\APCXL12.XBM"
#include "D:\ARDUINO-IDE\3-APC-MEGA\1-APC-MEGA\APC-MEGA\BUTTONS.XBM"

#define LINE_MAX 30 
// setup a text screen to support scrolling
#define ROW_MAX 12

uint8_t screen[ROW_MAX][LINE_MAX];


void setup(void) {
clear_screen();
}


void loop(void) {
  // picture loop
  u8g.firstPage(); //Begining of the picture loop
  do {
    draw1(); // Draw LOGO
 // rebuild the picture after some delay
  //delay(1000);
  clear_screen(); // Clear screen?
  draw2(); // Draw Buttons
  } while( u8g.nextPage() );
 
}

// clear entire screen, called during setup
void clear_screen(void) {
  uint8_t i, j;
  for( i = 0; i < ROW_MAX; i++ )
    for( j = 0; j < LINE_MAX; j++ )
      screen[i][j] = 0;  
}


void draw1(void) {
  // graphic commands to redraw the complete screen should be placed here  
  //u8g.drawBitmapP( 0, 0, 128, 240, rook_bitmap);
  //u8g.drawXBMP( 0, 0, u8g_logo_width, u8g_logo_height, u8g_logo_bits);
  u8g.drawXBMP( 0, 0, 240, 128, APCXL12_bits);
}
void draw2(void) {
u8g.drawXBMP( 0, 104, 24, 24, ButtHOME_bits);
  u8g.drawXBMP( 24, 104, 24, 24, ButtSCHR_bits);
  u8g.drawXBMP( 48, 104, 24, 24, ButtPHYS_bits);
  u8g.drawXBMP( 72, 104, 24, 24, ButtCHEM_bits);
  u8g.drawXBMP( 96, 104, 24, 24, ButtPROJ_bits);
  u8g.drawXBMP( 110, 104, 24, 24, ButtCONF_bits);
  u8g.drawXBMP( 134, 104, 24, 24, ButtTMDT_bits);
  u8g.drawXBMP( 158, 104, 24, 24, ButtDISP_bits);
}

Hi Breixo,

Hi,

I clear the OLED screen with u8glib using this function:

void clearOLED(){
u8g.firstPage();
do {
} while( u8g.nextPage() );
}

Maybe there is a simplier way to do it but I didn’t discovered yet.

Best Regards,

Paulo

I’m not familiar with u8glib, but…

void clear_screen(void) {
  uint8_t i, j;
  for( i = 0; i < ROW_MAX; i++ )
    for( j = 0; j < LINE_MAX; j++ )
      screen[i][j] = 0;  
}

I don’t see any code that copys your “screen” array to the actual display, nor anything that ties the screen variable intimately to the display that would make an explicit call unneeded. You probably need a:

u8g.drawBitmap( 0, 0, 128, 240, screen);

in there.
Depending on memory requirements, and whether you use screen for other things, you may be better off putting the “blank” bitmap in flash instead of setting it up in RAM and using a loop to initialize it.

SOLVED. Was my mistake. Sorry