Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce optional javascript semantics for event handling #418

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9dedea4
Introduce optional javascript semantics for event handling
finneyj Sep 27, 2018
69bf72e
Update string print() method to avoid unecessary delays
finneyj Feb 27, 2019
b1cb519
Simplify implementation of fiber_wake_on_event()
finneyj Feb 27, 2019
6112d74
MicroBitMessageBus::process() updated to pass events by value
finneyj Feb 27, 2019
ca43746
Ensure MicroBitDisplay::waitForFreeDisplay() is free of race conditions
finneyj Feb 27, 2019
31fea82
Change Fiber lists to be singly-linked
finneyj May 3, 2019
60d423e
Ignore .vscode metadata
finneyj May 3, 2019
1c1426f
Introduce FiberTable stucture
finneyj May 3, 2019
461fb33
Integrate optional fiber meta-data contributed in #424
finneyj May 7, 2019
07f07fb
Ensure Fiber stack allocation happens in the context of that Fiber
finneyj May 7, 2019
b71334e
Add user define limit to size of FiberPool
finneyj May 7, 2019
b9816a4
Reintroduce validation test in fiber_sleep()
finneyj May 7, 2019
226bf9c
Replace FiberTable with a list of all fibers to save memory
finneyj May 8, 2019
92c6cc6
Allow overriding of the heap allocator and getting heap sizes
finneyj May 8, 2019
7413352
Introduce optional javascript semantics for event handling
finneyj Sep 27, 2018
c9c98be
Update string print() method to avoid unecessary delays
finneyj Feb 27, 2019
b28dba4
MicroBitMessageBus::process() updated to pass events by value
finneyj Feb 27, 2019
77d679c
Ensure MicroBitDisplay::waitForFreeDisplay() is free of race conditions
finneyj Feb 27, 2019
c04b1fd
Merge branch 'js-event-semantics' of https://www.github.com/lancaster…
finneyj May 8, 2019
8075eab
.gitignore vscode metadata
finneyj Mar 24, 2020
25e1e10
Add Fiber->user_data and list_fiber()
mmoskal Jan 20, 2019
92d0cee
Allow overriding of the heap allocator and getting heap sizes
mmoskal Jan 20, 2019
415e5eb
Compilation fixes
mmoskal Jan 20, 2019
15ebed2
Add fiber_user_data to yotta mappings; fix some errors
mmoskal Jan 20, 2019
d823d4b
Rename list pointers in MicroBitFiber.h
finneyj Mar 25, 2020
c42776c
Merge branch 'pxtgc' into js-event-semantics
finneyj Mar 25, 2020
219feb8
Remove list_fibers API
finneyj Mar 25, 2020
3ed3674
Add CONFIG flag to indicate use of get_fiber_list() API
finneyj Mar 25, 2020
76538ef
Re-enumerate component ID values to align with CODAL
finneyj Mar 25, 2020
f96a390
Use schedule() not fiber_sleep(0) in MicroBitSerial.cpp (Fix #461)
finneyj Apr 1, 2020
dd339a7
Honour delay parameter in MicroBitDisplay::print(MicroBitImage)
finneyj Apr 1, 2020
0fd4a80
Correctly initialise animation timer for printChar() Fix #463
finneyj Apr 21, 2020
3bccdd6
Ensure consistent behaviour of MicroBitDisplay::print() operations
finneyj Apr 21, 2020
673228f
Align print() semantics with previous versions
finneyj Apr 24, 2020
2443beb
Align MICROBIT_PIN_EVENT_ON_* with codal
mmoskal Jun 8, 2020
e5b6741
Align allocateNotifyEvent() API with codal
finneyj Jul 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inc/drivers/MicroBitMessageBus.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class MicroBitMessageBus : public EventModel, public MicroBitComponent
* @note It is recommended that all external code uses the send() function instead of this function,
* or the constructors provided by MicrobitEvent.
*/
int process(MicroBitEvent &evt, bool urgent = false);
int process(MicroBitEvent evt, bool urgent = false);
Copy link
Contributor

@jamesadevine jamesadevine Feb 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@finneyj what's the overhead implications of this change?


/**
* Returns the microBitListener with the given position in our list.
Expand Down
5 changes: 0 additions & 5 deletions source/core/MicroBitFiber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,7 @@ int fiber_wake_on_event(uint16_t id, uint16_t value)
// If we're out of memory, there's nothing we can do.
// keep running in the context of the current thread as a best effort.
if (forkedFiber != NULL)
{
f = forkedFiber;
dequeue_fiber(f);
queue_fiber(f, &runQueue);
schedule();
}
}

// Encode the event data in the context field. It's handy having a 32 bit core. :-)
Expand Down
11 changes: 5 additions & 6 deletions source/drivers/MicroBitDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ void MicroBitDisplay::updateScrollText()
void MicroBitDisplay::updatePrintText()
{
image.print(printingChar < printingText.length() ? printingText.charAt(printingChar) : ' ',0,0);

if (printingChar > printingText.length())
if (printingChar >= printingText.length())
{
animationMode = ANIMATION_MODE_NONE;

Expand Down Expand Up @@ -448,7 +447,7 @@ void MicroBitDisplay::stopAnimation()
void MicroBitDisplay::waitForFreeDisplay()
{
// If there's an ongoing animation, wait for our turn to display.
if (animationMode != ANIMATION_MODE_NONE && animationMode != ANIMATION_MODE_STOPPED)
while (animationMode != ANIMATION_MODE_NONE && animationMode != ANIMATION_MODE_STOPPED)
fiber_wait_for_event(MICROBIT_ID_NOTIFY, MICROBIT_DISPLAY_EVT_FREE);
}

Expand Down Expand Up @@ -492,7 +491,7 @@ int MicroBitDisplay::printCharAsync(char c, int delay)
if (delay > 0)
{
animationDelay = delay;
animationTick = 0;
animationTick = delay-1;
animationMode = ANIMATION_MODE_PRINT_CHARACTER;
}
}
Expand Down Expand Up @@ -533,7 +532,7 @@ int MicroBitDisplay::printAsync(ManagedString s, int delay)
printingChar = 0;
printingText = s;
animationDelay = delay;
animationTick = 0;
animationTick = delay-1;

animationMode = ANIMATION_MODE_PRINT_TEXT;
}
Expand Down Expand Up @@ -576,7 +575,7 @@ int MicroBitDisplay::printAsync(MicroBitImage i, int x, int y, int alpha, int de
if(delay > 0)
{
animationDelay = delay;
animationTick = 0;
animationTick = delay-1;
animationMode = ANIMATION_MODE_PRINT_CHARACTER;
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/drivers/MicroBitMessageBus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ int MicroBitMessageBus::send(MicroBitEvent evt)
* @note It is recommended that all external code uses the send() function instead of this function,
* or the constructors provided by MicrobitEvent.
*/
int MicroBitMessageBus::process(MicroBitEvent &evt, bool urgent)
int MicroBitMessageBus::process(MicroBitEvent evt, bool urgent)
{
MicroBitListener *l;
int complete = 1;
Expand Down