Simple Blinky example for QP/C++, which demonstrates:
- Active object (Blinky) with state machine
- Board Support Package abstraction for portability
- BSP implementation for desktop OS (Windows, Linux, Mac)
- Platform-independent main() function
- make.bat batch file for Windows
Blinky constructor
: QActive(Q_STATE_CAST(&Blinky::initial)),
m_timeEvt(this, TIMEOUT_SIG, 0U)
QS_OBJ_DICTIONARY(&l_blinky);
QS_OBJ_DICTIONARY(&l_blinky.m_timeEvt);
// arm the private time event to expire in 1/2s
// and periodically every 1/2 second
me->m_timeEvt.armX(BSP::TICKS_PER_SEC/2,
BSP::TICKS_PER_SEC/2);
BSP::ledOff();
BSP::ledOn();
#ifndef blinky_h
#define blinky_h
enum BlinkySignals {
DUMMY_SIG = QP::Q_USER_SIG,
MAX_PUB_SIG, // the last published signal
TIMEOUT_SIG,
MAX_SIG // the last signal
};
extern QP::QActive * const AO_Blinky; // opaque pointer
#endif // blinky
#include "qpcpp.h" // QP/C++ framework API
#include "blinky.h" // Blinky application
#include "bsp.h" // Board Support Package interface
//using namespace QP;
// ask QM to declare the Blinky class ----------------------------------------
$declare${AOs::Blinky}
// instantiate the Blinky active object --------------------------------------
static Blinky l_blinky;
QP::QActive * const AO_Blinky = &l_blinky;
// ask QM to define the Blinky class (including the state machine) -----------
$define${AOs::Blinky}