Allow for the configuration of the HD44780 pins.
This commit is contained in:
parent
f7e2cff004
commit
3ee457830b
6 changed files with 42 additions and 7 deletions
16
Conf.cpp
16
Conf.cpp
|
@ -102,7 +102,8 @@ m_fusionNetworkDebug(false),
|
|||
m_tftSerialPort(),
|
||||
m_tftSerialBrightness(50U),
|
||||
m_hd44780Rows(2U),
|
||||
m_hd44780Columns(16U)
|
||||
m_hd44780Columns(16U),
|
||||
m_hd44780Pins()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -300,6 +301,14 @@ bool CConf::read()
|
|||
m_hd44780Rows = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Columns") == 0)
|
||||
m_hd44780Columns = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "Pins") == 0) {
|
||||
char* p = ::strtok(value, ",\r\n");
|
||||
while (p != NULL) {
|
||||
unsigned int pin = (unsigned int)::atoi(p);
|
||||
m_hd44780Pins.push_back(pin);
|
||||
p = ::strtok(NULL, ",\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -607,3 +616,8 @@ unsigned int CConf::getHD44780Columns() const
|
|||
{
|
||||
return m_hd44780Columns;
|
||||
}
|
||||
|
||||
std::vector<unsigned int> CConf::getHD44780Pins() const
|
||||
{
|
||||
return m_hd44780Pins;
|
||||
}
|
||||
|
|
2
Conf.h
2
Conf.h
|
@ -113,6 +113,7 @@ public:
|
|||
// The HD44780 section
|
||||
unsigned int getHD44780Rows() const;
|
||||
unsigned int getHD44780Columns() const;
|
||||
std::vector<unsigned int> getHD44780Pins() const;
|
||||
|
||||
private:
|
||||
std::string m_file;
|
||||
|
@ -187,6 +188,7 @@ private:
|
|||
|
||||
unsigned int m_hd44780Rows;
|
||||
unsigned int m_hd44780Columns;
|
||||
std::vector<unsigned int> m_hd44780Pins;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
10
HD44780.cpp
10
HD44780.cpp
|
@ -27,9 +27,15 @@
|
|||
|
||||
const char* LISTENING = "Listening ";
|
||||
|
||||
CHD44780::CHD44780(unsigned int rows, unsigned int cols) :
|
||||
CHD44780::CHD44780(unsigned int rows, unsigned int cols, const std::vector<unsigned int>& pins) :
|
||||
m_rows(rows),
|
||||
m_cols(cols),
|
||||
m_rb(pins.at(0U)),
|
||||
m_strb(pins.at(1U)),
|
||||
m_d0(pins.at(2U)),
|
||||
m_d1(pins.at(3U)),
|
||||
m_d2(pins.at(4U)),
|
||||
m_d3(pins.at(5U)),
|
||||
m_fd(-1)
|
||||
{
|
||||
assert(rows > 1U);
|
||||
|
@ -44,7 +50,7 @@ bool CHD44780::open()
|
|||
{
|
||||
::wiringPiSetup();
|
||||
|
||||
m_fd = ::lcdInit(m_rows, m_cols, 4, 11, 10, 0, 1, 2, 3, 0, 0, 0, 0);
|
||||
m_fd = ::lcdInit(m_rows, m_cols, 4, m_rb, m_strb, m_d0, m_d1, m_d2, m_d3, 0, 0, 0, 0);
|
||||
if (m_fd == -1) {
|
||||
LogError("Unable to open the HD44780");
|
||||
return false;
|
||||
|
|
|
@ -22,11 +22,12 @@
|
|||
#include "Display.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class CHD44780 : public IDisplay
|
||||
{
|
||||
public:
|
||||
CHD44780(unsigned int rows, unsigned int cols);
|
||||
CHD44780(unsigned int rows, unsigned int cols, const std::vector<unsigned int>& pins);
|
||||
virtual ~CHD44780();
|
||||
|
||||
virtual bool open();
|
||||
|
@ -53,6 +54,12 @@ public:
|
|||
private:
|
||||
unsigned int m_rows;
|
||||
unsigned int m_cols;
|
||||
unsigned int m_rb;
|
||||
unsigned int m_strb;
|
||||
unsigned int m_d0;
|
||||
unsigned int m_d1;
|
||||
unsigned int m_d2;
|
||||
unsigned int m_d3;
|
||||
int m_fd;
|
||||
};
|
||||
|
||||
|
|
|
@ -83,3 +83,5 @@ Brightness=50
|
|||
[HD44780]
|
||||
Rows=2
|
||||
Columns=16
|
||||
# rs, strb, d0, d1, d2, d3
|
||||
Pins=11,10,0,1,2,3
|
||||
|
|
|
@ -577,11 +577,15 @@ void CMMDVMHost::createDisplay()
|
|||
} else if (type == "HD44780") {
|
||||
unsigned int rows = m_conf.getHD44780Rows();
|
||||
unsigned int columns = m_conf.getHD44780Columns();
|
||||
std::vector<unsigned int> pins = m_conf.getHD44780Pins();
|
||||
|
||||
LogInfo(" Rows: %u", rows);
|
||||
LogInfo(" Columns: %u", columns);
|
||||
if (pins.size() == 6U) {
|
||||
LogInfo(" Rows: %u", rows);
|
||||
LogInfo(" Columns: %u", columns);
|
||||
LogInfo(" Pins: %u,%u,%u,%u,%u,%u", pins.at(0U), pins.at(1U), pins.at(2U), pins.at(3U), pins.at(4U), pins.at(5U));
|
||||
|
||||
m_display = new CHD44780(rows, columns);
|
||||
m_display = new CHD44780(rows, columns, pins);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
m_display = new CNullDisplay;
|
||||
|
|
Loading…
Reference in a new issue