Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Unified Diff: samples/raspberry_pi/basic/knight-rider.dart

Issue 1389573002: Refactor Raspberry Pi GPIO and add GPIO mock (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Remove unused constant Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/raspberry_pi/basic/door-bell.dart ('k') | tests/pkg/gpio/gpio_mock_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/raspberry_pi/basic/knight-rider.dart
diff --git a/samples/raspberry_pi/basic/knight-rider.dart b/samples/raspberry_pi/basic/knight-rider.dart
index caade8fc2829bc617d3c5f1f164b352d7e5bd434..ca3ee12066e754a3cff05c7eeeca8724089f3725 100644
--- a/samples/raspberry_pi/basic/knight-rider.dart
+++ b/samples/raspberry_pi/basic/knight-rider.dart
@@ -12,16 +12,20 @@
// https://storage.googleapis.com/fletch-archive/images/k-r-schematic.png
import 'package:gpio/gpio.dart';
+import 'package:raspberry_pi/raspberry_pi.dart';
import 'package:os/os.dart';
main() {
+ // Initialize Raspberry Pi
+ RaspberryPi pi = new RaspberryPi();
+
// Array constant containing the GPIO pins of the connected LEDs.
// You can add more LEDs simply by extending the list. Make sure
// the pins are listed in the order the LEDs are connected.
List<int> leds = [26, 19, 13, 6];
// Initialize the lights controller class.
- Lights lights = new Lights(leds);
+ Lights lights = new Lights(pi.memoryMappedGPIO, leds);
lights.init();
// Alternate between running left and right in a continuous loop.
@@ -33,10 +37,10 @@ main() {
}
class Lights {
- List<int> leds;
- PiMemoryMappedGPIO _gpio = new PiMemoryMappedGPIO();
+ final GPIO _gpio;
+ final List<int> leds;
- Lights(this.leds);
+ Lights(this._gpio, this.leds);
// Initializes GPIO and configures the pins.
void init() {
« no previous file with comments | « samples/raspberry_pi/basic/door-bell.dart ('k') | tests/pkg/gpio/gpio_mock_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698