Add example timer code to HD4470.cpp and .h
This commit is contained in:
parent
d474328c58
commit
628490097e
11
HD44780.cpp
11
HD44780.cpp
|
@ -50,7 +50,8 @@ m_pwmDim(pwmDim),
|
||||||
m_duplex(duplex),
|
m_duplex(duplex),
|
||||||
//m_duplex(true), // uncomment to force duplex display for testing!
|
//m_duplex(true), // uncomment to force duplex display for testing!
|
||||||
m_fd(-1),
|
m_fd(-1),
|
||||||
m_dmr(false)
|
m_dmr(false),
|
||||||
|
m_timer(1000U, 0U, 250U) // 250ms
|
||||||
{
|
{
|
||||||
assert(rows > 1U);
|
assert(rows > 1U);
|
||||||
assert(cols > 15U);
|
assert(cols > 15U);
|
||||||
|
@ -679,6 +680,14 @@ void CHD44780::clearFusionInt()
|
||||||
|
|
||||||
void CHD44780::clockInt(unsigned int ms)
|
void CHD44780::clockInt(unsigned int ms)
|
||||||
{
|
{
|
||||||
|
m_timer.clock(ms);
|
||||||
|
if (m_timer.isRunning() && m_timer.hasExpired()) {
|
||||||
|
// Do work every 250ms here
|
||||||
|
|
||||||
|
// Start the timer with m_timer.start();
|
||||||
|
// and stop it with m_timer.stop();
|
||||||
|
m_timer.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHD44780::close()
|
void CHD44780::close()
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#define HD44780_H
|
#define HD44780_H
|
||||||
|
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
|
#include "Timer.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -93,6 +94,7 @@ private:
|
||||||
bool m_duplex;
|
bool m_duplex;
|
||||||
int m_fd;
|
int m_fd;
|
||||||
bool m_dmr;
|
bool m_dmr;
|
||||||
|
CTimer m_timer;
|
||||||
|
|
||||||
#ifdef ADAFRUIT_DISPLAY
|
#ifdef ADAFRUIT_DISPLAY
|
||||||
void adafruitLCDSetup();
|
void adafruitLCDSetup();
|
||||||
|
|
Loading…
Reference in a new issue