#include <Arduino.h>
/************************************************************************
OLED DISPLAY
************************************************************************
INCLUDES
************************************************************************/
#include <U8g2lib.h>
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
//U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
int SCREEN_WIDTH;
int SCREEN_HEIGHT;
int USABLE_SCREEN_WIDTH;
/*
#define SCREEN_WIDTH u8g2.getDisplayWidth()
#define SCREEN_HEIGHT u8g2.getDisplayHeight()
*/
/************************************************************************
u8g2:
************************************************************************
Bitmaps
************************************************************************/
#define BUTTON_UP_PIN 41 // pin for UP button
#define BUTTON_SELECT_PIN 40 // pin for SELECT button
#define BUTTON_DOWN_PIN 39 // pin for DOWN button
/*
5px Height:
Normal: u8g2_font_4x6_tf
6px Height:
Normal: u8g2_font_5x8_tf
7px Height:
Normal: u8g2_font_6x10_tf
9px Height:
Normal: u8g2_font_6x13_tf
Bold: u8g2_font_6x13B_tf
Alt: u8g2_font_tpss_tn
10px Height:
Normal: u8g2_font_7x14_tf
Bold: u8g2_font_7x14B_tf
*/
/*
const uint8_t u8g2_font_tpss_tn[2005] U8G2_FONT_SECTION("u8g2_font_tpss_tn") =
"\263\0\3\2\4\4\2\5\5\13\21\377\374\11\374\11\0\1X\2\257\7\270 \5\0B\12!\7\221\303"
"\211\213\0\42\7#\337\212D\11#\13U\303\233\312\240T\6\245\2$\20\225\303\233\245\242d[\22%"
"J\242T\26\0%\15\225\303\213L\12\263\260\26FZ\0&\21\227\303\234\255\224e[)\213\262(K"
"\222%\1'\6!\337\11\1(\14\225\303;)\13\263\64LS\1)\14\225\303\13\265\230fa\26i"
"\0*\13u\307\253Je\313\226\246\10+\12U\307\253\60\32\244\60\2,\6\42\77\32\5-\6\25\317"
"\213A.\6\21\303\211\0/\14\225\303\313,\314\302Z\230\205\0\60\12\225B\233%\363[\262\0\61\13"
"\225B\253LJ\302\236\6\1\62\13\225B\233%\323\302\254\343 \63\15\225B\233%\13#\65\14\265d"
"\1\64\11\225BKM\33\306\36\65\14\225B\213c\70\210E-Y\0\66\15\225B\233%\23\207$s"
"K\26\0\67\12\225B\213A\314\32\273\1\70\15\225B\233%\323\222%sK\26\0\71\15\225B\233%"
"\263%C\30j\311\2:\6A\303\211(;\7R\77\232T\1<\10\225\303\313\254k\7=\10\65\313"
"\213A\35\4>\11\225\303\213\264[G\0\77\15\225\303\233%\13\263b\16\205\21\0@\25\211\303\235a"
"\212\223HJJISRR\242\34H\206!\1A\13\225B\233%\323\206!\363\26B\15\225B\213!"
"\311\264A\311\334\6\5C\13\225B\233%\23{K\26\0D\13\225B\213!\311\374\66(\0E\13\225"
"B\213c\70$a\343 F\13\225B\213c\70$aG\0G\15\225B\233%\23\223!sK\26\0"
"H\13\225B\213\314\66\14\231\267\0I\6\221B\211\7J\11\225B\313>j\311\2K\16\225B\213\314"
"\224\224\264$\252dZ\0L\11\225B\213\260\37\7\1M\14\227B\214t[*R\244z\15N\13\225"
"B\213lR\22i\363\26O\12\225B\233%\363[\262\0P\14\225B\213!\311\264A\11;\2Q\15"
"\225B\233%\363\222(\211RY\0R\14\225B\213!\311\264A\311\274\5S\14\225B\233%S\327P"
"\323\222\5T\11\225B\213A\12\373\11U\11\225B\213\314\337\222\5V\17\225B\213\314\226\224\222(\211"
"\222,\214\0W\21\227B\214\324\232\64%\245\244\226\204I\230D\0X\15\225B\213LKja\226\324"
"l\1Y\13\225B\213LKjaO\0Z\13\225B\213A\254u\14\7\1[\11\223\303\212!\352\323"
"\0\134\12u\303\213\64L\213i\0]\11\223\303\212\251OC\0^\6#\353\232\6_\6\26C\214\3"
"`\6\42k\32\5a\12eB\233%sK\206\0b\14\225B\213\260\70$\231[\262\0c\12eB"
"\233%\23k\311\2d\13\225B\313\226AsK\206\0e\14eB\233%\33\206\60K\26\0f\13\225"
"B+\251\222ma\67\0g\15\245\62\233%sK\206\60\324\222\5h\12\225B\213\260\305\244\271\5i"
"\7\221B\11e\30j\12\322\262\231Z\322/\12\0k\15\225B\213\260))iIT\311\2l\6\221"
"B\211\7m\16gB\214D\31\22S$ER$\25n\11eB\213\304\244\271\5o\12eB\233%"
"sK\26\0p\13\245\62\233%s\33\224\260\21q\22\246\262\233!\311\222,\311\222,\32\322pL\23"
"\0r\12d\302\212d\210\262\66\0s\12eB\233%]\265d\1t\13\224\302\232\254\64$Y'\0"
"u\11eB\213\314[\262\0v\14eB\213LKJI\26F\0w\16gB\214TM\232\222Z\22"
"&\21\0x\13eB\213,\251\205YR\13y\15\245\62\213\314[\62\204\241\226,\0z\11eB\233"
"A\353\66\10{\14\226CL-L\63\71\215c\1|\6\221\303\211\7}\14\226C\14\271\32ki\230"
"\211\0~\7%j\213E\31\241\7\221B\11e\30\242\15u\303\253l\251(QR\331\42\0\243\14\225"
"\303\213\60\34\222\260M\33\6\244\13U\307\213,\231\222h\311\2\245\17\225\303\213LKja\64H\321"
" E\0\246\6\221\303\211m\247\21\246C\234!\211\207$L\206\70M\305dH\0\250\6\25\317\213,"
"\251\17w\303\234AI\225E\311\224EM\6\5\252\17\206C\234)K\262$K\262h\211\207\1\253\7"
"\65\313\233Hj\254\7%\313\213A\14\255\5\0B\14\256\17w\303\234AI\225E\311\224LM\6\5"
"\257\6\25Z\213A\260\7\63\313\232.\0\261\14u\303\253\60\32\244\60\7\6\1\265\5\0B\14\267\5"
"\0B\14\273\11\65\313\213\250$%\0\300\16\305B\233\64G\226L\33\206\314[\0\301\15\305B\273:"
"\262d\332\60d\336\2\302\16\305B\253,\311\201%\323\206!\363\26\303\16\305B\213E\231\227L\33\206"
"\314[\0\304\15\265B\233:\260d\332\60d\336\2\305\17\325B\253,\311rd\311\264a\310\274\5\306"
"\23\231B\235\341\26f\341\60(Y\230\205Y\230\205\331 \307\14\225:\233%\23\333\222-\223\0\310\16"
"\305B\233\64\7\216\341\220\204\215\203\0\311\15\305B\273:p\14\207$l\34\4\312\16\305B\253,\211"
"\207\61\34\222\260q\20\313\15\265B\233\362\60\206C\22\66\16\2\314\11\302A\211(K\372\3\315\11\302"
"B\31-\351/\0\316\11\303A\231\306\250\277\0\317\12\263A\211$\214\372\13\0\320\15\225B\213!\311"
"\264!\321\334\6\5\321\16\305B\213EY\63\333\244$\322f\13\322\14\305B\233\64G\226\314o\311\2"
"\323\14\305B\273:\262d~K\26\0\324\15\305B\253,\311\201%\363[\262\0\325\14\305B\213E\231"
"\227\314o\311\2\326\14\265B\233:\260d~K\26\0\327\7\63J\213\244\3\330\22\227B\254\245\26E"
"RRJJII\252%\311\4\331\14\305B\233\64\7\62\177K\26\0\332\13\305B\273:\220\371[\262"
"\0\333\14\305B\253,\211\63\177K\26\0\334\12\265B\233r\346o\311\2\335\14\305B\273:\220iI"
"-\354\11\336\15\225B\213\60\34\222lP\302F\0\337\16\265:\213!\311\24%sQ\302F\0\340\14"
"\225B\233\64G\226\314-\31\2\341\13\225B\273:\262dn\311\20\342\15\225B\253,\311\201%sK"
"\206\0\343\14\225B\213E\231\227\314-\31\2\344\13\205B\233:\260dn\311\20\345\15\245B\253,\311"
"rd\311\334\222!\346\16iB\235K\226i\303\26f\225\13\0\347\13\205:\233%\23k\311V\3\350"
"\14eB\233%\33\206\60K\26\0\351\14eB\233%\33\206\60K\26\0\352\14eB\233%\33\206\60"
"K\26\0\353\14eB\233%\33\206\60K\26\0\354\10\242\302\211(Mz\355\10\242\302\31\65\351\5\356"
"\11\243B\232v \352\5\357\12\223B\212$\7\242^\0\360\14\225B\313hL\6\315-\31\2\361\13"
"\225B\213EY\23\223\346\26\362\14\225B\233\64G\226\314-Y\0\363\13\225B\273:\262dn\311\2"
"\364\15\225B\253,\311\201%sK\26\0\365\14\225B\213E\231\227\314-Y\0\366\13\205B\233:\260"
"dn\311\2\367\12UF\253\34\30t \2\370\14eB\233%Z\22%\231\222\5\371\13\225B\233\64"
"\7\62o\311\2\372\13\225B\273:\220yK\26\0\373\13\225B\253,\211\63o\311\2\374\12\205B\233"
"r\346-Y\0\375\16\325\62\273:\220yK\206\60\324\222\5\376\14e\302\212pH\262A\11C\0\377"
"\16\305\62\233r\346-\31\302PK\26\0\0\0\0\4\377\377\0";
*/
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32-S3!");
//u8g2.setColorIndex(1); // set the color to white
u8g2.begin();
//u8g2.setBitmapMode(1);
SCREEN_WIDTH = u8g2.getDisplayWidth();
SCREEN_HEIGHT = u8g2.getDisplayHeight();
USABLE_SCREEN_WIDTH = SCREEN_WIDTH;
// define pins for buttons
// INPUT_PULLUP means the button is HIGH when not pressed, and LOW when pressed
// since it´s connected between some pin and GND
pinMode(BUTTON_UP_PIN, INPUT_PULLUP); // up button
pinMode(BUTTON_SELECT_PIN, INPUT_PULLUP); // select button
pinMode(BUTTON_DOWN_PIN, INPUT_PULLUP); // down button
drawDisplay();
}
void loop() {
// put your main code here, to run repeatedly:
delay(1000); // this speeds up the simulation
}
int aligncenter_H(String text) {
int newposy = (SCREEN_HEIGHT / 2) + ((u8g2.getAscent() - u8g2.getDescent()) / 2) - 1 ;
return newposy;
}
int aligncenter(int posx, String text) {
int newposx = posx - (u8g2.getUTF8Width(text.c_str()) / 2);
return newposx;
}
int alignright(int posx, String text) {
int newposx = posx - u8g2.getUTF8Width(text.c_str());
return newposx;
}
void drawFramedText(int x, int y, String text) {
int space = 3;
int text_w;
if ( text == "zur\374ck" ) {
text_w = u8g2.getUTF8Width("zuruck");
} else {
text_w = u8g2.getUTF8Width(text.c_str());
}
int text_h = u8g2.getAscent() - u8g2.getDescent();
/*
https://github.com/olikraus/u8g2/wiki/u8g2reference#drawFrame
u8g2.drawFrame(u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h)
x: X-position of upper left edge.
y: Y-position of upper left edge.
w: Width of the box.
h: Height of the box.
*/
Serial.print("Text: ");
Serial.println(text);
Serial.print("space: ");
Serial.print(space);
Serial.print(", text_w: ");
Serial.print(text_w);
Serial.print(", text_h: ");
Serial.print(text_h);
Serial.print(", getAscent(): ");
Serial.print(u8g2.getAscent());
Serial.print(", getDescent(): ");
Serial.println(u8g2.getDescent());
// ***********************************************************************
// * DRAW FRAME
// ***********************************************************************
int frame_x = x - ( space + 1 ); // OK
int frame_y = y - u8g2.getAscent() - ( space + 1 ) ; // OK
int frame_width = text_w + ( 2 * space ) + 2; // OK
int frame_height = text_h + ( 2 * space ) + 1; // OK
u8g2.drawFrame(frame_x, frame_y, frame_width, frame_height);
Serial.print("Frame: X: ");
Serial.print(frame_x);
Serial.print(", Y: ");
Serial.print(frame_y);
Serial.print(", width: ");
Serial.print(frame_width);
Serial.print(", height: ");
Serial.println(frame_height);
// ***********************************************************************
// * DRAW STRING
// ***********************************************************************
int text_x = x;
int text_y = y;
u8g2.drawStr(text_x, text_y, text.c_str());
Serial.print("Text: X: ");
Serial.print(text_x);
Serial.print(", Y: ");
Serial.print(text_y);
Serial.print(", width: ");
Serial.print(text_w);
Serial.print(", height: ");
Serial.println(text_h);
}
void drawFramedTextSelected(int x, int y, String text) {
int space = 1;
int text_w;
if ( text == "zur\374ck" ) {
text_w = u8g2.getUTF8Width("zuruck");
} else {
text_w = u8g2.getUTF8Width(text.c_str());
}
int text_h = u8g2.getAscent() - u8g2.getDescent();
// ***********************************************************************
// * DRAW FRAME
// ***********************************************************************
int frame_x = x - ( space + 1 ); // OK
int frame_y = y - u8g2.getAscent() - ( space + 1 ) ; // OK
int frame_width = text_w + ( 2 * space ) + 2; // OK
int frame_height = text_h + ( 2 * space ) + 1; // OK
u8g2.drawBox(frame_x, frame_y, frame_width, frame_height);
// ***********************************************************************
// * DRAW STRING
// ***********************************************************************
int text_x = x;
int text_y = y;
u8g2.setDrawColor(0);
u8g2.drawStr(text_x, text_y, text.c_str());
u8g2.setDrawColor(1);
}
void drawSelectedTextLine(int y, String text, int space) {
int text_w;
if ( text == "zur\374ck" ) {
text_w = u8g2.getUTF8Width("zuruck");
} else {
text_w = u8g2.getUTF8Width(text.c_str());
}
int text_h = u8g2.getAscent() - u8g2.getDescent();
// ***********************************************************************
// * DRAW FRAME
// ***********************************************************************
//int space = 3;
int radius = 3;
int frame_x = 0;
int frame_y = y - u8g2.getAscent() - ( space + 1 ) ; // OK
int frame_width = USABLE_SCREEN_WIDTH;
int frame_height = text_h + ( 2 * space ) + 1; // OK
u8g2.drawRFrame(frame_x, frame_y, frame_width, frame_height, radius);
// ***********************************************************************
// * DRAW STRING
// ***********************************************************************
int text_x = frame_x + space + 1;
int text_y = y;
u8g2.drawStr(text_x, text_y, text.c_str());
}
void drawScrollbar(int pos, int max_pos) {
int pixel_size = 1;
int bar_width = ( 2 * pixel_size ) + pixel_size;
int bar_height = SCREEN_HEIGHT / max_pos;
for (int i = 1; i < SCREEN_HEIGHT; i++) {
u8g2.drawBox(SCREEN_WIDTH - (2 * pixel_size), i, pixel_size, pixel_size);
i = i + pixel_size + 1;
}
u8g2.drawBox(SCREEN_WIDTH - bar_width, bar_height * pos, bar_width, bar_height);
USABLE_SCREEN_WIDTH = SCREEN_WIDTH - bar_width - 1;
}
// display a string on multiple text lines, keeping words intact where possible,
// and accepting \n to force a new line
void drawWords(int xloc, int yloc /*bottom*/, const char *msg ) {
int dspwidth = u8g2.getDisplayWidth(); // display width in pixels
int strwidth = 0; // string width in pixels
char glyph[2]; glyph[1] = 0;
for (const char *ptr = msg, *lastblank = NULL; *ptr; ++ptr) {
while (xloc == 0 && (*msg == ' ' || *msg == '\n'))
if (ptr == msg++) ++ptr; // skip blanks and newlines at the left edge
glyph[0] = *ptr;
strwidth += u8g2.getStrWidth(glyph); // accumulate the pixel width
if (*ptr == ' ') lastblank = ptr; // remember where the last blank was
else ++strwidth; // non-blanks will be separated by one additional pixel
if (*ptr == '\n' || // if we found a newline character,
xloc + strwidth > dspwidth) { // or if we ran past the right edge of the display
int starting_xloc = xloc;
// print to just before the last blank, or to just before where we got to
while (msg < (lastblank ? lastblank : ptr)) {
glyph[0] = *msg++;
xloc += u8g2.drawStr(xloc, yloc, glyph);
}
strwidth -= xloc - starting_xloc; // account for what we printed
yloc += u8g2.getMaxCharHeight(); // advance to the next line
xloc = 0; lastblank = NULL;
}
}
while (*msg) { // print any characters left over
glyph[0] = *msg++;
xloc += u8g2.drawStr(xloc, yloc, glyph);
}
}
void drawDisplay() {
String tmptxt;
/*
u8g2.clearBuffer();
//u8g2.drawHLine(0, SCREEN_HEIGHT / 2, USABLE_SCREEN_WIDTH);
//u8g2.drawFrame(0, 0, USABLE_SCREEN_WIDTH, SCREEN_HEIGHT);
drawScrollbar(2, 6);
u8g2.setFont(u8g2_font_7x14_tf);
int mid_screen_pos = (SCREEN_HEIGHT/2)+(u8g2.getAscent()/2);
int mid_menu_pos = ((SCREEN_HEIGHT-12)/2)+(u8g2.getAscent()/2)+12;
tmptxt = "3 Menueintr\344ge";
u8g2.drawStr(aligncenter(USABLE_SCREEN_WIDTH/2, tmptxt), 10, tmptxt.c_str());
u8g2.setFont(u8g2_font_6x13_tf);
tmptxt = "Menu 1 y";
u8g2.drawStr(4, mid_menu_pos-17, tmptxt.c_str());
u8g2.setFont(u8g2_font_7x14_tf);
tmptxt = "Menu 2 j";
//u8g2.drawStr(0, 40, tmptxt.c_str());
drawSelectedTextLine(mid_menu_pos, tmptxt, 3);
u8g2.setFont(u8g2_font_6x13_tf);
tmptxt = "Menu 3 g";
u8g2.drawStr(4, mid_menu_pos+17, tmptxt.c_str());
u8g2.sendBuffer();
*/
/*
u8g2.clearBuffer();
//u8g2.drawHLine(0, SCREEN_HEIGHT / 2, USABLE_SCREEN_WIDTH);
//u8g2.drawFrame(0, 0, USABLE_SCREEN_WIDTH, SCREEN_HEIGHT);
drawScrollbar(2, 6);
u8g2.setFont(u8g2_font_7x14_tf);
int mid_screen_pos = (SCREEN_HEIGHT/2)+(u8g2.getAscent()/2);
int mid_menu_pos = ((SCREEN_HEIGHT-12)/2)+(u8g2.getAscent()/2)+12;
u8g2.drawHLine(0, 11, USABLE_SCREEN_WIDTH);
tmptxt = "5 Menueintr\344ge";
u8g2.drawStr(aligncenter(USABLE_SCREEN_WIDTH/2, tmptxt), 10, tmptxt.c_str());
u8g2.setFont(u8g2_font_5x8_tf);
tmptxt = "Menu 1 y";
u8g2.drawStr(5, mid_menu_pos-24, tmptxt.c_str());
u8g2.setFont(u8g2_font_6x10_tf);
tmptxt = "Menu 2 y";
u8g2.drawStr(4, mid_menu_pos-15, tmptxt.c_str());
u8g2.setFont(u8g2_font_7x14_tf);
tmptxt = "Menu 3 j";
drawSelectedTextLine(mid_menu_pos, tmptxt, 2);
u8g2.setFont(u8g2_font_6x10_tf);
tmptxt = "Menu 3 g";
u8g2.drawStr(4, mid_menu_pos+12, tmptxt.c_str());
u8g2.setFont(u8g2_font_5x8_tf);
tmptxt = "Menu 4 g";
u8g2.drawStr(5, mid_menu_pos+20, tmptxt.c_str());
u8g2.sendBuffer();
*/
/*
u8g2.clearBuffer();
tmptxt = "Cocktailname";
u8g2.setFont(u8g2_font_tpss_tn);
u8g2.drawStr(aligncenter(USABLE_SCREEN_WIDTH/2, tmptxt), 10, tmptxt.c_str());
tmptxt = "Pumpe: ";
u8g2.setFont(u8g2_font_7x14_tf);
//drawFramedText(4,30, tmptxt);
//drawFramedTextSelected(4,30, tmptxt);
u8g2.drawStr(4, 30, tmptxt.c_str());
int zahl = 9;
u8g2.setFont(u8g2_font_7x14B_tf);
//drawFramedText(alignright(74, String(zahl)), 30, String(zahl));
//drawFramedTextSelected(alignright(74, String(zahl)), 30, String(zahl));
u8g2.drawStr(alignright(74, String(zahl)), 30, String(zahl).c_str());
tmptxt = "alkoholisch";
u8g2.setFont(u8g2_font_5x8_tf);
u8g2.drawStr(4, 42, tmptxt.c_str());
tmptxt = "zur\374ck";
u8g2.setFont(u8g2_font_6x10_tf);
drawFramedText(alignright(SCREEN_WIDTH-4, "zuruck"), SCREEN_HEIGHT-5, tmptxt );
//drawFramedTextSelected(alignright(SCREEN_WIDTH-4, "zuruck"), SCREEN_HEIGHT-5, tmptxt );
//u8g2.drawStr(alignright(SCREEN_WIDTH-4, "zuruck"), SCREEN_HEIGHT-5, tmptxt.c_str());
u8g2.sendBuffer();
*/
/*
u8g2.clearBuffer();
tmptxt = "Cocktailname";
u8g2.setFont(u8g2_font_6x13_tf);
u8g2.drawStr(aligncenter(SCREEN_WIDTH/2, tmptxt), 10, tmptxt.c_str());
tmptxt = "wird zubereitet.";
u8g2.setFont(u8g2_font_6x13_tf);
u8g2.drawStr(aligncenter(SCREEN_WIDTH/2, tmptxt), 25, tmptxt.c_str());
//u8g2.drawVLine(SCREEN_WIDTH / 2, 0, SCREEN_HEIGHT);
tmptxt = "/";
u8g2.setFont(u8g2_font_6x10_tf);
u8g2.drawStr(aligncenter((SCREEN_WIDTH/2)-6, tmptxt), 37, tmptxt.c_str());
tmptxt = "XXXml";
u8g2.setFont(u8g2_font_6x10_tf);
u8g2.drawStr(alignright((SCREEN_WIDTH/2)+(5*6), tmptxt), 37, tmptxt.c_str());
tmptxt = "Zutat XYZ";
u8g2.setFont(u8g2_font_6x10_tf);
u8g2.drawStr(aligncenter(SCREEN_WIDTH/2, tmptxt), 47, tmptxt.c_str());
tmptxt = "Bitte warten...";
u8g2.setFont(u8g2_font_6x13_tf);
u8g2.drawStr(0, SCREEN_HEIGHT, tmptxt.c_str());
u8g2.sendBuffer();
for ( int i=0; i<150; i++) {
tmptxt = String(i);
u8g2.setFont(u8g2_font_6x10_tf);
u8g2.drawStr(alignright((SCREEN_WIDTH/2)-(2*6), tmptxt), 37, tmptxt.c_str());
u8g2.sendBuffer();
delay(100);
}
*/
/*
u8g2.clearBuffer();
tmptxt = "Waage";
u8g2.setFont(u8g2_font_6x13_tf);
u8g2.drawStr(aligncenter(SCREEN_WIDTH/2, tmptxt), 10, tmptxt.c_str());
tmptxt = String(1234) + "gr";
u8g2.setFont(u8g2_font_6x13_tf);
u8g2.drawStr(aligncenter(SCREEN_WIDTH/2, tmptxt), aligncenter_H(tmptxt), tmptxt.c_str());
tmptxt = "zur\374ck";
u8g2.setFont(u8g2_font_6x13_tf);
drawFramedText(alignright(SCREEN_WIDTH-4, "zuruck"), SCREEN_HEIGHT-5, tmptxt );
u8g2.sendBuffer();
*/
/*
int _resume = 0;
bool pos = false;
while (_resume < 16) {
u8g2.clearBuffer();
tmptxt = "Waage";
u8g2.setFont(u8g2_font_6x13_tf);
u8g2.drawStr(aligncenter(SCREEN_WIDTH/2, tmptxt), 10, tmptxt.c_str());
tmptxt = "Waage nullen?";
u8g2.setFont(u8g2_font_6x13_tf);
u8g2.drawStr(aligncenter(SCREEN_WIDTH/2, "Waage nullen?"), aligncenter_H("Waage nullen?"), tmptxt.c_str());
u8g2.setFont(u8g2_font_6x13_tf);
if (pos) {
tmptxt = "Ja";
drawFramedText(4, SCREEN_HEIGHT-5, tmptxt );
tmptxt = "Nein";
u8g2.drawStr(alignright(SCREEN_WIDTH-4, tmptxt), SCREEN_HEIGHT-5, tmptxt.c_str());
} else {
tmptxt = "Ja";
u8g2.drawStr(4, SCREEN_HEIGHT-5, tmptxt.c_str());
tmptxt = "Nein";
drawFramedText(alignright(SCREEN_WIDTH-4, tmptxt), SCREEN_HEIGHT-5, tmptxt );
}
u8g2.sendBuffer();
_resume++;
pos = !pos;
delay(150);
}
u8g2.clearBuffer();
tmptxt = "Waage";
u8g2.setFont(u8g2_font_6x13_tf);
u8g2.drawStr(aligncenter(SCREEN_WIDTH/2, tmptxt), 10, tmptxt.c_str());
tmptxt = "Waage nullen!";
u8g2.setFont(u8g2_font_6x13_tf);
u8g2.drawStr(aligncenter(SCREEN_WIDTH/2, tmptxt), aligncenter_H(tmptxt), tmptxt.c_str());
tmptxt = "bitte warten...";
u8g2.setFont(u8g2_font_6x13_tf);
u8g2.drawStr(4, SCREEN_HEIGHT-5 , tmptxt.c_str());
u8g2.sendBuffer();
u8g2.sendBuffer();
delay(1000);
u8g2.clearBuffer();
tmptxt = "Waage";
u8g2.setFont(u8g2_font_6x13_tf);
u8g2.drawStr(aligncenter(SCREEN_WIDTH/2, tmptxt), 10, tmptxt.c_str());
tmptxt = "Waage genullt.";
u8g2.setFont(u8g2_font_6x13_tf);
u8g2.drawStr(aligncenter(SCREEN_WIDTH/2, tmptxt), aligncenter_H(tmptxt), tmptxt.c_str());
u8g2.sendBuffer();
*/
u8g2.clearBuffer();
tmptxt = "Waage kalibrieren";
u8g2.setFont(u8g2_font_6x13_tf);
u8g2.drawStr(aligncenter(SCREEN_WIDTH/2, tmptxt), 10, tmptxt.c_str());
// drawWords(0, 20, "Remove any load applied to the load cell.");
// drawWords(0, 20, "Bitte alle Gewichte von der Waage entfernen.");
u8g2.setFont(u8g2_font_6x10_tf);
u8g2.drawStr(0, 22, "Bitte alle Gewichte");
u8g2.drawStr(0, 22+10, "von der Waage");
u8g2.drawStr(0, 22+10+10, "entfernen.");
tmptxt = "Ja";
drawFramedText(4, SCREEN_HEIGHT-5, tmptxt );
tmptxt = "Nein";
drawFramedText(alignright(SCREEN_WIDTH-4, tmptxt), SCREEN_HEIGHT-5, tmptxt );
u8g2.sendBuffer();
/*
u8g2.clearBuffer(); // clear buffer for storing display content in RAM
String text;
int posx;
int posy;
int font_h;
int text_w;
*/
/*
https://github.com/olikraus/u8g2/wiki/u8g2reference#drawRFrame
u8g2.drawRFrame(u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, u8g2_uint_t r)
x: X-position of upper left edge.
y: Y-position of upper left edge.
w: Width of the box.
h: Height of the box.
r: Radius for the four edges.
*/
//u8g2.drawRFrame( 0, 24, 124, 16, 5);
/*
drawScrollbar(2, 4);
u8g2.sendBuffer(); // send buffer from RAM to display controller
//u8g2.drawLine(u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t x1, u8g2_uint_t y1)
//u8g2.drawLine(0, 0, USABLE_SCREEN_WIDTH, 0);
//u8g2.drawLine(0, SCREEN_HEIGHT/2, USABLE_SCREEN_WIDTH, SCREEN_HEIGHT/2);
u8g2.drawHLine(0, SCREEN_HEIGHT / 2, USABLE_SCREEN_WIDTH);
//u8g2.drawLine(USABLE_SCREEN_WIDTH/2, 0, USABLE_SCREEN_WIDTH/2, SCREEN_HEIGHT);
u8g2.drawVLine(USABLE_SCREEN_WIDTH / 2, 0, SCREEN_HEIGHT);
// selected item background
//u8g2.drawXBMP(0, 22, 128, 21, bitmap_item_sel_outline);
u8g2.setFont(u8g2_font_6x13_tf);
text = "AbcD";
//drawFramedText(text, 4, 13);
u8g2.setFont(u8g2_font_6x13_tf);
text = "Wxyz";
//drawFramedTextSelected(text, 65, 13);
u8g2.setFont(u8g2_font_6x13_tf);
text = "Zentriert";
font_h = u8g2.getAscent() - u8g2.getDescent();
//drawFramedText(text, aligncenter(text, USABLE_SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) + (font_h / 2) - 1 );
u8g2.setFont(u8g2_font_5x8_tf);
text = "rechts unten";
//int space = 1;
//drawFramedText(text, alignright(text, USABLE_SCREEN_WIDTH - (space + 1)), SCREEN_HEIGHT - (space + 1) );
u8g2.setFont(u8g2_font_7x14_tf);
text = "AbcD";
//drawFramedText(text, 31, 14);
u8g2.setFont(u8g2_font_7x14B_tf);
text = "Wxyz";
//drawFramedTextSelected(text, 94, 14);
u8g2.setFont(u8g2_font_7x14_tf);
text = "AbcDwXyZ";
//drawFramedText(text, 4, 14);
u8g2.setFont(u8g2_font_7x14B_tf);
text = "selected gyJj";
int mid_screen_pos = (SCREEN_HEIGHT/2)+(u8g2.getAscent()/2);
drawSelectedTextLine(text, mid_screen_pos );
//u8g2.drawFrame(0, 0, USABLE_SCREEN_WIDTH, SCREEN_HEIGHT);
*/
/*
text_w = u8g2.getUTF8Width(text.c_str());
posx = USABLE_SCREEN_WIDTH/2 - USABLE_SCREEN_WIDTH/4;
posy = 11;
Serial.print("Line 1 - ");
Serial.print("POSX: ");
Serial.print(posx);
Serial.print(" - POSY: ");
Serial.println(posy-font_h+1);
drawHLine(0, USABLE_SCREEN_WIDTH, posy-font_h+1);
Serial.print("Text 1 - ");
Serial.print("POSX: ");
Serial.print(posx);
Serial.print(" - POSY: ");
Serial.println(posy);
u8g2.drawStr(aligncenter(text, posx), posy, text.c_str());
text = "Efgy";
posx = USABLE_SCREEN_WIDTH/2 + USABLE_SCREEN_WIDTH/4;
Serial.print("Text 2 - ");
Serial.print("POSX: ");
Serial.print(posx);
Serial.print(" - POSY: ");
Serial.println(posy);
u8g2.drawStr(aligncenter(text, posx), posy, text.c_str());
//posy = posy + 2 + 1;
posy = posy-u8g2.getDescent();
Serial.print("Line 2 - ");
Serial.print("POSX: ");
Serial.print(posx);
Serial.print(" - POSY: ");
Serial.println(posy);
drawHLine(0, USABLE_SCREEN_WIDTH, posy);
text = String(u8g2.getAscent()) + " + " + String(u8g2.getDescent()) + " = " + String(font_h) + " | " + u8g2.getMaxCharHeight();
text_w = u8g2.getUTF8Width(text.c_str());
posx = USABLE_SCREEN_WIDTH/2;
posy = SCREEN_HEIGHT-1;
Serial.print("Text 2 - ");
Serial.print("POSX: ");
Serial.print(posx);
Serial.print(" - POSY: ");
Serial.println(posy);
u8g2.drawStr(aligncenter(text, posx), posy, text.c_str());
Serial.print("Line 3 - ");
Serial.print("POSX: ");
Serial.print(posx);
Serial.print(" - POSY: ");
Serial.println(posy);
drawHLine(0, USABLE_SCREEN_WIDTH, posy);
*/
/*
// draw previous item as icon + label
//u8g2.setFont(u8g2_font_7x14_tf);
//u8g2.drawStr(25, 15, "previous item");
//u8g2.drawXBMP( 4, 2, 16, 16, bitmap_icons[item_sel_previous]);
// draw selected item as icon + label in bold font
u8g2.setFont(u8g2_font_7x14B_tf);
//u8g2.setFont(u8g2_font_tpss_tn);
u8g2.drawStr(25, 15 + 20 + 2, "selected item");
//u8g2.drawXBMP( 4, 24, 16, 16, bitmap_icons[item_selected]);
// draw next item as icon + label
//u8g2.setFont(u8g2_font_7x14_tf);
u8g2.setFont(u8g2_font_4x6_tf);
u8g2.drawStr(25, 15 + 20 + 20 + 2 + 2, "next item");
//u8g2.drawXBMP( 4, 46, 16, 16, bitmap_icons[item_sel_next]);
// draw scrollbar background
u8g2.drawXBMP(128 - 8, 0, 8, 64, bitmap_scrollbar_background);
// draw scrollbar handle
u8g2.drawBox(125, 64 / NUM_ITEMS * item_selected, 3, 64 / NUM_ITEMS);
*/
// draw upir logo
//u8g2.drawXBMP(128-16-4, 64-4, 16, 4, upir_logo);
/*
u8g2.sendBuffer(); // send buffer from RAM to display controller
*/
}