microbit: further fixes to #73
issue #73 highlighted an issue whereby the destruction of an instance registered as an idle or system component, would result in a hardfault. This was due to not deregistering idle or system callbacks. This patch has been applied to all components currently in use by the idle or system callbacks.
This commit is contained in:
parent
1cc814da60
commit
acf6bf76eb
8 changed files with 52 additions and 0 deletions
|
@ -310,6 +310,11 @@ class MicroBitAccelerometer : public MicroBitComponent
|
|||
*/
|
||||
virtual int isIdleCallbackNeeded();
|
||||
|
||||
/**
|
||||
* Destructor for MicroBitButton, so that we deregister ourselves as an idleComponent
|
||||
*/
|
||||
~MicroBitAccelerometer();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Issues a standard, 2 byte I2C command write to the accelerometer.
|
||||
|
|
|
@ -328,6 +328,11 @@ class MicroBitCompass : public MicroBitComponent
|
|||
*/
|
||||
virtual int isIdleCallbackNeeded();
|
||||
|
||||
/**
|
||||
* Destructor for MicroBitCompass, so that we deregister ourselves as an idleComponent
|
||||
*/
|
||||
~MicroBitCompass();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
|
|
@ -562,6 +562,11 @@ public:
|
|||
* Captures the bitmap currently being rendered on the display.
|
||||
*/
|
||||
MicroBitImage screenShot();
|
||||
|
||||
/**
|
||||
* Destructor for MicroBitDisplay, so that we deregister ourselves as a systemComponent
|
||||
*/
|
||||
~MicroBitDisplay();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -223,6 +223,11 @@ class MicroBitMessageBus : public MicroBitComponent
|
|||
*/
|
||||
MicroBitListener *elementAt(int n);
|
||||
|
||||
/**
|
||||
* Destructor for MicroBitMessageBus, so that we deregister ourselves as an idleComponent
|
||||
*/
|
||||
~MicroBitMessageBus();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
|
|
@ -571,6 +571,14 @@ int MicroBitAccelerometer::isIdleCallbackNeeded()
|
|||
return !int1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor for MicroBitAccelerometer, so that we deregister ourselves as an idleComponent
|
||||
*/
|
||||
MicroBitAccelerometer::~MicroBitAccelerometer()
|
||||
{
|
||||
uBit.removeIdleComponent(this);
|
||||
}
|
||||
|
||||
const MMA8653SampleRangeConfig MMA8653SampleRange[MMA8653_SAMPLE_RANGES] = {
|
||||
{2, 0},
|
||||
{4, 1},
|
||||
|
|
|
@ -537,6 +537,14 @@ int MicroBitCompass::isIdleCallbackNeeded()
|
|||
return int1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor for MicroBitMessageBus, so that we deregister ourselves as an idleComponent
|
||||
*/
|
||||
MicroBitCompass::~MicroBitCompass()
|
||||
{
|
||||
uBit.removeIdleComponent(this);
|
||||
}
|
||||
|
||||
const MAG3110SampleRateConfig MAG3110SampleRate[MAG3110_SAMPLE_RATES] = {
|
||||
{12500, 0x00}, // 80 Hz
|
||||
{25000, 0x20}, // 40 Hz
|
||||
|
|
|
@ -1080,3 +1080,11 @@ MicroBitImage MicroBitDisplay::screenShot()
|
|||
{
|
||||
return image.crop(0,0,MICROBIT_DISPLAY_WIDTH,MICROBIT_DISPLAY_HEIGHT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor for MicroBitDisplay, so that we deregister ourselves as a systemComponent
|
||||
*/
|
||||
MicroBitDisplay::~MicroBitDisplay()
|
||||
{
|
||||
uBit.removeSystemComponent(this);
|
||||
}
|
||||
|
|
|
@ -585,3 +585,11 @@ MicroBitListener* MicroBitMessageBus::elementAt(int n)
|
|||
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor for MicroBitMessageBus, so that we deregister ourselves as an idleComponent
|
||||
*/
|
||||
MicroBitMessageBus::~MicroBitMessageBus()
|
||||
{
|
||||
uBit.removeIdleComponent(this);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue