Skip to content

Commit

Permalink
Add example timer code to HD4470.cpp and .h
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed May 23, 2016
1 parent d474328 commit 6284900
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion HD44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ m_pwmDim(pwmDim),
m_duplex(duplex),
//m_duplex(true), // uncomment to force duplex display for testing!
m_fd(-1),
m_dmr(false)
m_dmr(false),
m_timer(1000U, 0U, 250U) // 250ms
{
assert(rows > 1U);
assert(cols > 15U);
Expand Down Expand Up @@ -679,6 +680,14 @@ void CHD44780::clearFusionInt()

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()
Expand Down
2 changes: 2 additions & 0 deletions HD44780.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define HD44780_H

#include "Display.h"
#include "Timer.h"

#include <string>
#include <vector>
Expand Down Expand Up @@ -93,6 +94,7 @@ class CHD44780 : public CDisplay
bool m_duplex;
int m_fd;
bool m_dmr;
CTimer m_timer;

#ifdef ADAFRUIT_DISPLAY
void adafruitLCDSetup();
Expand Down

0 comments on commit 6284900

Please sign in to comment.