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
SWCommon.h@62:bc5caf59fe39, 2017-04-09 (annotated)
- Committer:
- hazheng
- Date:
- Sun Apr 09 18:20:57 2017 +0000
- Revision:
- 62:bc5caf59fe39
- Parent:
- 57:0d8a155d511d
- Child:
- 94:32712e603a5f
Made the IMU working correctly.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hazheng | 56:7d3395ae022d | 1 | #pragma once |
hazheng | 56:7d3395ae022d | 2 | #ifndef SW_COMMON_H |
hazheng | 56:7d3395ae022d | 3 | #define SW_COMMON_H |
hazheng | 56:7d3395ae022d | 4 | |
hazheng | 56:7d3395ae022d | 5 | #include "ArduUTFT.h" |
hazheng | 57:0d8a155d511d | 6 | #include <mbed.h> |
hazheng | 56:7d3395ae022d | 7 | |
hazheng | 56:7d3395ae022d | 8 | #ifdef SW_DEBUG |
hazheng | 62:bc5caf59fe39 | 9 | #define LOGI(...) char sw_common_buf_v87t790[100];\ |
hazheng | 62:bc5caf59fe39 | 10 | sprintf(sw_common_buf_v87t790, __VA_ARGS__);\ |
hazheng | 62:bc5caf59fe39 | 11 | ardu_utft_print(sw_common_buf_v87t790, 230, 100); |
hazheng | 56:7d3395ae022d | 12 | |
hazheng | 56:7d3395ae022d | 13 | #else |
hazheng | 56:7d3395ae022d | 14 | #define LOGI(...) |
hazheng | 56:7d3395ae022d | 15 | |
hazheng | 56:7d3395ae022d | 16 | #endif |
hazheng | 56:7d3395ae022d | 17 | |
hazheng | 57:0d8a155d511d | 18 | class DebugCounter |
hazheng | 57:0d8a155d511d | 19 | { |
hazheng | 57:0d8a155d511d | 20 | public: |
hazheng | 57:0d8a155d511d | 21 | DebugCounter(uint16_t maxCount, PinName pin) : |
hazheng | 57:0d8a155d511d | 22 | m_output(DigitalOut(pin, 0)), |
hazheng | 57:0d8a155d511d | 23 | m_maxCount(maxCount), |
hazheng | 57:0d8a155d511d | 24 | m_counter(0) |
hazheng | 57:0d8a155d511d | 25 | { |
hazheng | 57:0d8a155d511d | 26 | |
hazheng | 57:0d8a155d511d | 27 | } |
hazheng | 57:0d8a155d511d | 28 | |
hazheng | 57:0d8a155d511d | 29 | void Update() |
hazheng | 57:0d8a155d511d | 30 | { |
hazheng | 57:0d8a155d511d | 31 | ++m_counter; |
hazheng | 57:0d8a155d511d | 32 | if(m_counter >= m_maxCount) |
hazheng | 57:0d8a155d511d | 33 | { |
hazheng | 57:0d8a155d511d | 34 | m_output.write(!(m_output.read())); |
hazheng | 57:0d8a155d511d | 35 | m_counter = 0; |
hazheng | 57:0d8a155d511d | 36 | } |
hazheng | 57:0d8a155d511d | 37 | } |
hazheng | 57:0d8a155d511d | 38 | |
hazheng | 57:0d8a155d511d | 39 | |
hazheng | 57:0d8a155d511d | 40 | private: |
hazheng | 57:0d8a155d511d | 41 | DigitalOut m_output; |
hazheng | 57:0d8a155d511d | 42 | const uint16_t m_maxCount; |
hazheng | 57:0d8a155d511d | 43 | uint16_t m_counter; |
hazheng | 57:0d8a155d511d | 44 | |
hazheng | 57:0d8a155d511d | 45 | }; |
hazheng | 57:0d8a155d511d | 46 | |
hazheng | 57:0d8a155d511d | 47 | |
hazheng | 56:7d3395ae022d | 48 | #endif //SW_COMMON_H |