Chromium Code Reviews| Index: dart/examples/led/led.dart |
| diff --git a/dart/examples/led/led.dart b/dart/examples/led/led.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c14ed149b1c51b3d9012d2b792ef8b950ccff312 |
| --- /dev/null |
| +++ b/dart/examples/led/led.dart |
| @@ -0,0 +1,31 @@ |
| +// Copyright (c) 2016, the Dartino project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE.md file. |
| + |
| +import "dart:dartino"; |
| +import "dart:async"; |
| +import "package:lk/leds.dart"; |
| + |
| +int count = 0; |
|
ricow1
2016/02/09 09:06:08
remove unused variable
herhut
2016/02/09 10:10:15
Thanks!
|
| + |
| +makeCallback(LED) { |
| + bool value = false; |
| + return (Timer timer) { |
| + LED.setState(value); |
| + value = ! value; |
| + }; |
| +} |
| + |
| +void main() { |
| + // Reset all LEDs for good measure. |
| + LED0.setState(false); |
| + LED1.setState(false); |
| + LED2.setState(false); |
| + LED3.setState(false); |
| + |
| + // Add some blinking action. |
| + new Timer.periodic(const Duration(milliseconds: 50), makeCallback(LED0)); |
|
Søren Gjesse
2016/02/09 09:16:01
If you add toggle to LED (and make state both a ge
herhut
2016/02/09 10:10:15
Done.
|
| + new Timer.periodic(const Duration(milliseconds: 100), makeCallback(LED1)); |
| + new Timer.periodic(const Duration(milliseconds: 75), makeCallback(LED2)); |
| + new Timer.periodic(const Duration(milliseconds: 333), makeCallback(LED3)); |
| +} |
|
lukechurch
2016/02/09 09:20:01
Consider adding an explanatory comment as to why t
herhut
2016/02/09 10:10:15
Done.
|