funmiles / picoasync Goto Github PK
View Code? Open in Web Editor NEWAn open-source library for C++ coroutine based asynchronous programming on the Raspberry Pi Pico.
An open-source library for C++ coroutine based asynchronous programming on the Raspberry Pi Pico.
A purely coroutine based multi-tasking system needs all tasks to be good citizen of the cooperative multi-tasking system, yielding the CPU to other tasks in a periodic manner, enabling long running compute intensive tasks to run while not stopping other tasks from operating.
A yield awaitable object is a clean way of achieving this goal. It can be awaited periodically in long running loops:
task<> do_some_long_computation(int iterationCount, auto &&operation, priority myPriority)
{
for (int i = 0; i < iterationCount; ++i) {
// Perform one iteration's work
operation(i);
// Yield the CPU, signaling the queueing system our priority (optional argument)
co_await cpu::yield(myPriority);
}
}
An example of such use is for the SSD1306 code. Filling the OLED screen buffer to print text can take tens of thousands of cycles.
The routine performing this operation should be capable of yielding so that time-critical operations can take place.
If you have multiple compilations units using the library, you get "multiple definitions" linker errors because of the functions defined in the header files, namely events.h. I guess a solution could be to inline those as well.
Off topic:
Great project! I'm glad I ran into this. I was looking for precedence to programming RP2040 async style. I hope the library catches on and keeps getting developed and maintained.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.