Commit Graph

332 Commits

Author SHA1 Message Date
Joe Finney 2f6d405e81 microbit: Introduced managed type for packet buffers.
Introduce PacketBuffer as a mutable reference counted type Radio operations
Updated send() and recv() to use PacketBuffer rather than ManagedString
2016-02-09 01:04:57 +00:00
James Devine af13c940c1 microbit: add RSSI to MicroBitRadio
Added the ability to capture the RSSI value, and an accessor and
mutator for the last received RSSI value.
2016-02-04 03:45:57 +00:00
James Devine ffc217e7ac microbit: fixed formatting issues in MicroBitRadio
Removed trailing whitespace.
2016-02-04 03:44:25 +00:00
Joe Finney a255711e8f version v1.4.14 2016-02-03 14:48:50 +00:00
Joe Finney 0625d4bf1b version v1.4.13 2016-02-03 14:44:55 +00:00
Joe Finney 9d039fd9be microbit: BUGFIX Corrected length calculation for validation case
Incorreclty calculated payload bug also addressed here.
2016-02-03 14:41:45 +00:00
Joe Finney 5cb265c158 microbit: BUGFIX: Length field of datagram receive now correct
Datagram receive code incorrectly calculated the payload length, resulting in
packets being delivered to applications that were two bytes shorter than they
should be.
2016-02-03 14:35:12 +00:00
James Devine 5a30b3c0b3 version v1.4.12 2016-02-02 21:53:51 +00:00
James Devine 6f1630f409 microbit: reverted change to ble-nrf51822 module
Reverted changes to the ble-nrf51822 that caused some
incompatibility issues.
2016-02-02 21:52:12 +00:00
James Devine 41447b634d Merge pull request #89 from lancaster-university/ble-ccccd-persist
Basic Persistent Storage
2016-02-02 21:50:33 +00:00
James Devine c9702aacb0 Merge pull request #88 from lancaster-university/ticker_improvements
Ticker improvements
2016-02-02 21:50:20 +00:00
James Devine 23d56edbdd microbit: integrated MicroBitStorage with MicroBitCompass
This commit introduces persistent storage for the compass between
device resets.

setCalibration now also stores the data in FLASH if it differs from
what it contains.

In source/MicroBitSuperMain.cpp, the data is restored if there is
persistent data available that is non-zero.

(i.e. x, y and z are NOT zero).

