mbed.org local branch of microbit-dal. The real version lives in git at https://github.com/lancaster-university/microbit-dal

Dependencies:   BLE_API nRF51822 mbed-dev-bin

Dependents:   microbit Microbit IoTChallenge1 microbit ... more

Embed: (wiki syntax)

« Back to documentation index

MicroBitComponent Class Reference

MicroBitComponent Class Reference

Class definition for MicroBitComponent. More...

#include <MicroBitComponent.h>

Inherited by MicroBitAccelerometer, MicroBitBLEManager [private], MicroBitButton, MicroBitCompass, MicroBitDisplay, MicroBitEventService, MicroBitIOPinService, MicroBitMessageBus, MicroBitMultiButton, MicroBitPin, MicroBitRadio [private], MicroBitSystemTimerCallback [private], and MicroBitThermometer.

Public Member Functions

 MicroBitComponent ()
 The default constructor of a MicroBitComponent.
virtual void systemTick ()
 The system timer will call this member function once the component has been added to the array of system components using system_timer_add_component.
virtual void idleTick ()
 The idle thread will call this member function once the component has been added to the array of idle components using fiber_add_idle_component.
virtual ~MicroBitComponent ()
 If you have added your component to the idle or system tick component arrays, you must remember to remove your component from them if your component is destructed.

Detailed Description

Class definition for MicroBitComponent.

All components should inherit from this class.

If a component requires regular updates, then that component can be added to the to the systemTick and/or idleTick queues. This provides a simple, extensible mechanism for code that requires periodic/occasional background processing but does not warrant the complexity of maintaining its own thread.

Two levels of support are available.

systemTick() provides a periodic callback during the micro:bit's system timer interrupt. This provides a guaranteed periodic callback, but in interrupt context and is suitable for code with lightweight processing requirements, but strict time constraints.

idleTick() provides a periodic callback whenever the scheduler is idle. This provides occasional, callbacks in the main thread context, but with no guarantees of frequency. This is suitable for non-urgent background tasks.

Components wishing to use these facilities should override the systemTick and/or idleTick functions defined here, and register their components using system_timer_add_component() fiber_add_idle_component() respectively.

Definition at line 102 of file MicroBitComponent.h.


Constructor & Destructor Documentation

The default constructor of a MicroBitComponent.

Definition at line 114 of file MicroBitComponent.h.

virtual ~MicroBitComponent (  ) [virtual]

If you have added your component to the idle or system tick component arrays, you must remember to remove your component from them if your component is destructed.

Definition at line 141 of file MicroBitComponent.h.


Member Function Documentation

virtual void idleTick (  ) [virtual]

The idle thread will call this member function once the component has been added to the array of idle components using fiber_add_idle_component.

Reimplemented in MicroBitBLEManager, MicroBitEventService, MicroBitIOPinService, MicroBitAccelerometer, MicroBitCompass, and MicroBitThermometer.

Definition at line 133 of file MicroBitComponent.h.

virtual void systemTick (  ) [virtual]

The system timer will call this member function once the component has been added to the array of system components using system_timer_add_component.

This callback will be in interrupt context.

Reimplemented in MicroBitSystemTimerCallback, MicroBitButton, and MicroBitDisplay.

Definition at line 125 of file MicroBitComponent.h.