Commit Graph

637 Commits

Author SHA1 Message Date
Joe Finney 3d9283b947 Merge branch 'master' of https://www.github.com/lancaster-university/microbit-dal 2016-05-13 16:43:52 +01:00
James Devine 51138b3d54 microbit-dal: removed OpenDrain from MicroBitPin setPull [issue #144] 2016-05-13 11:17:30 +01:00
Brendan Moran 8468823e21 Convert add operator to a friend operator
By replacing the addition operator with a friend operator, order of
operations doesn’t matter, provided that at least one argument is a
ManagedString.

```C++
ManagedString a = "A";           // OK
ManagedString b = a + ", " + 2;  // OK
ManagedString c = "a" + a + 2;   // OK
ManagedString d = 1 + "," + 2;   // FAILS
```
2016-05-12 15:06:01 +01:00
James Devine d887bbf670 Merge pull request #142 from bremoran/master
Add missing const qualifier from add operator
2016-05-12 12:27:10 +01:00
Brendan Moran d8c083d49c Add missing const qualifier from add operator
This change permits more friendly use of the type such as:

```C++
ManagedString s = "A";
ManagedString b = s + ", " + 2;
```
2016-05-12 10:54:09 +01:00
James Devine af46028260 microbit-dal: Moved from v2.0.0-rc2 to v2.0.0-rc3. 2016-05-11 13:52:28 +01:00
James Devine ed95d8197d Merge pull request #137 from lancaster-university/pin-events
Increased granularity of system timer.

Added events for Rise, Fall, Pulse HI and Pulse LO.

Pulse HI/LO events give the time that the pin was HI or LO for using the timestamp field of the MicroBitEvent.

Added setPull() to configure the pull of the pin when in a digital input mode.
2016-05-11 13:49:46 +01:00
James Devine dc9b007895 microbit-dal: added comparison to MicroBitStorage to prevent overwriting with duplicate data. [issue #140]
Issue #140 highlighted the fact there would be multiple writes of the
same data when storing calibration information.

This patch introduces a memcmp before initiating the storage of
KeyValuePairs in the “put” member function.
2016-05-11 13:33:20 +01:00
James Devine deac034189 microbit-dal: panic now accepts codes in the range 0 - 999 [issue #129 ]
Issue #129 illustrated that panic is capable of accepting numbers in
the range 0-999 and should therefore not have an arbitrary range of
0-255.

Additionally, this commit introduces gaps between consecutive numbers
of the same value e.g. 999. As a result, the speed of panic has also
been reduced.
2016-05-11 12:58:21 +01:00
James Devine 3b587e14ae microbit-dal: serial SYNC_SLEEP / SYNC_SPINWAIT modes transmit all characters [issue #141]
In SYNC_SLEEP and SYNC_SPINWAIT modes the maximum length that could be
sent was always dictated by the buffer size.

This was incorrect as these two modes should wait until all characters
have been transmitted from the given buffer before returning control to
the user.

ASYNC mode will still return immediately after copying the number of
bytes available in the TX buffer.
2016-05-10 17:46:35 +01:00
James Devine e935380685 microbit-dal: All pins are now capable of becoming a "touch" input [issue #90]
#90 illustrated out that even though 3 pins have the required pull ups
to perform resistive “touch” sensing, developers may want to attach
their own pull ups and use MicroBitPins as resistive inputs more
generally.

This patch removes PIN_CAPABILITY_TOUCH, as all pins with
PIN_CAPABILITY_DIGITAL can become a resistive input.

N.b. In order to utilise pins used by the display, the display MUST be
disabled.
2016-05-09 12:25:48 +01:00
Joe Finney c45eba9bdb microbit: Removed unnecessary Managedstring() conversions 2016-05-04 17:12:57 +01:00
Joe Finney eead32096b microbit: reuse variables in recalculatePitchRoll [issue #116]
Removed redundant function calls.
2016-04-29 10:47:44 +01:00
Joe Finney ece079c75f microbit: FREEFALL gesture event is now damped
After further testing, dmaping is required on FREEFALL event (but not impulse
events) to avoid false positives.
2016-04-29 10:39:28 +01:00
Joe Finney e0369cab6b microbit: Removed legacy isIdleCallbackNeeded() method. [issue #138]
This function has been deprecated, so now removed for v2.0.0 release.
2016-04-29 10:28:36 +01:00
Joe Finney d2319f6d30 microbit: Added support for freefall event
Replaced this functionality after testing showed funcitonality had been
accidentally removed.
2016-04-28 22:54:08 +01:00
Joe Finney 682063dc7b microbit: Replaced BasicGestures enum with #define equivalent [issue #106] 2016-04-28 22:40:41 +01:00
Joe Finney b5846f065a microbit: Fixed unreachable High-G gesture events [issue #109]
Ammended basic gesture recogniser to correclty generate threshold events for
high G forces (3G, 6G and 8G threshold events).

Also refined semantics such that events for any given impulse will be
generated for ALL thresholds below that below. e.g a 7G impulse will now raise
both the 3G and 6G threshold events.
2016-04-28 22:10:19 +01:00
Joe Finney 7443b78361 Fix typos 2016-04-28 09:25:38 +01:00
James Devine 4e71d61347 microbit-dal: Added setPull to MicroBitPin
This new member function allows the configuration of the pull currently
applied to the MicroBitPin instance. This member function only has
affect when the MicroBitPin instance is in a digital input mode.
2016-04-27 13:59:25 +01:00
James Devine 732971e758 microbit-dal: Added events to MicroBitPin
Added rise, fall, pulse HI and LO events.

The pulse Hi and LO event timestamp given in the MicroBitEvent is the
duration for which the input was HI or LO for.

eventOn(int eventType) is used to configure the events generated
from the pin instance.
2016-04-27 13:59:11 +01:00
James Devine cc381fe8f4 microbit-dal: BUGFIX: no parenthesis in MicroBitMessageBus.cpp
GCC was giving a very accurate warning regarding a lack of
parenthesis in MicroBitMessageBus.cpp. This has now been rectified.
2016-04-25 14:11:08 +01:00
Martin Williams db015d37ac Fix MICROBIT_IO_PIN_SERVICE_PINCOUNT
MicroBitIO only has 19 pins.
2016-04-25 13:09:53 +01:00
Martin Williams 36d9130bd1 Fix button B characteristic declaration
Button B characteristic is declared using A’s data buffer
2016-04-25 13:07:40 +01:00
James Devine 3923dffffc microbit-dal: increase granularity of the system wide timer
Added an mbed Timer instance to maintain a microsecond level timestamp.

Added a function system_timer_current_time_us() which now returns the
time since power on in microseconds.

MicroBitEvents now call system_timer_current_time_us() giving
microsecond level timestamps.
2016-04-25 11:30:28 +01:00
James Devine 3b435c0d30 microbit-dal: BUGFIX in MicroBitStorage
There was an off by one error when storing the key of the key value
pair, where the null terminator was dropped. This would mean that if
the returned key of the KeyValuePair were used, it would cause a number
of issues.

Another issue raised was the copying a random 48 bytes from memory
regardless of the position of memory in the stack. If the memory was
smaller than 48 bytes, and existed at the top of the stack, this could
have dire consequences. As a result, MicroBitStorage now accepts a size
parameter which informs the number of bytes to be copied into flash.

#130
2016-04-23 19:58:29 +01:00
James Devine 0048a9ac8e microbit-dal: fixed UART service buffer sizing, and re-enabled config options for default services
There was a perspective mismatch with the UART service, where the
actual buffer size given in the constructor, did not reflect the size
of the user buffer that was available to the application. This was not
documented, and hence cause confusion. The patch applied in this
commit, increments the given buffer sizes by one, so that the
application buffer has the available size given in the constructor.

Additionally, some configuration options were lost during the component
refactor, these have now been restored.
2016-04-19 15:41:51 +01:00
James Devine 6a78463791 microbit-dal: bumped to version number to RC2. 2016-04-19 15:12:33 +01:00
James Devine 8875dc35d2 microbit-dal: added yotta configuration mappings to DAL specific configuration options.
Yotta can now be used to configure the configuration options for the
dal.

An full config.json looks like:

{
    "microbit-dal":{
        "bluetooth":{
            "enabled": 1,
            "pairing_mode": 0,
            "private_addressing": 0,
            "open": 0,
            "whitelist": 1,
            "advertising_timeout": 0,
            "tx_power": 0,
            "dfu_service": 1,
            "event_service": 1,
            "device_info_service": 1
        },
        "reuse_sd": 1,
        "gatt_table_size": "0x300",
        "heap_allocator": 1,
        "nested_heap_proportion": 0.75,
        "system_tick_period": 6,
        "system_components": 10,
        "idle_components": 6,
        "use_accel_lsb": 0,
        "min_display_brightness": 1,
        "max_display_brightness": 255,
        "display_scroll_speed": 120,
        "display_scroll_stride": -1,
        "display_print_speed": 400,
        "panic_on_heap_full": 1,
        "debug": 0,
        "heap_debug": 0,
        "stack_size":2048,
        "sram_base":"0x20000008",
        "sram_end":"0x20004000",
        "sd_limit":"0x20002000",
        "gatt_table_start":"0x20001900"
    }
}
2016-04-19 15:02:28 +01:00
James Devine c844e6104a microbit-dal: fixed a warning in MicroBitBLEManager.cpp 2016-04-18 15:25:30 +01:00
James Devine 44b3daeca2 microbit-dal: modified duplicate conflicting ID for MICROBIT_ID_BLE_UART 2016-04-15 14:16:31 +01:00
James Devine 9914a98050 Merge pull request #120 from bluetooth-mdw/master
Added BLE connect/disconnect events and fixed bug in MagnetometerService.cpp

Possible fix for #114
2016-04-15 14:12:19 +01:00
Martin Woolley ae2c351d56 Fixed dodgy comment 2016-04-15 14:00:27 +01:00
Martin Woolley 051abec174 Changed BLE connection event constant names to match LU groovy naming convention 2016-04-15 13:56:23 +01:00
James Devine 7cf98c2290 microbit-dal: patch for fiber_wake_on_event
fiber_wake_on_event used to crash after forking a FOB fiber.

It would attempt to obtain a new fiber context, and would place it on the wait queue.
Then when that fiber was paged in, the context of that fiber would not have been
initialised, as the function presumed schedule would be called immediately after
fiber initialisation.

This patch catches that edge case.
2016-04-15 13:40:41 +01:00
Martin Woolley 87f7233a84 Added BLE connect/disconnect events and fixed bug in MagnetometerService re: bearing characteristic 2016-04-15 13:38:24 +01:00
Joe Finney 94e2c66185 microbit: Additional optional autoClear parameter to MicroBitDisplay::animate
The MicroBitDisplay::animate() and MicroBitDisplayAnimateAsync() function both
assumed that the display should be cleared once the requested animation was
complete.

This patch allows the user to control this funcitonality through an
addiitonal, optional boolean parameter to the animate() and animateAsync()
functions.
2016-04-15 12:37:09 +01:00
Joe Finney 82ed22d1b2 microbit: MicroBitRadio group ID now persists enable/disable operations
MicroBitradio::enable() would reset the group ID of the radio to the default
value on each call. Updated to do this only once at object initialisation time.
2016-04-15 11:33:53 +01:00
Joe Finney a82254b9e2 microbit: MicroBitRadio support for multiple enable/disable operations
MicroBitRadio::disable neglected to reset the internal status flag indicating
that the radio has bene initialised, which prevent subsequent enable()
operations completing properly.
2016-04-15 10:47:40 +01:00
Tom Ball 0639d7df6a Update README.md 2016-04-08 17:29:40 -04:00
James Devine c064eee3e7 microbit-dal: updated module.json to get the latest dependencies from support libs. 2016-04-08 11:45:15 +01:00
James Devine c39a6b3b36 microbit-dal: added default assembler file for armcc for mbed 2.0 compatability 2016-04-08 11:43:30 +01:00
Joe Finney 4159eb0665 microbit: Update to module dependency to include bugfix in ble-nrf51822 2016-04-08 00:06:23 +01:00
Joe Finney 3e72d679c1 microbit: Updated dependencies to use bugfixed Ticker implementation in mbed 2016-04-07 18:01:50 +01:00
James Devine 6702a5f51a microbit-dal: Zero initialised C99 compatible buffers 2016-04-07 17:45:32 +01:00
Joe Finney b5193dbcb7 microbit: BUGFIX - missing NULL initialisation in templated MicroBitListener 2016-04-07 17:41:21 +01:00
James Devine cdeabd26c6 microbit-dal: patched armcc incompatibilities. 2016-04-07 16:57:16 +01:00
Joe Finney 72d2d2b10a microbit: MessageBus now treats all listeners as MESSAGE_BUS_LISTENER_IMMEDIATE if no scheduler is present
The default THREADING_MODE for event handlers is typically set to run through
the scheduler. However, it is possible to create and operate a MessageBus without the scheduler being initialised.

This patch changes the behaviour of the MessageBus to treat all registered
listeners as MESSAGE_BUS_LISTENER_IMMEDIATE (i.e. directly called) if no
scheduler is present. This default allows for a more user friendly experience
in this case.
2016-04-07 11:55:31 +01:00
James Devine 63a8ae81ec microbit-dal: Fixed multiline note which had artefacts in microbit-docs. 2016-04-07 11:32:13 +01:00
James Devine 387c4f18e4 microbit-dal: fixed C99 incompatible array initialisation.
Removed { 0 }; from all buffer initialisations.

Also replaced all uses of Serial::IrqType:: with IrqType::
2016-04-07 11:31:33 +01:00