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
- Committer:
- hazheng
- Date:
- 2017-04-19
- Revision:
- 94:32712e603a5f
- Parent:
- 62:bc5caf59fe39
- Child:
- 98:fc92bb37ee17
File content as of revision 94:32712e603a5f:
/** * @file SWCommon.h * @brief The header file for Smart Wheels Common functions. Note: The functions in here will be only used in debug purpose, and all of these debug functions will not be included for the release version. * @author Jordan Brack <jabrack@mix.wvu.edu>, Haofan Zheng <hazheng@mix.wvu.edu> * */ #pragma once #ifndef SW_COMMON_H #define SW_COMMON_H #include "ArduUTFT.h" #include <mbed.h> #ifdef SW_DEBUG #define LOGI(...) char sw_common_buf_v87t790[100];\ /*!< @brief Print debug message on the UTFT screen in debug mode. Do nothing in release mode. */ sprintf(sw_common_buf_v87t790, __VA_ARGS__);\ ardu_utft_print(sw_common_buf_v87t790, 230, 100); #else //SW_DEBUG #define LOGI(...) /*!< @brief Print debug message on the UTFT screen in debug mode. Do nothing in release mode. */ #endif //SW_DEBUG #ifdef SW_DEBUGCOUNTER /** * @class DebugCounter * @brief This class will be used as a counter during debugging. This class can be used when estimating the running speed of the system, or some specific function. */ class DebugCounter { public: /** * @brief The constructor for the DebugCounter class. * @param maxCount The number of counts that should be accumulated before changing the output pin status. * @param pin The read address for the slave device. */ DebugCounter(uint16_t maxCount, PinName pin) : m_output(DigitalOut(pin, 0)), m_maxCount(maxCount), m_counter(0) { } /** * @brief The update function, where the counter gets count. If the number of counts approached the max count, the output pin status will be flipped. */ void Update() { ++m_counter; if(m_counter >= m_maxCount) { m_output.write(!(m_output.read())); m_counter = 0; } } private: DigitalOut m_output; /*!< @brief The output pin. */ const uint16_t m_maxCount; /*!< @brief The max count. */ uint16_t m_counter; /*!< @brief The counter. */ }; #endif //SW_DEBUGCOUNTER #endif //SW_COMMON_H