Modern software development for microcontrollers

The Moddable SDK is an open source combination of development tools and runtime software to create applications for microcontrollers.

Microcontrollers are highly constrained devices compared to modern computers and mobile devices. A typical microcontroller used with the Moddable SDK has about 45 KB of free memory, 1 MB of Flash ROM, and runs at 80 MHz. The Moddable SDK uses many different techniques, both at build time and at run time, to work efficiently on these devices.

JS logo

The primary programming language for development is JavaScript. The XS JavaScript engine at the center of the Moddable SDK implements the 2021 JavaScript language standard with better than 99% conformance.[1] The constraints of the target microcontroller may limit the number of language features that can be used in combination by a single application.

The JavaScript language implemented in the Moddable SDK is the same language used in web pages and Node.js. The microcontroller that the scripts run on, however, is very different from a personal computer, server, or mobile device. These differences often require a different approach to using JavaScript. The APIs and objects in the Moddable SDK are quite different, being designed with the goal of minimizing memory use. Bring your existing experience with JavaScript, but be prepared to think about performance, code size, and memory use in a different way.[2]

As much as practical, the Moddable SDK is implemented in JavaScript. Portions of the Moddable SDK are implemented in C for performance or direct access to native APIs.[3] There is no C++.

A significant part of building efficient software for microcontrollers occurs at build time. The Moddable SDK contains many tools and options for the build process.[4] Take time to learn about these to get the best results.

[1] See also: XS Conformance
[2] See also: XS Differences
[3] See also: XS in C
[4] See also: Tools

Content covering Moddable SDK here...

SDK License

Major features

Multi-platform

The Moddable SDK is avaliable for for macOS, Linux, and Windows.

Networking

The Moddable SDK implements network sockets and a variety of standard, secure networking protocols built on sockets including HTTP/HTTPS, WebSockets, MQTT, mDNS, DNS, SNTP, and telnet.

There is also Bluetooth Low Energy (BLE) protocol support for both BLE peripheral and central device development.

Graphics

Two APIs for building modern user interfaces are available:

  • Commodetto, a bitmap graphics library that provides a 2D graphics API. Commodetto includes the lightweight Poco rendering engine, a display list renderer able to efficiently render a single scanline at a time, saving considerable memory by eliminating the need for a frame buffer.
  • Piu, a user interface framework built on top of Commodetto. Piu is an object-based framework that makes it easier to create complex, responsive layouts.

The Moddable SDK also includes command line tools for image format conversion, image compression, image rotation, font compression, localization, and more. The build system automatically makes use of these tools.

Hardware

The Moddable SDK implements a variety of hardware protocols including digital (GPIO), analog, PWM, and I2C. A number of drivers for common off-the-shelf sensors and corresponding example apps are also available.

Source level debugger

The xsbug JavaScript source level debugger is a full-featured debugger that supports debugging modules and applications for XS platforms.

Similar to other debuggers, xsbug supports setting breakpoints, browsing source code, and inspection of the call stack and variables. The xsbug debugger additionally provides real-time instrumentation to track memory usage and profile application and resource consumption.

See also: xsbug documentation

XS Vitural Machine

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem libero adipisci odit, iure quibusdam veniam eius perferendis numquam cumque repudiandae, quisquam veritatis mollitia. Molestiae ipsa porro, id enim deleniti aspernatur? Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Mods

The option to do partial updates to embedded binaries opens new possiblities. Mods can be installed with a local wired connection or via OTA.