Go Down

Topic: UCGLIB text locations (Read 266 times) previous topic - next topic

dave-in-nj

Mar 13, 2018, 12:41 pm Last Edit: Mar 13, 2018, 12:45 pm by dave-in-nj
I connected my 1.8  128x160 TFT display and am using UCGLIB

I have 4 sensors, 
(2) BMP that show temperature, humidity and pressure
and (2) DS18B20  temperature only

I cannot figure out how to place the text on the screen to be aligned.

I cannot find a reference to how this line puts the text over so many columns

 ucg.setPrintPos(2,50+d);     ucg.print("Temp = "); ucg.print(temp1);

question :  what does   ucg.setPrintPos(2,50+d); 
do ?  the 2, is not start, or the +d does something I do not understand.


it would seem like it should start at 2,50  but is it more like 50,50 for  (temp1)

Since this is the first color display, I am just starting to figure things out.
my display completely refreshes, like a window shade
I would like to only have the text refresh.

What am hoping for is to align the decimal places in the screen, always have 2

Here is my font segment

Code: [Select]

void fonts(void) // ++++++++++++++++++ FONTS +++++++++++++++++
{
  ucg_int_t d = 5;
  ucg.setColor(0, 0, 40, 80);
  ucg.setColor(1, 150, 0, 200);
  ucg.setColor(2, 60, 0, 40);
  ucg.setColor(3, 0, 160, 160);
  //ucg.setColor(255, 255, 255); // white
 
  ucg.drawGradientBox(0, 0, ucg.getWidth(), ucg.getHeight());

    ucg.setColor(255, 255, 255);
  ucg.setPrintDir(0);
  ucg.setPrintPos(18,16);
  ucg.print("Daves Sensors");
  ucg.drawRFrame(50,41, 54,18, 5);  // left frame
  ucg.drawRFrame(50,58, 54,18, 5);  // left frame
  ucg.drawRFrame(50,75, 54,18, 5);  // left frame
  ucg.drawRFrame(50,92, 54,18, 5);  // left frame
  ucg.drawRFrame(50,109, 54,17, 5);  // left frame

  ucg.drawRFrame(103,41, 50,18, 5);  // right frame
  ucg.drawRFrame(103,58, 50,18, 5);  // right frame
  ucg.drawRFrame(103,75, 50,18, 5);  // right frame
  ucg.drawRFrame(103,92, 50,18, 5);  // right frame

 
  ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
   //ucg.setFontMode(UCG_FONT_MODE_SOLID);

  ucg.setColor(255, 200, 170);   // orange ish
  //ucg.setColor(1, 0, 100, 120);    // background color in solid mode
 
  ucg.setFont(ucg_font_helvB10_hr); 
  ucg.setPrintPos(60,30+d);     ucg.print("One");
  ucg.setPrintPos(115,30+d);     ucg.print("Two");
   
  ucg.setPrintPos(2,50+d);     ucg.print("Temp = "); ucg.print(temp1);
  ucg.setPrintPos(2,67+d);     ucg.print("Humd= "); ucg.print(rh1);
  ucg.setPrintPos(2,84+d);     ucg.print("Pres  = "); ucg.print(pres1);
  ucg.setPrintPos(2,101+d);    ucg.print("Coil  =  "); ucg.print(tempDS18F1);
  ucg.setPrintPos(2,118+d);    ucg.print("D.P.  =  "); ucg.print(deltaT);

  ucg.setPrintPos(108,50+d);    ucg.print(temp2); // testing font location
  ucg.setPrintPos(109,67+d);    ucg.print(rh2);
  ucg.setPrintPos(110,84+d);    ucg.print(pres2);
  ucg.setPrintPos(110,101+d);   ucg.print(tempDS18F2);
 // ucg.setPrintPos(2,118+d);   ucg.print(OAT); // not implemented yet Other Air Temp ds18b20

 
  ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
 
  ucg.setFont(ucg_font_ncenR14_hr);
  DLY();
}


my full code was too large to attach.


dave-in-nj

#1
Mar 13, 2018, 02:14 pm Last Edit: Mar 13, 2018, 02:15 pm by dave-in-nj
Here is a screen shot


olikraus

#2
Mar 13, 2018, 07:36 pm Last Edit: Mar 13, 2018, 08:25 pm by olikraus
Quote
question :  what does   ucg.setPrintPos(2,50+d);
do ?  the 2, is not start, or the +d does something I do not understand.
It is written in the user manual: https://github.com/olikraus/ucglib/wiki/reference#setprintpos


Quote
the 2, is not start, or the +d does something I do not understand.
Isn't it your program? If you don't understand this, then why did you code it?


Quote
What am hoping for is to align the decimal places in the screen, always have 2
Your code selects a none-monospaced font. These fonts look better, but each glyph has a different width.
With such a code you should prefix each print command with its own setPos command.

Oliver



dave-in-nj

It is written in the user manual: https://github.com/olikraus/ucglib/wiki/reference#setprintpos

Isn't it your program? If you don't understand this, then why did you code it?

Your code selects a none-monospaced font. These fonts look better, but each glyph has a different width.
With such a code you should prefix each print command with its own setPos command.

Oliver



the manual does not list this bit of code.
the code came from the example in the Arudion IDE, so I need to find out who wrote that code and ask them.
I just took the example and extracted the fonts section as I did not need the bits about drawing random triangles and blocks.

Thanks for the tip on printing each line.  I could not find if an 'align on decimal point' is a supported feature.
I did not find an alight to right column for text.   it seems that the starting point is the left point, this means that due to variable width and numbers in the results, the decimals will not align easily.
I was hoping that if an align to decimal was not available, I would align the whole numbers to the right point, place a decimal, then align the decimals after the more normal left point

Thanks for the libraries and all your hard work on this.  

Dave



Go Up