Fixed build
This commit is contained in:
parent
002ed86bc2
commit
30ce7f099d
68 changed files with 611 additions and 611 deletions
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -86,16 +86,16 @@ void loop()
|
|||
// print RSSI of packet
|
||||
Serial.print("' with RSSI ");
|
||||
Serial.println(LoRa.packetRssi());
|
||||
if (u8g2) {
|
||||
u8g2->clearBuffer();
|
||||
if (disp) {
|
||||
disp->clearBuffer();
|
||||
char buf[256];
|
||||
u8g2->drawStr(0, 12, "Received OK!");
|
||||
u8g2->drawStr(0, 26, recv.c_str());
|
||||
disp->drawStr(0, 12, "Received OK!");
|
||||
disp->drawStr(0, 26, recv.c_str());
|
||||
snprintf(buf, sizeof(buf), "RSSI:%i", LoRa.packetRssi());
|
||||
u8g2->drawStr(0, 40, buf);
|
||||
disp->drawStr(0, 40, buf);
|
||||
snprintf(buf, sizeof(buf), "SNR:%.1f", LoRa.packetSnr());
|
||||
u8g2->drawStr(0, 56, buf);
|
||||
u8g2->sendBuffer();
|
||||
disp->drawStr(0, 56, buf);
|
||||
disp->sendBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -75,13 +75,13 @@ void loop()
|
|||
LoRa.print(counter);
|
||||
LoRa.endPacket();
|
||||
|
||||
if (u8g2) {
|
||||
if (disp) {
|
||||
char buf[256];
|
||||
u8g2->clearBuffer();
|
||||
u8g2->drawStr(0, 12, "Transmitting: OK!");
|
||||
disp->clearBuffer();
|
||||
disp->drawStr(0, 12, "Transmitting: OK!");
|
||||
snprintf(buf, sizeof(buf), "Sending: %d", counter);
|
||||
u8g2->drawStr(0, 30, buf);
|
||||
u8g2->sendBuffer();
|
||||
disp->drawStr(0, 30, buf);
|
||||
disp->sendBuffer();
|
||||
}
|
||||
counter++;
|
||||
delay(5000);
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -81,12 +81,12 @@ void do_send(osjob_t *j)
|
|||
// Prepare upstream data transmission at the next possible time.
|
||||
LMIC_setTxData2(1, mydata, sizeof(mydata) - 1, 0);
|
||||
os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(TX_INTERVAL), do_send);
|
||||
if (u8g2) {
|
||||
if (disp) {
|
||||
char buf[256];
|
||||
u8g2->clearBuffer();
|
||||
disp->clearBuffer();
|
||||
snprintf(buf, sizeof(buf), "[%lu]data sending!", millis() / 1000);
|
||||
u8g2->drawStr(0, 12, buf);
|
||||
u8g2->sendBuffer();
|
||||
disp->drawStr(0, 12, buf);
|
||||
disp->sendBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -122,19 +122,19 @@ void onEvent (ev_t ev)
|
|||
lora_msg = "OTAA joining....";
|
||||
joinStatus = EV_JOINING;
|
||||
|
||||
if (u8g2) {
|
||||
u8g2->clearBuffer();
|
||||
u8g2->drawStr(0, 12, "OTAA joining....");
|
||||
u8g2->sendBuffer();
|
||||
if (disp) {
|
||||
disp->clearBuffer();
|
||||
disp->drawStr(0, 12, "OTAA joining....");
|
||||
disp->sendBuffer();
|
||||
}
|
||||
break;
|
||||
case EV_JOIN_FAILED:
|
||||
Serial.println(F("EV_JOIN_FAILED: -> Joining failed"));
|
||||
lora_msg = "OTAA Joining failed";
|
||||
if (u8g2) {
|
||||
u8g2->clearBuffer();
|
||||
u8g2->drawStr(0, 12, "OTAA joining failed");
|
||||
u8g2->sendBuffer();
|
||||
if (disp) {
|
||||
disp->clearBuffer();
|
||||
disp->drawStr(0, 12, "OTAA joining failed");
|
||||
disp->sendBuffer();
|
||||
}
|
||||
break;
|
||||
case EV_JOINED:
|
||||
|
|
@ -142,10 +142,10 @@ void onEvent (ev_t ev)
|
|||
lora_msg = "Joined!";
|
||||
joinStatus = EV_JOINED;
|
||||
|
||||
if (u8g2) {
|
||||
u8g2->clearBuffer();
|
||||
u8g2->drawStr(0, 12, "Joined TTN!");
|
||||
u8g2->sendBuffer();
|
||||
if (disp) {
|
||||
disp->clearBuffer();
|
||||
disp->drawStr(0, 12, "Joined TTN!");
|
||||
disp->sendBuffer();
|
||||
}
|
||||
delay(3);
|
||||
// Disable link check validation (automatically enabled
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -350,16 +350,16 @@ void setup()
|
|||
|
||||
Serial.println(F("Ready!\n"));
|
||||
|
||||
if (u8g2) {
|
||||
u8g2->clearBuffer();
|
||||
u8g2->setFont(u8g2_font_NokiaLargeBold_tf );
|
||||
uint16_t str_w = u8g2->getStrWidth(BOARD_VARIANT_NAME);
|
||||
u8g2->drawStr((u8g2->getWidth() - str_w) / 2, 16, BOARD_VARIANT_NAME);
|
||||
u8g2->drawHLine(5, 21, u8g2->getWidth() - 5);
|
||||
if (disp) {
|
||||
disp->clearBuffer();
|
||||
disp->setFont(u8g2_font_NokiaLargeBold_tf );
|
||||
uint16_t str_w = disp->getStrWidth(BOARD_VARIANT_NAME);
|
||||
disp->drawStr((disp->getWidth() - str_w) / 2, 16, BOARD_VARIANT_NAME);
|
||||
disp->drawHLine(5, 21, disp->getWidth() - 5);
|
||||
|
||||
u8g2->setCursor(0, 38);
|
||||
u8g2->print("Join LoRaWAN Ready!");
|
||||
u8g2->sendBuffer();
|
||||
disp->setCursor(0, 38);
|
||||
disp->print("Join LoRaWAN Ready!");
|
||||
disp->sendBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
How to overwrite previous text with a new text.
|
||||
How to avoid the buffer clear command.
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/disp/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
|
@ -36,19 +36,19 @@
|
|||
|
||||
|
||||
Usually, a sequence like this is used:
|
||||
u8g2->clearBuffer(); // clear the internal memory
|
||||
u8g2->setFont(u8g2_font_ncenB08_tr); // choose a suitable font
|
||||
u8g2->setCursor(0,20) // set write position
|
||||
u8g2->print("Hello World!"); // write something to the internal memory
|
||||
u8g2->sendBuffer(); // transfer internal memory to the display
|
||||
disp->clearBuffer(); // clear the internal memory
|
||||
disp->setFont(u8g2_font_ncenB08_tr); // choose a suitable font
|
||||
disp->setCursor(0,20) // set write position
|
||||
disp->print("Hello World!"); // write something to the internal memory
|
||||
disp->sendBuffer(); // transfer internal memory to the display
|
||||
|
||||
In order to speed up the display content rendering for any modified text,
|
||||
we could drop the clearBuffer command and just overwrite the previous string:
|
||||
|
||||
u8g2->setFont(u8g2_font_ncenB08_tr); // choose a suitable font
|
||||
u8g2->setCursor(0,20) // set write position
|
||||
u8g2->print("hello there"); // write something to the internal memory
|
||||
u8g2->sendBuffer(); // transfer internal memory to the display
|
||||
disp->setFont(u8g2_font_ncenB08_tr); // choose a suitable font
|
||||
disp->setCursor(0,20) // set write position
|
||||
disp->print("hello there"); // write something to the internal memory
|
||||
disp->sendBuffer(); // transfer internal memory to the display
|
||||
|
||||
This will only work if:
|
||||
- Background is drawn
|
||||
|
|
@ -59,11 +59,11 @@
|
|||
To draw the background: use font mode 0
|
||||
To ensure that all glyphs have the same height, use h or m fonts.
|
||||
|
||||
u8g2->setFontMode(0); // write solid glyphs
|
||||
u8g2->setFont(u8g2_font_ncenB08_hr); // choose a suitable h font
|
||||
u8g2->setCursor(0,20) // set write position
|
||||
u8g2->print("hello there "); // use extra spaces here
|
||||
u8g2->sendBuffer(); // transfer internal memory to the display
|
||||
disp->setFontMode(0); // write solid glyphs
|
||||
disp->setFont(u8g2_font_ncenB08_hr); // choose a suitable h font
|
||||
disp->setCursor(0,20) // set write position
|
||||
disp->print("hello there "); // use extra spaces here
|
||||
disp->sendBuffer(); // transfer internal memory to the display
|
||||
|
||||
|
||||
*/
|
||||
|
|
@ -97,7 +97,7 @@ uint32_t lcg_rnd(void)
|
|||
void setup(void)
|
||||
{
|
||||
setupBoards();
|
||||
if (!u8g2) {
|
||||
if (!disp) {
|
||||
Serial.println("No find SH1106 display!Please check whether the connection is normal");
|
||||
while (1);
|
||||
}
|
||||
|
|
@ -124,24 +124,24 @@ void draw(int is_blank)
|
|||
s[3] = '\0';
|
||||
|
||||
// print number
|
||||
u8g2->setCursor(0, 15);
|
||||
u8g2->print("Number: ");
|
||||
disp->setCursor(0, 15);
|
||||
disp->print("Number: ");
|
||||
if ( is_blank )
|
||||
u8g2->print(" ");
|
||||
u8g2->setCursor(70, 15);
|
||||
u8g2->print(n);
|
||||
disp->print(" ");
|
||||
disp->setCursor(70, 15);
|
||||
disp->print(n);
|
||||
|
||||
|
||||
// print string
|
||||
u8g2->setCursor(0, 30);
|
||||
u8g2->print("Text: ");
|
||||
u8g2->setCursor(70, 30);
|
||||
u8g2->print(s);
|
||||
disp->setCursor(0, 30);
|
||||
disp->print("Text: ");
|
||||
disp->setCursor(70, 30);
|
||||
disp->print(s);
|
||||
if ( is_blank )
|
||||
u8g2->print(" ");
|
||||
disp->print(" ");
|
||||
|
||||
// make the result visible
|
||||
u8g2->sendBuffer();
|
||||
disp->sendBuffer();
|
||||
|
||||
// delay, so that the user can see the result
|
||||
delay(200);
|
||||
|
|
@ -150,116 +150,116 @@ void draw(int is_blank)
|
|||
|
||||
void draw_m1_t()
|
||||
{
|
||||
u8g2->clearBuffer();
|
||||
disp->clearBuffer();
|
||||
|
||||
u8g2->setFontMode(1);
|
||||
u8g2->setFont(u8g2_font_cu12_tr);
|
||||
disp->setFontMode(1);
|
||||
disp->setFont(u8g2_font_cu12_tr);
|
||||
|
||||
u8g2->setCursor(0, 15);
|
||||
u8g2->print(F("setFontMode(1);"));
|
||||
u8g2->setCursor(0, 30);
|
||||
u8g2->print(F("setFont(..._tr);"));
|
||||
u8g2->setCursor(0, 55);
|
||||
u8g2->print(F("Very Bad"));
|
||||
disp->setCursor(0, 15);
|
||||
disp->print(F("setFontMode(1);"));
|
||||
disp->setCursor(0, 30);
|
||||
disp->print(F("setFont(..._tr);"));
|
||||
disp->setCursor(0, 55);
|
||||
disp->print(F("Very Bad"));
|
||||
|
||||
u8g2->sendBuffer();
|
||||
disp->sendBuffer();
|
||||
delay(INFO_SCREEN_DELAY);
|
||||
|
||||
u8g2->setFontMode(1);
|
||||
u8g2->setFont(u8g2_font_cu12_tr);
|
||||
u8g2->clearBuffer(); // clear the internal memory once
|
||||
disp->setFontMode(1);
|
||||
disp->setFont(u8g2_font_cu12_tr);
|
||||
disp->clearBuffer(); // clear the internal memory once
|
||||
draw(0);
|
||||
}
|
||||
|
||||
void draw_m0_t()
|
||||
{
|
||||
u8g2->clearBuffer();
|
||||
disp->clearBuffer();
|
||||
|
||||
u8g2->setFontMode(1);
|
||||
u8g2->setFont(u8g2_font_cu12_tr);
|
||||
disp->setFontMode(1);
|
||||
disp->setFont(u8g2_font_cu12_tr);
|
||||
|
||||
u8g2->setCursor(0, 15);
|
||||
u8g2->print(F("setFontMode(0);"));
|
||||
u8g2->setCursor(0, 30);
|
||||
u8g2->print(F("setFont(.._tr);"));
|
||||
u8g2->setCursor(0, 55);
|
||||
u8g2->print(F("Wrong"));
|
||||
disp->setCursor(0, 15);
|
||||
disp->print(F("setFontMode(0);"));
|
||||
disp->setCursor(0, 30);
|
||||
disp->print(F("setFont(.._tr);"));
|
||||
disp->setCursor(0, 55);
|
||||
disp->print(F("Wrong"));
|
||||
|
||||
u8g2->sendBuffer();
|
||||
disp->sendBuffer();
|
||||
delay(INFO_SCREEN_DELAY);
|
||||
|
||||
u8g2->setFontMode(0);
|
||||
u8g2->setFont(u8g2_font_cu12_tr);
|
||||
u8g2->clearBuffer(); // clear the internal memory once
|
||||
disp->setFontMode(0);
|
||||
disp->setFont(u8g2_font_cu12_tr);
|
||||
disp->clearBuffer(); // clear the internal memory once
|
||||
draw(0);
|
||||
}
|
||||
|
||||
void draw_m1_h()
|
||||
{
|
||||
u8g2->clearBuffer();
|
||||
disp->clearBuffer();
|
||||
|
||||
u8g2->setFontMode(1);
|
||||
u8g2->setFont(u8g2_font_cu12_tr);
|
||||
disp->setFontMode(1);
|
||||
disp->setFont(u8g2_font_cu12_tr);
|
||||
|
||||
u8g2->setCursor(0, 15);
|
||||
u8g2->print(F("setFontMode(0);"));
|
||||
u8g2->setCursor(0, 30);
|
||||
u8g2->print(F("setFont(.._hr);"));
|
||||
u8g2->setCursor(0, 55);
|
||||
u8g2->print(F("Still bad"));
|
||||
disp->setCursor(0, 15);
|
||||
disp->print(F("setFontMode(0);"));
|
||||
disp->setCursor(0, 30);
|
||||
disp->print(F("setFont(.._hr);"));
|
||||
disp->setCursor(0, 55);
|
||||
disp->print(F("Still bad"));
|
||||
|
||||
u8g2->sendBuffer();
|
||||
disp->sendBuffer();
|
||||
delay(INFO_SCREEN_DELAY);
|
||||
|
||||
u8g2->setFontMode(1);
|
||||
u8g2->setFont(u8g2_font_cu12_hr);
|
||||
u8g2->clearBuffer(); // clear the internal memory once
|
||||
disp->setFontMode(1);
|
||||
disp->setFont(u8g2_font_cu12_hr);
|
||||
disp->clearBuffer(); // clear the internal memory once
|
||||
draw(0);
|
||||
}
|
||||
|
||||
void draw_m0_h()
|
||||
{
|
||||
u8g2->clearBuffer();
|
||||
disp->clearBuffer();
|
||||
|
||||
u8g2->setFontMode(1);
|
||||
u8g2->setFont(u8g2_font_cu12_tr);
|
||||
disp->setFontMode(1);
|
||||
disp->setFont(u8g2_font_cu12_tr);
|
||||
|
||||
u8g2->setCursor(0, 15);
|
||||
u8g2->print(F("setFontMode(0);"));
|
||||
u8g2->setCursor(0, 30);
|
||||
u8g2->print(F("setFont(.._hr);"));
|
||||
u8g2->setCursor(0, 55);
|
||||
u8g2->print(F("Almost ok"));
|
||||
disp->setCursor(0, 15);
|
||||
disp->print(F("setFontMode(0);"));
|
||||
disp->setCursor(0, 30);
|
||||
disp->print(F("setFont(.._hr);"));
|
||||
disp->setCursor(0, 55);
|
||||
disp->print(F("Almost ok"));
|
||||
|
||||
u8g2->sendBuffer();
|
||||
disp->sendBuffer();
|
||||
delay(INFO_SCREEN_DELAY);
|
||||
|
||||
u8g2->setFontMode(0);
|
||||
u8g2->setFont(u8g2_font_cu12_hr);
|
||||
u8g2->clearBuffer(); // clear the internal memory once
|
||||
disp->setFontMode(0);
|
||||
disp->setFont(u8g2_font_cu12_hr);
|
||||
disp->clearBuffer(); // clear the internal memory once
|
||||
draw(0);
|
||||
}
|
||||
|
||||
void draw_m0_h_with_extra_blank()
|
||||
{
|
||||
u8g2->clearBuffer();
|
||||
disp->clearBuffer();
|
||||
|
||||
u8g2->setFontMode(1);
|
||||
u8g2->setFont(u8g2_font_cu12_tr);
|
||||
disp->setFontMode(1);
|
||||
disp->setFont(u8g2_font_cu12_tr);
|
||||
|
||||
u8g2->setCursor(0, 15);
|
||||
u8g2->print(F("setFontMode(0);"));
|
||||
u8g2->setCursor(0, 30);
|
||||
u8g2->print(F("setFont(.._hr);"));
|
||||
u8g2->setCursor(0, 55);
|
||||
u8g2->print(F("Extra blank --> Ok"));
|
||||
disp->setCursor(0, 15);
|
||||
disp->print(F("setFontMode(0);"));
|
||||
disp->setCursor(0, 30);
|
||||
disp->print(F("setFont(.._hr);"));
|
||||
disp->setCursor(0, 55);
|
||||
disp->print(F("Extra blank --> Ok"));
|
||||
|
||||
u8g2->sendBuffer();
|
||||
disp->sendBuffer();
|
||||
delay(INFO_SCREEN_DELAY);
|
||||
|
||||
u8g2->setFontMode(0);
|
||||
u8g2->setFont(u8g2_font_cu12_hr);
|
||||
u8g2->clearBuffer(); // clear the internal memory once
|
||||
disp->setFontMode(0);
|
||||
disp->setFont(u8g2_font_cu12_hr);
|
||||
disp->clearBuffer(); // clear the internal memory once
|
||||
draw(1);
|
||||
}
|
||||
|
||||
|
|
@ -268,16 +268,16 @@ void loop(void)
|
|||
{
|
||||
|
||||
// This problem applies only to full buffer mode
|
||||
u8g2->clearBuffer();
|
||||
u8g2->setFontMode(1);
|
||||
u8g2->setFont(u8g2_font_cu12_tr);
|
||||
u8g2->setCursor(0, 15);
|
||||
u8g2->print(F("Problems with"));
|
||||
u8g2->setCursor(0, 30);
|
||||
u8g2->print(F("full buffer mode"));
|
||||
u8g2->setCursor(0, 45);
|
||||
u8g2->print(F("and skipped clear."));
|
||||
u8g2->sendBuffer();
|
||||
disp->clearBuffer();
|
||||
disp->setFontMode(1);
|
||||
disp->setFont(u8g2_font_cu12_tr);
|
||||
disp->setCursor(0, 15);
|
||||
disp->print(F("Problems with"));
|
||||
disp->setCursor(0, 30);
|
||||
disp->print(F("full buffer mode"));
|
||||
disp->setCursor(0, 45);
|
||||
disp->print(F("and skipped clear."));
|
||||
disp->sendBuffer();
|
||||
delay(INFO_SCREEN_DELAY);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
GraphicsTest.ino
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/disp/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
|
@ -39,80 +39,80 @@
|
|||
|
||||
void u8g2_prepare(void)
|
||||
{
|
||||
u8g2->setFont(u8g2_font_6x10_tf);
|
||||
u8g2->setFontRefHeightExtendedText();
|
||||
u8g2->setDrawColor(1);
|
||||
u8g2->setFontPosTop();
|
||||
u8g2->setFontDirection(0);
|
||||
disp->setFont(u8g2_font_6x10_tf);
|
||||
disp->setFontRefHeightExtendedText();
|
||||
disp->setDrawColor(1);
|
||||
disp->setFontPosTop();
|
||||
disp->setFontDirection(0);
|
||||
}
|
||||
|
||||
void u8g2_box_frame(uint8_t a)
|
||||
{
|
||||
u8g2->drawStr( 0, 0, "drawBox");
|
||||
u8g2->drawBox(5, 10, 20, 10);
|
||||
u8g2->drawBox(10 + a, 15, 30, 7);
|
||||
u8g2->drawStr( 0, 30, "drawFrame");
|
||||
u8g2->drawFrame(5, 10 + 30, 20, 10);
|
||||
u8g2->drawFrame(10 + a, 15 + 30, 30, 7);
|
||||
disp->drawStr( 0, 0, "drawBox");
|
||||
disp->drawBox(5, 10, 20, 10);
|
||||
disp->drawBox(10 + a, 15, 30, 7);
|
||||
disp->drawStr( 0, 30, "drawFrame");
|
||||
disp->drawFrame(5, 10 + 30, 20, 10);
|
||||
disp->drawFrame(10 + a, 15 + 30, 30, 7);
|
||||
}
|
||||
|
||||
void u8g2_disc_circle(uint8_t a)
|
||||
{
|
||||
u8g2->drawStr( 0, 0, "drawDisc");
|
||||
u8g2->drawDisc(10, 18, 9);
|
||||
u8g2->drawDisc(24 + a, 16, 7);
|
||||
u8g2->drawStr( 0, 30, "drawCircle");
|
||||
u8g2->drawCircle(10, 18 + 30, 9);
|
||||
u8g2->drawCircle(24 + a, 16 + 30, 7);
|
||||
disp->drawStr( 0, 0, "drawDisc");
|
||||
disp->drawDisc(10, 18, 9);
|
||||
disp->drawDisc(24 + a, 16, 7);
|
||||
disp->drawStr( 0, 30, "drawCircle");
|
||||
disp->drawCircle(10, 18 + 30, 9);
|
||||
disp->drawCircle(24 + a, 16 + 30, 7);
|
||||
}
|
||||
|
||||
void u8g2_r_frame(uint8_t a)
|
||||
{
|
||||
u8g2->drawStr( 0, 0, "drawRFrame/Box");
|
||||
u8g2->drawRFrame(5, 10, 40, 30, a + 1);
|
||||
u8g2->drawRBox(50, 10, 25, 40, a + 1);
|
||||
disp->drawStr( 0, 0, "drawRFrame/Box");
|
||||
disp->drawRFrame(5, 10, 40, 30, a + 1);
|
||||
disp->drawRBox(50, 10, 25, 40, a + 1);
|
||||
}
|
||||
|
||||
void u8g2_string(uint8_t a)
|
||||
{
|
||||
u8g2->setFontDirection(0);
|
||||
u8g2->drawStr(30 + a, 31, " 0");
|
||||
u8g2->setFontDirection(1);
|
||||
u8g2->drawStr(30, 31 + a, " 90");
|
||||
u8g2->setFontDirection(2);
|
||||
u8g2->drawStr(30 - a, 31, " 180");
|
||||
u8g2->setFontDirection(3);
|
||||
u8g2->drawStr(30, 31 - a, " 270");
|
||||
disp->setFontDirection(0);
|
||||
disp->drawStr(30 + a, 31, " 0");
|
||||
disp->setFontDirection(1);
|
||||
disp->drawStr(30, 31 + a, " 90");
|
||||
disp->setFontDirection(2);
|
||||
disp->drawStr(30 - a, 31, " 180");
|
||||
disp->setFontDirection(3);
|
||||
disp->drawStr(30, 31 - a, " 270");
|
||||
}
|
||||
|
||||
void u8g2_line(uint8_t a)
|
||||
{
|
||||
u8g2->drawStr( 0, 0, "drawLine");
|
||||
u8g2->drawLine(7 + a, 10, 40, 55);
|
||||
u8g2->drawLine(7 + a * 2, 10, 60, 55);
|
||||
u8g2->drawLine(7 + a * 3, 10, 80, 55);
|
||||
u8g2->drawLine(7 + a * 4, 10, 100, 55);
|
||||
disp->drawStr( 0, 0, "drawLine");
|
||||
disp->drawLine(7 + a, 10, 40, 55);
|
||||
disp->drawLine(7 + a * 2, 10, 60, 55);
|
||||
disp->drawLine(7 + a * 3, 10, 80, 55);
|
||||
disp->drawLine(7 + a * 4, 10, 100, 55);
|
||||
}
|
||||
|
||||
void u8g2_triangle(uint8_t a)
|
||||
{
|
||||
uint16_t offset = a;
|
||||
u8g2->drawStr( 0, 0, "drawTriangle");
|
||||
u8g2->drawTriangle(14, 7, 45, 30, 10, 40);
|
||||
u8g2->drawTriangle(14 + offset, 7 - offset, 45 + offset, 30 - offset, 57 + offset, 10 - offset);
|
||||
u8g2->drawTriangle(57 + offset * 2, 10, 45 + offset * 2, 30, 86 + offset * 2, 53);
|
||||
u8g2->drawTriangle(10 + offset, 40 + offset, 45 + offset, 30 + offset, 86 + offset, 53 + offset);
|
||||
disp->drawStr( 0, 0, "drawTriangle");
|
||||
disp->drawTriangle(14, 7, 45, 30, 10, 40);
|
||||
disp->drawTriangle(14 + offset, 7 - offset, 45 + offset, 30 - offset, 57 + offset, 10 - offset);
|
||||
disp->drawTriangle(57 + offset * 2, 10, 45 + offset * 2, 30, 86 + offset * 2, 53);
|
||||
disp->drawTriangle(10 + offset, 40 + offset, 45 + offset, 30 + offset, 86 + offset, 53 + offset);
|
||||
}
|
||||
|
||||
void u8g2_ascii_1()
|
||||
{
|
||||
char s[2] = " ";
|
||||
uint8_t x, y;
|
||||
u8g2->drawStr( 0, 0, "ASCII page 1");
|
||||
disp->drawStr( 0, 0, "ASCII page 1");
|
||||
for ( y = 0; y < 6; y++ ) {
|
||||
for ( x = 0; x < 16; x++ ) {
|
||||
s[0] = y * 16 + x + 32;
|
||||
u8g2->drawStr(x * 7, y * 10 + 10, s);
|
||||
disp->drawStr(x * 7, y * 10 + 10, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -121,33 +121,33 @@ void u8g2_ascii_2()
|
|||
{
|
||||
char s[2] = " ";
|
||||
uint8_t x, y;
|
||||
u8g2->drawStr( 0, 0, "ASCII page 2");
|
||||
disp->drawStr( 0, 0, "ASCII page 2");
|
||||
for ( y = 0; y < 6; y++ ) {
|
||||
for ( x = 0; x < 16; x++ ) {
|
||||
s[0] = y * 16 + x + 160;
|
||||
u8g2->drawStr(x * 7, y * 10 + 10, s);
|
||||
disp->drawStr(x * 7, y * 10 + 10, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void u8g2_extra_page(uint8_t a)
|
||||
{
|
||||
u8g2->drawStr( 0, 0, "Unicode");
|
||||
u8g2->setFont(u8g2_font_unifont_t_symbols);
|
||||
u8g2->setFontPosTop();
|
||||
u8g2->drawUTF8(0, 24, "☀ ☁");
|
||||
disp->drawStr( 0, 0, "Unicode");
|
||||
disp->setFont(u8g2_font_unifont_t_symbols);
|
||||
disp->setFontPosTop();
|
||||
disp->drawUTF8(0, 24, "☀ ☁");
|
||||
switch (a) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
u8g2->drawUTF8(a * 3, 36, "☂");
|
||||
disp->drawUTF8(a * 3, 36, "☂");
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
u8g2->drawUTF8(a * 3, 36, "☔");
|
||||
disp->drawUTF8(a * 3, 36, "☔");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -186,44 +186,44 @@ void u8g2_bitmap_overlay(uint8_t a)
|
|||
{
|
||||
uint8_t frame_size = 28;
|
||||
|
||||
u8g2->drawStr(0, 0, "Bitmap overlay");
|
||||
disp->drawStr(0, 0, "Bitmap overlay");
|
||||
|
||||
u8g2->drawStr(0, frame_size + 12, "Solid / transparent");
|
||||
u8g2->setBitmapMode(false /* solid */);
|
||||
u8g2->drawFrame(0, 10, frame_size, frame_size);
|
||||
u8g2->drawXBMP(2, 12, cross_width, cross_height, cross_bits);
|
||||
disp->drawStr(0, frame_size + 12, "Solid / transparent");
|
||||
disp->setBitmapMode(false /* solid */);
|
||||
disp->drawFrame(0, 10, frame_size, frame_size);
|
||||
disp->drawXBMP(2, 12, cross_width, cross_height, cross_bits);
|
||||
if (a & 4)
|
||||
u8g2->drawXBMP(7, 17, cross_block_width, cross_block_height, cross_block_bits);
|
||||
disp->drawXBMP(7, 17, cross_block_width, cross_block_height, cross_block_bits);
|
||||
|
||||
u8g2->setBitmapMode(true /* transparent*/);
|
||||
u8g2->drawFrame(frame_size + 5, 10, frame_size, frame_size);
|
||||
u8g2->drawXBMP(frame_size + 7, 12, cross_width, cross_height, cross_bits);
|
||||
disp->setBitmapMode(true /* transparent*/);
|
||||
disp->drawFrame(frame_size + 5, 10, frame_size, frame_size);
|
||||
disp->drawXBMP(frame_size + 7, 12, cross_width, cross_height, cross_bits);
|
||||
if (a & 4)
|
||||
u8g2->drawXBMP(frame_size + 12, 17, cross_block_width, cross_block_height, cross_block_bits);
|
||||
disp->drawXBMP(frame_size + 12, 17, cross_block_width, cross_block_height, cross_block_bits);
|
||||
}
|
||||
|
||||
void u8g2_bitmap_modes(uint8_t transparent)
|
||||
{
|
||||
const uint8_t frame_size = 24;
|
||||
|
||||
u8g2->drawBox(0, frame_size * 0.5, frame_size * 5, frame_size);
|
||||
u8g2->drawStr(frame_size * 0.5, 50, "Black");
|
||||
u8g2->drawStr(frame_size * 2, 50, "White");
|
||||
u8g2->drawStr(frame_size * 3.5, 50, "XOR");
|
||||
disp->drawBox(0, frame_size * 0.5, frame_size * 5, frame_size);
|
||||
disp->drawStr(frame_size * 0.5, 50, "Black");
|
||||
disp->drawStr(frame_size * 2, 50, "White");
|
||||
disp->drawStr(frame_size * 3.5, 50, "XOR");
|
||||
|
||||
if (!transparent) {
|
||||
u8g2->setBitmapMode(false /* solid */);
|
||||
u8g2->drawStr(0, 0, "Solid bitmap");
|
||||
disp->setBitmapMode(false /* solid */);
|
||||
disp->drawStr(0, 0, "Solid bitmap");
|
||||
} else {
|
||||
u8g2->setBitmapMode(true /* transparent*/);
|
||||
u8g2->drawStr(0, 0, "Transparent bitmap");
|
||||
disp->setBitmapMode(true /* transparent*/);
|
||||
disp->drawStr(0, 0, "Transparent bitmap");
|
||||
}
|
||||
u8g2->setDrawColor(0);// Black
|
||||
u8g2->drawXBMP(frame_size * 0.5, 24, cross_width, cross_height, cross_bits);
|
||||
u8g2->setDrawColor(1); // White
|
||||
u8g2->drawXBMP(frame_size * 2, 24, cross_width, cross_height, cross_bits);
|
||||
u8g2->setDrawColor(2); // XOR
|
||||
u8g2->drawXBMP(frame_size * 3.5, 24, cross_width, cross_height, cross_bits);
|
||||
disp->setDrawColor(0);// Black
|
||||
disp->drawXBMP(frame_size * 0.5, 24, cross_width, cross_height, cross_bits);
|
||||
disp->setDrawColor(1); // White
|
||||
disp->drawXBMP(frame_size * 2, 24, cross_width, cross_height, cross_bits);
|
||||
disp->setDrawColor(2); // XOR
|
||||
disp->drawXBMP(frame_size * 3.5, 24, cross_width, cross_height, cross_bits);
|
||||
}
|
||||
|
||||
uint8_t draw_state = 0;
|
||||
|
|
@ -251,7 +251,7 @@ void draw(void)
|
|||
void setup(void)
|
||||
{
|
||||
setupBoards();
|
||||
if (!u8g2) {
|
||||
if (!disp) {
|
||||
Serial.println("No find SH1106 display!Please check whether the connection is normal");
|
||||
while (1);
|
||||
}
|
||||
|
|
@ -260,9 +260,9 @@ void setup(void)
|
|||
void loop(void)
|
||||
{
|
||||
// picture loop
|
||||
u8g2->clearBuffer();
|
||||
disp->clearBuffer();
|
||||
draw();
|
||||
u8g2->sendBuffer();
|
||||
disp->sendBuffer();
|
||||
|
||||
// increase the state
|
||||
draw_state++;
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
This is an interactive demo and requires "next", "prev" and "select" button.
|
||||
Minimum height of the display should be 64.
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/disp/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
|
@ -42,11 +42,11 @@
|
|||
void setup(void)
|
||||
{
|
||||
setupBoards();
|
||||
if (!u8g2) {
|
||||
if (!disp) {
|
||||
Serial.println("No find SH1106 display!Please check whether the connection is normal");
|
||||
while (1);
|
||||
}
|
||||
u8g2->setFont(u8g2_font_6x12_tr);
|
||||
disp->setFont(u8g2_font_6x12_tr);
|
||||
}
|
||||
|
||||
struct menu_entry_type {
|
||||
|
|
@ -89,28 +89,28 @@ void draw(struct menu_state *state)
|
|||
x = state->menu_start;
|
||||
i = 0;
|
||||
while ( menu_entry_list[i].icon > 0 ) {
|
||||
if ( x >= -ICON_WIDTH && x < u8g2->getDisplayWidth() ) {
|
||||
u8g2->setFont(menu_entry_list[i].font);
|
||||
u8g2->drawGlyph(x, ICON_Y, menu_entry_list[i].icon );
|
||||
if ( x >= -ICON_WIDTH && x < disp->getDisplayWidth() ) {
|
||||
disp->setFont(menu_entry_list[i].font);
|
||||
disp->drawGlyph(x, ICON_Y, menu_entry_list[i].icon );
|
||||
}
|
||||
i++;
|
||||
x += ICON_WIDTH + ICON_GAP;
|
||||
}
|
||||
u8g2->drawFrame(state->frame_position - 1, ICON_Y - ICON_HEIGHT - 1, ICON_WIDTH + 2, ICON_WIDTH + 2);
|
||||
u8g2->drawFrame(state->frame_position - 2, ICON_Y - ICON_HEIGHT - 2, ICON_WIDTH + 4, ICON_WIDTH + 4);
|
||||
u8g2->drawFrame(state->frame_position - 3, ICON_Y - ICON_HEIGHT - 3, ICON_WIDTH + 6, ICON_WIDTH + 6);
|
||||
disp->drawFrame(state->frame_position - 1, ICON_Y - ICON_HEIGHT - 1, ICON_WIDTH + 2, ICON_WIDTH + 2);
|
||||
disp->drawFrame(state->frame_position - 2, ICON_Y - ICON_HEIGHT - 2, ICON_WIDTH + 4, ICON_WIDTH + 4);
|
||||
disp->drawFrame(state->frame_position - 3, ICON_Y - ICON_HEIGHT - 3, ICON_WIDTH + 6, ICON_WIDTH + 6);
|
||||
}
|
||||
|
||||
|
||||
void to_right(struct menu_state *state)
|
||||
{
|
||||
if ( menu_entry_list[state->position + 1].font != NULL ) {
|
||||
if ( (int16_t)state->frame_position + 2 * (int16_t)ICON_WIDTH + (int16_t)ICON_BGAP < (int16_t)u8g2->getDisplayWidth() ) {
|
||||
if ( (int16_t)state->frame_position + 2 * (int16_t)ICON_WIDTH + (int16_t)ICON_BGAP < (int16_t)disp->getDisplayWidth() ) {
|
||||
state->position++;
|
||||
state->frame_position += ICON_WIDTH + (int16_t)ICON_GAP;
|
||||
} else {
|
||||
state->position++;
|
||||
state->frame_position = (int16_t)u8g2->getDisplayWidth() - (int16_t)ICON_WIDTH - (int16_t)ICON_BGAP;
|
||||
state->frame_position = (int16_t)disp->getDisplayWidth() - (int16_t)ICON_WIDTH - (int16_t)ICON_BGAP;
|
||||
state->menu_start = state->frame_position - state->position * ((int16_t)ICON_WIDTH + (int16_t)ICON_GAP);
|
||||
}
|
||||
}
|
||||
|
|
@ -164,21 +164,21 @@ void loop(void)
|
|||
int8_t event;
|
||||
|
||||
do {
|
||||
u8g2->clearBuffer();
|
||||
disp->clearBuffer();
|
||||
draw(¤t_state);
|
||||
u8g2->setFont(u8g2_font_helvB10_tr);
|
||||
u8g2->setCursor((u8g2->getDisplayWidth() - u8g2->getStrWidth(menu_entry_list[destination_state.position].name)) / 2, u8g2->getDisplayHeight() - 5);
|
||||
u8g2->print(menu_entry_list[destination_state.position].name);
|
||||
u8g2->sendBuffer();
|
||||
disp->setFont(u8g2_font_helvB10_tr);
|
||||
disp->setCursor((disp->getDisplayWidth() - disp->getStrWidth(menu_entry_list[destination_state.position].name)) / 2, disp->getDisplayHeight() - 5);
|
||||
disp->print(menu_entry_list[destination_state.position].name);
|
||||
disp->sendBuffer();
|
||||
delay(10);
|
||||
event = u8g2->getMenuEvent();
|
||||
event = disp->getMenuEvent();
|
||||
if ( event == U8X8_MSG_GPIO_MENU_NEXT )
|
||||
to_right(&destination_state);
|
||||
if ( event == U8X8_MSG_GPIO_MENU_PREV )
|
||||
to_left(&destination_state);
|
||||
if ( event == U8X8_MSG_GPIO_MENU_SELECT ) {
|
||||
u8g2->setFont(u8g2_font_helvB10_tr);
|
||||
u8g2->userInterfaceMessage("Selection:", menu_entry_list[destination_state.position].name, "", " Ok ");
|
||||
disp->setFont(u8g2_font_helvB10_tr);
|
||||
disp->userInterfaceMessage("Selection:", menu_entry_list[destination_state.position].name, "", " Ok ");
|
||||
}
|
||||
} while ( towards(¤t_state, &destination_state) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
PrintUTF8.ino
|
||||
|
||||
Use the (Arduino compatible) u8g2 function "print" to draw a text.
|
||||
Use the (Arduino compatible) disp function "print" to draw a text.
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/disp/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
|
@ -42,23 +42,23 @@
|
|||
void setup(void)
|
||||
{
|
||||
setupBoards();
|
||||
if (!u8g2) {
|
||||
if (!disp) {
|
||||
Serial.println("No find SH1106 display!Please check whether the connection is normal");
|
||||
while (1);
|
||||
}
|
||||
u8g2->enableUTF8Print(); // enable UTF8 support for the Arduino print() function
|
||||
disp->enableUTF8Print(); // enable UTF8 support for the Arduino print() function
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
u8g2->setFont(u8g2_font_unifont_t_chinese2); // use chinese2 for all the glyphs of "你好世界"
|
||||
u8g2->setFontDirection(0);
|
||||
u8g2->clearBuffer();
|
||||
u8g2->setCursor(0, 15);
|
||||
u8g2->print("Hello World!");
|
||||
u8g2->setCursor(0, 40);
|
||||
u8g2->print("你好世界"); // Chinese "Hello World"
|
||||
u8g2->sendBuffer();
|
||||
disp->setFont(u8g2_font_unifont_t_chinese2); // use chinese2 for all the glyphs of "你好世界"
|
||||
disp->setFontDirection(0);
|
||||
disp->clearBuffer();
|
||||
disp->setCursor(0, 15);
|
||||
disp->print("Hello World!");
|
||||
disp->setCursor(0, 40);
|
||||
disp->print("你好世界"); // Chinese "Hello World"
|
||||
disp->sendBuffer();
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -447,24 +447,24 @@ void loop()
|
|||
|
||||
void drawMain()
|
||||
{
|
||||
if (u8g2) {
|
||||
u8g2->clearBuffer();
|
||||
u8g2->drawRFrame(0, 0, 128, 64, 5);
|
||||
u8g2->setFont(u8g2_font_pxplusibmvga8_mr);
|
||||
u8g2->setCursor(15, 20);
|
||||
u8g2->print("RX:");
|
||||
u8g2->setCursor(15, 35);
|
||||
u8g2->print("SNR:");
|
||||
u8g2->setCursor(15, 50);
|
||||
u8g2->print("RSSI:");
|
||||
if (disp) {
|
||||
disp->clearBuffer();
|
||||
disp->drawRFrame(0, 0, 128, 64, 5);
|
||||
disp->setFont(u8g2_font_pxplusibmvga8_mr);
|
||||
disp->setCursor(15, 20);
|
||||
disp->print("RX:");
|
||||
disp->setCursor(15, 35);
|
||||
disp->print("SNR:");
|
||||
disp->setCursor(15, 50);
|
||||
disp->print("RSSI:");
|
||||
|
||||
u8g2->setFont(u8g2_font_crox1h_tr);
|
||||
u8g2->setCursor( U8G2_HOR_ALIGN_RIGHT(payload.c_str()) - 21, 20 );
|
||||
u8g2->print(payload);
|
||||
u8g2->setCursor( U8G2_HOR_ALIGN_RIGHT(snr.c_str()) - 21, 35 );
|
||||
u8g2->print(snr);
|
||||
u8g2->setCursor( U8G2_HOR_ALIGN_RIGHT(rssi.c_str()) - 21, 50 );
|
||||
u8g2->print(rssi);
|
||||
u8g2->sendBuffer();
|
||||
disp->setFont(u8g2_font_crox1h_tr);
|
||||
disp->setCursor( U8G2_HOR_ALIGN_RIGHT(payload.c_str()) - 21, 20 );
|
||||
disp->print(payload);
|
||||
disp->setCursor( U8G2_HOR_ALIGN_RIGHT(snr.c_str()) - 21, 35 );
|
||||
disp->print(snr);
|
||||
disp->setCursor( U8G2_HOR_ALIGN_RIGHT(rssi.c_str()) - 21, 50 );
|
||||
disp->print(rssi);
|
||||
disp->sendBuffer();
|
||||
}
|
||||
}
|
||||
|
|
@ -67,9 +67,9 @@ void setup()
|
|||
delay(1000);
|
||||
} else {
|
||||
Serial.println(F("No device responding"));
|
||||
u8g2->clearBuffer();
|
||||
u8g2->drawStr(0, 12, "No device responding");
|
||||
u8g2->sendBuffer();
|
||||
disp->clearBuffer();
|
||||
disp->drawStr(0, 12, "No device responding");
|
||||
disp->sendBuffer();
|
||||
while (1) {
|
||||
led_Flash(50, 50); //long fast speed flash indicates device error
|
||||
}
|
||||
|
|
@ -89,19 +89,19 @@ void setup()
|
|||
Serial.println();
|
||||
|
||||
#ifdef ENABLEDISPLAY
|
||||
if (u8g2) {
|
||||
if (disp) {
|
||||
Serial.println("Display Enabled");
|
||||
u8g2->setFont(u8g2_font_unifont_t_chinese2); // use chinese2 for all the glyphs of "你好世界"
|
||||
u8g2->setFontDirection(0);
|
||||
disp->setFont(u8g2_font_unifont_t_chinese2); // use chinese2 for all the glyphs of "你好世界"
|
||||
disp->setFontDirection(0);
|
||||
char buf[256];
|
||||
u8g2->clearBuffer();
|
||||
u8g2->drawStr(0, 12, "Ranging RAW Ready");
|
||||
disp->clearBuffer();
|
||||
disp->drawStr(0, 12, "Ranging RAW Ready");
|
||||
snprintf(buf, sizeof(buf), "Power:%.d dBm", RangingTXPower);
|
||||
u8g2->drawStr(0, 12 * 2, buf);
|
||||
disp->drawStr(0, 12 * 2, buf);
|
||||
snprintf(buf, sizeof(buf), "Cal: %d ", Calibration);
|
||||
u8g2->drawStr(0, 12 * 3, buf);
|
||||
disp->drawStr(0, 12 * 3, buf);
|
||||
snprintf(buf, sizeof(buf), "Adjust: %d ", distance_adjustment);
|
||||
u8g2->sendBuffer();
|
||||
disp->sendBuffer();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -176,19 +176,19 @@ void loop()
|
|||
Serial.print(distance_average, 1);
|
||||
|
||||
#ifdef ENABLEDISPLAY
|
||||
if (u8g2) {
|
||||
u8g2->clearBuffer();
|
||||
if (disp) {
|
||||
disp->clearBuffer();
|
||||
char buf[256];
|
||||
u8g2->drawStr(0, 12, "Rang_Master");
|
||||
disp->drawStr(0, 12, "Rang_Master");
|
||||
snprintf(buf, sizeof(buf), "Distance:%.2f m", distance_average);
|
||||
u8g2->drawStr(0, 12 * 2, buf);
|
||||
disp->drawStr(0, 12 * 2, buf);
|
||||
snprintf(buf, sizeof(buf), "RSSI: %d dBm", RangingRSSI);
|
||||
u8g2->drawStr(0, 12 * 3, buf);
|
||||
disp->drawStr(0, 12 * 3, buf);
|
||||
// snprintf(buf, sizeof(buf), "OK: %d ", rangeings_valid);
|
||||
// u8g2->drawStr(0, 12 * 4, buf);
|
||||
// disp->drawStr(0, 12 * 4, buf);
|
||||
// snprintf(buf, sizeof(buf), "Err: %d ", rangeing_errors);
|
||||
// u8g2->drawStr(0, 12 * 5, buf);
|
||||
u8g2->sendBuffer();
|
||||
// disp->drawStr(0, 12 * 5, buf);
|
||||
disp->sendBuffer();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#ifdef HAS_DISPLAY
|
||||
#include <U8g2lib.h>
|
||||
U8G2_SSD1306_128X64_NONAME_F_HW_I2C *u8g2 = nullptr;
|
||||
U8G2_SSD1306_128X64_NONAME_F_HW_I2C *disp = nullptr;
|
||||
#endif
|
||||
|
||||
Ticker ledTicker;
|
||||
|
|
@ -144,68 +144,68 @@ void initBoard()
|
|||
Wire.beginTransmission(0x3C);
|
||||
if (Wire.endTransmission() == 0) {
|
||||
Serial.println("Started OLED");
|
||||
u8g2 = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0, U8X8_PIN_NONE);
|
||||
u8g2->begin();
|
||||
u8g2->clearBuffer();
|
||||
u8g2->setFlipMode(0);
|
||||
u8g2->setFontMode(1); // Transparent
|
||||
u8g2->setDrawColor(1);
|
||||
u8g2->setFontDirection(0);
|
||||
u8g2->firstPage();
|
||||
disp = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0, U8X8_PIN_NONE);
|
||||
disp->begin();
|
||||
disp->clearBuffer();
|
||||
disp->setFlipMode(0);
|
||||
disp->setFontMode(1); // Transparent
|
||||
disp->setDrawColor(1);
|
||||
disp->setFontDirection(0);
|
||||
disp->firstPage();
|
||||
do {
|
||||
u8g2->setFont(u8g2_font_inb19_mr);
|
||||
u8g2->drawStr(0, 30, "LilyGo");
|
||||
u8g2->drawHLine(2, 35, 47);
|
||||
u8g2->drawHLine(3, 36, 47);
|
||||
u8g2->drawVLine(45, 32, 12);
|
||||
u8g2->drawVLine(46, 33, 12);
|
||||
u8g2->setFont(u8g2_font_inb19_mf);
|
||||
u8g2->drawStr(58, 60, "LoRa");
|
||||
} while ( u8g2->nextPage() );
|
||||
u8g2->sendBuffer();
|
||||
u8g2->setFont(u8g2_font_fur11_tf);
|
||||
disp->setFont(u8g2_font_inb19_mr);
|
||||
disp->drawStr(0, 30, "LilyGo");
|
||||
disp->drawHLine(2, 35, 47);
|
||||
disp->drawHLine(3, 36, 47);
|
||||
disp->drawVLine(45, 32, 12);
|
||||
disp->drawVLine(46, 33, 12);
|
||||
disp->setFont(u8g2_font_inb19_mf);
|
||||
disp->drawStr(58, 60, "LoRa");
|
||||
} while ( disp->nextPage() );
|
||||
disp->sendBuffer();
|
||||
disp->setFont(u8g2_font_fur11_tf);
|
||||
delay(3000);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAS_SDCARD
|
||||
if (u8g2) {
|
||||
u8g2->setFont(u8g2_font_ncenB08_tr);
|
||||
if (disp) {
|
||||
disp->setFont(u8g2_font_ncenB08_tr);
|
||||
}
|
||||
pinMode(SDCARD_MISO, INPUT_PULLUP);
|
||||
SDSPI.begin(SDCARD_SCLK, SDCARD_MISO, SDCARD_MOSI, SDCARD_CS);
|
||||
if (u8g2) {
|
||||
u8g2->clearBuffer();
|
||||
if (disp) {
|
||||
disp->clearBuffer();
|
||||
}
|
||||
|
||||
if (!SD.begin(SDCARD_CS, SDSPI)) {
|
||||
|
||||
Serial.println("setupSDCard FAIL");
|
||||
if (u8g2) {
|
||||
if (disp) {
|
||||
do {
|
||||
u8g2->setCursor(0, 16);
|
||||
u8g2->println( "SDCard FAILED");;
|
||||
} while ( u8g2->nextPage() );
|
||||
disp->setCursor(0, 16);
|
||||
disp->println( "SDCard FAILED");;
|
||||
} while ( disp->nextPage() );
|
||||
}
|
||||
|
||||
} else {
|
||||
uint32_t cardSize = SD.cardSize() / (1024 * 1024);
|
||||
if (u8g2) {
|
||||
if (disp) {
|
||||
do {
|
||||
u8g2->setCursor(0, 16);
|
||||
u8g2->print( "SDCard:");;
|
||||
u8g2->print(cardSize / 1024.0);;
|
||||
u8g2->println(" GB");;
|
||||
} while ( u8g2->nextPage() );
|
||||
disp->setCursor(0, 16);
|
||||
disp->print( "SDCard:");;
|
||||
disp->print(cardSize / 1024.0);;
|
||||
disp->println(" GB");;
|
||||
} while ( disp->nextPage() );
|
||||
}
|
||||
|
||||
Serial.print("setupSDCard PASS . SIZE = ");
|
||||
Serial.print(cardSize / 1024.0);
|
||||
Serial.println(" GB");
|
||||
}
|
||||
if (u8g2) {
|
||||
u8g2->sendBuffer();
|
||||
if (disp) {
|
||||
disp->sendBuffer();
|
||||
}
|
||||
delay(3000);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -67,10 +67,10 @@ void setup()
|
|||
Serial.println(LT.getSetCalibrationValue()); //reads the calibratuion value currently set
|
||||
delay(2000);
|
||||
|
||||
if (u8g2) {
|
||||
u8g2->clearBuffer();
|
||||
u8g2->drawStr(0, 12, "Rang_Slave");
|
||||
u8g2->sendBuffer();
|
||||
if (disp) {
|
||||
disp->clearBuffer();
|
||||
disp->drawStr(0, 12, "Rang_Slave");
|
||||
disp->sendBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#ifdef HAS_DISPLAY
|
||||
#include <U8g2lib.h>
|
||||
U8G2_SSD1306_128X64_NONAME_F_HW_I2C *u8g2 = nullptr;
|
||||
U8G2_SSD1306_128X64_NONAME_F_HW_I2C *disp = nullptr;
|
||||
#endif
|
||||
|
||||
Ticker ledTicker;
|
||||
|
|
@ -144,68 +144,68 @@ void initBoard()
|
|||
Wire.beginTransmission(0x3C);
|
||||
if (Wire.endTransmission() == 0) {
|
||||
Serial.println("Started OLED");
|
||||
u8g2 = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0, U8X8_PIN_NONE);
|
||||
u8g2->begin();
|
||||
u8g2->clearBuffer();
|
||||
u8g2->setFlipMode(0);
|
||||
u8g2->setFontMode(1); // Transparent
|
||||
u8g2->setDrawColor(1);
|
||||
u8g2->setFontDirection(0);
|
||||
u8g2->firstPage();
|
||||
disp = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0, U8X8_PIN_NONE);
|
||||
disp->begin();
|
||||
disp->clearBuffer();
|
||||
disp->setFlipMode(0);
|
||||
disp->setFontMode(1); // Transparent
|
||||
disp->setDrawColor(1);
|
||||
disp->setFontDirection(0);
|
||||
disp->firstPage();
|
||||
do {
|
||||
u8g2->setFont(u8g2_font_inb19_mr);
|
||||
u8g2->drawStr(0, 30, "LilyGo");
|
||||
u8g2->drawHLine(2, 35, 47);
|
||||
u8g2->drawHLine(3, 36, 47);
|
||||
u8g2->drawVLine(45, 32, 12);
|
||||
u8g2->drawVLine(46, 33, 12);
|
||||
u8g2->setFont(u8g2_font_inb19_mf);
|
||||
u8g2->drawStr(58, 60, "LoRa");
|
||||
} while ( u8g2->nextPage() );
|
||||
u8g2->sendBuffer();
|
||||
u8g2->setFont(u8g2_font_fur11_tf);
|
||||
disp->setFont(u8g2_font_inb19_mr);
|
||||
disp->drawStr(0, 30, "LilyGo");
|
||||
disp->drawHLine(2, 35, 47);
|
||||
disp->drawHLine(3, 36, 47);
|
||||
disp->drawVLine(45, 32, 12);
|
||||
disp->drawVLine(46, 33, 12);
|
||||
disp->setFont(u8g2_font_inb19_mf);
|
||||
disp->drawStr(58, 60, "LoRa");
|
||||
} while ( disp->nextPage() );
|
||||
disp->sendBuffer();
|
||||
disp->setFont(u8g2_font_fur11_tf);
|
||||
delay(3000);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAS_SDCARD
|
||||
if (u8g2) {
|
||||
u8g2->setFont(u8g2_font_ncenB08_tr);
|
||||
if (disp) {
|
||||
disp->setFont(u8g2_font_ncenB08_tr);
|
||||
}
|
||||
pinMode(SDCARD_MISO, INPUT_PULLUP);
|
||||
SDSPI.begin(SDCARD_SCLK, SDCARD_MISO, SDCARD_MOSI, SDCARD_CS);
|
||||
if (u8g2) {
|
||||
u8g2->clearBuffer();
|
||||
if (disp) {
|
||||
disp->clearBuffer();
|
||||
}
|
||||
|
||||
if (!SD.begin(SDCARD_CS, SDSPI)) {
|
||||
|
||||
Serial.println("setupSDCard FAIL");
|
||||
if (u8g2) {
|
||||
if (disp) {
|
||||
do {
|
||||
u8g2->setCursor(0, 16);
|
||||
u8g2->println( "SDCard FAILED");;
|
||||
} while ( u8g2->nextPage() );
|
||||
disp->setCursor(0, 16);
|
||||
disp->println( "SDCard FAILED");;
|
||||
} while ( disp->nextPage() );
|
||||
}
|
||||
|
||||
} else {
|
||||
uint32_t cardSize = SD.cardSize() / (1024 * 1024);
|
||||
if (u8g2) {
|
||||
if (disp) {
|
||||
do {
|
||||
u8g2->setCursor(0, 16);
|
||||
u8g2->print( "SDCard:");;
|
||||
u8g2->print(cardSize / 1024.0);;
|
||||
u8g2->println(" GB");;
|
||||
} while ( u8g2->nextPage() );
|
||||
disp->setCursor(0, 16);
|
||||
disp->print( "SDCard:");;
|
||||
disp->print(cardSize / 1024.0);;
|
||||
disp->println(" GB");;
|
||||
} while ( disp->nextPage() );
|
||||
}
|
||||
|
||||
Serial.print("setupSDCard PASS . SIZE = ");
|
||||
Serial.print(cardSize / 1024.0);
|
||||
Serial.println(" GB");
|
||||
}
|
||||
if (u8g2) {
|
||||
u8g2->sendBuffer();
|
||||
if (disp) {
|
||||
disp->sendBuffer();
|
||||
}
|
||||
delay(3000);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -100,23 +100,23 @@ void loop()
|
|||
|
||||
}
|
||||
|
||||
if (u8g2) {
|
||||
u8g2->clearBuffer();
|
||||
u8g2->drawRFrame(0, 0, 128, 64, 5);
|
||||
if (disp) {
|
||||
disp->clearBuffer();
|
||||
disp->drawRFrame(0, 0, 128, 64, 5);
|
||||
|
||||
u8g2->setFont(u8g2_font_pxplusibmvga8_mr);
|
||||
u8g2->setCursor(22, 25);
|
||||
u8g2->print("Meters(raw):");
|
||||
u8g2->setCursor(22, 40);
|
||||
u8g2->print("STATE:");
|
||||
disp->setFont(u8g2_font_pxplusibmvga8_mr);
|
||||
disp->setCursor(22, 25);
|
||||
disp->print("Meters(raw):");
|
||||
disp->setCursor(22, 40);
|
||||
disp->print("STATE:");
|
||||
|
||||
u8g2->setFont(u8g2_font_crox1h_tr);
|
||||
u8g2->setCursor( U8G2_HOR_ALIGN_RIGHT(result.c_str()) - 21, 25 );
|
||||
u8g2->print(result);
|
||||
disp->setFont(u8g2_font_crox1h_tr);
|
||||
disp->setCursor( U8G2_HOR_ALIGN_RIGHT(result.c_str()) - 21, 25 );
|
||||
disp->print(result);
|
||||
String state = state == RADIOLIB_ERR_NONE ? "NONE" : String(state);
|
||||
u8g2->setCursor( U8G2_HOR_ALIGN_RIGHT(state.c_str()) - 21, 40 );
|
||||
u8g2->print(state);
|
||||
u8g2->sendBuffer();
|
||||
disp->setCursor( U8G2_HOR_ALIGN_RIGHT(state.c_str()) - 21, 40 );
|
||||
disp->print(state);
|
||||
disp->sendBuffer();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -437,22 +437,22 @@ void loop()
|
|||
|
||||
void drawMain()
|
||||
{
|
||||
if (u8g2) {
|
||||
u8g2->clearBuffer();
|
||||
u8g2->drawRFrame(0, 0, 128, 64, 5);
|
||||
if (disp) {
|
||||
disp->clearBuffer();
|
||||
disp->drawRFrame(0, 0, 128, 64, 5);
|
||||
|
||||
u8g2->setFont(u8g2_font_pxplusibmvga8_mr);
|
||||
u8g2->setCursor(22, 25);
|
||||
u8g2->print("TX:");
|
||||
u8g2->setCursor(22, 40);
|
||||
u8g2->print("STATE:");
|
||||
disp->setFont(u8g2_font_pxplusibmvga8_mr);
|
||||
disp->setCursor(22, 25);
|
||||
disp->print("TX:");
|
||||
disp->setCursor(22, 40);
|
||||
disp->print("STATE:");
|
||||
|
||||
u8g2->setFont(u8g2_font_crox1h_tr);
|
||||
u8g2->setCursor( U8G2_HOR_ALIGN_RIGHT(payload.c_str()) - 21, 25 );
|
||||
u8g2->print(payload);
|
||||
disp->setFont(u8g2_font_crox1h_tr);
|
||||
disp->setCursor( U8G2_HOR_ALIGN_RIGHT(payload.c_str()) - 21, 25 );
|
||||
disp->print(payload);
|
||||
String state = transmissionState == RADIOLIB_ERR_NONE ? "NONE" : String(transmissionState);
|
||||
u8g2->setCursor( U8G2_HOR_ALIGN_RIGHT(state.c_str()) - 21, 40 );
|
||||
u8g2->print(state);
|
||||
u8g2->sendBuffer();
|
||||
disp->setCursor( U8G2_HOR_ALIGN_RIGHT(state.c_str()) - 21, 40 );
|
||||
disp->print(state);
|
||||
disp->sendBuffer();
|
||||
}
|
||||
}
|
||||
|
|
@ -39,12 +39,12 @@ void setup()
|
|||
|
||||
if (! bme.begin(0x77, &Wire)) {
|
||||
Serial.println("Could not find a valid BME280 sensor, check wiring!");
|
||||
if (u8g2) {
|
||||
u8g2->setFont(u8g2_font_ncenB08_tr);
|
||||
u8g2->clearBuffer();
|
||||
u8g2->setCursor(0, 16);
|
||||
u8g2->print("BME280 Could not find");
|
||||
u8g2->sendBuffer();
|
||||
if (disp) {
|
||||
disp->setFont(u8g2_font_ncenB08_tr);
|
||||
disp->clearBuffer();
|
||||
disp->setCursor(0, 16);
|
||||
disp->print("BME280 Could not find");
|
||||
disp->sendBuffer();
|
||||
}
|
||||
while (1);
|
||||
}
|
||||
|
|
@ -165,32 +165,32 @@ void printValues()
|
|||
|
||||
Serial.println();
|
||||
|
||||
if (u8g2) {
|
||||
u8g2->setFont(u8g2_font_ncenB08_tr);
|
||||
u8g2->clearBuffer();
|
||||
if (disp) {
|
||||
disp->setFont(u8g2_font_ncenB08_tr);
|
||||
disp->clearBuffer();
|
||||
|
||||
u8g2->setCursor(0, 16);
|
||||
disp->setCursor(0, 16);
|
||||
|
||||
u8g2->print("Temperature:");
|
||||
u8g2->print(bme.readTemperature());
|
||||
u8g2->print(" *C");
|
||||
disp->print("Temperature:");
|
||||
disp->print(bme.readTemperature());
|
||||
disp->print(" *C");
|
||||
|
||||
u8g2->setCursor(0, 32);
|
||||
u8g2->print("Pressure:");
|
||||
u8g2->println(bme.readPressure() / 100.0F);
|
||||
u8g2->print(" hPa");
|
||||
disp->setCursor(0, 32);
|
||||
disp->print("Pressure:");
|
||||
disp->println(bme.readPressure() / 100.0F);
|
||||
disp->print(" hPa");
|
||||
|
||||
u8g2->setCursor(0, 48);
|
||||
u8g2->print("Altitude:");
|
||||
u8g2->println(bme.readAltitude(SEALEVELPRESSURE_HPA));
|
||||
u8g2->print(" m");
|
||||
disp->setCursor(0, 48);
|
||||
disp->print("Altitude:");
|
||||
disp->println(bme.readAltitude(SEALEVELPRESSURE_HPA));
|
||||
disp->print(" m");
|
||||
|
||||
u8g2->setCursor(0, 64);
|
||||
u8g2->print("Humidity:");
|
||||
u8g2->println(bme.readHumidity());
|
||||
u8g2->print(" %");
|
||||
disp->setCursor(0, 64);
|
||||
disp->print("Humidity:");
|
||||
disp->println(bme.readHumidity());
|
||||
disp->print(" %");
|
||||
|
||||
u8g2->sendBuffer();
|
||||
disp->sendBuffer();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -49,12 +49,12 @@ void setup()
|
|||
Serial.print(" ID of 0x56-0x58 represents a BMP 280,\n");
|
||||
Serial.print(" ID of 0x60 represents a BME 280.\n");
|
||||
Serial.print(" ID of 0x61 represents a BME 680.\n");
|
||||
if (u8g2) {
|
||||
u8g2->setFont(u8g2_font_ncenB08_tr);
|
||||
u8g2->clearBuffer();
|
||||
u8g2->setCursor(0, 16);
|
||||
u8g2->print("BME280 Could not find");
|
||||
u8g2->sendBuffer();
|
||||
if (disp) {
|
||||
disp->setFont(u8g2_font_ncenB08_tr);
|
||||
disp->clearBuffer();
|
||||
disp->setCursor(0, 16);
|
||||
disp->print("BME280 Could not find");
|
||||
disp->sendBuffer();
|
||||
}
|
||||
while (1) delay(10);
|
||||
}
|
||||
|
|
@ -94,31 +94,31 @@ void printValues()
|
|||
|
||||
Serial.println();
|
||||
|
||||
if (u8g2) {
|
||||
u8g2->setFont(u8g2_font_ncenB08_tr);
|
||||
u8g2->clearBuffer();
|
||||
if (disp) {
|
||||
disp->setFont(u8g2_font_ncenB08_tr);
|
||||
disp->clearBuffer();
|
||||
|
||||
u8g2->setCursor(0, 16);
|
||||
disp->setCursor(0, 16);
|
||||
|
||||
u8g2->print("Temperature:");
|
||||
u8g2->print(bme.readTemperature());
|
||||
u8g2->print(" *C");
|
||||
disp->print("Temperature:");
|
||||
disp->print(bme.readTemperature());
|
||||
disp->print(" *C");
|
||||
|
||||
u8g2->setCursor(0, 32);
|
||||
u8g2->print("Pressure:");
|
||||
u8g2->println(bme.readPressure() / 100.0F);
|
||||
u8g2->print(" hPa");
|
||||
disp->setCursor(0, 32);
|
||||
disp->print("Pressure:");
|
||||
disp->println(bme.readPressure() / 100.0F);
|
||||
disp->print(" hPa");
|
||||
|
||||
u8g2->setCursor(0, 48);
|
||||
u8g2->print("Altitude:");
|
||||
u8g2->println(bme.readAltitude(SEALEVELPRESSURE_HPA));
|
||||
u8g2->print(" m");
|
||||
disp->setCursor(0, 48);
|
||||
disp->print("Altitude:");
|
||||
disp->println(bme.readAltitude(SEALEVELPRESSURE_HPA));
|
||||
disp->print(" m");
|
||||
|
||||
u8g2->setCursor(0, 64);
|
||||
u8g2->print("Humidity:");
|
||||
u8g2->println(bme.readHumidity());
|
||||
u8g2->print(" %");
|
||||
disp->setCursor(0, 64);
|
||||
disp->print("Humidity:");
|
||||
disp->println(bme.readHumidity());
|
||||
disp->print(" %");
|
||||
|
||||
u8g2->sendBuffer();
|
||||
disp->sendBuffer();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@ void setup()
|
|||
|
||||
if (!bme.begin()) {
|
||||
Serial.println(F("Could not find a valid BME280 sensor, check wiring!"));
|
||||
if (u8g2) {
|
||||
u8g2->setFont(u8g2_font_ncenB08_tr);
|
||||
u8g2->clearBuffer();
|
||||
u8g2->setCursor(0, 16);
|
||||
u8g2->print("BME280 Could not find");
|
||||
u8g2->sendBuffer();
|
||||
if (disp) {
|
||||
disp->setFont(u8g2_font_ncenB08_tr);
|
||||
disp->clearBuffer();
|
||||
disp->setCursor(0, 16);
|
||||
disp->print("BME280 Could not find");
|
||||
disp->sendBuffer();
|
||||
}
|
||||
while (1) delay(10);
|
||||
}
|
||||
|
|
@ -72,27 +72,27 @@ void loop()
|
|||
Serial.println();
|
||||
|
||||
|
||||
if (u8g2) {
|
||||
u8g2->setFont(u8g2_font_ncenB08_tr);
|
||||
u8g2->clearBuffer();
|
||||
if (disp) {
|
||||
disp->setFont(u8g2_font_ncenB08_tr);
|
||||
disp->clearBuffer();
|
||||
|
||||
u8g2->setCursor(0, 16);
|
||||
disp->setCursor(0, 16);
|
||||
|
||||
u8g2->print("Temperature:");
|
||||
u8g2->print(temp_event.temperature);
|
||||
u8g2->print(" *C");
|
||||
disp->print("Temperature:");
|
||||
disp->print(temp_event.temperature);
|
||||
disp->print(" *C");
|
||||
|
||||
u8g2->setCursor(0, 32);
|
||||
u8g2->print("Pressure:");
|
||||
u8g2->println(pressure_event.pressure);
|
||||
u8g2->print(" hPa");
|
||||
disp->setCursor(0, 32);
|
||||
disp->print("Pressure:");
|
||||
disp->println(pressure_event.pressure);
|
||||
disp->print(" hPa");
|
||||
|
||||
u8g2->setCursor(0, 48);
|
||||
u8g2->print("Humidity:");
|
||||
u8g2->println(humidity_event.relative_humidity);
|
||||
u8g2->print(" %");
|
||||
disp->setCursor(0, 48);
|
||||
disp->print("Humidity:");
|
||||
disp->println(humidity_event.relative_humidity);
|
||||
disp->print(" %");
|
||||
|
||||
u8g2->sendBuffer();
|
||||
disp->sendBuffer();
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ void disablePeripherals();
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
extern U8G2 *disp;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue