From 86df456b0f189b18f5c2fc0714c849b27c229807 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Fri, 24 Feb 2017 21:47:35 +0100 Subject: [PATCH] Added a DEM16101 lcd display to the shift register --- DeviceLib | 2 +- MyLcd.cpp | 38 ++++++++++++++++++++++++++++++++++++++ MyLcd.h | 13 +++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 MyLcd.cpp create mode 100644 MyLcd.h diff --git a/DeviceLib b/DeviceLib index 9f8ad33..d9ac375 160000 --- a/DeviceLib +++ b/DeviceLib @@ -1 +1 @@ -Subproject commit 9f8ad3372382536275926cd95d5e5343235faf21 +Subproject commit d9ac375268cb6bfa03a16b803b4d11ef9531dd3a diff --git a/MyLcd.cpp b/MyLcd.cpp new file mode 100644 index 0000000..f1f5652 --- /dev/null +++ b/MyLcd.cpp @@ -0,0 +1,38 @@ +#include "MyLcd.h" +#include "Hardware.h" + +void MyLcd::execute(const Command &cmd, bool RS, double delay) +{ + static const uint8_t eMask = 0b00000010; + static const uint8_t rsMask = 0b01000000; + //static const double pulseLength = 0.5; + + { + uint8_t output = (cmd.data & 0xf0) >> 2; + if (RS) + { + output |= rsMask; + } + + m_lcdShiftReg.set(output | eMask); + //delay_us(pulseLength); + m_lcdShiftReg.set(output); + } + + { + uint8_t output = (cmd.data & 0x0f) << 2; + if (RS) + { + output |= rsMask; + } + + m_lcdShiftReg.set(output | eMask); + //delay_us(pulseLength); + m_lcdShiftReg.set(output); + } + + delay_ms(delay); +} + + + diff --git a/MyLcd.h b/MyLcd.h new file mode 100644 index 0000000..cc338d5 --- /dev/null +++ b/MyLcd.h @@ -0,0 +1,13 @@ +#pragma once + +#include "LcdShiftReg.h" +#include "DeviceLib/Lcd.h" + +class MyLcd : public Lcd +{ +private: + LcdShiftReg m_lcdShiftReg; + +private: + virtual void execute(const Command &cmd, bool RS, double delay) override; +};