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 haofan Zheng

Committer:
hazheng
Date:
Sat Apr 08 15:58:52 2017 +0000
Revision:
57:0d8a155d511d
Parent:
56:7d3395ae022d
Child:
62:bc5caf59fe39
move the image processing to the main thread. Created the debug counter.

Who changed what in which revision?

UserRevisionLine numberNew 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 56:7d3395ae022d 9 #define LOGI(...) char buf[100];\
hazheng 56:7d3395ae022d 10 sprintf(buf, __VA_ARGS__);\
hazheng 56:7d3395ae022d 11 ardu_utft_print(buf, 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