Skip to content

Commit

Permalink
Update the display code for P25.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Sep 12, 2016
1 parent 3079c9f commit e2ec529
Show file tree
Hide file tree
Showing 12 changed files with 241 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,29 @@ void CDisplay::clearFusion()
}
}

void CDisplay::writeP25(const char* source, bool group, const char* dest, const char* type)
{
assert(source != NULL);
assert(dest != NULL);
assert(type != NULL);

m_timer1.start();
m_mode1 = MODE_IDLE;

writeP25Int(source, group, dest, type);
}

void CDisplay::clearP25()
{
if (m_timer1.hasExpired()) {
clearP25Int();
m_timer1.stop();
m_mode1 = MODE_IDLE;
} else {
m_mode1 = MODE_P25;
}
}

void CDisplay::clock(unsigned int ms)
{
m_timer1.clock(ms);
Expand All @@ -175,6 +198,11 @@ void CDisplay::clock(unsigned int ms)
m_mode1 = MODE_IDLE;
m_timer1.stop();
break;
case MODE_P25:
clearP25Int();
m_mode1 = MODE_IDLE;
m_timer1.stop();
break;
default:
break;
}
Expand Down
6 changes: 6 additions & 0 deletions Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class CDisplay
void writeFusion(const char* source, const char* dest, const char* type, const char* origin);
void clearFusion();

void writeP25(const char* source, bool group, const char* dest, const char* type);
void clearP25();

virtual void close() = 0;

void clock(unsigned int ms);
Expand All @@ -62,6 +65,9 @@ class CDisplay
virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin) = 0;
virtual void clearFusionInt() = 0;

virtual void writeP25Int(const char* source, bool group, const char* dest, const char* type) = 0;
virtual void clearP25Int() = 0;

virtual void clockInt(unsigned int ms);

private:
Expand Down
86 changes: 86 additions & 0 deletions HD44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,92 @@ void CHD44780::clearFusionInt()
}
}

void CHD44780::writeP25Int(const char* source, bool group, const char* dest, const char* type)
{
assert(source != NULL);
assert(dest != NULL);
assert(type != NULL);

#ifdef ADAFRUIT_DISPLAY
adafruitLCDColour(AC_RED);
#endif

m_clockDisplayTimer.stop(); // Stop the clock display
::lcdClear(m_fd);

if (m_pwm) {
if (m_pwmPin != 1U)
::softPwmWrite(m_pwmPin, m_pwmBright);
else
::pwmWrite(m_pwmPin, (m_pwmBright / 100) * 1024);
}

::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "P25");

if (m_rows == 2U && m_cols == 16U) {
char m_buffer1[16U];
::sprintf(m_buffer1, "%.10s >", source);
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
} else if (m_rows == 4U && m_cols == 16U) {
char m_buffer1[16U];
::sprintf(m_buffer1, "%.10s >", source);
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);

::sprintf(m_buffer1, "%s%.10s", group ? "TG" : "", dest);
::lcdPosition(m_fd, 0, 2);
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
} else if (m_rows == 4U && m_cols == 20U) {
char m_buffer1[20U];
::sprintf(m_buffer1, "%.10s >", source);
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);

::sprintf(m_buffer1, "%s%.10s", group ? "TG" : "", dest);
::lcdPosition(m_fd, 0, 2);
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
} else if (m_rows == 2 && m_cols == 40U) {
char m_buffer1[40U];
::sprintf(m_buffer1, "%.10s > %s%.10s", source, group ? "TG" : "", dest);

::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
}

m_dmr = false;
}

void CHD44780::clearP25Int()
{
#ifdef ADAFRUIT_DISPLAY
adafruitLCDColour(AC_PURPLE);
#endif

m_clockDisplayTimer.stop(); // Stop the clock display

if (m_rows == 2U && m_cols == 16U) {
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
} else if (m_rows == 4U && m_cols == 16U) {
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);

::lcdPosition(m_fd, 0, 2);
::lcdPrintf(m_fd, "%.*s", m_cols, " ");
} else if (m_rows == 4U && m_cols == 20U) {
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);

::lcdPosition(m_fd, 0, 2);
::lcdPrintf(m_fd, "%.*s", m_cols, " ");
} else if (m_rows == 2 && m_cols == 40U) {
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
}
}

void CHD44780::clockInt(unsigned int ms)
{
m_clockDisplayTimer.clock(ms);
Expand Down
3 changes: 3 additions & 0 deletions HD44780.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ class CHD44780 : public CDisplay
virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin);
virtual void clearFusionInt();

virtual void writeP25Int(const char* source, bool group, const char* dest, const char* type);
virtual void clearP25Int();

virtual void clockInt(unsigned int ms);

private:
Expand Down
31 changes: 31 additions & 0 deletions Nextion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,37 @@ void CNextion::clearFusionInt()
sendCommand("t2.txt=\"\"");
}

