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

@ -119,9 +119,13 @@ void CHD44780::writeDStar(const char* my1, const char* my2, const char* your, co
::lcdPosition(m_fd, 0, 0); ::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "D-Star"); ::lcdPuts(m_fd, "D-Star");
if (m_rows > 2U) { if (m_rows == 2U && m_cols == 16U) {
char buffer[40U]; 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); ::sprintf(buffer, "%s %.8s/%.4s >", type, my1, my2);
::lcdPosition(m_fd, 0, 1); ::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, buffer); ::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); ::sprintf(buffer, "%.8s", your);
::lcdPosition(m_fd, 0, 2); ::lcdPosition(m_fd, 0, 2);
::lcdPrintf(m_fd, "%.*s", m_cols, buffer); ::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
} else { } else if (m_rows == 2 && m_cols == 40U) {
char buffer[40U]; char buffer[40U];
::sprintf(buffer, "%s %.8s/%.4s > %.8s", type, my1, my2, your); ::sprintf(buffer, "%s %.8s/%.4s > %.8s", type, my1, my2, your);
::lcdPosition(m_fd, 0, 1); ::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, buffer); ::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() 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); ::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
::lcdPosition(m_fd, 0, 2); ::lcdPosition(m_fd, 0, 2);
::lcdPrintf(m_fd, "%.*s", m_cols, " "); ::lcdPrintf(m_fd, "%.*s", m_cols, " ");
} else { } else if (m_rows == 2 && m_cols == 40U) {
::lcdPosition(m_fd, 0, 1); ::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
} }
@ -162,52 +168,101 @@ void CHD44780::writeDMR(unsigned int slotNo, const char* src, bool group, const
if (!m_dmr) { if (!m_dmr) {
::lcdClear(m_fd); ::lcdClear(m_fd);
if (m_rows > 2U) { if (m_rows == 2U && m_cols == 16U) {
::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "DMR");
}
if (slotNo == 1U) { if (slotNo == 1U) {
::lcdPosition(m_fd, 0, m_rows > 2U ? 2 : 1); ::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING);
} else { } else {
::lcdPosition(m_fd, 0, m_rows > 2U ? 1 : 0); ::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, 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); ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING);
} }
} }
}
if (m_rows == 2U && m_cols == 16U) {
char buffer[16U];
if (slotNo == 1U) { if (slotNo == 1U) {
char buffer[40U];
if (m_cols > 16U)
::sprintf(buffer, "%s %s > %s%s", type, src, group ? "TG" : "", dst);
else
::sprintf(buffer, "%s > %s%s", src, group ? "TG" : "", dst); ::sprintf(buffer, "%s > %s%s", src, group ? "TG" : "", dst);
::lcdPosition(m_fd, 0, 0);
::lcdPosition(m_fd, 0, m_rows > 2U ? 1 : 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer);
} else { } else {
char buffer[40U];
if (m_cols > 16U)
::sprintf(buffer, "%s %s > %s%s", type, src, group ? "TG" : "", dst);
else
::sprintf(buffer, "%s > %s%s", src, group ? "TG" : "", dst); ::sprintf(buffer, "%s > %s%s", src, group ? "TG" : "", dst);
::lcdPosition(m_fd, 0, 1);
::lcdPosition(m_fd, 0, m_rows > 2U ? 2 : 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); ::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; m_dmr = true;
} }
void CHD44780::clearDMR(unsigned int slotNo) void CHD44780::clearDMR(unsigned int slotNo)
{ {
if (m_rows == 2U && m_cols == 16U) {
if (slotNo == 1U) { if (slotNo == 1U) {
::lcdPosition(m_fd, 0, m_rows > 2U ? 1 : 0); ::lcdPosition(m_fd, 0, 0);
::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING);
} else { } else {
::lcdPosition(m_fd, 0, m_rows > 2U ? 2 : 1); ::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); ::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);
}
}
} }
void CHD44780::writeFusion(const char* source, const char* dest) void CHD44780::writeFusion(const char* source, const char* dest)
@ -220,9 +275,13 @@ void CHD44780::writeFusion(const char* source, const char* dest)
::lcdPosition(m_fd, 0, 0); ::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "System Fusion"); ::lcdPuts(m_fd, "System Fusion");
if (m_rows > 2U) { if (m_rows == 2U && m_cols == 16U) {
char buffer[40U]; 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); ::sprintf(buffer, "%.10s >", source);
::lcdPosition(m_fd, 0, 1); ::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, buffer); ::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
@ -230,7 +289,7 @@ void CHD44780::writeFusion(const char* source, const char* dest)
::sprintf(buffer, "%.10s", dest); ::sprintf(buffer, "%.10s", dest);
::lcdPosition(m_fd, 0, 2); ::lcdPosition(m_fd, 0, 2);
::lcdPrintf(m_fd, "%.*s", m_cols, buffer); ::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
} else { } else if (m_rows == 2 && m_cols == 40U) {
char buffer[40U]; char buffer[40U];
::sprintf(buffer, "%.10s > %.10s", source, dest); ::sprintf(buffer, "%.10s > %.10s", source, dest);
@ -243,13 +302,16 @@ void CHD44780::writeFusion(const char* source, const char* dest)
void CHD44780::clearFusion() 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); ::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
::lcdPosition(m_fd, 0, 2); ::lcdPosition(m_fd, 0, 2);
::lcdPrintf(m_fd, "%.*s", m_cols, " "); ::lcdPrintf(m_fd, "%.*s", m_cols, " ");
} else { } else if (m_rows == 2 && m_cols == 40U) {
::lcdPosition(m_fd, 0, 1); ::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
} }