Skip to content

Explore the Examples

To get a quick feel about modm's APIs you can look at and experiment with our examples, especially if you have a development board that modm supports out-of-box.

Make sure you've installed all tools required for building modm and you've cloned the modm repository recursively:

git clone --recurse-submodules --jobs 8 https://github.com/modm-io/modm.git

TL;DR

Change directory into any of the examples and compile it:

# cd into any example you like
cd modm/examples/generic/blinky
# generate modm library (call only once)
lbuild build
# compile the example
scons -j8
# Connect your development board and upload the firmware
scons program

To debug with GDB in TUI mode. Make sure to change to the debug profile:

# compile and upload debug profile
scons program profile=debug
# launch OpenOCD and GDB for debugging
scons debug profile=debug

To generate your target specific Doxypress documentation:

(cd modm/docs && doxypress doxypress.json)
# open modm/docs/html/index.html

To remove it all:

# Remove build artifacts
scons -c
# Remove generated files
lbuild clean

Have a look at the build system documentation and the online documentation.

Interesting Examples

We have hundreds of examples but here are some of our favorite ones for our supported development boards:

Here are some additional examples of displays and sensors we like:

Copy Carefully

When copying from our examples make sure to set the repository path correctly! All example modm/examples/**/project.xml files are missing this path, since we set it in the inherited base modm/examples/lbuild.xml configuration. You must also add the modm:docs module manually if you want it.

The modm/examples/lbuild.xml file:

<library>
  <!-- This is the default lbuild configuration file for every
       example in this folder. It only defaults the common settings,
       so that this isn't duplicated in every single example.
       When you write your own application, you must set this
       path yourself! -->
  <repositories>
    <repository><path>../repo.lb</path></repository>
  </repositories>
  <modules>
    <module>modm:docs</module>
  </modules>
</library>