From 76ee3045bc2016f895a039076ea8a971177b2012 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 17 Nov 2020 16:56:12 +0000 Subject: [PATCH] Add modem I2C/OLED support. --- Conf.cpp | 10 ++++++++- Conf.h | 4 +++- Display.cpp | 17 ++++++++++++++- I2CModem.cpp | 45 +++++++++++++++++++++++++++++++++++++++ I2CModem.h | 40 ++++++++++++++++++++++++++++++++++ I2CPort.cpp | 23 ++++++++++++++++++++ I2CPort.h | 35 ++++++++++++++++++++++++++++++ MMDVM.ini | 2 ++ MMDVMHost.vcxproj | 4 ++++ MMDVMHost.vcxproj.filters | 12 +++++++++++ Makefile | 12 +++++------ Makefile.Pi | 12 +++++------ Makefile.Pi.Adafruit | 12 +++++------ Makefile.Pi.HD44780 | 12 +++++------ Makefile.Pi.OLED | 12 +++++------ Makefile.Pi.PCF8574 | 12 +++++------ OLED.cpp | 20 ++++++++++++----- OLED.h | 4 +++- 18 files changed, 243 insertions(+), 45 deletions(-) create mode 100644 I2CModem.cpp create mode 100644 I2CModem.h create mode 100644 I2CPort.cpp create mode 100644 I2CPort.h diff --git a/Conf.cpp b/Conf.cpp index 122be9a..eed5d52 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -301,6 +301,7 @@ m_nextionUTC(false), m_nextionIdleBrightness(20U), m_nextionScreenLayout(0U), m_nextionTempInFahrenheit(false), +m_oledPort(), m_oledType(3U), m_oledBrightness(0U), m_oledInvert(false), @@ -1030,7 +1031,9 @@ bool CConf::read() else if (::strcmp(key, "DisplayTempInFahrenheit") == 0) m_nextionTempInFahrenheit = ::atoi(value) == 1; } else if (section == SECTION_OLED) { - if (::strcmp(key, "Type") == 0) + if (::strcmp(key, "Port") == 0) + m_oledPort = value; + else if (::strcmp(key, "Type") == 0) m_oledType = (unsigned char)::atoi(value); else if (::strcmp(key, "Brightness") == 0) m_oledBrightness = (unsigned char)::atoi(value); @@ -2243,6 +2246,11 @@ unsigned int CConf::getNextionScreenLayout() const return m_nextionScreenLayout; } +std::string CConf::getOLEDPort() const +{ + return m_oledPort; +} + unsigned char CConf::getOLEDType() const { return m_oledType; diff --git a/Conf.h b/Conf.h index 01d36fd..77b34b4 100644 --- a/Conf.h +++ b/Conf.h @@ -324,6 +324,7 @@ public: bool getNextionTempInFahrenheit() const; // The OLED section + std::string getOLEDPort() const; unsigned char getOLEDType() const; unsigned char getOLEDBrightness() const; bool getOLEDInvert() const; @@ -613,7 +614,8 @@ private: unsigned int m_nextionIdleBrightness; unsigned int m_nextionScreenLayout; bool m_nextionTempInFahrenheit; - + + std::string m_oledPort; unsigned char m_oledType; unsigned char m_oledBrightness; bool m_oledInvert; diff --git a/Display.cpp b/Display.cpp index 4a358be..c42e3e7 100644 --- a/Display.cpp +++ b/Display.cpp @@ -25,6 +25,8 @@ #include "LCDproc.h" #include "Nextion.h" #include "CASTInfo.h" +#include "I2CModem.h" +#include "I2CPort.h"" #include "Conf.h" #include "Modem.h" #include "OLED.h" @@ -34,6 +36,10 @@ #include "HD44780.h" #endif +#if defined(OLED) +#include "I2CPi.h"" +#endif + #include #include #include @@ -666,6 +672,7 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, IModem* modem) } #endif } else if (type == "OLED") { + std::string port = conf.getOLEDPort(); unsigned char type = conf.getOLEDType(); unsigned char brightness = conf.getOLEDBrightness(); bool invert = conf.getOLEDInvert(); @@ -673,7 +680,15 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, IModem* modem) bool rotate = conf.getOLEDRotate(); bool logosaver = conf.getOLEDLogoScreensaver(); - display = new COLED(type, brightness, invert, scroll, rotate, logosaver, conf.getDMRNetworkSlot1(), conf.getDMRNetworkSlot2()); + if (port == "modem") { + II2CPort* i2c = new CI2CModem(modem); + display = new COLED(i2c, type, brightness, invert, scroll, rotate, logosaver, conf.getDMRNetworkSlot1(), conf.getDMRNetworkSlot2()); +#if defined(OLED) + } else { + II2CPort* i2c = new CI2CPi; + display = new COLED(i2c, type, brightness, invert, scroll, rotate, logosaver, conf.getDMRNetworkSlot1(), conf.getDMRNetworkSlot2()); +#endif + } } else if (type == "CAST") { display = new CCASTInfo(modem); } else { diff --git a/I2CModem.cpp b/I2CModem.cpp new file mode 100644 index 0000000..b9619be --- /dev/null +++ b/I2CModem.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2020 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 "I2CModem.h" + +#include + +CI2CModem::CI2CModem(IModem* modem) : +m_modem(modem) +{ + assert(modem != NULL); +} + +CI2CModem::~CI2CModem() +{ +} + +bool CI2CModem::open() +{ + return true; +} + +bool CI2CModem::write(const uint8_t* data, uint16_t length) +{ + return m_modem->writeI2C(data, length); +} + +void CI2CModem::close() +{ +} diff --git a/I2CModem.h b/I2CModem.h new file mode 100644 index 0000000..cbdfb8f --- /dev/null +++ b/I2CModem.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2020 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. + */ + +#ifndef I2CMODEM_H +#define I2CMODEM_H + +#include "I2CPort.h" +#include "Modem.h" + +class CI2CModem : public II2CPort { +public: + CI2CModem(IModem* modem); + virtual ~CI2CModem(); + + virtual bool open(); + + virtual bool write(const uint8_t* data, uint16_t length); + + virtual void close(); + +private: + IModem* m_modem; +}; + +#endif diff --git a/I2CPort.cpp b/I2CPort.cpp new file mode 100644 index 0000000..d52353e --- /dev/null +++ b/I2CPort.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 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 "I2CPort.h" + +II2CPort::~II2CPort() +{ +} diff --git a/I2CPort.h b/I2CPort.h new file mode 100644 index 0000000..c4175a8 --- /dev/null +++ b/I2CPort.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 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. + */ + +#ifndef I2CPORT_H +#define I2CPORT_H + +#include + +class II2CPort { +public: + virtual ~II2CPort() = 0; + + virtual bool open() = 0; + + virtual bool write(const uint8_t* data, uint16_t length) = 0; + + virtual void close() = 0; +}; + +#endif diff --git a/MMDVM.ini b/MMDVM.ini index f35e75e..1ad5e98 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -303,6 +303,8 @@ ScreenLayout=2 IdleBrightness=20 [OLED] +# Port=Pi +Port=Modem Type=3 Brightness=0 Invert=0 diff --git a/MMDVMHost.vcxproj b/MMDVMHost.vcxproj index 60f6fde..367c6c5 100644 --- a/MMDVMHost.vcxproj +++ b/MMDVMHost.vcxproj @@ -190,6 +190,8 @@ + + @@ -297,6 +299,8 @@ + + diff --git a/MMDVMHost.vcxproj.filters b/MMDVMHost.vcxproj.filters index 1a77588..89161ef 100644 --- a/MMDVMHost.vcxproj.filters +++ b/MMDVMHost.vcxproj.filters @@ -338,6 +338,12 @@ Header Files + + Header Files + + + Header Files + @@ -634,5 +640,11 @@ Source Files + + Source Files + + + Source Files + \ No newline at end of file diff --git a/Makefile b/Makefile index bd052ec..42a2532 100644 --- a/Makefile +++ b/Makefile @@ -10,12 +10,12 @@ OBJECTS = \ AMBEFEC.o BCH.o AX25Control.o AX25Network.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o \ DMREmbeddedData.o DMRFullLC.o DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o \ DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o FMControl.o FMNetwork.o Golay2087.o Golay24128.o Hamming.o I2CController.o \ - IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o MMDVMHost.o Modem.o ModemSerialPort.o \ - Mutex.o NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o \ - NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \ - P25Network.o P25NID.o P25Trellis.o P25Utils.o PseudoTTYController.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o \ - RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UserDB.o UserDBentry.o \ - Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o + I2CPort.o I2CModem.o IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o MMDVMHost.o \ + Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o \ + NXDNIcomNetwork.o NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o \ + P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o PseudoTTYController.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o \ + RS241213.o RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UserDB.o \ + UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o all: MMDVMHost RemoteCommand diff --git a/Makefile.Pi b/Makefile.Pi index c82bbbd..f959ff0 100644 --- a/Makefile.Pi +++ b/Makefile.Pi @@ -10,12 +10,12 @@ OBJECTS = \ AMBEFEC.o AX25Control.o AX25Network.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o \ DMREmbeddedData.o DMRFullLC.o DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o \ DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o FMControl.o FMNetwork.o Golay2087.o Golay24128.o Hamming.o I2CController.o \ - IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o MMDVMHost.o Modem.o ModemSerialPort.o \ - Mutex.o NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o \ - NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \ - P25Network.o P25NID.o P25Trellis.o P25Utils.o PseudoTTYController.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o \ - RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UserDB.o UserDBentry.o \ - Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o + I2CPort.o I2CModem.o IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o MMDVMHost.o \ + Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o \ + NXDNIcomNetwork.o NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o \ + P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o PseudoTTYController.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o \ + RS241213.o RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UserDB.o \ + UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o all: MMDVMHost RemoteCommand diff --git a/Makefile.Pi.Adafruit b/Makefile.Pi.Adafruit index 355c95d..5e7d346 100644 --- a/Makefile.Pi.Adafruit +++ b/Makefile.Pi.Adafruit @@ -11,12 +11,12 @@ OBJECTS = \ AMBEFEC.o AX25Control.o AX25Network.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o \ DMREmbeddedData.o DMRFullLC.o DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o \ DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o FMControl.o FMNetwork.o Golay2087.o Golay24128.o Hamming.o HD44780.o I2CController.o \ - IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o MMDVMHost.o Modem.o ModemSerialPort.o \ - Mutex.o NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o \ - NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \ - P25Network.o P25NID.o P25Trellis.o P25Utils.o PseudoTTYController.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o \ - RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UserDB.o UserDBentry.o \ - Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o + I2CPort.o I2CModem.o IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o MMDVMHost.o \ + Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o \ + NXDNIcomNetwork.o NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o \ + P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o PseudoTTYController.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o \ + RS241213.o RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UserDB.o \ + UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o all: MMDVMHost RemoteCommand diff --git a/Makefile.Pi.HD44780 b/Makefile.Pi.HD44780 index d4bbe63..3dae570 100644 --- a/Makefile.Pi.HD44780 +++ b/Makefile.Pi.HD44780 @@ -10,12 +10,12 @@ OBJECTS = \ AMBEFEC.o AX25Control.o AX25Network.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o \ DMREmbeddedData.o DMRFullLC.o DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o \ DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o FMControl.o FMNetwork.o Golay2087.o Golay24128.o Hamming.o HD44780.o I2CController.o \ - IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o MMDVMHost.o Modem.o ModemSerialPort.o \ - Mutex.o NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o \ - NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \ - P25Network.o P25NID.o P25Trellis.o P25Utils.o PseudoTTYController.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o \ - RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UserDB.o UserDBentry.o \ - Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o + I2CPort.o I2CModem.o IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o MMDVMHost.o \ + Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o \ + NXDNIcomNetwork.o NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o \ + P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o PseudoTTYController.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o \ + RS241213.o RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UserDB.o \ + UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o all: MMDVMHost RemoteCommand diff --git a/Makefile.Pi.OLED b/Makefile.Pi.OLED index 3c9a487..764ab78 100644 --- a/Makefile.Pi.OLED +++ b/Makefile.Pi.OLED @@ -14,12 +14,12 @@ OBJECTS = \ AMBEFEC.o AX25Control.o AX25Network.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o \ DMREmbeddedData.o DMRFullLC.o DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o \ DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o FMControl.o FMNetwork.o Golay2087.o Golay24128.o Hamming.o I2CController.o \ - IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o MMDVMHost.o Modem.o ModemSerialPort.o \ - Mutex.o NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o \ - NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o OLED.o P25Audio.o P25Control.o P25Data.o \ - P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o PseudoTTYController.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o \ - RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o \ - UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o + I2CPi.o I2CPort.o I2CModem.o IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o \ + MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o \ + NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o OLED.o P25Audio.o \ + P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o PseudoTTYController.o POCSAGControl.o POCSAGNetwork.o QR1676.o \ + RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSurenoo.o Thread.o Timer.o \ + UDPSocket.o UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o all: MMDVMHost RemoteCommand diff --git a/Makefile.Pi.PCF8574 b/Makefile.Pi.PCF8574 index 0798819..e9fcffc 100644 --- a/Makefile.Pi.PCF8574 +++ b/Makefile.Pi.PCF8574 @@ -11,12 +11,12 @@ OBJECTS = \ AMBEFEC.o AX25Control.o AX25Network.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o \ DMREmbeddedData.o DMRFullLC.o DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o \ DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o FMControl.o FMNetwork.o Golay2087.o Golay24128.o Hamming.o HD44780.o I2CController.o \ - IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o MMDVMHost.o Modem.o ModemSerialPort.o \ - Mutex.o NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o \ - NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \ - P25Network.o P25NID.o P25Trellis.o P25Utils.o PseudoTTYController.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o \ - RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UserDB.o UserDBentry.o \ - Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o + I2CPort.o I2CModem.o IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o MMDVMHost.o \ + Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o \ + NXDNIcomNetwork.o NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o \ + P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o PseudoTTYController.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o \ + RS241213.o RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UserDB.o \ + UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o all: MMDVMHost RemoteCommand diff --git a/OLED.cpp b/OLED.cpp index 0f7c9c5..e446e7f 100644 --- a/OLED.cpp +++ b/OLED.cpp @@ -20,6 +20,8 @@ #include "Log.h" #include "NetworkInfo.h" +#include + const uint16_t BLACK = 0U; const uint16_t WHITE = 1U; @@ -471,7 +473,8 @@ const unsigned char logo_POCSAG_bmp [] = { 0xFFU, 0xFFU, 0xFFU, 0xE6U, 0x7FU, 0xFEU, 0x07U, 0xFFU, 0xF6U, 0xFFU, 0xDFU, 0xF6U, 0x00U, 0xFBU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU}; -COLED::COLED(unsigned char displayType, unsigned char displayBrightness, bool displayInvert, bool displayScroll, bool displayRotate, bool displayLogoScreensaver, bool slot1Enabled, bool slot2Enabled) : +COLED::COLED(II2CPort* port, unsigned char displayType, unsigned char displayBrightness, bool displayInvert, bool displayScroll, bool displayRotate, bool displayLogoScreensaver, bool slot1Enabled, bool slot2Enabled) : +m_port(port), m_mode(MODE_IDLE), m_displayType(displayType), m_displayBrightness(displayBrightness), @@ -493,6 +496,7 @@ m_textSize(1U), m_textColor(0xFFFFU), m_textBGColor(0xFFFFU) { + assert(port != NULL); } COLED::~COLED() @@ -505,6 +509,10 @@ bool COLED::open() if (!m_display.init(OLED_I2C_RESET, m_displayType)) return false; + bool ret = m_port->open(); + if (!ret) + return false; + m_display.begin(); m_oledBuffer = new uint8_t[m_width * m_height]; @@ -1073,6 +1081,8 @@ void COLED::close() m_display.close(); + m_port->close(); + delete[] m_oledBuffer; } @@ -1304,7 +1314,7 @@ void COLED::display(void) for (uint8_t x = 1U; x <= 16U; x++) buff[x] = *p++; - fastI2Cwrite(buff, 17U); + m_port->write(buff, 17U); } } } else { @@ -1314,21 +1324,21 @@ void COLED::display(void) for (uint8_t x = 1U; x <= 16U; x++) buff[x] = *p++; - fastI2Cwrite(buff, 17U); + m_port->write(buff, 17U); } } } void COLED::sendCommand(uint8_t c) { - char buff[2U]; + uint8_t buff[2U]; // Clear D/C to switch to command mode buff[0] = SSD_Command_Mode; buff[1] = c; // Write Data on I2C - fastI2Cwrite(buff, 2U); + m_port->write(buff, 2U); } size_t COLED::write(uint8_t c) diff --git a/OLED.h b/OLED.h index e84085f..1c860cf 100644 --- a/OLED.h +++ b/OLED.h @@ -22,13 +22,14 @@ #include "Display.h" #include "Defines.h" #include "UserDBentry.h" +#include "I2CPort.h" #include class COLED : public CDisplay { public: - COLED(unsigned char displayType, unsigned char displayBrighness, bool displayInvert, bool displayScroll, bool displayRotate, bool displayLogoScreensaver, bool slot1Enabled, bool slot2Enabled); + COLED(II2CPort* port, unsigned char displayType, unsigned char displayBrighness, bool displayInvert, bool displayScroll, bool displayRotate, bool displayLogoScreensaver, bool slot1Enabled, bool slot2Enabled); virtual ~COLED(); virtual bool open(); @@ -69,6 +70,7 @@ public: virtual void close(); private: + II2CPort* m_port; unsigned char m_mode; unsigned char m_displayType; unsigned char m_displayBrightness;