Skip to content

remove reference to temp, Display on a correct line #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 12, 2021

Conversation

marcmerlin
Copy link
Contributor

I unfortunately wasted 1H trying to use the oled due to this example.
Display lines need to be 9, 18, 27, 36, 45, 54
Using 33 is not good, it's an incorrect value that ends up in the wrong place, and gives the
impression that you can give any Y coordinate, when in fact you cannot.
If you don't, text gets overlayed on top of other text, even though it shouldn't according to Y

See #6 for an example.

I unfortunately wasted 1H trying to use the oled due to this example.
Display lines need to be 9, 18, 27, 36, 45, 54
Using 33 is not good, it's an incorrect value that ends up in the wrong place, and gives the
impression that you can give any Y coordinate, when in fact you cannot.
If you don't, text gets overlayed on top of other text, even though it shouldn't according to Y

See arduino-libraries#6 for an example.
@noppatoppa
Copy link
Contributor

noppatoppa commented Jan 4, 2021

Display lines need to be 9, 18, 27, 36, 45, 54
Using 33 is not good, it's an incorrect value that ends up in the wrong place, and gives the

Wait, are you sure? I might be missing something, but looks like using anything larger than (0,7) just loops the screen over. This is using the normal sized fonts from the u8x8 font list (https://github.com/olikraus/u8g2/wiki/fntlist8x8). Using larger (1x2) moves characters over others.

My example code:

#include "Arduino_SensorKit.h"

void setup() {
  Oled.begin();
  Oled.setFlipMode(true);
}

void loop() {
  Oled.setFont(u8x8_font_chroma48medium8_r);
  for (int i = 0; i <= 8; i++) {
    Oled.setCursor(0, i);
    if (i < 8) {
      Oled.print(i);
    }
    else {
      Oled.print("... goes over");
    }
  }
  delay(1000);
}

@marcmerlin
Copy link
Contributor Author

I noticed that with U8x8 line 33 did not print at line 33 (although it does with U8g2)
Does this print on line 33 for you with the basic example?
Try setting the cursor lines 9, 18, 27, 36, 45, 54 to see the difference

@noppatoppa
Copy link
Contributor

noppatoppa commented Jan 5, 2021

I noticed that with U8x8 line 33 did not print at line 33 (although it does with U8g2)
Does this print on line 33 for you with the basic example?
Try setting the cursor lines 9, 18, 27, 36, 45, 54 to see the difference

I think u8x8 setCursor works not as pixel rows, but rows of 8x8 squares: "Arguments: x, y: Column/row position for the cursor of the print function." (https://github.com/olikraus/u8g2/wiki/u8x8reference#setcursor). Anything printed over the row limit loops over to the top again. If you run getRows (https://github.com/olikraus/u8g2/wiki/u8x8reference#getrows) on the SensorKit OLED, you get 8 rows. So printing to row 33 is actually printed on row number 1 (range 0, 7) because (33 % 8 == 1).

So printing anything over row num 7 is futile. That's why I'd use Oled.home() to reset cursor and Oled.getRows() to get row count if you want other placements.

Try this example to see what I mean:

#include "Arduino_SensorKit.h"

void setup() {
  Serial.begin(9600);
  Oled.begin();
  Oled.setFlipMode(true);
}

void loop() {
  // Works with any standard size u8x8 font
  Oled.setFont(u8x8_font_chroma48medium8_r);
  Serial.println(Oled.getRows());
  // Populate rows with numbers 0 to 7
  for (int i = 0; i <= 8; i++) {
    Oled.setCursor(0, i);
    if (i < 8) {
      Oled.print(i);
    }
  }
  // Move the looped values a bit on the x axis to see result
  Oled.setCursor(3, 9); // This is line num 1
  Oled.print(9);
  Oled.setCursor(3, 18);
  Oled.print(18);
  Oled.setCursor(3, 27);
  Oled.print(27);
  Oled.setCursor(3, 36);
  Oled.print(36);
  Oled.setCursor(3, 45); // This is line num 5
  Oled.print(45);
  
  delay(1000);
}

@noppatoppa
Copy link
Contributor

noppatoppa commented Jan 5, 2021

I'm guessing U8g2 works on pixel coordinate basis and U8x8 on 8 by 8 pixel grid basis. And that's confusing this for everybody?

In U8x8 printing on row 33 == 9 == 1. If larger font like 2x2 (e.g. u8x8_font_px437wyse700a_2x2_f) is used, single character uses two rows, not 16.

Although it's possible the parameters on how the rows are calculated might have changed with different versions, but based on U8x8 reference it seems unlikely.

@marcmerlin
Copy link
Contributor Author

@noppatoppa actually what you're saying is very possible, yes.
Either way, using line 33 does not print at line 33, which is one of the things my patch corrects.

@noppatoppa
Copy link
Contributor

noppatoppa commented Jan 5, 2021

@marcmerlin what I'm trying to say is

Using 33 is not good, it's an incorrect value that ends up in the wrong place, and gives the
impression that you can give any Y coordinate, when in fact you cannot.

But my point is, that you can and it produces expected results.

Either way, using line 33 does not print at line 33, which is one of the things my patch corrects.
But it kinda does not. It now prints at line 3, though it loops over the screen several times to get there. And using line 33 prints on line 1. So both are equally wrong IMHO.

Really sorry about the potato quality of the photo, but the top right row is 33 and row number 3 is 27. But if you print on row 28 (that is, row 4) it prints correctly without overlap.
oled_arduino

I'm just a user, but banged my head against the same wall. It is also very likely it would be wise to use multiples of 8 as row numbers, but I just can't see it right now. It would mess up for example iterating the rows with getRows.

One final bit of documentation (I promise):

Description: Draw a string. The first character is placed in column x and row y. A graphics display with 128x64 pixel has 16 colums and 8 rows. For such a display suitable values for x are 0 to 15.
https://github.com/olikraus/u8g2/wiki/u8x8reference#drawstring

Copy link
Contributor

@noppatoppa noppatoppa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested changes based on comments I made. Again, I'm just a user and not at all responsible for the library.

// will end up in an incorrect place.
Oled.setCursor(0, 27);
Oled.print("Value: ");
Oled.print(random_value)
Oled.refreshDisplay();
Copy link
Contributor

@noppatoppa noppatoppa Jan 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed with U8x8.

Suggested change
Oled.refreshDisplay();

Writes directly to the display. No buffer in the microcontroller required.
(https://github.com/olikraus/u8g2/wiki)

Description: Transfer the content of the display RAM to the display itself. This is only required for e-Paper/e-Ink devices.
(https://github.com/olikraus/u8g2/wiki/u8x8reference#refreshdisplay)

Oled.print("C");
// Y needs to be a multiple of 9 for a font of 8 or the display
// will end up in an incorrect place.
Oled.setCursor(0, 27);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be

Suggested change
Oled.setCursor(0, 27);
Oled.setCursor(0, 3);

Or

Suggested change
Oled.setCursor(0, 27);
Oled.home();

@marcmerlin
Copy link
Contributor Author

Thanks for the info, you are correct on the cursor value, I fixed it.
I also updated #6

Copy link
Contributor

@noppatoppa noppatoppa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 👌

@marqdevx marqdevx merged commit 915f40a into arduino-libraries:main Jan 12, 2021
@marqdevx
Copy link
Member

@noppatoppa @marcmerlin
Thanks!

@marcmerlin marcmerlin deleted the patch-1 branch January 12, 2021 22:41
@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: documentation Related to documentation for the project labels Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: documentation Related to documentation for the project type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants