rpi_spi 0.1.2

Dart native js
Flutter Android iOS web

rpi_spi is a Dart library for using SPI on the Raspberry Pi.

example/example.dart

import 'dart:async';

import 'package:rpi_spi/rpi_spi.dart';

import 'mcp3008.dart';

main() async {
  final spi = RpiSpi();
  await readSensor(Mcp3008(spi, 0, 24));
  spi.dispose();
}

Future readSensor(Mcp3008 mcp3008) async {
  StringBuffer out;
  print('Read analog values from MCP3008 channels 0 - 7:');

  print('      | Channel');
  out = StringBuffer('      ');
  for (int channel = 0; channel < 8; ++channel) {
    out.write('| ${channel.toString().padLeft(4)} ');
  }
  print(out.toString());
  print('-' * 63);

  for (int count = 1; count <= 10; ++count) {
    out = StringBuffer(' ${count.toString().padLeft(4)} ');
    for (int channel = 0; channel < 8; ++channel) {
      var value = mcp3008.read(channel);
      out.write('| ${value.toString().padLeft(4)} ');
    }
    print(out.toString());
    await Future.delayed(Duration(milliseconds: 10));
  }
}
0
likes
95
pub points
11%
popularity

rpi_spi is a Dart library for using SPI on the Raspberry Pi.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploaders

danrubel@google.com
devoncarew@google.com
dan.rubel.usa@gmail.com

License

BSD (LICENSE)

Dependencies

path

More

Packages that depend on rpi_spi