Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
7585537dcb
7 changed files with 72 additions and 8 deletions
8
Conf.cpp
8
Conf.cpp
|
@ -130,6 +130,7 @@ m_tftSerialBrightness(50U),
|
||||||
m_hd44780Rows(2U),
|
m_hd44780Rows(2U),
|
||||||
m_hd44780Columns(16U),
|
m_hd44780Columns(16U),
|
||||||
m_hd44780Pins(),
|
m_hd44780Pins(),
|
||||||
|
m_hd44780i2cAddress(),
|
||||||
m_hd44780PWM(false),
|
m_hd44780PWM(false),
|
||||||
m_hd44780PWMPin(),
|
m_hd44780PWMPin(),
|
||||||
m_hd44780PWMBright(),
|
m_hd44780PWMBright(),
|
||||||
|
@ -438,6 +439,8 @@ bool CConf::read()
|
||||||
m_hd44780Rows = (unsigned int)::atoi(value);
|
m_hd44780Rows = (unsigned int)::atoi(value);
|
||||||
else if (::strcmp(key, "Columns") == 0)
|
else if (::strcmp(key, "Columns") == 0)
|
||||||
m_hd44780Columns = (unsigned int)::atoi(value);
|
m_hd44780Columns = (unsigned int)::atoi(value);
|
||||||
|
else if (::strcmp(key, "I2CAddress") == 0)
|
||||||
|
m_hd44780i2cAddress = (unsigned int)::strtoul(value, NULL, 16);
|
||||||
else if (::strcmp(key, "PWM") == 0)
|
else if (::strcmp(key, "PWM") == 0)
|
||||||
m_hd44780PWM = ::atoi(value) == 1;
|
m_hd44780PWM = ::atoi(value) == 1;
|
||||||
else if (::strcmp(key, "PWMPin") == 0)
|
else if (::strcmp(key, "PWMPin") == 0)
|
||||||
|
@ -889,6 +892,11 @@ std::vector<unsigned int> CConf::getHD44780Pins() const
|
||||||
return m_hd44780Pins;
|
return m_hd44780Pins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int CConf::getHD44780i2cAddress() const
|
||||||
|
{
|
||||||
|
return m_hd44780i2cAddress;
|
||||||
|
}
|
||||||
|
|
||||||
bool CConf::getHD44780PWM() const
|
bool CConf::getHD44780PWM() const
|
||||||
{
|
{
|
||||||
return m_hd44780PWM;
|
return m_hd44780PWM;
|
||||||
|
|
2
Conf.h
2
Conf.h
|
@ -137,6 +137,7 @@ public:
|
||||||
unsigned int getHD44780Rows() const;
|
unsigned int getHD44780Rows() const;
|
||||||
unsigned int getHD44780Columns() const;
|
unsigned int getHD44780Columns() const;
|
||||||
std::vector<unsigned int> getHD44780Pins() const;
|
std::vector<unsigned int> getHD44780Pins() const;
|
||||||
|
unsigned int getHD44780i2cAddress() const;
|
||||||
bool getHD44780PWM() const;
|
bool getHD44780PWM() const;
|
||||||
unsigned int getHD44780PWMPin() const;
|
unsigned int getHD44780PWMPin() const;
|
||||||
unsigned int getHD44780PWMBright() const;
|
unsigned int getHD44780PWMBright() const;
|
||||||
|
@ -252,6 +253,7 @@ private:
|
||||||
unsigned int m_hd44780Rows;
|
unsigned int m_hd44780Rows;
|
||||||
unsigned int m_hd44780Columns;
|
unsigned int m_hd44780Columns;
|
||||||
std::vector<unsigned int> m_hd44780Pins;
|
std::vector<unsigned int> m_hd44780Pins;
|
||||||
|
unsigned int m_hd44780i2cAddress;
|
||||||
bool m_hd44780PWM;
|
bool m_hd44780PWM;
|
||||||
unsigned int m_hd44780PWMPin;
|
unsigned int m_hd44780PWMPin;
|
||||||
unsigned int m_hd44780PWMBright;
|
unsigned int m_hd44780PWMBright;
|
||||||
|
|
|
@ -36,7 +36,7 @@ char m_buffer2[128U];
|
||||||
char m_buffer3[128U];
|
char m_buffer3[128U];
|
||||||
char m_buffer4[128U];
|
char m_buffer4[128U];
|
||||||
|
|
||||||
CHD44780::CHD44780(unsigned int rows, unsigned int cols, const std::string& callsign, unsigned int dmrid, const std::vector<unsigned int>& pins, bool pwm, unsigned int pwmPin, unsigned int pwmBright, unsigned int pwmDim, bool displayClock, bool utc, bool duplex) :
|
CHD44780::CHD44780(unsigned int rows, unsigned int cols, const std::string& callsign, unsigned int dmrid, const std::vector<unsigned int>& pins, unsigned int i2cAddress, bool pwm, unsigned int pwmPin, unsigned int pwmBright, unsigned int pwmDim, bool displayClock, bool utc, bool duplex) :
|
||||||
CDisplay(),
|
CDisplay(),
|
||||||
m_rows(rows),
|
m_rows(rows),
|
||||||
m_cols(cols),
|
m_cols(cols),
|
||||||
|
@ -48,6 +48,7 @@ m_d0(pins.at(2U)),
|
||||||
m_d1(pins.at(3U)),
|
m_d1(pins.at(3U)),
|
||||||
m_d2(pins.at(4U)),
|
m_d2(pins.at(4U)),
|
||||||
m_d3(pins.at(5U)),
|
m_d3(pins.at(5U)),
|
||||||
|
m_i2cAddress(i2cAddress),
|
||||||
m_pwm(pwm),
|
m_pwm(pwm),
|
||||||
m_pwmPin(pwmPin),
|
m_pwmPin(pwmPin),
|
||||||
m_pwmBright(pwmBright),
|
m_pwmBright(pwmBright),
|
||||||
|
@ -239,7 +240,7 @@ bool CHD44780::open()
|
||||||
void CHD44780::adafruitLCDSetup()
|
void CHD44780::adafruitLCDSetup()
|
||||||
{
|
{
|
||||||
// The other control pins are initialised with lcdInit()
|
// The other control pins are initialised with lcdInit()
|
||||||
::mcp23017Setup(AF_BASE, MCP23017);
|
::mcp23017Setup(AF_BASE, m_i2caddress);
|
||||||
|
|
||||||
// Backlight LEDs
|
// Backlight LEDs
|
||||||
::pinMode(AF_RED, OUTPUT);
|
::pinMode(AF_RED, OUTPUT);
|
||||||
|
@ -311,7 +312,7 @@ void CHD44780::adafruitLCDColour(ADAFRUIT_COLOUR colour)
|
||||||
void CHD44780::pcf8574LCDSetup()
|
void CHD44780::pcf8574LCDSetup()
|
||||||
{
|
{
|
||||||
// Initalize PFC8574
|
// Initalize PFC8574
|
||||||
::pcf8574Setup(AF_BASE, PCF8574);
|
::pcf8574Setup(AF_BASE, m_i2cAddress);
|
||||||
|
|
||||||
// Turn on backlight
|
// Turn on backlight
|
||||||
::pinMode (AF_BL, OUTPUT);
|
::pinMode (AF_BL, OUTPUT);
|
||||||
|
|
|
@ -67,7 +67,7 @@ enum ADAFRUIT_COLOUR {
|
||||||
#define AF_ON LOW
|
#define AF_ON LOW
|
||||||
#define AF_OFF HIGH
|
#define AF_OFF HIGH
|
||||||
|
|
||||||
#define MCP23017 0x20
|
// #define MCP23017 0x20
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Define for HD44780 connected via a PCF8574 GPIO extender
|
// Define for HD44780 connected via a PCF8574 GPIO extender
|
||||||
|
@ -83,13 +83,13 @@ enum ADAFRUIT_COLOUR {
|
||||||
#define AF_D2 (AF_BASE + 6)
|
#define AF_D2 (AF_BASE + 6)
|
||||||
#define AF_D3 (AF_BASE + 7)
|
#define AF_D3 (AF_BASE + 7)
|
||||||
|
|
||||||
#define PCF8574 0x27
|
// #define PCF8574 0x27
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class CHD44780 : public CDisplay
|
class CHD44780 : public CDisplay
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CHD44780(unsigned int rows, unsigned int cols, const std::string& callsign, unsigned int dmrid, const std::vector<unsigned int>& pins, bool pwm, unsigned int pwmPin, unsigned int pwmBright, unsigned int pwmDim, bool displayClock, bool utc, bool duplex);
|
CHD44780(unsigned int rows, unsigned int cols, const std::string& callsign, unsigned int dmrid, const std::vector<unsigned int>& pins, unsigned int i2cAddress, bool pwm, unsigned int pwmPin, unsigned int pwmBright, unsigned int pwmDim, bool displayClock, bool utc, bool duplex);
|
||||||
virtual ~CHD44780();
|
virtual ~CHD44780();
|
||||||
|
|
||||||
virtual bool open();
|
virtual bool open();
|
||||||
|
@ -123,6 +123,7 @@ private:
|
||||||
unsigned int m_d1;
|
unsigned int m_d1;
|
||||||
unsigned int m_d2;
|
unsigned int m_d2;
|
||||||
unsigned int m_d3;
|
unsigned int m_d3;
|
||||||
|
unsigned int m_i2cAddress;
|
||||||
bool m_pwm;
|
bool m_pwm;
|
||||||
unsigned int m_pwmPin;
|
unsigned int m_pwmPin;
|
||||||
unsigned int m_pwmBright;
|
unsigned int m_pwmBright;
|
||||||
|
|
|
@ -107,15 +107,20 @@ Brightness=50
|
||||||
[HD44780]
|
[HD44780]
|
||||||
Rows=2
|
Rows=2
|
||||||
Columns=16
|
Columns=16
|
||||||
|
|
||||||
|
# For basic HD44780 displays (4-bit connection)
|
||||||
# rs, strb, d0, d1, d2, d3
|
# rs, strb, d0, d1, d2, d3
|
||||||
# For basic HD44780 displays
|
|
||||||
Pins=11,10,0,1,2,3
|
Pins=11,10,0,1,2,3
|
||||||
|
|
||||||
|
# Device address for I2C
|
||||||
|
I2CAddress=0x20
|
||||||
|
|
||||||
# PWM backlight
|
# PWM backlight
|
||||||
PWM=0
|
PWM=0
|
||||||
PWMPin=21
|
PWMPin=21
|
||||||
PWMBright=100
|
PWMBright=100
|
||||||
PWMDim=16
|
PWMDim=16
|
||||||
|
|
||||||
DisplayClock=1
|
DisplayClock=1
|
||||||
UTC=0
|
UTC=0
|
||||||
|
|
||||||
|
|
|
@ -875,6 +875,7 @@ void CMMDVMHost::createDisplay()
|
||||||
unsigned int rows = m_conf.getHD44780Rows();
|
unsigned int rows = m_conf.getHD44780Rows();
|
||||||
unsigned int columns = m_conf.getHD44780Columns();
|
unsigned int columns = m_conf.getHD44780Columns();
|
||||||
std::vector<unsigned int> pins = m_conf.getHD44780Pins();
|
std::vector<unsigned int> pins = m_conf.getHD44780Pins();
|
||||||
|
unsigned int i2cAddress = m_conf.getHD44780i2cAddress();
|
||||||
bool pwm = m_conf.getHD44780PWM();
|
bool pwm = m_conf.getHD44780PWM();
|
||||||
unsigned int pwmPin = m_conf.getHD44780PWMPin();
|
unsigned int pwmPin = m_conf.getHD44780PWMPin();
|
||||||
unsigned int pwmBright = m_conf.getHD44780PWMBright();
|
unsigned int pwmBright = m_conf.getHD44780PWMBright();
|
||||||
|
@ -898,7 +899,7 @@ void CMMDVMHost::createDisplay()
|
||||||
if (displayClock)
|
if (displayClock)
|
||||||
LogInfo(" Display UTC: %s", utc ? "yes" : "no");
|
LogInfo(" Display UTC: %s", utc ? "yes" : "no");
|
||||||
|
|
||||||
m_display = new CHD44780(rows, columns, m_callsign, dmrid, pins, pwm, pwmPin, pwmBright, pwmDim, displayClock, utc, m_duplex);
|
m_display = new CHD44780(rows, columns, m_callsign, dmrid, pins, i2cAddress, pwm, pwmPin, pwmBright, pwmDim, displayClock, utc, m_duplex);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(OLED)
|
#if defined(OLED)
|
||||||
|
|
46
README.HD44780
Normal file
46
README.HD44780
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
- HD44780 LCD SUPPORT -
|
||||||
|
|
||||||
|
Support for the HD44780 LCD is via the wiringPi library available at
|
||||||
|
http://wiringpi.com/download-and-install/ which must be installed in all cases.
|
||||||
|
|
||||||
|
The HD44780 in 4-bit mode is probably the most common connection method and
|
||||||
|
wiring details can be found at http://wiringpi.com/dev-lib/lcd-library/
|
||||||
|
|
||||||
|
To compile MMDVMHost with support for the HD44780 use the following commands.
|
||||||
|
|
||||||
|
# cp Makefile.Pi.HD44780 Makefile
|
||||||
|
# make clean
|
||||||
|
# make
|
||||||
|
|
||||||
|
Other HD44780 variations exist that connect via I2C. Support is also via
|
||||||
|
wiringPi, but to compile for each I2C device requires a different Makefile
|
||||||
|
depending on the IC attached to the LCD.
|
||||||
|
|
||||||
|
- ADAFRUIT RGB LCD SHIELD -
|
||||||
|
|
||||||
|
The Adafruit RGB LCD Shield is available from https://www.adafruit.com/product/714
|
||||||
|
I2C is via the MCP23017 IC and is enabled with Makefile.Pi.Adafruit. The
|
||||||
|
I2C device address in MMDVM.ini should be set to 0x20.
|
||||||
|
|
||||||
|
- PCF8574 IC -
|
||||||
|
|
||||||
|
HD44780 LCDs connected via a PCF8574 Remote 8-Bit I/O Expander are available on
|
||||||
|
eBay for very little money! This IC uses Makefile.Pi.PCF8574 and the I2C
|
||||||
|
device address should be set to 0x27.
|
||||||
|
|
||||||
|
- BEWARE -
|
||||||
|
|
||||||
|
The I2C device address can be manually configured on some devices!
|
||||||
|
|
||||||
|
- CHECK YOUR ACTUAL DEVICE ADDRESS -
|
||||||
|
|
||||||
|
More information on configuring and using I2C on the RPi including how to probe
|
||||||
|
the I2C bus for device addresses can be found at
|
||||||
|
https://learn.sparkfun.com/tutorials/raspberry-pi-spi-and-i2c-tutorial#i2c-on-pi
|
||||||
|
|
||||||
|
- PWM BACKLIGHT CONTROL -
|
||||||
|
|
||||||
|
Whilst connected in 4-bit mode or via the PCF8574 IC, the LED backlight can be
|
||||||
|
wired for control via PWM. Connect the backlight +ve pin to any spare GPIO pin
|
||||||
|
and configure MMDVM.ini as appropriate. By default, wiringPi pin 21 is
|
||||||
|
configured.
|
Loading…
Reference in a new issue