danrubel / rpi_gpio.dart

Dart library for accessing the Raspberry Pi GPIO pins
Other
48 stars 5 forks source link

Simplify API and examples #5

Closed danrubel closed 6 years ago

danrubel commented 9 years ago
danrubel commented 9 years ago

For example, it should be easy to consume te the rpi_gpio package in order to drive hardware buttons and strips of LEDs.

import 'dart:math';
import 'package:rpi_gpio/rpi_gpio.dart';

Random random = new Random();
double next() => random.nextDouble();

void change(Strip led) {
  led
    ..red = next()
    ..blue = next()
    ..green = next();
}

main() {
  var led = new Strip(pin(1, output), pin(2, output), pin(3, output));
  change(led);
  new Button(pin(4, input), () => change(led));
}
danrubel commented 6 years ago

New API published in version 0.5.0