Update the display code for P25.

This commit is contained in:
Jonathan Naylor 2016-09-12 18:12:32 +01:00
parent 3079c9faf2
commit e2ec5292b5
12 changed files with 241 additions and 0 deletions

View file

@ -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);
@ -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;
}

View file

@ -44,6 +44,9 @@ public:
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);
@ -62,6 +65,9 @@ protected:
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:

View file

@ -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);

View file

@ -110,6 +110,9 @@ protected:
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:

View file

@ -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

View file

@ -50,6 +50,9 @@ protected:
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:

View file

@ -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()
{
}

View file

@ -47,6 +47,9 @@ protected:
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:
};

View file

@ -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();
@ -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
OLED.h
View file

@ -94,6 +94,9 @@ public:
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:

View file

@ -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();

View file

@ -49,6 +49,9 @@ protected:
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;