First version of distortos published! |
Written by Freddie Chopin
|
Thursday, 10 March 2016 16:39 |
Less than two weeks ago, after 584 days since I started working on distortos system, I finally published first version - 0.1.0. List of functionalities included in this release can be found in the change log and packages with source code can be found on http://distortos.org/ in Downloads section. In the same place you can also download packages with project template and example applications that were published on the same day. This second package currently has just the "classic" LED blinker which uses static or dynamic threads. I've even recorded a short video featuring this application (;
As a small incentive - a little bit of "magic" code, which asynchronously calculates result of sine function for four different numbers in four separate threads. It is a complete and working code of application - you don't need to add anything else!
#include "distortos/board/leds.hpp"
#include "distortos/chip/ChipOutputPin.hpp"
#include "distortos/StaticThread.hpp"
void sinWrapper(const double operand, double& result)
{
result = sin(operand);
}
int main()
{
const double operands[4] {0.9867816015, 0.4641984149, 0.4665572273, 0.8926178650};
double results[4] {};
auto sinThread0 = distortos::makeAndStartStaticThread<512>(1, sinWrapper, operands[0], std::ref(results[0]));
auto sinThread1 = distortos::makeAndStartStaticThread<512>(1, sinWrapper, operands[1], std::ref(results[1]));
auto sinThread2 = distortos::makeAndStartStaticThread<512>(1, sinWrapper, operands[2], std::ref(results[2]));
auto sinThread3 = distortos::makeAndStartStaticThread<512>(1, sinWrapper, operands[3], std::ref(results[3]));
// do something while the threads are calculating results...
distortos::board::leds[0].set(true);
// make sure the threads are done
sinThread0.join();
sinThread1.join();
sinThread2.join();
sinThread3.join();
// results are ready!
distortos::board::leds[0].set(false);
}
|
Last Updated on Thursday, 10 March 2016 17:55 |