From 957070a6b5886719557b6880afa7e3716548c18a Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Sun, 25 Aug 2019 14:37:55 -0500 Subject: 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 --- tmk_core/common/timer.h | 11 +++++++++++ tmk_core/protocol/usb_hid/override_wiring.c | 7 +++---- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'tmk_core') diff --git a/tmk_core/common/timer.h b/tmk_core/common/timer.h index fe23f87aec..a8dd85663f 100644 --- a/tmk_core/common/timer.h +++ b/tmk_core/common/timer.h @@ -19,6 +19,7 @@ along with this program. If not, see . #define TIMER_H 1 #include +#include #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 diff --git a/tmk_core/protocol/usb_hid/override_wiring.c b/tmk_core/protocol/usb_hid/override_wiring.c index 1e9a94ce26..52f03c300f 100644 --- a/tmk_core/protocol/usb_hid/override_wiring.c +++ b/tmk_core/protocol/usb_hid/override_wiring.c @@ -4,14 +4,13 @@ #define __DELAY_BACKWARD_COMPATIBLE__ #include #include "common/timer.h" -#include "Arduino.h" -unsigned long millis() +unsigned long millis(void) { return timer_read32(); } -unsigned long micros() +unsigned long micros(void) { return timer_read32() * 1000UL; } @@ -23,7 +22,7 @@ void delayMicroseconds(unsigned int us) { _delay_us(us); } -void init() +void init(void) { timer_init(); } -- cgit v1.2.3