Commit Graph

31 Commits (9218e647e0868ae68608aab18b53c6c417fe5240)

Author SHA1 Message Date
Joe Finney 9218e647e0 microbit: Refactor of periodc timer callbacks
- Factored periodic timer funcitonality out of fiber scheduler and into a new SystemTimer module module.
- Enapsulated "ticks" variable within SystemTimer module, with accessor funciton.
- Added accessor/mutator functions to get and set the tick period.
- Added a class wrapper to permit periodic callbacks to both C and C++
- Updated all references in microbit-dal to use this refactored API.
2016-03-10 17:01:17 +00:00
Joe Finney 000351b599 Factored idle/interrupt callback events out of MicroBit.cpp 2016-03-10 12:02:15 +00:00
Joe Finney 5231b5f526 First cut at a build without a global MicroBit singleton 2016-03-10 12:02:13 +00:00
Joe Finney 72d14be1d4 microbit: Added ability to define how long a device will remain in panic
before resetting

Requests made for an optional timeout function to define the period of time in
which the device will remain in a panic state. This patch introduces a
setErrorTimeout() method with this functionality.
2016-02-08 14:37:43 +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

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 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 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 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
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,
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 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.


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
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
Michal Moskal 56a560e5bc Merge branch 'master' into flatstring
2015-11-12 16:13:45 -08:00
Joe Finney 435debffed Merge branch 'quiet-gcc-build' of into remay-quiet-gcc-build 2015-11-08 13:50:33 +00:00
Joe Finney 1a65e4e7bc microbit: Added support for soft reset button in panic mode
Also recalibrated loop timers in MicroBitDisplay::Error(), as used by panic()...
strange these now seem off by several orders of magnitude.

TODO: Ensure CPU is running at correct internal frequency with an oscilloscope test...
2015-11-01 21:33:46 +00:00
Robert May 1a1a5976a8 Silence GCC -Wall 2015-11-01 20:19:17 +00:00
Joe Finney 194f19a428 Merge branch 'simplified-eventing' 2015-11-01 18:22:27 +00:00
Joe Finney 84da6a4a09 microbit: Minor bug fixes and refinements
- Add maximum depth for event queues, to prevent buggy scripts causing total memory exhaustion.
  - Suppress generation of A/B click events when A+B click is generated
  - preservation of event ordering on messagebus for resursive event generation cases.
  - bugfix of message bus processing to prevent occasional dual processing of events
  - bugfix MicroBitDisplay to behave correctly when delay parameter is zero.
2015-10-31 10:27:38 +00:00
Joe Finney 823a956d68 microbit: First cut at updates to provide tight validation within the runtime code, with a view to moving
NOP/clamping behaviour out of teh micro:bit runtime and into the glue layers of higher level

 - Updates to many functions to provide explicut return codes.
 - Updates to many functions to remove heuristic calidation (NOP/clamping/defaults)
 - Updates to ErrorNo.h to provide clearer return values, and place return values in a better scope
 - Updates to MicroBitDisplay to use enums where appropriate.
2015-10-25 21:51:33 +00:00
Michal Moskal 4f82a6c37c Use RefCounted also for MicroBitImage. 2015-10-24 20:58:03 -07:00
Joe Finney 72e5a9a6a6 microbit: BUGFIX - post merge fixes
- MicroBitDisplay::scroll() timing bug
  - MicroBitDisplay::print() timing bug
  - MicroBitFiber wait/notify bug
2015-10-18 19:09:54 +01:00
Joe Finney aca544677e microbit: Updates to enable queing of display animation calls
Updates to change the behaviour of the scroll/print/animate faily of function away
from being pre-emtive and instead prroviding queing behaviour.

Minor updates to provide complete sets of async equivalent operations

Updates to the scheduler to provide wait/notify/waitone semantics.
2015-10-17 20:35:16 +01:00
Damien George 0dcb6834ec microbit: Use default constructor for MatrixPoint so data is ROMable.
Previous to this patch an explicit constructor was provided for creating
MatrixPoint instances, which meant that such objects could not be put in
ROM (since they needed to be constructed at runtime).

By using the defualt construction method for structs the MatrixPoint map
is now compiled into the rodata section, hence freeing up RAM.

Saves: 4 bytes data, 56 bytes bss, 148 bytes code.
2015-09-25 21:19:10 +01:00
Joe Finney a875d5fccd microbit: Added configurable concurrency modes for MicroBitMessageBus handlers.
MessageBus handlers can now have one of four concurrency modes for the eventuality
of an event being raised whilst a previous event is still being processed. An additional
(optional) parameter is provided to the listen() functions to allow this to be selected
on a per event handler basis. The permissable options are:

The event handler is fired with the new event, regardless of whether or not
a previous event is still be processed by that handler.

The new event is queued until such a time as the previous event has completed
execution. The new event is then processed. This option does not preclude the
processing of the new event by other event handlers.

The new event is dropped, and will never be processed the the event handler.
This option does not preclude the processing of the new event by other event handlers.

The event handler is self-declaring that it never blocks. This flag is used purely
for optimisation, as it permits direct execution of the event hadnelr without inducing
any overhead from the scheduler.

In addition, the following minor revisions were made in this release:

* Cleanup of the #include dependencies contained in the microbit-dal .h files
* Bugfix to the scheduler block on event matching code.
* Introduced a MICROBIT_ID_ALERT MessageBus channel, for general purpose eventing using nonces.
2015-09-11 16:39:38 +01:00
Joe Finney 6470b71b1d microbit: Conditional compilation on MicroBitConfig
All options defined in MicroBitConfig are now set IFF they already do not have a value.
This allows external configuration of these options much more cleanly. Additional macros
also defined to provide clean implementation for boolean configuration switches.

Also some minor bugfixes:

  - Correction of typo of "Microbit.h" => "MicroBit.h"
  - Fixed heap corruption bug on gcc as a result of a debug printf in an unsafe context.
2015-09-02 12:42:24 +01:00
Joe Finney 42f43b2255 Merge branch 'master' of 2015-08-19 23:48:36 +01:00
Joe Finney 0fec4ae87c microbit: BUGFIX - Input validation in MicroBitDisplay::setBrightness()
Updates to MicroBitDisplay::setBrightness() to perform a NOP for out of bound parameters.
This aligns the functionality of the runtime with the TD simulator.
2015-08-19 23:36:17 +01:00
James Devine d7b3ba9dab microbit-dal: Fixed a bug on printing a character with a delay
Previously when a blocking print finished, the animatemode was not
reset, which meant sometimes there would be a race condition.
2015-08-14 01:06:41 +01:00
James Devine 538e1c48bd microbit-dal: Initial Commit
This is the first commit of the microbit-dal on GitHub.
This repository contains the runtime, which is a light
weight operating system developed by Lancaster University.
2015-08-12 11:53:41 +01:00