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

Side by Side Diff: samples/raspberry_pi/basic/blinky.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 unified diff | Download patch
« no previous file with comments | « pkg/raspberry_pi/lib/raspberry_pi.dart ('k') | samples/raspberry_pi/basic/buzzer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 // 4 //
5 // The 'hello world' of embedded: Blinking an LED. Uses the on-board 5 // The 'hello world' of embedded: Blinking an LED. Uses the on-board
6 // Raspberry Pi 2 activity LED. 6 // Raspberry Pi 2 activity LED.
7 7
8 import 'package:gpio/gpio.dart'; 8 import 'package:gpio/gpio.dart';
9 import 'package:raspberry_pi/raspberry_pi.dart';
9 import 'package:os/os.dart'; 10 import 'package:os/os.dart';
10 11
11 main() { 12 main() {
12 // Constant for the Raspberry Pi 2 onboard green LED. 13 // Initialize Raspberry Pi and configure the activity LED to be GPIO
13 const int led = 47; 14 // controlled.
14 15 RaspberryPi pi = new RaspberryPi();
15 // Initialize gpio and configure the pin. 16 pi.leds.activityLED.setMode(OnboardLEDMode.gpio);
16 PiMemoryMappedGPIO gpio = new PiMemoryMappedGPIO();
17 gpio.setMode(led, Mode.output);
18 17
19 // Turn LED on and off in a continuous loop. 18 // Turn LED on and off in a continuous loop.
20 while (true) { 19 while (true) {
21 gpio.setPin(led, true); 20 pi.leds.activityLED.on();
22 sleep(500); 21 sleep(500);
23 gpio.setPin(led, false); 22 pi.leds.activityLED.off();
24 sleep(500); 23 sleep(500);
25 } 24 }
26 } 25 }
OLDNEW
« no previous file with comments | « pkg/raspberry_pi/lib/raspberry_pi.dart ('k') | samples/raspberry_pi/basic/buzzer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698