OLED Display - Add IP address to display format
Add IP address to bottom of screen by adjusting existing lines upward as far as possible.
This commit is contained in:
parent
57a799972e
commit
e14b650106
|
@ -116,10 +116,10 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
|
|||
}
|
||||
|
||||
if (family == AF_INET) {
|
||||
::sprintf(interfacelist[ifnr], "%s: %s", ifa->ifa_name, host);
|
||||
::sprintf(interfacelist[ifnr], "%s:%s", ifa->ifa_name, host);
|
||||
LogInfo(" IPv4: %s", interfacelist[ifnr]);
|
||||
} else {
|
||||
::sprintf(interfacelist[ifnr], "%s: %s", ifa->ifa_name, host);
|
||||
::sprintf(interfacelist[ifnr], "%s:%s", ifa->ifa_name, host);
|
||||
LogInfo(" IPv6: %s", interfacelist[ifnr]);
|
||||
}
|
||||
|
||||
|
|
54
OLED.cpp
54
OLED.cpp
|
@ -17,6 +17,10 @@
|
|||
*/
|
||||
|
||||
#include "OLED.h"
|
||||
#include "Log.h"
|
||||
|
||||
static bool networkInfoInitialized = false;
|
||||
static unsigned char passCounter = 0;
|
||||
|
||||
//Logo MMDVM for Idle Screen
|
||||
static unsigned char logo_glcd_bmp[] =
|
||||
|
@ -117,6 +121,7 @@ COLED::~COLED()
|
|||
|
||||
bool COLED::open()
|
||||
{
|
||||
|
||||
// SPI
|
||||
if (display.oled_is_spi_proto(m_displayType))
|
||||
{
|
||||
|
@ -131,6 +136,7 @@ bool COLED::open()
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
display.begin();
|
||||
|
||||
display.invertDisplay(m_displayInvert ? 1 : 0);
|
||||
|
@ -163,6 +169,26 @@ void COLED::setIdleInt()
|
|||
// display.setTextSize(1);
|
||||
display.startscrolldiagright(0x00,0x0f); //the MMDVM logo scrolls the whole screen
|
||||
display.display();
|
||||
|
||||
unsigned char info[100U];
|
||||
CNetworkInfo* m_network;
|
||||
|
||||
passCounter ++;
|
||||
if (passCounter > 253U)
|
||||
networkInfoInitialized = false;
|
||||
|
||||
if (! networkInfoInitialized) {
|
||||
LogMessage("Initialize CNetworkInfo");
|
||||
info[0]=0;
|
||||
m_network = new CNetworkInfo;
|
||||
m_network->getNetworkInterface(info);
|
||||
m_ipaddress = (char*)info;
|
||||
delete m_network;
|
||||
|
||||
networkInfoInitialized = true;
|
||||
passCounter = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void COLED::setErrorInt(const char* text)
|
||||
|
@ -217,8 +243,11 @@ void COLED::clearDStarInt()
|
|||
{
|
||||
display.fillRect(0,OLED_LINE1, display.width(),display.height(),BLACK); //clear everything beneath the logo
|
||||
|
||||
display.setCursor(40,38);
|
||||
display.setCursor(40,OLED_LINE2);
|
||||
display.print("Listening");
|
||||
|
||||
display.setCursor(0,OLED_LINE5);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
|
||||
display.display();
|
||||
}
|
||||
|
@ -243,7 +272,6 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co
|
|||
display.fillRect(0,OLED_LINE2,display.width(),20,BLACK); //20=> clear 2 lines
|
||||
display.setCursor(0,OLED_LINE2);
|
||||
display.print("1 Listening");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,7 +291,8 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co
|
|||
display.setCursor(0,OLED_LINE5);
|
||||
display.printf("%s%s", group ? "TG" : "", dst.c_str());
|
||||
}
|
||||
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
OLED_statusbar();
|
||||
display.display();
|
||||
}
|
||||
|
@ -281,8 +310,10 @@ void COLED::clearDMRInt(unsigned int slotNo)
|
|||
display.fillRect(0, OLED_LINE4, display.width(), 20, BLACK);
|
||||
display.setCursor(0, OLED_LINE4);
|
||||
display.print("2 Listening");
|
||||
}
|
||||
|
||||
}
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
display.display();
|
||||
}
|
||||
|
||||
|
@ -308,8 +339,11 @@ void COLED::clearFusionInt()
|
|||
{
|
||||
display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK);
|
||||
|
||||
display.setCursor(40,38);
|
||||
display.setCursor(40,OLED_LINE2);
|
||||
display.print("Listening");
|
||||
|
||||
display.setCursor(0,OLED_LINE5);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
|
||||
display.display();
|
||||
}
|
||||
|
@ -335,8 +369,11 @@ void COLED::clearP25Int()
|
|||
{
|
||||
display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK);
|
||||
|
||||
display.setCursor(40,38);
|
||||
display.setCursor(40,OLED_LINE2);
|
||||
display.print("Listening");
|
||||
|
||||
display.setCursor(0,OLED_LINE5);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
|
||||
display.display();
|
||||
}
|
||||
|
@ -362,8 +399,11 @@ void COLED::clearNXDNInt()
|
|||
{
|
||||
display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK);
|
||||
|
||||
display.setCursor(40,38);
|
||||
display.setCursor(40,OLED_LINE2);
|
||||
display.print("Listening");
|
||||
|
||||
display.setCursor(0,OLED_LINE5);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
|
||||
display.display();
|
||||
}
|
||||
|
|
17
OLED.h
17
OLED.h
|
@ -20,11 +20,12 @@
|
|||
#define OLED_H
|
||||
|
||||
#define OLED_STATUSBAR 0
|
||||
#define OLED_LINE1 16
|
||||
#define OLED_LINE2 26
|
||||
#define OLED_LINE3 36
|
||||
#define OLED_LINE4 46
|
||||
#define OLED_LINE5 56
|
||||
#define OLED_LINE1 8 //16
|
||||
#define OLED_LINE2 18 //26
|
||||
#define OLED_LINE3 28 //36
|
||||
#define OLED_LINE4 37 //46
|
||||
#define OLED_LINE5 47 //56
|
||||
#define OLED_LINE6 57
|
||||
|
||||
#include "Display.h"
|
||||
#include "Defines.h"
|
||||
|
@ -34,6 +35,7 @@
|
|||
#include "ArduiPi_OLED_lib.h"
|
||||
#include "Adafruit_GFX.h"
|
||||
#include "ArduiPi_OLED.h"
|
||||
#include "NetworkInfo.h"
|
||||
|
||||
class COLED : public CDisplay
|
||||
{
|
||||
|
@ -76,9 +78,12 @@ private:
|
|||
unsigned char m_displayBrightness;
|
||||
bool m_displayInvert;
|
||||
bool m_displayScroll;
|
||||
|
||||
std::string m_ipaddress;
|
||||
|
||||
ArduiPi_OLED display;
|
||||
void OLED_statusbar();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue