There was a duplication in IDs for MICROBIT_ID_THERMOMETER and MICROBIT_ID_IO_P0
for the event bus. This has been rectified by appending the MICROBIT_ID_THERMOMETER
All internal uses of accelerometer sample values now updated to access the
data via accessor methods. This now ensures consistent use irrespective of
the coordinate system used.
declarations
Added missing operator new[] wrapper in MicroBitHeapAllocator.h
Ammended defualt microBitConfig.h to allocate 90% of available heap, rather
than 95%. this is to leave a little more heap for external libraries.
native printf() call.
The Matrix4::print() function is useful, but non essential for most
applications, and the underlying printf() call required cost an
additional 1K of RAM on first use, which is currently above the budget for
micro:bit.
An e-compass solution requires knowwlede two pieces of data to provide an
accurate heading:
- Accurate calibration of the magnetometer hardware so that reliable
measurements can be taken.
- Knowledge of the pitch and roll of of device, so that the correct
components of the X/Y and Z axis sensors of the magnetomer can be used
to sense the magnetic field in a horizontal plane regardless of the tilt
of the device.
This commit represent changes to the MicroBitAccelerometer and MicroBitCompass
classes to implemen tthese goals. More specifically, this commit provides:
- The introduciton of an interactive calibration 'game', that can rapidly
gather all the data required to calibrate the compass.
- An improved calibration algorithm based on a Least Mean Squares approach of
compass samples, as documened in Freescale Application Note AN4248.
- The inclusion of a simple Matrix4 class to enable efficient Least Mean
Squares implementation.
- A change from asynchronous to synchronous calibration of the compass when
first used. This is in repsonse to a feature request for this from users
and high level languages using microbit-dal.
- Support for detemrining tilt and roll angle in MicroBitAccelerometer
- Support for multiple co-ordinate spaces in MicroBitAccelerometer and
MicroBitCompass. Data can now be read in either RAW (unaltered) data.
MICORBIT_SIMPLE_CARTESIAN (as used previously) or NORTH_EAST_DOWN
(the industry convention in mobile phones, tablets and aviation)
- Implementation of a tilt compensated algorithm, used when determining
device heading.
Freefall now detected when the net force on the device drops below 0.4g,
rather than 0.2g as previously defined. This improves sensitivity, without
generating false positives under common use.
Also correction of minor typos / layout errors.
- updated acceleration threshold event names to reflect numeric values e.g.
GESTURE_3G, GESTURE_6G, GESTURE_8G.
- Add scoping to elements of SimpleGesture enum.
- Code scrub of code layout caused by editor with incorrect configuration.
- rename of internal state variables and functions to better reflect use.
- added clarification to some comments.
Whilst Android devices permit explicit initiation of the BLE pairing process,
IOS based devices are only capable of implicit initiation of pairing based
on accessing a protected characteristic. Adding read capability to the
ControlPoint characteristic provides a safe and convenient way for IOS devices
to initiate pairing.
Minor amends:
- bleDisconnectionCallback signature change
- bleSetAdvertisingInterval now takes milliseconds as a parameter
- event based invocation of DFU bootloader
More specifically:
- BLUEZONE mode renamed to PairingMode (by popular request).
- Added timeout of 90 seconds before automatic device reboot.
- Move from a scroll to a print based algorithm to improve the amount of time key is displayed fully.
- Added compulsory 'click to bond' button press.
- Improved response time of tick/cross being displayed.
Changes to default BLE name. During normal operation, all micro:bits now have the same name: BBC micro:bit
When pairing mode (AKA BLUEZONE) is entered, device name details re appended as before, to give BBC micro:bit [<name>]
This is to provide a degree of anonymity to users, to make tracking of kids more difficult.
This option is now configured when the BLE stack is initialised. This ensures that SoftDevice is never
starved of CPU during periods of criticality. This does lock out the CPU for application use, but prevents
MIC failures caused by __disable_irq() operations (as found in the mbed Ticker API for example).
Minor amends:
- bleDisconnectionCallback signature change
- bleSetAdvertisingInterval now takes milliseconds as a parameter
- event based invocation of DFU bootloader
The following postures of the device are now detected:
- TILT_UP
- TILT_DOWN
- TILT_LEFT
- TILT_RIGHT
- FACE_UP
- FACE_DOWN
In addition, the following gestures are inferred:
- NONE
- SHAKE
- FREEFALL
- WHEEE (>=3g)
- SICK (>=5g)
- UNCONSCIOUS (>=8g)
Events are now triggered on the MessageBus upon the transition from one posture/gesture to another,
and a synchronous getGesture() method is now also provided to interogate the last gesture recognised.
I should be noted that the default accelerator range of +/-2g will be insufficient to detect some of
the events noted above, and MicroBitAccelerometer::setRange() should be used to increase the range
if required.
- LFSR generated values in a subset of the range requested (rounded to the nearest lower power of 2).
Corrected by increasing the number of bits usedby one, such that it now generated st least the power of 2 greater.
- replaced enable/disable of interrupts with a local snapshot of randomValue. Much of the nordic software is sensitive to interrupt timings,
so best avoided where possible. Chance of race condition is low, and effect is minimal (duplicate number returned).
- Removed flashcode base authorization
- silenced unused parameter in MicroBitHeapAllocator
- bugfixed BLUEZONE mode so that sensor data is still available via BLE