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

Side by Side Diff: samples/stm32f746g-discovery/knight-rider.dart

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 10 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
OLDNEW
1 // Copyright (c) 2016, the Dartino project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dartino 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 // Remember those red running lights KITT had in Knight Rider? 5 // Remember those red running lights KITT had in Knight Rider?
6 // https://www.youtube.com/watch?v=Mo8Qls0HnWo 6 // https://www.youtube.com/watch?v=Mo8Qls0HnWo
7 // 7 //
8 // This sample recreates those with a chain of LEDs running right and left: 8 // This sample recreates those with a chain of LEDs running right and left:
9 // https://storage.googleapis.com/fletch-archive/images/knight-rider.mp4 9 // https://storage.googleapis.com/dartino-archive/images/knight-rider.mp4
10 // 10 //
11 // TODO: Add a schematics. 11 // TODO: Add a schematics.
12 // For breadboard layout and connections to the STM32F746G Discovery board, see: 12 // For breadboard layout and connections to the STM32F746G Discovery board, see:
13 // https://storage.googleapis.com/fletch-archive/images/xxx.png 13 // https://storage.googleapis.com/dartino-archive/images/xxx.png
14 14
15 import 'dart:fletch'; 15 import 'dart:dartino';
16 16
17 import 'package:stm32f746g_disco/gpio.dart'; 17 import 'package:stm32f746g_disco/gpio.dart';
18 import 'package:stm32f746g_disco/stm32f746g_disco.dart'; 18 import 'package:stm32f746g_disco/stm32f746g_disco.dart';
19 19
20 main() { 20 main() {
21 // Initialize STM32F746G Discovery board. 21 // Initialize STM32F746G Discovery board.
22 STM32F746GDiscovery board = new STM32F746GDiscovery(); 22 STM32F746GDiscovery board = new STM32F746GDiscovery();
23 23
24 // Array constant containing the GPIO pins of the connected LEDs. 24 // Array constant containing the GPIO pins of the connected LEDs.
25 // You can add more LEDs simply by extending the list. Make sure 25 // You can add more LEDs simply by extending the list. Make sure
(...skipping 26 matching lines...) Expand all
52 // Initializes all pins as output. 52 // Initializes all pins as output.
53 void init() { 53 void init() {
54 gpioPins = leds.map((pin) => _gpio.initOutput(pin)).toList(); 54 gpioPins = leds.map((pin) => _gpio.initOutput(pin)).toList();
55 } 55 }
56 56
57 // Iterates though the lights in increasing order, and sets the LEDs using 57 // Iterates though the lights in increasing order, and sets the LEDs using
58 // a helper function. Pauses [waitTime] milliseconds before returning. 58 // a helper function. Pauses [waitTime] milliseconds before returning.
59 void runLightLeft(int waitTime) { 59 void runLightLeft(int waitTime) {
60 for (int counter = 0; counter < leds.length; counter++) { 60 for (int counter = 0; counter < leds.length; counter++) {
61 _setLeds(counter); 61 _setLeds(counter);
62 // TODO(sgjesse): Use the Fletch sleep function. 62 // TODO(sgjesse): Use the Dartino sleep function.
63 for (int i= 0; i < 50000; i++) {} 63 for (int i= 0; i < 50000; i++) {}
64 //sleep(waitTime); 64 //sleep(waitTime);
65 } 65 }
66 } 66 }
67 67
68 // Iterates though the lights in decreasing order, and sets the LEDs using 68 // Iterates though the lights in decreasing order, and sets the LEDs using
69 // a helper function. Pauses [waitTime] milliseconds before returning. 69 // a helper function. Pauses [waitTime] milliseconds before returning.
70 void runLightRight(int waitTime) { 70 void runLightRight(int waitTime) {
71 for (int counter = leds.length - 1; counter >= 0; counter--) { 71 for (int counter = leds.length - 1; counter >= 0; counter--) {
72 _setLeds(counter); 72 _setLeds(counter);
73 // TODO(sgjesse): Use the Fletch sleep function. 73 // TODO(sgjesse): Use the Dartino sleep function.
74 for (int i= 0; i < 50000; i++) {} 74 for (int i= 0; i < 50000; i++) {}
75 //sleep(waitTime); 75 //sleep(waitTime);
76 } 76 }
77 } 77 }
78 78
79 // Sets LED [ledToEnable] to true, and all others to false. 79 // Sets LED [ledToEnable] to true, and all others to false.
80 void _setLeds(int ledToEnable) { 80 void _setLeds(int ledToEnable) {
81 for (int i = 0; i < gpioPins.length; i++) { 81 for (int i = 0; i < gpioPins.length; i++) {
82 gpioPins[i].state = (i == ledToEnable); 82 gpioPins[i].state = (i == ledToEnable);
83 } 83 }
84 } 84 }
85 } 85 }
OLDNEW
« no previous file with comments | « samples/simple_todo/simple_todo_service_tests.dart ('k') | samples/todomvc/android/TodoMVC/.gitignore » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698