/FogLight-Grove

Grove component examples with instructions

Primary LanguageJavaBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

OE FogLight Grove Examples

FogLight is a lightweight runtime that enables makers of all ages and skill levels to create highly performant apps for embedded devices like Raspberry Pis.

What It Is

FogLight is a Java 8 functional API for embedded systems that's built on top of GreenLightning, a small footprint, garbage free compact 1 Java web server and message routing platform,

FogLight is...

  • Fast - Built on top of GreenLightning, FogLight is a garbage-free, lock-free and low latency way to talk directly to hardware.
  • Simple - Taking advantage of the latest Java 8 APIs, FogLight has a clean and fluent set of APIs that make it easy to learn and apply with minimal training.
  • Secure - By taking advantage of the compile-time graph validation system, all FogLight applications can be compiled and compressed to a point where injecting malicious code into the final production JAR would prove difficult, if not impossible.

FogLight-API demos

How It Works

Every FogLight application starts with an FogApp implementation which initializes the FogRuntime by defining various hardware connections and behaviors for handling state changes in those connections.

A very simple example of a FogLight application is below (omitting boilerplate import statements and so on); this app makes an LED connected to a GrovePi board blink every 500 milliseconds:

public class IoTApp implements FogApp {
    
    private static final int PAUSE = 500;
           
    public static final Port LED_PORT = D5;
    
    public static void main( String[] args) {
        FogRuntime.run(new IoTApp());
    }    
    
    @Override
    public void declareConnections(Hardware c) {
        c.connect(LED, LED_PORT);
        c.setTriggerRate(PAUSE*2);
    }

    @Override
    public void declareBehavior(FogRuntime runtime) {
        
        final FogCommandChannel blinkerChannel = runtime.newCommandChannel(); 
        
        runtime.addTimeListener((time,instance)->{
        	
        	blinkerChannel.setValueAndBlock(LED_PORT, true, PAUSE);
        	blinkerChannel.setValue(LED_PORT, false);
        });
    }  
}

Of course, this is just a simple example; for more interesting examples that demonstrate the various features currently available in FogLight, you should take a look at our examples repository.

What You Need Before You Start:

Hardware

Software

Starting Your Maven Project

Starting a mvn project

Information and Demos for Grove Devices