This ensures that users can code without interference from persistent
storage.
2016-02-02 21:24:40 +00:00
James Devine 4c9f32d79a microbit: added debug to MicroBitStorage
Added debug to make testing simpler and faster.
2016-02-02 21:24:40 +00:00
James Devine 0412a5b322 microbit: added comparators to CompassSample
Added two new comparator operations equals and not equals to make the
task of comparing two CompassSamples Simpler.
2016-02-02 21:24:40 +00:00
Joe Finney 5e7334b0bf microbit: integrated persistent storage for CCCD data.
There is an issue (https://github.com/bbc/microbit-extras/issues/2755)
whereby CCCD data is required to be persisted through device resets.

This commit integrates the new MicroBitStorage class, and persistently
stores this information in flash.

P.S. what a long night!
2016-02-02 21:24:40 +00:00
Joe Finney d1d78b9b35 microbit: added MicroBitStorage for Persistent data
Integrated simple 1K block buffer to host small amount of persistent
data and a 1K FLASH memory block located immediately below the FOTA/DFU
bootloader and APPDATA region that intended to hold core configuration
information, such as:

* BLE bonding information.
* Compass Calibration data.
* Thermometer Calibration data.

The block is resident at 0x0003B400 - 0x0003B800.
2016-02-02 21:22:49 +00:00
James Devine f546da66e8 microbit: improved appearance of greyscale
The impact of the pixels at lower values was  not distinct enough
this commit adds a blocking wait for the first two timings for
greyscale.

Additionally, this commit  modifies the timings const array to
take into account the time taken for renderGreyscale to execute.
2016-02-02 17:05:59 +00:00
James Devine 3596f3d842 microbit: update to greyscale mode
Floats were used as timings for the renderTimer in MicroBitDisplay.
Now timings are in us, and a direct called to renderTimer.attach_us
is now used.
2016-02-02 16:36:09 +00:00
James Devine 4cefd55ef5 microbit: updated the dal to use a higher resolution ticker.
Previously the DAL relied upon an implementation of a timer that
was very imprecise and lacked resolution, this commit adds a reference
to a frozen repo with us_ticker.c modifications, so that a higher resolution
timer is utilised.

This fixes #13 (finally), and also fixes lower brightness levels when using
DISPLAY_MODE_BLACK_AND_WHITE to not cause a device lockup.
2016-02-02 16:21:28 +00:00
James Sheppard 9ce46e5f89 Removed redundant TODOs 2016-02-02 11:47:21 +00:00
James Devine b049d3275d version v1.4.11 2016-02-02 01:19:10 +00:00
James Devine 3fa9bb09c2 microbit: fixed an off by 10 bug
Missed a zero in a previous commit, that caused a system lockup due to
a missed timer event.

This commit also changes the minimum display brightness to 4, to also
minimise another feature that needs fixing in the future, where the
timer does not interrupt in the expected time frame.
2016-02-02 01:13:39 +00:00
James Devine e5bc926dcd microbit: formatting fixes to MicroBitConfig.h
Fixed some tabulation errors in MicroBitConfig.h
2016-02-02 01:11:00 +00:00
James Devine a27b2314be microbit: modified the range of read() MicroBitLightSensor
Previously the range of MicrobitLightSensor read() was 0 - 100,
this didn't align with other APIs.

The new range is 0-255 which aligns with display brightness to give
a more consistent overall API.
2016-02-01 23:58:33 +00:00
Joe Finney 104493299e Merge branch 'ble-bondtablepurge' 2016-02-01 22:51:23 +00:00
Joe Finney e983b80b0b Merge branch 'master' into ble-bondtablepurge 2016-02-01 22:50:05 +00:00
Joe Finney fe004386fc microbit: Update nrf51-sdk dependency 2016-02-01 22:47:10 +00:00
Joe Finney e7132b0d13 microbit: Change to BLE bonding table replacement policy
Previous revisions of microbit-dal would handle the case of a bonding request
when the bond table was full by attempting to purge the bonding table on
demand. This suffered two flaws:

 1) Nordic's device manager does not support the purging of the bonding table
while a connection is active (including a pairing request).

 2) Some devices (e.g. Android 4.4.2 take two entries in the bonding table
when paired), thus making predictions of how 'full' the table is challenging.

This patch employs a simpler replacement policy. The maximum size of the bond
table has been increased to 6 (from 4). However, if the bond table contains 4
or more entries when entering pairing mode it will be purged in advance of any
pairing requetss being initiated.
2016-02-01 22:30:03 +00:00
James Devine 97c49d3279 Merge pull request #87 from lancaster-university/broadcast-radio
Adding Multicast peer-to-peer radio support MicroBitRadio!
2016-02-01 21:50:54 +00:00
James Devine 004b701419 Merge pull request #86 from lancaster-university/light-sensor
Adding MicroBitLightSensor to the DAL
2016-02-01 21:50:22 +00:00
James Devine 8150b2ac67 microbit: modified as per suggestions
* This commit fixes an exposed member variable
  that was not intended to be public 'tickPeriod'

* normalised the light level to return values between 0 - 100
2016-02-01 21:46:15 +00:00
Joe Finney 2c3125ae82 Merge branch 'bug-2768' 2016-02-01 19:29:58 +00:00
Joe Finney 9026ca6e98 microbit: Optimisation of BLE mutex.
The BLE stack locks out the CPU for long periods of time when necessary. This
can be alleviated by eans of a flag that release the CPU between radio events.
(BLE_COMMON_OPT_RADIO_CPU_MUTEX).

