What is wrong with this code ?

Please see below piece of code.
It prints the value of a variable in x.y format on a line, clears that line 2 seconds later, then writes the variable in x.y format again to the same place on the screen.
First two actions work, the third (most likely) not, because nothing is printed on the screen anymore.
Any ideas what I am doing wrong here, please ?

#include "Ucglib.h"

#define __DC 15
#define __CS 17
#define __RST 14

#define traceDisplay(format, ...)
#define traceError(format, ...)

#include "CacheDisplay.h"

Display ucg(__DC,__CS,__RST);

#define fontTiny    ucg_font_9x15_mr
#define fontSmaller ucg_font_10x20_mr
#define fontSmall   ucg_font_profont17_mr
#define fontSmall4  ucg_font_courB14_mr
#define fontSmall5  ucg_font_courR10_mr
#define fontMedium  ucg_font_inb16_mr
#define fontLarge   ucg_font_inb24_mr
#define fontLarger  ucg_font_inr33_mr
#define fontHuge    ucg_font_inb33_mr

void printmenuid(int menuid)
{
  ucg.setFont(fontSmaller); ucg.setColor(0, 255, 255, 0); ucg.setColor(1, 0, 0, 0);
  ucg.setPrintPos(3,132);
  static const char separator[] = {'.', ' '};
  uint8_t ids[] = {(uint8_t)(menuid >> 4), (uint8_t)(menuid & 0xF)};
  for(int i = 0; i < 2; i++){
    uint8_t id = ids[i];
    if(id >= 10){
      id -= 10;
      ucg.print('1');
    }
    ucg.print(char('0' + id));
    ucg.print(separator[i]);
  }  
}

void printBlanks(int x, int y)
{
  ucg.drawString(x,y,0,"          ");
}

void clearArea()
{
  printBlanks(3,132);
}

void setup()
{
  ucg.begin(UCG_FONT_MODE_SOLID);
  ucg.clearScreen();
  ucg.setRotate90();

  int menuid = 0x11;

  printmenuid(menuid);
  delay(2000);
  clearArea();
  delay(2000);
  printmenuid(menuid);
}

void loop()
{
}

You only call it two times.

Thanks for answering, but I don't understand. I intentionally call printmenuid twice to simulate what happens.
So, 1st call to printmenuid does print some text on the display. The clearArea clears this line. The 2nd call to printmenuid should print the exact same text as in the 1st call, but doesn't. Or at least, I can't see something being printed. Can you elaborate please?

Maybe the color of the text being black (background) after clearing the area to black?

Hmmm,

Nope.
When I remove the ucg.setColor(1,0,0,0) statement, still nothing is printed the second time (or printed invisible).

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