Giter Club home page Giter Club logo

Comments (3)

ladislas avatar ladislas commented on June 3, 2024

Communication / Command Processing

In our avr prototype, we use a homemade circular buffer to group commands before processing.

mbed provides something similar with built-in critical sections lock so it can be used from ISR (if needed).

https://os.mbed.com/docs/mbed-os/v5.14/apis/circularbuffer.html

Both have push/write, pop/read, peek/peek and status functions.

Our buffer also has a hasPattern function to look for specific patterns inside the buffer, e.g. the start sequence (https://github.com/leka/LKAlphaComSpecs/#start-sequence)

https://github.com/leka/LKAlphaOS-avr/blob/develop/lib/Buffer/Buffer.cpp#L153

from lekaos.

ladislas avatar ladislas commented on June 3, 2024

Thread synchronization with EventFlags

https://os.mbed.com/docs/mbed-os/v5.14/apis/eventflags.html

I haven't tested it, but EventFlags could be a very nice tool to synchronize our threads with the wait_any function:

https://os.mbed.com/docs/mbed-os/v5.14/mbed-os-api-doxy/classrtos_1_1_event_flags.html#a666b81f3ea18439300f8c6d88cacad80

For LED animation, something like this could work, we need to try it out:

// inside a thread function doing the animation
while(true) {
	// ...
	leds.shine(200, 34, 78);
	if event_flags.wait_any(STOP_FLAG, 10/*ms to wait*/) != 0 {
		break; // break from while loop
	}
	leds.shine(150, 34, 90);
	// ...
}

The same tool can be used to "start" threads.

signal_wait should also be explored:

https://os.mbed.com/docs/mbed-os/v5.14/mbed-os-api-doxy/classrtos_1_1_thread.html#a2b0659360b5cb4b1273d2362398c0294

from lekaos.

ladislas avatar ladislas commented on June 3, 2024

Simplify your code with mbed-events

from lekaos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.