mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-21 15:09:23 +08:00
Make the code more readable
This commit is contained in:
199
OLED.cpp
199
OLED.cpp
@@ -106,9 +106,9 @@ const unsigned char logo_fusion_bmp [] =
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
//Logo P25 128x16px
|
||||
const unsigned char logo_P25_bmp [] =
|
||||
{
|
||||
//Logo P25 128x16px
|
||||
const unsigned char logo_P25_bmp [] =
|
||||
{
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xf8, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xfc, 0x00, 0x00, 0x3f, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x7f,
|
||||
0xf8, 0x00, 0x00, 0x00, 0x03, 0xff, 0xc0, 0x00, 0x00, 0x03, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x7f,
|
||||
@@ -125,11 +125,11 @@ const unsigned char logo_fusion_bmp [] =
|
||||
0xf0, 0x01, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0x00, 0x00, 0x00, 0x3f,
|
||||
0xf0, 0x01, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0x03, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||
};
|
||||
};
|
||||
|
||||
// Logo NXDN_sm, 128x16px
|
||||
const unsigned char logo_NXDN_bmp [] =
|
||||
{
|
||||
{
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xf0, 0x1f, 0xf8, 0x0f, 0x00, 0xff, 0x80, 0x7c, 0x00, 0x0f, 0xff, 0x80, 0x7f, 0xe0, 0x7f,
|
||||
@@ -213,24 +213,24 @@ void COLED::setIdleInt()
|
||||
display.startscrolldiagright(0x00,0x0f); //the MMDVM logo scrolls the whole screen
|
||||
display.display();
|
||||
|
||||
unsigned char info[100U];
|
||||
CNetworkInfo* m_network;
|
||||
unsigned char info[100U];
|
||||
CNetworkInfo* m_network;
|
||||
|
||||
passCounter ++;
|
||||
if (passCounter > 253U)
|
||||
networkInfoInitialized = false;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
networkInfoInitialized = true;
|
||||
passCounter = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -278,8 +278,8 @@ void COLED::writeDStarInt(const char* my1, const char* my2, const char* your, co
|
||||
display.setCursor(0,OLED_LINE5);
|
||||
display.printf("via %.8s",reflector);
|
||||
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
|
||||
OLED_statusbar();
|
||||
display.display();
|
||||
@@ -292,8 +292,8 @@ void COLED::clearDStarInt()
|
||||
display.setCursor(40,OLED_LINE3);
|
||||
display.print("Listening");
|
||||
|
||||
display.setCursor(0,OLED_LINE5);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
display.setCursor(0,OLED_LINE5);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
|
||||
display.display();
|
||||
}
|
||||
@@ -302,77 +302,74 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co
|
||||
{
|
||||
|
||||
if (m_mode != MODE_DMR) {
|
||||
display.clearDisplay();
|
||||
m_mode = MODE_DMR;
|
||||
clearDMRInt(slotNo);
|
||||
}
|
||||
// if both slots, use lines 2-3 for slot 1, lines 4-5 for slot 2
|
||||
// if single slot, use lines 3-4
|
||||
if ( m_slot1Enabled && m_slot2Enabled ) {
|
||||
display.clearDisplay();
|
||||
m_mode = MODE_DMR;
|
||||
clearDMRInt(slotNo);
|
||||
}
|
||||
// if both slots, use lines 2-3 for slot 1, lines 4-5 for slot 2
|
||||
// if single slot, use lines 3-4
|
||||
if ( m_slot1Enabled && m_slot2Enabled ) {
|
||||
|
||||
if (slotNo == 1U) {
|
||||
display.fillRect(0,OLED_LINE2,display.width(),40,BLACK);
|
||||
display.setCursor(0,OLED_LINE2);
|
||||
display.printf("%s",src.c_str());
|
||||
display.setCursor(0,OLED_LINE3);
|
||||
display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG: " : "",dst.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
display.fillRect(0,OLED_LINE4,display.width(),40,BLACK);
|
||||
display.setCursor(0,OLED_LINE4);
|
||||
display.printf("%s",src.c_str());
|
||||
display.setCursor(0,OLED_LINE5);
|
||||
display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG: " : "",dst.c_str());
|
||||
}
|
||||
if (slotNo == 1U) {
|
||||
display.fillRect(0,OLED_LINE2,display.width(),40,BLACK);
|
||||
display.setCursor(0,OLED_LINE2);
|
||||
display.printf("%s",src.c_str());
|
||||
display.setCursor(0,OLED_LINE3);
|
||||
display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG: " : "",dst.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
display.fillRect(0,OLED_LINE4,display.width(),40,BLACK);
|
||||
display.setCursor(0,OLED_LINE4);
|
||||
display.printf("%s",src.c_str());
|
||||
display.setCursor(0,OLED_LINE5);
|
||||
display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG: " : "",dst.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
display.fillRect(0,OLED_LINE3,display.width(),20,BLACK);
|
||||
display.setCursor(0,OLED_LINE3);
|
||||
display.printf("%s",src.c_str());
|
||||
display.setCursor(0,OLED_LINE4);
|
||||
display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG: " : "",dst.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
display.fillRect(0,OLED_LINE3,display.width(),20,BLACK);
|
||||
display.setCursor(0,OLED_LINE3);
|
||||
display.printf("%s",src.c_str());
|
||||
display.setCursor(0,OLED_LINE4);
|
||||
display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG: " : "",dst.c_str());
|
||||
}
|
||||
|
||||
display.fillRect(0,OLED_LINE6,display.width(),20,BLACK);
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
display.fillRect(0,OLED_LINE6,display.width(),20,BLACK);
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
|
||||
OLED_statusbar();
|
||||
display.display();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void COLED::clearDMRInt(unsigned int slotNo)
|
||||
{
|
||||
// if both slots, use lines 2-3 for slot 1, lines 4-5 for slot 2
|
||||
// if single slot, use lines 3-4
|
||||
if ( m_slot1Enabled && m_slot2Enabled ){
|
||||
if (slotNo == 1U)
|
||||
{
|
||||
display.fillRect(0, OLED_LINE3, display.width(), 40, BLACK);
|
||||
display.setCursor(0,OLED_LINE3);
|
||||
display.print("Slot: 1 Listening");
|
||||
}
|
||||
else
|
||||
{
|
||||
display.fillRect(0, OLED_LINE5, display.width(), 40, BLACK);
|
||||
display.setCursor(0, OLED_LINE5);
|
||||
display.print("Slot: 2 Listening");
|
||||
}
|
||||
}
|
||||
else {
|
||||
display.fillRect(0, OLED_LINE4, display.width(), 40, BLACK);
|
||||
display.setCursor(0,OLED_LINE4);
|
||||
display.printf("Slot: %i Listening",slotNo);
|
||||
}
|
||||
// if both slots, use lines 2-3 for slot 1, lines 4-5 for slot 2
|
||||
// if single slot, use lines 3-4
|
||||
if ( m_slot1Enabled && m_slot2Enabled ){
|
||||
if (slotNo == 1U) {
|
||||
display.fillRect(0, OLED_LINE3, display.width(), 40, BLACK);
|
||||
display.setCursor(0,OLED_LINE3);
|
||||
display.print("Slot: 1 Listening");
|
||||
}
|
||||
else {
|
||||
display.fillRect(0, OLED_LINE5, display.width(), 40, BLACK);
|
||||
display.setCursor(0, OLED_LINE5);
|
||||
display.print("Slot: 2 Listening");
|
||||
}
|
||||
}
|
||||
else {
|
||||
display.fillRect(0, OLED_LINE4, display.width(), 40, BLACK);
|
||||
display.setCursor(0,OLED_LINE4);
|
||||
display.printf("Slot: %i Listening",slotNo);
|
||||
}
|
||||
|
||||
|
||||
display.fillRect(0, OLED_LINE6, display.width(), 20, BLACK);
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
display.fillRect(0, OLED_LINE6, display.width(), 20, BLACK);
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
display.display();
|
||||
}
|
||||
|
||||
@@ -401,8 +398,8 @@ void COLED::clearFusionInt()
|
||||
display.setCursor(40,OLED_LINE4);
|
||||
display.print("Listening");
|
||||
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
|
||||
display.display();
|
||||
}
|
||||
@@ -431,8 +428,8 @@ void COLED::clearP25Int()
|
||||
display.setCursor(40,OLED_LINE4);
|
||||
display.print("Listening");
|
||||
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
|
||||
display.display();
|
||||
}
|
||||
@@ -461,8 +458,8 @@ void COLED::clearNXDNInt()
|
||||
display.setCursor(40,OLED_LINE4);
|
||||
display.print("Listening");
|
||||
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
|
||||
display.display();
|
||||
}
|
||||
@@ -491,8 +488,8 @@ void COLED::clearPOCSAGInt()
|
||||
display.setCursor(40,OLED_LINE4);
|
||||
display.print("Listening");
|
||||
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
display.setCursor(0,OLED_LINE6);
|
||||
display.printf("%s",m_ipaddress.c_str());
|
||||
|
||||
display.display();
|
||||
}
|
||||
@@ -526,8 +523,8 @@ void COLED::clearCWInt()
|
||||
void COLED::close()
|
||||
{
|
||||
display.clearDisplay();
|
||||
display.fillRect(0, 0, display.width(), 16, BLACK);
|
||||
display.startscrollright(0x00,0x01);
|
||||
display.fillRect(0, 0, display.width(), 16, BLACK);
|
||||
display.startscrollright(0x00,0x01);
|
||||
display.setCursor(0,00);
|
||||
display.setTextSize(2);
|
||||
display.print("-CLOSE-");
|
||||
@@ -544,18 +541,18 @@ void COLED::OLED_statusbar()
|
||||
|
||||
display.setCursor(0,0);
|
||||
if (m_mode == MODE_DMR)
|
||||
display.drawBitmap(0, 0, logo_dmr_bmp, 128, 16, WHITE);
|
||||
display.drawBitmap(0, 0, logo_dmr_bmp, 128, 16, WHITE);
|
||||
else if (m_mode == MODE_DSTAR)
|
||||
display.drawBitmap(0, 0, logo_dstar_bmp, 128, 16, WHITE);
|
||||
display.drawBitmap(0, 0, logo_dstar_bmp, 128, 16, WHITE);
|
||||
else if (m_mode == MODE_YSF)
|
||||
display.drawBitmap(0, 0, logo_fusion_bmp, 128, 16, WHITE);
|
||||
display.drawBitmap(0, 0, logo_fusion_bmp, 128, 16, WHITE);
|
||||
else if (m_mode == MODE_P25)
|
||||
display.drawBitmap(0, 0, logo_P25_bmp, 128, 16, WHITE);
|
||||
display.drawBitmap(0, 0, logo_P25_bmp, 128, 16, WHITE);
|
||||
else if (m_mode == MODE_NXDN)
|
||||
display.drawBitmap(0, 0, logo_NXDN_bmp, 128, 16, WHITE);
|
||||
display.drawBitmap(0, 0, logo_NXDN_bmp, 128, 16, WHITE);
|
||||
else
|
||||
display.drawBitmap(0, 0, logo_glcd_bmp, 128, 16, WHITE);
|
||||
display.drawBitmap(0, 0, logo_glcd_bmp, 128, 16, WHITE);
|
||||
|
||||
if (m_displayScroll)
|
||||
display.startscrollright(0x00,0x02);
|
||||
display.startscrollright(0x00,0x02);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user