SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.
Dependencies: TSI USBDevice mbed-dev
Fork of SmartWheels by
Diff: SWCommon.h
- Revision:
- 57:0d8a155d511d
- Parent:
- 56:7d3395ae022d
- Child:
- 62:bc5caf59fe39
--- a/SWCommon.h Thu Apr 06 22:19:59 2017 +0000 +++ b/SWCommon.h Sat Apr 08 15:58:52 2017 +0000 @@ -3,6 +3,7 @@ #define SW_COMMON_H #include "ArduUTFT.h" +#include <mbed.h> #ifdef SW_DEBUG #define LOGI(...) char buf[100];\ @@ -14,4 +15,34 @@ #endif +class DebugCounter +{ +public: + DebugCounter(uint16_t maxCount, PinName pin) : + m_output(DigitalOut(pin, 0)), + m_maxCount(maxCount), + m_counter(0) + { + + } + + void Update() + { + ++m_counter; + if(m_counter >= m_maxCount) + { + m_output.write(!(m_output.read())); + m_counter = 0; + } + } + + +private: + DigitalOut m_output; + const uint16_t m_maxCount; + uint16_t m_counter; + +}; + + #endif //SW_COMMON_H \ No newline at end of file