mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-21 23:45:49 +08:00
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:
54
OLED.cpp
54
OLED.cpp
@@ -17,6 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "OLED.h"
|
#include "OLED.h"
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
|
static bool networkInfoInitialized = false;
|
||||||
|
static unsigned char passCounter = 0;
|
||||||
|
|
||||||
//Logo MMDVM for Idle Screen
|
//Logo MMDVM for Idle Screen
|
||||||
static unsigned char logo_glcd_bmp[] =
|
static unsigned char logo_glcd_bmp[] =
|
||||||
@@ -117,6 +121,7 @@ COLED::~COLED()
|
|||||||
|
|
||||||
bool COLED::open()
|
bool COLED::open()
|
||||||
{
|
{
|
||||||
|
|
||||||
// SPI
|
// SPI
|
||||||
if (display.oled_is_spi_proto(m_displayType))
|
if (display.oled_is_spi_proto(m_displayType))
|
||||||
{
|
{
|
||||||
@@ -131,6 +136,7 @@ bool COLED::open()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
display.begin();
|
display.begin();
|
||||||
|
|
||||||
display.invertDisplay(m_displayInvert ? 1 : 0);
|
display.invertDisplay(m_displayInvert ? 1 : 0);
|
||||||
@@ -163,6 +169,26 @@ void COLED::setIdleInt()
|
|||||||
// display.setTextSize(1);
|
// display.setTextSize(1);
|
||||||
display.startscrolldiagright(0x00,0x0f); //the MMDVM logo scrolls the whole screen
|
display.startscrolldiagright(0x00,0x0f); //the MMDVM logo scrolls the whole screen
|
||||||
display.display();
|
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)
|
void COLED::setErrorInt(const char* text)
|
||||||
@@ -217,9 +243,12 @@ void COLED::clearDStarInt()
|
|||||||
{
|
{
|
||||||
display.fillRect(0,OLED_LINE1, display.width(),display.height(),BLACK); //clear everything beneath the logo
|
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.print("Listening");
|
||||||
|
|
||||||
|
display.setCursor(0,OLED_LINE5);
|
||||||
|
display.printf("%s",m_ipaddress.c_str());
|
||||||
|
|
||||||
display.display();
|
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.fillRect(0,OLED_LINE2,display.width(),20,BLACK); //20=> clear 2 lines
|
||||||
display.setCursor(0,OLED_LINE2);
|
display.setCursor(0,OLED_LINE2);
|
||||||
display.print("1 Listening");
|
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.setCursor(0,OLED_LINE5);
|
||||||
display.printf("%s%s", group ? "TG" : "", dst.c_str());
|
display.printf("%s%s", group ? "TG" : "", dst.c_str());
|
||||||
}
|
}
|
||||||
|
display.setCursor(0,OLED_LINE6);
|
||||||
|
display.printf("%s",m_ipaddress.c_str());
|
||||||
OLED_statusbar();
|
OLED_statusbar();
|
||||||
display.display();
|
display.display();
|
||||||
}
|
}
|
||||||
@@ -281,8 +310,10 @@ void COLED::clearDMRInt(unsigned int slotNo)
|
|||||||
display.fillRect(0, OLED_LINE4, display.width(), 20, BLACK);
|
display.fillRect(0, OLED_LINE4, display.width(), 20, BLACK);
|
||||||
display.setCursor(0, OLED_LINE4);
|
display.setCursor(0, OLED_LINE4);
|
||||||
display.print("2 Listening");
|
display.print("2 Listening");
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
display.setCursor(0,OLED_LINE6);
|
||||||
|
display.printf("%s",m_ipaddress.c_str());
|
||||||
display.display();
|
display.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,9 +339,12 @@ void COLED::clearFusionInt()
|
|||||||
{
|
{
|
||||||
display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK);
|
display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK);
|
||||||
|
|
||||||
display.setCursor(40,38);
|
display.setCursor(40,OLED_LINE2);
|
||||||
display.print("Listening");
|
display.print("Listening");
|
||||||
|
|
||||||
|
display.setCursor(0,OLED_LINE5);
|
||||||
|
display.printf("%s",m_ipaddress.c_str());
|
||||||
|
|
||||||
display.display();
|
display.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,9 +369,12 @@ void COLED::clearP25Int()
|
|||||||
{
|
{
|
||||||
display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK);
|
display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK);
|
||||||
|
|
||||||
display.setCursor(40,38);
|
display.setCursor(40,OLED_LINE2);
|
||||||
display.print("Listening");
|
display.print("Listening");
|
||||||
|
|
||||||
|
display.setCursor(0,OLED_LINE5);
|
||||||
|
display.printf("%s",m_ipaddress.c_str());
|
||||||
|
|
||||||
display.display();
|
display.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,9 +399,12 @@ void COLED::clearNXDNInt()
|
|||||||
{
|
{
|
||||||
display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK);
|
display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK);
|
||||||
|
|
||||||
display.setCursor(40,38);
|
display.setCursor(40,OLED_LINE2);
|
||||||
display.print("Listening");
|
display.print("Listening");
|
||||||
|
|
||||||
|
display.setCursor(0,OLED_LINE5);
|
||||||
|
display.printf("%s",m_ipaddress.c_str());
|
||||||
|
|
||||||
display.display();
|
display.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
OLED.h
15
OLED.h
@@ -20,11 +20,12 @@
|
|||||||
#define OLED_H
|
#define OLED_H
|
||||||
|
|
||||||
#define OLED_STATUSBAR 0
|
#define OLED_STATUSBAR 0
|
||||||
#define OLED_LINE1 16
|
#define OLED_LINE1 8 //16
|
||||||
#define OLED_LINE2 26
|
#define OLED_LINE2 18 //26
|
||||||
#define OLED_LINE3 36
|
#define OLED_LINE3 28 //36
|
||||||
#define OLED_LINE4 46
|
#define OLED_LINE4 37 //46
|
||||||
#define OLED_LINE5 56
|
#define OLED_LINE5 47 //56
|
||||||
|
#define OLED_LINE6 57
|
||||||
|
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
#include "Defines.h"
|
#include "Defines.h"
|
||||||
@@ -34,6 +35,7 @@
|
|||||||
#include "ArduiPi_OLED_lib.h"
|
#include "ArduiPi_OLED_lib.h"
|
||||||
#include "Adafruit_GFX.h"
|
#include "Adafruit_GFX.h"
|
||||||
#include "ArduiPi_OLED.h"
|
#include "ArduiPi_OLED.h"
|
||||||
|
#include "NetworkInfo.h"
|
||||||
|
|
||||||
class COLED : public CDisplay
|
class COLED : public CDisplay
|
||||||
{
|
{
|
||||||
@@ -76,9 +78,12 @@ private:
|
|||||||
unsigned char m_displayBrightness;
|
unsigned char m_displayBrightness;
|
||||||
bool m_displayInvert;
|
bool m_displayInvert;
|
||||||
bool m_displayScroll;
|
bool m_displayScroll;
|
||||||
|
std::string m_ipaddress;
|
||||||
|
|
||||||
ArduiPi_OLED display;
|
ArduiPi_OLED display;
|
||||||
void OLED_statusbar();
|
void OLED_statusbar();
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user