/**************************************************
u8g2_font_6x10_mr: A compact font that is 6 pixels wide and 10 pixels high.
u8g2_font_6x12_mr: Slightly taller than the 6x10, providing a bit more legibility.
u8g2_font_7x14_tf: A taller font that is 7 pixels wide and 14 pixels high, good for displays with more vertical space.
u8g2_font_5x8_tf: A smaller font that is 5 pixels wide and 8 pixels high, useful for fitting more text on a screen.
****************************************/
#include <Arduino.h>
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
// Initialize the display
U8G2_MAX7219_64X8_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE);
void setup(void) {
// Begin the display
u8g2.begin();
// Set the display contrast
u8g2.setContrast(160);
}
void loop(void) {
// Set the font for the display uncomment witch you want to use
u8g2.setFont(u8g2_font_victoriabold8_8r);
//u8g2.setFont(u8g2_font_6x10_mr);
//u8g2.setFont(u8g2_font_6x12_mr);
//u8g2.setFont(u8g2_font_7x14_tf);
//u8g2.setFont(u8g2_font_5x8_tf);
// Calculate the width of the string
int strWidth = u8g2.getStrWidth("I AM KAI29 FROM THAILAND HAVE A NICE DAY");
// Loop to scroll the text from right to left
for (int i = 64; i >= -strWidth; i--) {
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawStr(i, 8, "I AM KAI29 FROM THAILAND HAVE A NICE DAY"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(200); // delay between each scroll step
}
}