From 628490097e89546515566fc009d349f639f07d89 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 23 May 2016 18:43:44 +0100 Subject: [PATCH] Add example timer code to HD4470.cpp and .h --- HD44780.cpp | 11 ++++++++++- HD44780.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/HD44780.cpp b/HD44780.cpp index 99b23cd..821d41d 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -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); @@ -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() diff --git a/HD44780.h b/HD44780.h index 28400b6..332a14f 100644 --- a/HD44780.h +++ b/HD44780.h @@ -20,6 +20,7 @@ #define HD44780_H #include "Display.h" +#include "Timer.h" #include #include @@ -93,6 +94,7 @@ private: bool m_duplex; int m_fd; bool m_dmr; + CTimer m_timer; #ifdef ADAFRUIT_DISPLAY void adafruitLCDSetup();