This patch:
- Corrects the getPitch() and getRoll() methods to use normalized data from accelerometer sensors.
- Provides a compile time option (default: enabled) to provide full range 0..360 degree pitch data
that is consistent with the rage of the roll data.
- Updates the tilt compensated compass heading calculation to use normalized data from accelerometer sensors.
This commit introduces differentiation of listeners based on the cb_arg. This means that multiple listeners can be registered for the same event source and value, but with different cb_args.
Upon listener deletion, the listener_deletion_callback is invoked if non-NULL.
Motivation:
MakeCode uses cb_arg as context for higher level function pointer mapping (key / value), it can currently hold only one function pointer due to dal limitations.
MakeCode currently has an indirection layer for events that could be first class listener invocations, this is due to omitting cb_arg when ignoring / adding listeners.
Implementation:
there is probably a "cooler" way of doing this, i.e. a meta listener where the cb arg is set with a pointer to the listener being removed.
reasons why a callback function is superior:
1) fast and immediate
2) requires far less configuration (could be really complex with a meta listener)
3) smaller memory and processing overhead
In upcoming commits I will add the ability to add/ignore listeners based also on the given listener cb_arg. With the possibility of multiple handlers being deleted at once, it's useful to application developers to be able to inspect what is being removed.
These values are determined from
http://infocenter.nordicsemi.com/pdf/S130_SDS_v1.0.pdf
pg 41
It appears using S130v2 would allow even lower memory consumption
This is for use in conjunction with the
bbc-microbot-classic-gcc-s130
target, which also needs a fix before it will work.
MicroBitCompassCalibrator
- A new form of constructor now allows for a persistent storage object to be
provided. If present, compass calibration data will be automatically
stored and retrieved from FLASH when needed.
- Matrix4 was used only for the least mean squres calculation as part of the
MicroBitCompassCalibrator. This has now been replace with an itereative
approximation algorithm.
- Add mutator to allow accelerometer to be added to a compass after construction
- Use floating point values for Sample3D:dSquared() operations to resmove possible overflow
- Change compass calibration hill climb algorithm to use 100 unit steps to converge faster.
- Update autodetect functions to register accelerometer instances with compass instances upon detection
- Clean and fix axis alignments for tilt compensation algorithm
- Autodetection logic added to MicroBitAccelerometer/MicroBitCompass
- Added single byte I2C read utility function into MicroBitI2C
- Added isDetected() method into sensor drivers
- Add pin mapping for third interrupt line as used by FXOS8700
- Move FXOS to open drain interrupt configuration
- Add pullup onto interrupt line to FXOS
* Movd MICROBIT_MODE_* defines to MicroBitConfig.h
* Search for embedded source and remove magic
* Fixed memcpy
* Change offset order
* Fixed memcpy for data
Using the function atoi() pulls in a dependency from newlib, which in turn
pulls in locale support, and locale support requires about 350 bytes of
RAM. This patch removes such a dependency by rewriting the MicroBitImage
parsing code so that it directly converts the input string to an integer
instead of building a buffer and passing it to atoi().
This patch saves about 640 bytes of code space and 364 bytes of RAM. It
also reduces the amount of stack space used by the MicroBitImage
constructor.