This can cause issues from applications with tighter timing requirements.
This patch only enables this MUTEX when a BLE connection is active, rather
than automatically at startup. Therefore, application that do not actively use
BLE will not suffer this penalty.
2016-02-01 19:25:07 +00:00
Joe Finney 6838b38fc1 microbit: Remove redundant characteristics in BLE DeviceInformationService
The MANUFACTURER and HARDWARE_REVISION fields from this standard service have
been removed, as they carried no useful information.
2016-02-01 18:59:48 +00:00
Joe Finney 8bec31fe76 microbit: Additional validation on MicroBitRadio methods
MicroBitRadio methods that touch internal RADIO registers now ensure that
the BLE stack is not running before changing such registers.
2016-02-01 18:19:02 +00:00
Joe Finney d7aa95e867 microbit: minor updates to consistently use the MICROBIT_RADIO_HEADER_SIZE constant 2016-02-01 18:05:02 +00:00
Joe Finney 12c9ed246a microbit: Whitespace fixes 2016-02-01 17:54:33 +00:00
Joe Finney 420a73673d microbit: rename of MicroBitRadioEvent methods to align with MessageBus naming conventions. 2016-02-01 17:43:17 +00:00
Joe Finney 336c30f2ec microbit: Integrate Multicast peer to peer communications into MicroBit.cpp
- Added instance variable and constructor call in MircoBit.cpp
  - Added event definitions for RADIO related indications
2016-02-01 04:40:21 +00:00
Joe Finney d9d2343ab6 microbit: Add Multicast peer-to-peer radio capability
Integration of new radio mode that permits simple local area multicast communication
directly between micro:bits using the device's on board radio hardware.

It should be noted that this implementation build directly on the nrf51822
hardware. It is not a BLE protocol, and must (currently) be operated with BLE
disabled.

A standard on the wire configuration is defined, to promote future
interoperability between projects and languages. A lightweight
packet format is also defined and adhered to, so as to promote future
extensibility without sacrificing compatibility. The notion of groups is also
introduced, that enable multiple groups of children to work in the same area
without compromising each other's projects.

In adition to a low level packet radio driver, two higher level protocols are
defined that allow simple user datagram communication between micro:bits and
an EventBus protocol that allows the micro:bit's MessageBus to be extended to
other micro:bits.
2016-02-01 04:29:27 +00:00
Joe Finney e3a23988f6 microbit: Promote constants in MicroBitBLEManager to .h file
Moved configuration constants from .cpp to .h file, so that they can be reused
more easily from other code, such as the broadcast radio code.
2016-02-01 04:25:51 +00:00
Joe Finney 66ed227663 microbit: Add new eventcodes for micro:bit App and radio broadcast
New registered eventcodes added for:
  - Game controller functions in the micro:bit app
  - General broadcast event ID in preparation for broadcast radio capability
2016-02-01 04:22:36 +00:00
James Devine 6b0e9cf489 microbit: integrated MicroBitLightSensor with MicroBitDisplay
Previously, to light sense a user would have to configure a
MicroBitLightSensor instance themselves, and flip the display mode
manually. This is difficult in languages that target our API.

This commit resolves that by adding a new method readLightLevel which
flips the display mode, and instantiates a light sensor.

When changing the mode, the tickSpeed is also modified to reduce
artefacts on the display.
2016-01-29 14:13:41 +00:00
James Devine 2049e63039 microbit: added MicroBitLightSensor
Added a new class called MicroBitLightSensor which interleaves sensing
with the display.

This class takes advantage of the previous commits which add a dynamic
system tick, and a new display mode for the display.

A future optimisation would be for the display to handle the instantion
of a light sensor when the display mode is changed!
2016-01-29 14:10:52 +00:00
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 06aaefb40a Merge branch 'compass-calibration-light' 2016-01-28 17:10:46 +00:00
Joe Finney 0bbb5b9123 microbit: Code cleanup
Removal of debugging information and redundant algorithms.
2016-01-28 17:09:01 +00:00
Joe Finney 8756bbd103 WIP: Lower RAM footprint compass calibration
- moved to single precision floats
- optimised transpose/multiply operation
- optimisation of algorithm
2016-01-26 21:52:22 +00:00