Commit graph

285 commits

Author SHA1 Message Date
James Devine
6e316dc741 microbit: added accessor/mutator for systemTick
This commit adds a mutator that dynamically reconfigures the
systemTicker to call systemTick at a different period to the default.

The accessor returns the current tick speed in milliseconds.

The accessor is now also used in scheduler_tick to keep timing as
accurate as possible.

MICROBIT_DISPLAY_REFRESH_PERIOD has now been removed, and replaced with
MICROBIT_DEFAULT_TICK_PERIOD.
2016-01-29 14:07:36 +00:00
James Devine
6f812aa474 microbit: added new display mode, and accessor
This commit introduces a new display mode,
DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE, where the 4th render in
every “frame” is dropped allowing for other components that use the
display to use this dropped frame for processing. This is in
preparation for Light Sensing on the 5x5 LED matrix.

An accessor has also been added to MicroBitDisplay to check the current
display mode!
2016-01-29 14:03:24 +00:00
James Devine
6939ad25d9 microbit: formatting changes to MicroBitFiber
Corrected whitespace in MicroBitFiber.
2016-01-29 13:57:34 +00:00
Joe Finney
844a77972f version v1.4.10 2016-01-25 21:19:36 +00:00
Joe Finney
98573c0328 Merge branch 'ble-servicechanged' 2016-01-25 21:19:22 +00:00
Joe Finney
3ae389462b microbit: Update ble-nrf51822 dependency to latest revision 2016-01-25 21:06:14 +00:00
Joe Finney
e3fdc5a290 microbit: Support for bonding only available in pairing mode
Update to BLE initialisation code. Ability to initiate pairing is now
restricted to pairing mode.
2016-01-25 21:05:15 +00:00
Joe Finney
99d7231945 microbit: Persistance of BLE Service Chnaged metadata
BLE maintains metadata on its characterisitics, some of which record whether
or not a central device (phone/tablet) wishes to receive notifications when a
given BLE characteristic changes value. One such characterisitic is used as
part of a core BLE service to indicate of the BLE profile of a device has
changed.

IOS is heavily reliant on this feature, and expects the state of this metadata
to be persistent across device reboots. This patch ensures that this metadata
is always set to allow Service Changed indications to be propagated to central
devices.
2016-01-25 21:05:13 +00:00
Joe Finney
6a7436e5c7 Merge pull request #48 from remay/quiet-gcc-build
Tidy up gcc -Wall fixes

Thanks @remay!
2016-01-25 20:55:37 +00:00
James Devine
458347473e version v1.4.9 2016-01-25 15:36:57 +00:00
James Devine
46af76fefb Merge pull request #81 from dpgeorge/seedrandom
Make MicroBit::seedRandom a public function with 2 variants.
2016-01-25 15:23:44 +00:00
Damien George
3160ba6268 Make MicroBit::seedRandom a public function with 2 variants.
seedRandom() seeds from the hardware RNG, whilst seedRandom(uint32_t)
seeds from the given 32-bit number.
2016-01-25 15:20:25 +00:00
James Devine
0a5e4a06af microbit: Added details for the i2c silicone glitch
As per https://github.com/lancaster-university/microbit-dal/issues/83 the comment in the MicroBitI2c.h file lacked context around a known hardware glitch. This commit rectifies this issue by adding a link to a collection PDF providing a more detailed explanation.
2016-01-25 10:09:53 +00:00
Joe Finney
d22a36fdd5 version v1.4.8 2016-01-19 00:43:25 +00:00
Joe Finney
c8d2e42e85 microbit: Move to latest revision of ble-nrf51822 2016-01-19 00:36:49 +00:00
Joe Finney
a4c0915fff microbit: BUGFIX Prevent BLE Magnetometer service from initiating compass
calibration

MicroBitCompass initiates a calibration procedure on demand if a heading is
requested from an uncalibrated device. The BLE MagnetometerService also
attempts to retrieve a heading periodically, but it is not good behaviour to
initiate calibration as a response to this.

This patch introduces a check such that the BLE MagnetometerService will only
attempt to read heading data from a previously calibrated compass.
2016-01-19 00:32:02 +00:00
Joe Finney
d2e1798258 version v1.4.7 2016-01-17 01:14:55 +00:00
Joe Finney
ec0fecb36d microbit: Add explicit dependency on lancaster-university/nrf51-sdk
Minor configuration changed now required in the nrf51-sdk to support micro:bit
requirements.
2016-01-17 01:13:24 +00:00
Joe Finney
797d58ba51 Merge branch 'ble-whitelisting' 2016-01-17 00:45:17 +00:00
Joe Finney
4f1870fda9 Merge branch 'master' into ble-whitelisting 2016-01-17 00:44:35 +00:00
Joe Finney
13eb3c07e7 microbit: Add explicit service changed notification
BLE central devices (such as mobile phones/tablets) are permitted to cache the
list of services and characteristics provided by a BLE peripheral such as the
micro:bit. This was causing compatibility problems with IOS during FOTA
flashing, as the the list of BLE services may change after flashing.
2016-01-17 00:23:00 +00:00
Joe Finney
1c9ae30d1c microbit: Added basic bond table management
The Nordic BLE stack contains a fixed size bond table - a list of devices that
have paired with our device (in the case the micro:bit). The default mbed
wrapper around the nordic stack does not account for the case where the bond
table is full.

This patch implements basic bounds checking within the MicroBitBLEManager so
that this table cannot overrun. If a new device attempts to pair when the bond
table is full, the table is emptied prior to completing bonding.
2016-01-16 21:05:46 +00:00
Joe Finney
e754ecf3aa microbit: Setting of default BLE transmission power level
Added configuration option in MicroBitConfig to allow the default power level
to be defined. Based on experiments undertaken by the BBC and subsequent policies defined by
the BBC's child protection panel, to is set by default it's lowest level (0),
in order to protect children's privacy.

It should be noted that this is 30dB below the device's default setting, so will
inevitably leave the device more susceptible to interference, and therefore
significantly reduce the reliability of the device. This will likely present
itself through increased packet loss, reduced thorughout, lost data and
connection drop outs. The normal BLE power level on commercial devices
translates to  power level of 6.

The author has witnessed an inability to connect to a micro:bit from a
distance of 40cm under domestic conditions using a Samsung S5 mini
running Android 4.4.2.
2016-01-16 17:29:46 +00:00
Joe Finney
07852b0cd6 microbit: Added support for BLE transmission power control
Added new method to MicroBitBLEManager to allow the radio transmission power
to be controlled. Provides a linear power level scale in the range 0..7.
2016-01-16 17:07:20 +00:00
Joe Finney
f17151a0bf microbit: Added optional support for whitelisting and limited advertising
Added MicroBitConfig.h option to enable/disable whitelisting
Added MicroBitConfig.h option to enable/disable limited period advertising
Added support for limited period advertising
Minor code cleanups
2016-01-16 16:54:58 +00:00
James Devine
f29323aa35 version v1.4.6 2016-01-14 22:15:07 +00:00
James Devine
5a10616b70 Merge pull request #77 from lancaster-university/scroll-behaviour-fix
microbit: patch for animation/scroll behaviour for images
2016-01-14 22:14:16 +00:00
James Devine
b2484dcc97 microbit: patch for animation/scroll behaviour for images
See bbc/microbit-extras/issues/#1100 or lancaster-university/microbit-dal/issues/5 for full details.

Summary:

A stride of 0 would lock the calling fiber indefinitely, which was not the expected behaviour
for many people.

This update fixes this issue in both animate and scroll, returning immediately when there is
a stride of zero.
2016-01-14 12:56:58 +00:00
Robert May
098a2378e3 Merge lancaster-university/master and silence warnings. 2016-01-13 20:51:49 +01:00
James Devine
32faae520d Merge pull request #75 from lancaster-university/idle-system-issue-patch
Formatting corrections and further fixes for #73
2016-01-13 16:37:20 +00:00
James Devine
acf6bf76eb 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.
2016-01-13 16:25:34 +00:00
James Devine
1cc814da60 microbit: further formatting corrections
Corrected trailing whitespace, and tabulated lines with no content for:

* MicroBitCompass.h (.cpp)
* MicroBitDisplay.h (.cpp)
* MicroBitMessageBus.h (.cpp)
2016-01-13 16:16:18 +00:00
James Devine
d8240cfb74 microbit: formatting changes to MicroBitAccelerometer.h (.cpp)
Removed trailing whitespace, and tabulated lines with no content.
2016-01-13 16:01:51 +00:00
James Devine
a209857007 microbit: fix for #74
Replaced newer struct-style initialisation of CompassSample in MicroBit.cpp
with the more traditional constructor-style initialisation, to enfore
C98 compliance.

Closes #74
2016-01-13 15:12:13 +00:00
James Devine
7b7998e4eb microbit: formatting changes to MicroBit.h (.cpp)
Removed trailing whitespace, and tabulated lines with no content.
2016-01-13 15:04:29 +00:00
James Devine
8d3f3affbd microbit: fix for #73
The destructor for MicroBitButton didn't take into account the fact that
an instance can be destructed after registering a callback. This would then
result in a HardFault if an instance was destructed.

A clear repro case was registering a Touch input on a pin (abstracted as a button)
and swapping to a DigitalIn.
2016-01-13 14:15:50 +00:00
James Devine
d2df88417b microbit: whitespace changes to MicroBitButton.h and .cpp
Cleared the files of trailing whitespace, and tabulated lines
2016-01-13 14:07:10 +00:00
Joe Finney
90cf35a38a WIP: compiling but untested first cut at whitelisting code 2016-01-13 00:20:37 +00:00
James Devine
e46ca3fc34 version v1.4.5 2016-01-12 23:42:03 +00:00
James Devine
c568dd7cf0 Merge pull request #68 from lancaster-university/updating-dynamic-pwm
DynamicPwm behaviour modifications, and added a new Servo API to MicroBitPin
2016-01-12 21:14:29 +00:00
James Devine
983e9e1ad3 microbit: added Servo API to MicroBitPin
* Added a number of #defines to MicroBitPin.h which ultimately lead to retabulation of the #defines

* Added two new instance methods:

	- setServoValue() which sets the default servo period (20ms) and accepts a value in the range
			  0 - 180, which maps to a duty cycle between 5% and 10% respectively. This
			  mapping is also configurable.

	- setServoPulseUs() which accepts a pulse width in microseconds, and maps it onto the PWM
			    channel.
2016-01-12 20:54:09 +00:00
James Devine
2650aaa569 microbit: MicroBitPin api additions
Based on the previous commit, the api for MicroBitPin
has two new accessor methods:

	* getAnalogPeriodUs
	* getAnalogPeriod

There are also whitespace changes in the MicroBitPin head file
as well as some minor textual changes.
2016-01-12 20:52:50 +00:00
James Devine
32c40cdc29 microbit: DynamicPwm fixes and additions
This commit introduces an initial draft fix
for a bug where it would take two "setPeriods" for the
PWM class to update to the expected value.

This commit also adds three new methods to a DynamicPwm instance:

	* write() -  which is a lightweight wrapper around PwmOut write,
	  so that the value can be trapped. The trapping of the value
	  is necessary for the bug fix.
	* getPeriod() - which returns the value of a static variable,
	  containing the current period shared across the pwm bus.
	* getValue() - which returns a scaled value in the range 0-1024
	  representing the current duty cycle.
2016-01-12 20:50:42 +00:00
James Devine
500f851991 microbit: whitespace corrections
Corrected additional whitespace on some lines of source/MicroBitPin.cpp
2016-01-12 20:50:42 +00:00
James Devine
643f408ed2 microbit: modified the behaviour of pwm allocation
Dynamic pwm previously didn't round robin transient pwm channels,
and would therefore bias towards the first transient channel it found.
This update ensures that there is now an equal opportunity for all
channels to be considered for redirection.
2016-01-12 20:50:42 +00:00
James Devine
68474c5e58 microbit: modified constructor for DynamicPwm
Previously there would be the possibility of the period being reset
each time a new DynamicPwm was instantiated. This has now been
removed from the constructor, and the comments have been updated
2016-01-12 20:50:42 +00:00
James Devine
6b1e020392 microbit: formatting corrections
There was some incorrect tabulation in a few lines of this file, this has now been corrected.
2016-01-12 20:50:42 +00:00
Joe Finney
59d0f09ea0 version v1.4.4 2016-01-12 17:37:53 +00:00
Joe Finney
56a495fbd7 microbit: Update of MESEvent codes to avoid MICROBIT_EVT_ANY collision
Events listed recorded in MESEvents.h were enumerated from zero.
This is not ideal, as MicroBitMessageBus uses a code of zero for
MICROBIT_EVT_ANY - a wildcard mechanism to register interest in all events
from a given ID.

All event values recorded in MESEvents.h have therefore incremented.
2016-01-12 17:29:54 +00:00
Joe Finney
09cc2d73f4 microbit: update of edge connector pin mappings to match updated hardware design.
Definitions of pins changed as follows:

MICROBIT_PIN_P6 =>  P0_12 (COL9)
MICROBIT_PIN_P7 =>  P0_11 (COL8)
MICROBIT_PIN_P9 =>  P0_10 (COL7)
2016-01-12 14:50:36 +00:00