2016-01-14 18:45:04 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "TFTSerial.h"
|
|
|
|
#include "Log.h"
|
|
|
|
|
2016-02-16 18:30:12 +00:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cassert>
|
2016-01-14 22:58:45 +00:00
|
|
|
#include <cstring>
|
|
|
|
|
2016-02-18 19:09:10 +00:00
|
|
|
const unsigned char ROTATION_PORTRAIT_LEFT = 0U;
|
|
|
|
const unsigned char ROTATION_LANDSCAPE_UD = 1U;
|
|
|
|
const unsigned char ROTATION_PORTRAIT_RIGHT = 2U;
|
|
|
|
const unsigned char ROTATION_LANDSCAPE = 3U;
|
|
|
|
|
2016-03-02 13:38:02 +00:00
|
|
|
const unsigned char COLOUR_BLACK = 0U;
|
|
|
|
const unsigned char COLOUR_BLUE = 1U;
|
|
|
|
const unsigned char COLOUR_RED = 2U;
|
|
|
|
const unsigned char COLOUR_GREEN = 3U;
|
|
|
|
const unsigned char COLOUR_CYAN = 4U;
|
|
|
|
const unsigned char COLOUR_MAGENTA = 5U;
|
|
|
|
const unsigned char COLOUR_YELLOW = 6U;
|
|
|
|
const unsigned char COLOUR_WHITE = 7U;
|
|
|
|
|
|
|
|
const unsigned char FONT_SMALL = 1U;
|
|
|
|
const unsigned char FONT_MEDIUM = 2U;
|
|
|
|
const unsigned char FONT_LARGE = 3U;
|
2016-02-18 19:09:10 +00:00
|
|
|
|
|
|
|
// x = 0 to 159, y = 0 to 127 - Landscape
|
|
|
|
// x = 0 to 127, y = 0 to 159 - Portrait
|
|
|
|
|
2016-10-06 17:38:16 +00:00
|
|
|
CTFTSerial::CTFTSerial(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness) :
|
2016-05-09 17:14:27 +00:00
|
|
|
CDisplay(),
|
2016-04-11 09:55:20 +00:00
|
|
|
m_callsign(callsign),
|
|
|
|
m_dmrid(dmrid),
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial(serial),
|
2016-04-11 11:21:46 +00:00
|
|
|
m_brightness(brightness),
|
|
|
|
m_mode(MODE_IDLE)
|
2016-01-14 18:45:04 +00:00
|
|
|
{
|
2016-10-06 17:38:16 +00:00
|
|
|
assert(serial != NULL);
|
2016-02-16 18:30:12 +00:00
|
|
|
assert(brightness >= 0U && brightness <= 100U);
|
2016-01-14 18:45:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CTFTSerial::~CTFTSerial()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CTFTSerial::open()
|
|
|
|
{
|
2016-10-06 17:38:16 +00:00
|
|
|
bool ret = m_serial->open();
|
2016-01-14 18:45:04 +00:00
|
|
|
if (!ret) {
|
|
|
|
LogError("Cannot open the port for the TFT Serial");
|
2016-10-06 17:38:16 +00:00
|
|
|
delete m_serial;
|
2016-01-14 18:45:04 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-18 19:09:10 +00:00
|
|
|
setRotation(ROTATION_LANDSCAPE);
|
2016-02-16 18:30:12 +00:00
|
|
|
|
|
|
|
setBrightness(m_brightness);
|
|
|
|
|
2016-03-02 13:38:02 +00:00
|
|
|
setBackground(COLOUR_WHITE);
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2016-03-02 13:38:02 +00:00
|
|
|
setForeground(COLOUR_BLACK);
|
2016-01-14 18:45:04 +00:00
|
|
|
|
|
|
|
setIdle();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-09 17:14:27 +00:00
|
|
|
void CTFTSerial::setIdleInt()
|
2016-01-14 18:45:04 +00:00
|
|
|
{
|
|
|
|
// Clear the screen
|
2016-02-16 07:48:07 +00:00
|
|
|
clearScreen();
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2016-03-03 21:27:03 +00:00
|
|
|
setFontSize(FONT_LARGE);
|
|
|
|
|
2016-01-14 18:45:04 +00:00
|
|
|
// Draw MMDVM logo
|
2016-02-18 18:31:44 +00:00
|
|
|
displayBitmap(0U, 0U, "MMDVM_sm.bmp");
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2016-04-11 09:55:20 +00:00
|
|
|
char text[30];
|
2016-04-21 10:09:54 +00:00
|
|
|
::sprintf(text, "%-6s / %u", m_callsign.c_str(), m_dmrid);
|
2016-04-11 09:55:20 +00:00
|
|
|
|
|
|
|
gotoPosPixel(18U, 55U);
|
|
|
|
displayText(text);
|
|
|
|
|
|
|
|
gotoPosPixel(45U, 90U);
|
2016-03-03 18:01:01 +00:00
|
|
|
displayText("IDLE");
|
2016-04-11 11:21:46 +00:00
|
|
|
|
|
|
|
m_mode = MODE_IDLE;
|
2016-03-03 18:01:01 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 17:14:27 +00:00
|
|
|
void CTFTSerial::setErrorInt(const char* text)
|
2016-03-21 22:47:58 +00:00
|
|
|
{
|
|
|
|
assert(text != NULL);
|
|
|
|
|
|
|
|
// Clear the screen
|
|
|
|
clearScreen();
|
|
|
|
|
|
|
|
setFontSize(FONT_MEDIUM);
|
|
|
|
|
|
|
|
// Draw MMDVM logo
|
|
|
|
displayBitmap(0U, 0U, "MMDVM_sm.bmp");
|
|
|
|
|
|
|
|
setForeground(COLOUR_RED);
|
|
|
|
|
|
|
|
gotoPosPixel(18U, 55U);
|
|
|
|
displayText(text);
|
|
|
|
|
|
|
|
gotoPosPixel(18U, 90U);
|
|
|
|
displayText("ERROR");
|
|
|
|
|
|
|
|
setForeground(COLOUR_BLACK);
|
2016-04-11 11:21:46 +00:00
|
|
|
|
|
|
|
m_mode = MODE_ERROR;
|
2016-03-21 22:47:58 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 17:14:27 +00:00
|
|
|
void CTFTSerial::setLockoutInt()
|
2016-03-03 18:01:01 +00:00
|
|
|
{
|
|
|
|
// Clear the screen
|
|
|
|
clearScreen();
|
|
|
|
|
2016-03-03 21:27:03 +00:00
|
|
|
setFontSize(FONT_LARGE);
|
|
|
|
|
2016-03-03 18:01:01 +00:00
|
|
|
// Draw MMDVM logo
|
|
|
|
displayBitmap(0U, 0U, "MMDVM_sm.bmp");
|
|
|
|
|
2016-03-03 21:27:03 +00:00
|
|
|
gotoPosPixel(20U, 60U);
|
2016-03-03 18:01:01 +00:00
|
|
|
displayText("LOCKOUT");
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2016-04-11 11:21:46 +00:00
|
|
|
m_mode = MODE_LOCKOUT;
|
2016-01-14 18:45:04 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 17:14:27 +00:00
|
|
|
void CTFTSerial::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector)
|
2016-01-14 18:45:04 +00:00
|
|
|
{
|
2016-02-16 18:30:12 +00:00
|
|
|
assert(my1 != NULL);
|
|
|
|
assert(my2 != NULL);
|
|
|
|
assert(your != NULL);
|
2016-04-12 16:46:48 +00:00
|
|
|
assert(type != NULL);
|
2016-04-16 20:25:51 +00:00
|
|
|
assert(reflector != NULL);
|
2016-02-16 18:30:12 +00:00
|
|
|
|
2016-04-11 11:21:46 +00:00
|
|
|
if (m_mode != MODE_DSTAR) {
|
|
|
|
// Clear the screen
|
|
|
|
clearScreen();
|
|
|
|
|
|
|
|
setFontSize(FONT_MEDIUM);
|
|
|
|
|
|
|
|
// Draw D-Star insignia
|
|
|
|
displayBitmap(0U, 0U, "DStar_sm.bmp");
|
|
|
|
}
|
|
|
|
|
2016-02-29 22:43:26 +00:00
|
|
|
char text[30U];
|
2016-03-03 21:27:03 +00:00
|
|
|
|
2016-04-28 08:53:15 +00:00
|
|
|
::sprintf(text, "%s %.8s/%4.4s", type, my1, my2);
|
|
|
|
gotoPosPixel(5U, 70U);
|
2016-03-03 21:27:03 +00:00
|
|
|
displayText(text);
|
|
|
|
|
2016-04-28 08:53:15 +00:00
|
|
|
::sprintf(text, "%.8s", your);
|
|
|
|
gotoPosPixel(5U, 90U);
|
|
|
|
displayText(text);
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2016-04-28 12:29:12 +00:00
|
|
|
if (::strcmp(reflector, " ") != 0) {
|
|
|
|
::sprintf(text, "via %.8s", reflector);
|
|
|
|
gotoPosPixel(5U, 110U);
|
|
|
|
displayText(text);
|
2016-05-09 08:31:59 +00:00
|
|
|
} else {
|
|
|
|
gotoPosPixel(5U, 110U);
|
|
|
|
displayText(" ");
|
2016-04-28 12:29:12 +00:00
|
|
|
}
|
2016-04-11 11:21:46 +00:00
|
|
|
|
|
|
|
m_mode = MODE_DSTAR;
|
2016-01-14 18:45:04 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 17:14:27 +00:00
|
|
|
void CTFTSerial::clearDStarInt()
|
2016-01-14 18:45:04 +00:00
|
|
|
{
|
2016-04-28 08:53:15 +00:00
|
|
|
gotoPosPixel(5U, 70U);
|
2016-03-03 21:27:03 +00:00
|
|
|
displayText(" Listening ");
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2016-04-28 08:53:15 +00:00
|
|
|
gotoPosPixel(5U, 90U);
|
|
|
|
displayText(" ");
|
|
|
|
|
|
|
|
gotoPosPixel(5U, 110U);
|
2016-04-28 12:29:12 +00:00
|
|
|
displayText(" ");
|
2016-01-14 18:45:04 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 17:14:27 +00:00
|
|
|
void CTFTSerial::writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type)
|
2016-01-14 18:45:04 +00:00
|
|
|
{
|
2016-04-11 11:21:46 +00:00
|
|
|
assert(type != NULL);
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2016-04-11 11:21:46 +00:00
|
|
|
if (m_mode != MODE_DMR) {
|
|
|
|
// Clear the screen
|
|
|
|
clearScreen();
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2016-04-11 11:21:46 +00:00
|
|
|
setFontSize(FONT_MEDIUM);
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2016-04-11 11:21:46 +00:00
|
|
|
// Draw DMR insignia
|
|
|
|
displayBitmap(0U, 0U, "DMR_sm.bmp");
|
2016-02-18 18:31:44 +00:00
|
|
|
|
2016-04-11 11:21:46 +00:00
|
|
|
if (slotNo == 1U) {
|
|
|
|
gotoPosPixel(5U, 90U);
|
|
|
|
displayText("2 Listening");
|
|
|
|
} else {
|
|
|
|
gotoPosPixel(5U, 55U);
|
|
|
|
displayText("1 Listening");
|
|
|
|
}
|
|
|
|
}
|
2016-02-16 18:30:12 +00:00
|
|
|
|
2016-02-18 18:31:44 +00:00
|
|
|
if (slotNo == 1U) {
|
2016-02-29 22:43:26 +00:00
|
|
|
char text[30U];
|
2016-03-03 21:27:03 +00:00
|
|
|
|
2016-04-21 12:01:53 +00:00
|
|
|
::sprintf(text, "1 %s %s", type, src.c_str());
|
2016-03-03 21:27:03 +00:00
|
|
|
gotoPosPixel(5U, 55U);
|
|
|
|
displayText(text);
|
|
|
|
|
2016-04-21 12:01:53 +00:00
|
|
|
::sprintf(text, "%s%s", group ? "TG" : "", dst.c_str());
|
2016-03-03 21:27:03 +00:00
|
|
|
gotoPosPixel(65U, 72U);
|
2016-02-18 18:31:44 +00:00
|
|
|
displayText(text);
|
|
|
|
} else {
|
2016-02-29 22:43:26 +00:00
|
|
|
char text[30U];
|
2016-03-03 21:27:03 +00:00
|
|
|
|
2016-04-21 12:01:53 +00:00
|
|
|
::sprintf(text, "2 %s %s", type, src.c_str());
|
2016-03-03 21:27:03 +00:00
|
|
|
gotoPosPixel(5U, 90U);
|
|
|
|
displayText(text);
|
|
|
|
|
2016-04-21 12:01:53 +00:00
|
|
|
::sprintf(text, "%s%s", group ? "TG" : "", dst.c_str());
|
2016-03-03 21:27:03 +00:00
|
|
|
gotoPosPixel(65U, 107U);
|
2016-02-18 18:31:44 +00:00
|
|
|
displayText(text);
|
|
|
|
}
|
2016-04-11 11:21:46 +00:00
|
|
|
|
|
|
|
m_mode = MODE_DMR;
|
2016-01-14 18:45:04 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 17:14:27 +00:00
|
|
|
void CTFTSerial::clearDMRInt(unsigned int slotNo)
|
2016-01-14 18:45:04 +00:00
|
|
|
{
|
2016-02-18 18:31:44 +00:00
|
|
|
if (slotNo == 1U) {
|
2016-03-03 21:27:03 +00:00
|
|
|
gotoPosPixel(5U, 55U);
|
2016-03-06 19:01:08 +00:00
|
|
|
displayText("1 Listening ");
|
2016-03-03 21:27:03 +00:00
|
|
|
|
|
|
|
gotoPosPixel(65U, 72U);
|
|
|
|
displayText(" ");
|
2016-02-18 18:31:44 +00:00
|
|
|
} else {
|
2016-03-03 21:27:03 +00:00
|
|
|
gotoPosPixel(5U, 90U);
|
2016-03-06 19:01:08 +00:00
|
|
|
displayText("2 Listening ");
|
2016-03-03 21:27:03 +00:00
|
|
|
|
|
|
|
gotoPosPixel(65U, 107U);
|
|
|
|
displayText(" ");
|
2016-02-18 18:31:44 +00:00
|
|
|
}
|
2016-01-14 18:45:04 +00:00
|
|
|
}
|
|
|
|
|
2016-05-19 18:08:48 +00:00
|
|
|
void CTFTSerial::writeFusionInt(const char* source, const char* dest, const char* type, const char* origin)
|
2016-01-14 18:45:04 +00:00
|
|
|
{
|
2016-02-29 22:43:26 +00:00
|
|
|
assert(source != NULL);
|
|
|
|
assert(dest != NULL);
|
2016-05-16 20:57:32 +00:00
|
|
|
assert(type != NULL);
|
2016-05-19 18:08:48 +00:00
|
|
|
assert(origin != NULL);
|
2016-02-29 22:43:26 +00:00
|
|
|
|
2016-04-11 11:21:46 +00:00
|
|
|
if (m_mode != MODE_YSF) {
|
|
|
|
// Clear the screen
|
|
|
|
clearScreen();
|
|
|
|
|
|
|
|
setFontSize(FONT_MEDIUM);
|
|
|
|
|
|
|
|
// Draw the System Fusion insignia
|
|
|
|
displayBitmap(0U, 0U, "YSF_sm.bmp");
|
|
|
|
}
|
|
|
|
|
2016-02-29 22:43:26 +00:00
|
|
|
char text[30U];
|
2016-05-16 20:57:32 +00:00
|
|
|
::sprintf(text, "%s %.10s", type, source);
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2016-05-19 18:08:48 +00:00
|
|
|
gotoPosPixel(5U, 70U);
|
2016-03-03 21:27:03 +00:00
|
|
|
displayText(text);
|
|
|
|
|
2016-05-16 20:57:32 +00:00
|
|
|
::sprintf(text, " %.10s", dest);
|
2016-03-03 21:27:03 +00:00
|
|
|
|
2016-05-19 18:08:48 +00:00
|
|
|
gotoPosPixel(5U, 90U);
|
2016-02-18 18:31:44 +00:00
|
|
|
displayText(text);
|
2016-04-11 11:21:46 +00:00
|
|
|
|
2016-05-19 18:08:48 +00:00
|
|
|
if (::strcmp(origin, " ") != 0) {
|
2016-05-23 17:04:17 +00:00
|
|
|
::sprintf(text, "at %.10s", origin);
|
2016-05-19 18:08:48 +00:00
|
|
|
gotoPosPixel(5U, 110U);
|
|
|
|
displayText(text);
|
|
|
|
} else {
|
|
|
|
gotoPosPixel(5U, 110U);
|
|
|
|
displayText(" ");
|
|
|
|
}
|
|
|
|
|
2016-04-11 11:21:46 +00:00
|
|
|
m_mode = MODE_YSF;
|
2016-01-14 18:45:04 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 17:14:27 +00:00
|
|
|
void CTFTSerial::clearFusionInt()
|
2016-01-14 18:45:04 +00:00
|
|
|
{
|
2016-05-19 18:08:48 +00:00
|
|
|
gotoPosPixel(5U, 70U);
|
|
|
|
displayText(" Listening ");
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2016-05-19 18:08:48 +00:00
|
|
|
gotoPosPixel(5U, 90U);
|
|
|
|
displayText(" ");
|
|
|
|
|
|
|
|
gotoPosPixel(5U, 110U);
|
|
|
|
displayText(" ");
|
2016-01-14 18:45:04 +00:00
|
|
|
}
|
|
|
|
|
2016-09-12 19:23:50 +00:00
|
|
|
void CTFTSerial::writeP25Int(const char* source, bool group, unsigned int dest, const char* type)
|
2016-09-12 17:12:32 +00:00
|
|
|
{
|
|
|
|
assert(source != 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);
|
|
|
|
|
2016-09-12 19:23:50 +00:00
|
|
|
::sprintf(text, " %s%u", group ? "TG" : "", dest);
|
2016-09-12 17:12:32 +00:00
|
|
|
|
|
|
|
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(" ");
|
|
|
|
}
|
|
|
|
|
2016-09-15 11:57:07 +00:00
|
|
|
void CTFTSerial::writeCWInt()
|
|
|
|
{
|
2016-09-15 21:26:17 +00:00
|
|
|
gotoPosPixel(45U, 90U);
|
|
|
|
displayText("CW TX");
|
|
|
|
|
|
|
|
m_mode = MODE_CW;
|
2016-09-15 11:57:07 +00:00
|
|
|
}
|
|
|
|
|
2016-09-15 13:17:51 +00:00
|
|
|
void CTFTSerial::clearCWInt()
|
|
|
|
{
|
2016-09-15 21:26:17 +00:00
|
|
|
gotoPosPixel(45U, 90U);
|
|
|
|
displayText("IDLE");
|
2016-09-15 13:17:51 +00:00
|
|
|
}
|
|
|
|
|
2016-01-14 18:45:04 +00:00
|
|
|
void CTFTSerial::close()
|
|
|
|
{
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->close();
|
|
|
|
delete m_serial;
|
2016-01-14 18:45:04 +00:00
|
|
|
}
|
2016-02-16 07:48:07 +00:00
|
|
|
|
|
|
|
void CTFTSerial::clearScreen()
|
|
|
|
{
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)"\x1B\x00\xFF", 3U);
|
2016-02-16 07:48:07 +00:00
|
|
|
}
|
|
|
|
|
2016-02-16 18:30:12 +00:00
|
|
|
void CTFTSerial::setForeground(unsigned char colour)
|
|
|
|
{
|
|
|
|
assert(colour >= 0U && colour <= 7U);
|
|
|
|
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)"\x1B\x01", 2U);
|
|
|
|
m_serial->write(&colour, 1U);
|
|
|
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
2016-02-16 18:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CTFTSerial::setBackground(unsigned char colour)
|
|
|
|
{
|
|
|
|
assert(colour >= 0U && colour <= 7U);
|
|
|
|
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)"\x1B\x02", 2U);
|
|
|
|
m_serial->write(&colour, 1U);
|
|
|
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
2016-02-16 18:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CTFTSerial::setRotation(unsigned char rotation)
|
|
|
|
{
|
|
|
|
assert(rotation >= 0U && rotation <= 3U);
|
|
|
|
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)"\x1B\x03", 2U);
|
|
|
|
m_serial->write(&rotation, 1U);
|
|
|
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
2016-02-16 18:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CTFTSerial::setFontSize(unsigned char size)
|
|
|
|
{
|
2016-03-02 13:38:02 +00:00
|
|
|
assert(size >= 1U && size <= 3U);
|
2016-02-16 18:30:12 +00:00
|
|
|
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)"\x1B\x04", 2U);
|
|
|
|
m_serial->write(&size, 1U);
|
|
|
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
2016-02-16 18:30:12 +00:00
|
|
|
}
|
|
|
|
|
2016-02-18 18:31:44 +00:00
|
|
|
void CTFTSerial::gotoBegOfLine()
|
2016-02-16 07:48:07 +00:00
|
|
|
{
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)"\x1B\x05\xFF", 3U);
|
2016-02-18 18:31:44 +00:00
|
|
|
}
|
2016-02-16 18:30:12 +00:00
|
|
|
|
2016-02-18 18:31:44 +00:00
|
|
|
void CTFTSerial::gotoPosText(unsigned char x, unsigned char y)
|
|
|
|
{
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)"\x1B\x06", 2U);
|
|
|
|
m_serial->write(&x, 1U);
|
|
|
|
m_serial->write(&y, 1U);
|
|
|
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
2016-02-18 18:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CTFTSerial::gotoPosPixel(unsigned char x, unsigned char y)
|
|
|
|
{
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)"\x1B\x07", 2U);
|
|
|
|
m_serial->write(&x, 1U);
|
|
|
|
m_serial->write(&y, 1U);
|
|
|
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
2016-02-16 07:48:07 +00:00
|
|
|
}
|
|
|
|
|
2016-02-16 18:30:12 +00:00
|
|
|
void CTFTSerial::drawLine(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2)
|
2016-02-16 07:48:07 +00:00
|
|
|
{
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)"\x1B\x08", 2U);
|
|
|
|
m_serial->write(&x1, 1U);
|
|
|
|
m_serial->write(&y1, 1U);
|
|
|
|
m_serial->write(&x2, 1U);
|
|
|
|
m_serial->write(&y2, 1U);
|
|
|
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
2016-02-16 18:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CTFTSerial::drawBox(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, bool filled)
|
|
|
|
{
|
|
|
|
if (filled)
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)"\x1B\x0A", 2U);
|
2016-02-16 18:30:12 +00:00
|
|
|
else
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)"\x1B\x09", 2U);
|
2016-02-16 18:30:12 +00:00
|
|
|
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write(&x1, 1U);
|
|
|
|
m_serial->write(&y1, 1U);
|
|
|
|
m_serial->write(&x2, 1U);
|
|
|
|
m_serial->write(&y2, 1U);
|
|
|
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
2016-02-16 18:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CTFTSerial::drawCircle(unsigned char x, unsigned char y, unsigned char radius, bool filled)
|
|
|
|
{
|
|
|
|
if (filled)
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)"\x1B\x0C", 2U);
|
2016-02-16 18:30:12 +00:00
|
|
|
else
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)"\x1B\x0B", 2U);
|
2016-02-16 18:30:12 +00:00
|
|
|
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write(&x, 1U);
|
|
|
|
m_serial->write(&y, 1U);
|
|
|
|
m_serial->write(&radius, 1U);
|
|
|
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
2016-02-16 18:30:12 +00:00
|
|
|
}
|
|
|
|
|
2016-02-18 18:31:44 +00:00
|
|
|
void CTFTSerial::displayBitmap(unsigned char x, unsigned char y, const char* filename)
|
2016-02-16 18:30:12 +00:00
|
|
|
{
|
|
|
|
assert(filename != NULL);
|
|
|
|
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)"\x1B\x0D", 2U);
|
|
|
|
m_serial->write(&x, 1U);
|
|
|
|
m_serial->write(&y, 1U);
|
|
|
|
m_serial->write((unsigned char*)filename, ::strlen(filename));
|
|
|
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
2016-02-16 07:48:07 +00:00
|
|
|
}
|
2016-02-16 18:30:12 +00:00
|
|
|
|
|
|
|
void CTFTSerial::setBrightness(unsigned char brightness)
|
|
|
|
{
|
|
|
|
assert(brightness >= 0U && brightness <= 100U);
|
|
|
|
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)"\x1B\x0E", 2U);
|
|
|
|
m_serial->write(&brightness, 1U);
|
|
|
|
m_serial->write((unsigned char*)"\xFF", 1U);
|
2016-02-16 18:30:12 +00:00
|
|
|
}
|
2016-02-18 18:31:44 +00:00
|
|
|
|
|
|
|
void CTFTSerial::displayText(const char* text)
|
|
|
|
{
|
|
|
|
assert(text != NULL);
|
|
|
|
|
2016-10-06 17:38:16 +00:00
|
|
|
m_serial->write((unsigned char*)text, ::strlen(text));
|
2016-02-18 18:31:44 +00:00
|
|
|
}
|