Skip to content
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

oled.println(); not going in new line on display #87

Open
microicRI opened this issue Mar 3, 2022 · 3 comments
Open

oled.println(); not going in new line on display #87

microicRI opened this issue Mar 3, 2022 · 3 comments

Comments

@microicRI
Copy link

Hi,
arduino IDE 1.8.19
ESP32 + OLED128x64

// Test for minimum program size.

#include <Wire.h>
#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"

// 0X3C+SA0 - 0x3C or 0x3D
#define I2C_ADDRESS 0x3C

// Define proper RST_PIN if required.
#define RST_PIN -1
char test[20];

SSD1306AsciiWire oled;
//------------------------------------------------------------------------------
void setup() {
Wire.begin();
Wire.setClock(400000L);

#if RST_PIN >= 0
oled.begin(&Adafruit128x64, I2C_ADDRESS, RST_PIN);
#else // RST_PIN >= 0
oled.begin(&Adafruit128x64, I2C_ADDRESS);
#endif // RST_PIN >= 0

oled.setFont(Adafruit5x7); //System5x7);
oled.clear();
oled.print(" Hello world");
delay(2000);
oled.clear();
String test_str="";
test_str=("damir");
//oled.set2X();
oled.print("duzina_test_str= "); int duzina_test_str=test_str.length();oled.println(duzina_test_str); oled.println(); // go to next line
oled.write('\n');
//oled.print("test_str= ");oled.println(test_str);
delay(2000);
test_str+="š"; //ŠđĐčČćĆžŽ");
oled.println("duzina_test_str= ");duzina_test_str=test_str.length();oled.println(duzina_test_str);; oled.print("\n");//oled.print(", ");oled.println("test_str= ");oled.println(test_str);

delay(5000);
/*
for (int n=0;n<256;n++){
oled.clear();
int i=n;
oled.print(i);
oled.print("= ");
oled.print((char)n);
delay(500);

}*/

}
//------------------------------------------------------------------------------
void loop() {}``

@greiman
Copy link
Owner

greiman commented Mar 3, 2022

Might be that you are printing characters not in the font. This will cause print to fail.

Also long lines are truncated.

@microicRI
Copy link
Author

microicRI commented Mar 5, 2022 via email

@greiman
Copy link
Owner

greiman commented Mar 6, 2022

char str[] = "š";
void setup() {
  Serial.begin(9600);
  for (uint8_t i = 0; i < strlen(str); i++) {
    Serial.println((uint8_t) str[i], HEX);
  }
}
void loop() {
}

Output is the UFT8 two byte character:

C5
A1

SSD1306Ascii only supports ASCII characters - note the name has Ascii for a reason.

Try this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants