ich würde gerne einen Lauftext realisieren unabh. vom Text selber.
Ich verwende ein Heltec WiFi Kit 32 (V3)-Display.
In der Recherche bin ich hier fündig geworden: Laufschrift auf einer LED Matrix
Jedoch ist das für eine LED-Matrix, die ich nicht habe.
Grundsätzlich: wie passe ich folgenden Code auf mein Display an?
aktuelle Fehlermeldung: MD_MAX72xx.h: No such file or directory (obwohl ich //#include <MD_MAX72xx.h> kommentiert habe)
#include <MD_Parola.h> // Bibliothek für Textanimationen und Effekte
//#include <MD_MAX72xx.h> // Bibliothek für die Steuerung der Matrix selbst
#include <SPI.h>
#include <Wire.h> //display initialization
#include "HT_SSD1306Wire.h" //display initialization
#include "images.h"
#include "heltec.h"
static SSD1306Wire display(0x3c, 500000, SDA_OLED, SCL_OLED, GEOMETRY_128_64, RST_OLED); //Für Ansteuerung des Displays
// 0x3c: I²C address of the display , 500000: I²C clock frequency in Hz , SDA_OLED: SDA pin for the I²C bus , SCL_OLED: SCL pin for the I²C bus,
// resolution GEOMETRY_128_64 x=128px y=64px , RST_OLED: Reset pin for the display
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define DATA_PIN 11
#define CLK_PIN 13
#define CS_PIN 10
MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
void setup() {
P.begin();
P.setIntensity(5); // P.setIntensity(5); Einstellung der Helligkeit der LED-Matrix
P.displayClear();
P.displayText("Das ist der neue Text", PA_CENTER, 50, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT); //steuert, wie und wo der Text auf dem Display angezeigt wird.
//(Text, Zentrierung Text, Scrollgeschw. (je kleiner desto schneller),0: Pause vor neuem Start,
//Einblendeffekt, Ausblendeffekt)
}
void loop() {
if (P.displayAnimate()) // steuert den Ablauf
{
P.displayReset(); // startet die Animation nach dem Durchlauf erneut
}
}
Im englischen Teil des Forum müssen die Beiträge und Diskussionen in englischer Sprache verfasst werden.
Deswegen wurde diese Diskussion in den deutschen Teil des Forums verschoben.
Die Lib basiert auf den HW-Eigenschaften der MAX72xx und ist damit für LED-Matrix-Displays.
Ob Du sie umschreiben kannst, musst Du mit Deinen Kenntnissen abgleichen.
Soll der Lauftext pixelweise oder zeichenweise (einfacher) stattfinden?
Ich habe jetzt mal "display.startscrollright(0x00, 0x0F);" ausprobiert und es gibt einen Fehler aus: class SSD1306Wire' has no member named 'startscrollright'
D.h. für Heltec Display ist dieser Befehl nicht verfügbar?
Du solltest die verlinkten Beiträge besser lesen und nicht einfach irgendeine Anweisung kopieren. Man sollte schon verstehen was man macht.
So wie ich es sehe, benötigst du eine andere Library um diese Anweisung zu nutzen.
Allerdings ist das Ergebnis noch nicht zufriedenstellend, weil Buchstabe für Buchstabe angesetzt wird und nicht der ganze Satz flüssig läuft. Außerdem beginnt der Textaufbau mittig und nicht am Rand des Bildschirms. Und der Text verläuft von rechts nach links anstatt umgekehrt.
#include <Wire.h> //display initialization
#include "HT_SSD1306Wire.h" //display initialization
//#include "SSD1306Wire.h"
#include "images.h"
#include "heltec.h"
#include "JLInfoTicker.h"
static SSD1306Wire display(0x3c, 500000, SDA_OLED, SCL_OLED, GEOMETRY_128_64, RST_OLED); //Für Ansteuerung des Displays / Anzeige von Text am SSD1306 Kommunikation mit I2C.
// 0x3c: I²C address of the display , 500000: I²C clock frequency in Hz , SDA_OLED: SDA pin (serial data pin, Pin 21, data exchange) for the I²C bus ,
// SCL_OLED: SCL pin (serial clock pin, Pin 22, regular interval) for the I²C bus, resolution GEOMETRY_128_64 x=128px y=64px , RST_OLED: Reset pin for the display
JLInfoTicker infoTicker;
String abc[]={
"Das soll ein Beispielsatz sein",
};
void setup() { //Einstellungen
Serial.begin(115200); // baudrate
Serial.println();
Serial.println();
Heltec.VextON(); // Turn on external voltage
delay(100); // Wait for display power stabilization 100 sec
// Initialising the UI will init the display too.
display.init(); // Initialisierung des Displays
// display.clear(); Display löschen
// display.display(); Display updaten
// display.setContrast(255); Kontrastlevel einstellen (0-255)
display.setTextAlignment(TEXT_ALIGN_CENTER_BOTH); // Textausrichtung zentral
//display.setFont(ArialMT_Plain_16); // allg. Textschriftart und Größe festgelegt, z.B. ArialMT_Plain_10: Small 10px font, ArialMT_Plain_16: Medium 16px font, ArialMT_Plain_24: Large 24px font
// max. 64px font hier möglich
display.setColor(WHITE);
display.display();
infoTicker.init(&display,ArialMT_Plain_16,[](int nr){int n=nr;return abc[n];});
}
void loop() {
//display.clear();
//display.drawString(0, 20, "Chris Test");
infoTicker.tick();
}
Die von Dir verwendete Bibliothek ist mir leider unbekannt und enthält wenig Funktionalität. Ich verwende lieber U8g2 von Olli Kraus. Das Beispiel ScrollingText.ino habe ich für den ESP32 mit full_buffer leicht abgewandelt:
ScrollingText (zum Aufklappen)
#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/U8X8_PIN_NONE);
// This example shows a scrolling text.
// If U8G2_16BIT is not set (default), then the pixel width of the text must be lesser than 128
// If U8G2_16BIT is set, then the pixel width an be up to 32000
u8g2_uint_t offset; // current offset for the scrolling text
u8g2_uint_t width; // pixel width of the scrolling text (must be lesser than 128 unless U8G2_16BIT is defined
const char *text = "U8g2 "; // scroll this text from right to left
void setup(void) {
u8g2.begin();
u8g2.setFont(u8g2_font_inb30_mr); // set the target font to calculate the pixel width
width = u8g2.getUTF8Width(text); // calculate the pixel width of the text
u8g2.setFontMode(0); // enable transparent mode, which is faster
}
void loop(void) {
u8g2_uint_t x;
// draw the scrolling text at current offset
x = offset;
u8g2.setFont(u8g2_font_inb30_mr); // set the target font
do { // repeated drawing of the scrolling text...
u8g2.drawUTF8(x, 30, text); // draw the scolling text
x += width; // add the pixel width of the scrolling text
} while (x < u8g2.getDisplayWidth()); // draw again until the complete display is filled
u8g2.setFont(u8g2_font_inb16_mr); // draw the current pixel width
u8g2.setCursor(0, 58);
u8g2.print(width); // this value must be lesser than 128 unless U8G2_16BIT is set
u8g2.sendBuffer(); // transfer internal memory to the display
offset -= 1; // scroll by one pixel
if ((u8g2_uint_t)offset < (u8g2_uint_t)-width)
offset = 0; // start over again
delay(10); // do some small delay
}
ich wollte dein Beispiel gerade ausprobieren. Leider bekomme ich die Fehlermeldung: "U8g2.h: No such file or directory".
Ich habe aber U8g2 und U8glib von Oliver als neueste Version installiert.
Ok ich habe herausgefunden, dass ich #include "U8g2.h" statt #include "U8g2lib.h" verwendet habe.
Meine Fehler sind weg.
Aber das Display bleibt jetzt schwarz.
Aktuell schaut der Code so aus:
#include "Arduino.h"
#include "U8g2lib.h"
#include "Wire.h"
#include "HT_SSD1306Wire.h"
#include "images.h"
#include "heltec.h"
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/U8X8_PIN_NONE);
static SSD1306Wire display(0x3c, 500000, SDA_OLED, SCL_OLED, GEOMETRY_128_64, RST_OLED); //Für Ansteuerung des Displays / Anzeige von Text am SSD1306 Kommunikation mit I2C.
// 0x3c: I²C address of the display , 500000: I²C clock frequency in Hz , SDA_OLED: SDA pin (serial data pin, Pin 21, data exchange) for the I²C bus ,
// SCL_OLED: SCL pin (serial clock pin, Pin 22, regular interval) for the I²C bus, resolution GEOMETRY_128_64 x=128px y=64px , RST_OLED: Reset pin for the display
// This example shows a scrolling text.
// If U8G2_16BIT is not set (default), then the pixel width of the text must be lesser than 128
// If U8G2_16BIT is set, then the pixel width can be up to 32000
u8g2_uint_t offset; // current offset for the scrolling text
u8g2_uint_t width; // pixel width of the scrolling text (must be lesser than 128 unless U8G2_16BIT is defined
const char *text = "Beispieltext "; // scroll this text from right to left
void setup(void) {
u8g2.begin();
u8g2.setFont(u8g2_font_inb30_mr); // set the target font to calculate the pixel width
width = u8g2.getUTF8Width(text); // calculate the pixel width of the text
u8g2.setFontMode(0); // enable transparent mode, which is faster
}
void loop(void) {
u8g2_uint_t x;
// draw the scrolling text at current offset
x = offset; // offset der X-Koordinate "xStart"
u8g2.setFont(u8g2_font_inb30_mr); // set the target font
do
{ // repeated drawing of the scrolling text...
u8g2.drawUTF8(x, 30, text); // draw the scolling text (xStart, yStart, Text)
x += width; // add the pixel width of the scrolling text
} while (x < u8g2.getDisplayWidth()); // draw again until the complete display is filled
u8g2.setFont(u8g2_font_inb16_mr); // draw the current pixel width
u8g2.setCursor(0, 58);
u8g2.print(width); // this value must be lesser than 128 unless U8G2_16BIT is set
u8g2.sendBuffer(); // transfer internal memory to the display
offset -= 1; // scroll by one pixel
if ((u8g2_uint_t)offset < (u8g2_uint_t)-width)
offset = 0; // start over again
delay(10); // do some small delay
}
stimmt die doppelte Displayansteuerung am Anfang wahrscheinlich nicht, oder?