aboutsummaryrefslogtreecommitdiffstats
path: root/tmk_core/common
diff options
context:
space:
mode:
authorXScorpion2 <rcalt2vt@gmail.com>2019-08-25 14:37:55 -0500
committerDrashna Jaelre <drashna@live.com>2019-08-25 12:37:55 -0700
commit957070a6b5886719557b6880afa7e3716548c18a (patch)
tree68adde454ad00f5c74538b0927f76b7db7afcb09 /tmk_core/common
parentf22c5c17b6fe069bec1241262a1c27eb89d3d3af (diff)
downloadfirmware-957070a6b5886719557b6880afa7e3716548c18a.tar.gz
firmware-957070a6b5886719557b6880afa7e3716548c18a.tar.bz2
firmware-957070a6b5886719557b6880afa7e3716548c18a.zip
Added OLED Display autoscroll during periods of OLED data inactivity (#6546)
* Added OLED Display autoscroll during periods of OLED data inactivity. * Fixing compile errors * Feedback from review
Diffstat (limited to 'tmk_core/common')
-rw-r--r--tmk_core/common/timer.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/tmk_core/common/timer.h b/tmk_core/common/timer.h
index fe23f87ae..a8dd85663 100644
--- a/tmk_core/common/timer.h
+++ b/tmk_core/common/timer.h
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define TIMER_H 1
#include <stdint.h>
+#include <stdbool.h>
#if defined(__AVR__)
#include "avr/timer_avr.h"
@@ -46,6 +47,16 @@ uint32_t timer_read32(void);
uint16_t timer_elapsed(uint16_t last);
uint32_t timer_elapsed32(uint32_t last);
+// Utility functions to check if a future time has expired & autmatically handle time wrapping if checked / reset frequently (half of max value)
+inline bool timer_expired(uint16_t current, uint16_t last)
+{
+ return current - last < 0x8000;
+}
+
+inline bool timer_expired32(uint32_t current, uint32_t future) {
+ return current - future < 0x80000000;
+}
+
#ifdef __cplusplus
}
#endif