void CNextion::writeP25Int(const char* source, bool group, const char* dest, const char* type)
{
assert(source != NULL);
assert(dest != NULL);
assert(type != NULL);

if (m_mode != MODE_P25)
sendCommand("page P25");

char text[30U];
::sprintf(text, "dim=%u", m_brightness);
sendCommand(text);

::sprintf(text, "t0.txt=\"%s %.10s\"", type, source);
sendCommand(text);

::sprintf(text, "t1.txt=\"%s%.10s\"", group ? "TG" : "", dest);
sendCommand(text);

m_clockDisplayTimer.stop();

m_mode = MODE_P25;
}

void CNextion::clearP25Int()
{
sendCommand("t0.txt=\"Listening\"");
sendCommand("t1.txt=\"\"");
sendCommand("t2.txt=\"\"");
}

void CNextion::clockInt(unsigned int ms)
{
// Update the clock display in IDLE mode every 400ms
Expand Down
3 changes: 3 additions & 0 deletions Nextion.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class CNextion : public CDisplay
virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin);
virtual void clearFusionInt();

virtual void writeP25Int(const char* source, bool group, const char* dest, const char* type);
virtual void clearP25Int();

virtual void clockInt(unsigned int ms);

private:
Expand Down
8 changes: 8 additions & 0 deletions NullDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ void CNullDisplay::clearFusionInt()
{
}

void CNullDisplay::writeP25Int(const char* source, bool group, const char* dest, const char* type)
{
}

void CNullDisplay::clearP25Int()
{
}

void CNullDisplay::close()
{
}
3 changes: 3 additions & 0 deletions NullDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class CNullDisplay : public CDisplay
virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin);
virtual void clearFusionInt();

virtual void writeP25Int(const char* source, bool group, const char* dest, const char* type);
virtual void clearP25Int();

private:
};

Expand Down
25 changes: 25 additions & 0 deletions OLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,29 @@ void COLED::clearFusionInt()
display.display();
}

void COLED::writeP25Int(const char* source, bool group, const char* dest, const char* type)
{
m_mode = MODE_P25;
display.fillRect(0, OLED_LINE1, display.width(), 10, BLACK);
display.setCursor(0,OLED_LINE1);
display.printf("%s %.10s", type, source);
display.fillRect(0, OLED_LINE2, display.width(), 10, BLACK);
display.setCursor(0,OLED_LINE2);
display.printf(" %s%.10s", group ? "TG" : "", dest);
OLED_statusbar();
display.display();
}

void COLED::clearP25Int()
{
display.fillRect(0, OLED_LINE1, display.width(), 10, BLACK);
display.setCursor(0,OLED_LINE1);
display.print("Listening");
display.fillRect(0, OLED_LINE2, display.width(), 10, BLACK);
OLED_statusbar();
display.display();
}

void COLED::close()
{
display.close();
Expand All @@ -227,6 +250,8 @@ void COLED::OLED_statusbar()
display.print("D-Star");
else if (m_mode == MODE_YSF)
display.print("Fusion");
else if (m_mode == MODE_P25)
display.print("P25");
else
display.drawBitmap(0, 0, logo_glcd_bmp, 16, 15, WHITE);
}
3 changes: 3 additions & 0 deletions OLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class COLED : public CDisplay
virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin);
virtual void clearFusionInt();

virtual void writeP25Int(const char* source, bool group, const char* dest, const char* type);
virtual void clearP25Int();

virtual void close();

private:
Expand Down
42 changes: 42 additions & 0 deletions TFTSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,48 @@ void CTFTSerial::clearFusionInt()
displayText(" ");
}

void CTFTSerial::writeP25Int(const char* source, bool group, const char* dest, const char* type)
{
assert(source != NULL);
assert(dest != NULL);
assert(type != NULL);

if (m_mode != MODE_P25) {
// Clear the screen
clearScreen();

setFontSize(FONT_MEDIUM);

// Draw the P25 insignia
displayBitmap(0U, 0U, "P25_sm.bmp");
}

char text[30U];
::sprintf(text, "%s %.10s", type, source);

gotoPosPixel(5U, 70U);
displayText(text);

::sprintf(text, " %s%.10s", group ? "TG" : "", dest);

gotoPosPixel(5U, 90U);
displayText(text);

m_mode = MODE_P25;
}

void CTFTSerial::clearP25Int()
{
gotoPosPixel(5U, 70U);
displayText(" Listening ");

gotoPosPixel(5U, 90U);
displayText(" ");

gotoPosPixel(5U, 110U);
displayText(" ");
}

void CTFTSerial::close()
{
m_serial.close();
Expand Down
3 changes: 3 additions & 0 deletions TFTSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class CTFTSerial : public CDisplay
virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin);
virtual void clearFusionInt();

virtual void writeP25Int(const char* source, bool group, const char* dest, const char* type);
virtual void clearP25Int();

private:
std::string m_callsign;
unsigned int m_dmrid;
Expand Down

0 comments on commit e2ec529

Please sign in to comment.