Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
You are viewing an older revision! See the latest version
Homepage
Simple framework to allow for mini-programs, or Sketchlets, to be executed on a single SoC. Distributed under the MIT license.
Arduino version of this library can be found at https://github.com/murrellrr/arduino_sketchlet.
Example Usage:¶
Inside your man.cpp file.
#include "main.h" using namespace com::aerialspecs::mbed::sketchlet; void setup() { controller = new Controller(MAX_SKETCHLET_SIZE); controller->setup(); } bool loop() { return controller->loop(); } void shutdown() { delete controller; } /** * */ int main() { setup(); while(loop()) {} shutdown(); }
A sample of a Sketchlet. DefaultSketchlet.h and DefaultSketchlet.cpp
// In your header file. #define LED_PIN 13 #define BLINK_TIMEOUT 1000 #include "Sketchlet.h" using namespace com::aerialspecs::mbed::sketchlet; class DefaultSketchlet : public Sketchlet { public: DefaultSketchlet(); virtual void initialize(); virtual bool loop(); virtual void terminate(); virtual ~DefaultSketchlet(); private: uint32_t lastTime; }; // Inside CPP file. #include "DefaultSketchlet.h" using namespace com::aerialspecs::mbed::sketchlet; DefaultSketchlet::DefaultSketchlet() : public Sketchlet() { this->lastTime = millis(); } void DefaultSketchlet::initialize() { // initialize your led } bool DefaultSketchlet::loop() { uint32_t currentTime = millis(); if((currentTime - this->lastTime) >= BLINK_TIMEOUT) { // toggle your led this->lastTime = currentTime; } return true; } void DefaultSketchlet::terminate() { // release the LED is required by your platform. } DefaultSketchlet::~DefaultSketchlet() { // cleanup anything... }