Anyone know how to right justified the output? This is my first program. I tried changing the cursor to (128,32), but that pushed the number off of screen.
Thanks!
#include <U8g2lib.h>
int num = 123;
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0); //note: this is a numeric only font
void setup(void)
{
u8g2.begin();
}
void loop(void)
{
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_helvB24_tn);
u8g2.setCursor (0,32);
u8g2.print (num);
u8g2.sendBuffer();
delay(10);
}
Something like this
#include <U8g2lib.h>
int num = 123;
byte xOffset = 0;
byte digitWidth = 16;
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0); //note: this is a numeric only font
void setup(void)
{
u8g2.begin();
}
void loop(void)
{
u8g2.setFont(u8g2_font_helvB24_tn);
for (int num = 0; num < 200; num++)
{
u8g2.clearBuffer();
if (num < 10)
{
xOffset = digitWidth * 2;
}
else if (num < 100)
{
xOffset = digitWidth;
}
else
{
xOffset = 0;
}
u8g2.setCursor (50 + xOffset, 32);
u8g2.print (num);
u8g2.sendBuffer();
delay(100);
}
}
You may need to change the offset but it shows the principle