Merge pull request #14 from phl0/define_display_sizes

Define display sizes
This commit is contained in:
Jonathan Naylor 2016-04-16 16:06:31 +01:00
commit 103950d27f

View file

@ -25,7 +25,7 @@
#include <cstdio>
#include <cassert>
const char* LISTENING = "Listening ";
const char* LISTENING = "Listening ";
CHD44780::CHD44780(unsigned int rows, unsigned int cols, const char* callsign, unsigned int dmrid, const std::vector<unsigned int>& pins) :
m_rows(rows),
@ -119,9 +119,13 @@ void CHD44780::writeDStar(const char* my1, const char* my2, const char* your, co
::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "D-Star");
if (m_rows > 2U) {
char buffer[40U];
if (m_rows == 2U && m_cols == 16U) {
char buffer[16U];
::sprintf(buffer, "%s %.8s/%.4s", type, my1, my2);
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
} else if (m_rows == 4U && m_cols == 20U) {
char buffer[20U];
::sprintf(buffer, "%s %.8s/%.4s >", type, my1, my2);
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
@ -129,10 +133,9 @@ void CHD44780::writeDStar(const char* my1, const char* my2, const char* your, co
::sprintf(buffer, "%.8s", your);
::lcdPosition(m_fd, 0, 2);
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
} else {
} else if (m_rows == 2 && m_cols == 40U) {
char buffer[40U];
::sprintf(buffer, "%s %.8s/%.4s > %.8s", type, my1, my2, your);
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
}
@ -142,13 +145,16 @@ void CHD44780::writeDStar(const char* my1, const char* my2, const char* your, co
void CHD44780::clearDStar()
{
if (m_rows > 2U) {
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 == 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 {
::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);
}
@ -162,38 +168,69 @@ void CHD44780::writeDMR(unsigned int slotNo, const char* src, bool group, const
if (!m_dmr) {
::lcdClear(m_fd);
if (m_rows > 2U) {
if (m_rows == 2U && m_cols == 16U) {
if (slotNo == 1U) {
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
} else {
::lcdPosition(m_fd, 0, 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING);
}
} else if (m_rows == 4U && m_cols == 20U) {
::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "DMR");
}
if (slotNo == 1U) {
::lcdPosition(m_fd, 0, m_rows > 2U ? 2 : 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
} else {
::lcdPosition(m_fd, 0, m_rows > 2U ? 1 : 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING);
if (slotNo == 1U) {
::lcdPosition(m_fd, 0, 2);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
} else {
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING);
}
} else if (m_rows == 2U && m_cols == 40U) {
if (slotNo == 1U) {
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
} else {
::lcdPosition(m_fd, 0, 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING);
}
}
}
if (slotNo == 1U) {
char buffer[40U];
if (m_cols > 16U)
::sprintf(buffer, "%s %s > %s%s", type, src, group ? "TG" : "", dst);
else
if (m_rows == 2U && m_cols == 16U) {
char buffer[16U];
if (slotNo == 1U) {
::sprintf(buffer, "%s > %s%s", src, group ? "TG" : "", dst);
::lcdPosition(m_fd, 0, m_rows > 2U ? 1 : 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer);
} else {
char buffer[40U];
if (m_cols > 16U)
::sprintf(buffer, "%s %s > %s%s", type, src, group ? "TG" : "", dst);
else
::lcdPosition(m_fd, 0, 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer);
} else {
::sprintf(buffer, "%s > %s%s", src, group ? "TG" : "", dst);
::lcdPosition(m_fd, 0, m_rows > 2U ? 2 : 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer);
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer);
}
} else if (m_rows == 4U && m_cols == 20U) {
char buffer[20U];
if (slotNo == 1U) {
::sprintf(buffer, "%s %s > %s%s", type, src, group ? "TG" : "", dst);
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer);
} else {
::sprintf(buffer, "%s %s > %s%s", type, src, group ? "TG" : "", dst);
::lcdPosition(m_fd, 0, 2);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer);
}
} else if (m_rows == 2U && m_cols == 40U) {
char buffer[40U];
if (slotNo == 1U) {
::sprintf(buffer, "%s %s > %s%s", type, src, group ? "TG" : "", dst);
::lcdPosition(m_fd, 0, 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer);
} else {
::sprintf(buffer, "%s %s > %s%s", type, src, group ? "TG" : "", dst);
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer);
}
}
m_dmr = true;
@ -201,12 +238,30 @@ void CHD44780::writeDMR(unsigned int slotNo, const char* src, bool group, const
void CHD44780::clearDMR(unsigned int slotNo)
{
if (slotNo == 1U) {
::lcdPosition(m_fd, 0, m_rows > 2U ? 1 : 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING);
} else {
::lcdPosition(m_fd, 0, m_rows > 2U ? 2 : 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
if (m_rows == 2U && m_cols == 16U) {
if (slotNo == 1U) {
::lcdPosition(m_fd, 0, 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING);
} else {
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
}
} else if (m_rows == 4U && m_cols == 20U) {
if (slotNo == 1U) {
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING);
} else {
::lcdPosition(m_fd, 0, 2);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
}
} else if (m_rows == 2U && m_cols == 40U) {
if (slotNo == 1U) {
::lcdPosition(m_fd, 0, 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING);
} else {
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
}
}
}
@ -220,9 +275,13 @@ void CHD44780::writeFusion(const char* source, const char* dest)
::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "System Fusion");
if (m_rows > 2U) {
char buffer[40U];
if (m_rows == 2U && m_cols == 16U) {
char buffer[16U];
::sprintf(buffer, "%.10s >", source);
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
} else if (m_rows == 4U && m_cols == 20U) {
char buffer[20U];
::sprintf(buffer, "%.10s >", source);
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
@ -230,7 +289,7 @@ void CHD44780::writeFusion(const char* source, const char* dest)
::sprintf(buffer, "%.10s", dest);
::lcdPosition(m_fd, 0, 2);
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
} else {
} else if (m_rows == 2 && m_cols == 40U) {
char buffer[40U];
::sprintf(buffer, "%.10s > %.10s", source, dest);
@ -243,13 +302,16 @@ void CHD44780::writeFusion(const char* source, const char* dest)
void CHD44780::clearFusion()
{
if (m_rows > 2U) {
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 == 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 {
::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);
}