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

Side by Side Diff: dart/pkg/lk/lib/leds.dart

Issue 1684433003: Add a small LED interface and demo app. (Closed) Base URL: git@github.com:domokit/sod.git@master
Patch Set: fix exports for qemu target 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
« no previous file with comments | « dart/examples/led/led.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016, the SoD project authors. Please see the AUTHORS file
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.
4
5 import 'dart:dartino.ffi';
6
7 final ForeignFunction _setGpio = ForeignLibrary.main.lookup('gpio_set');
8 final ForeignFunction _getGpio = ForeignLibrary.main.lookup('gpio_get');
9 final ForeignFunction _getLedGpio = ForeignLibrary.main.lookup('led_get_gpio');
10
11 class LED {
12 final int _id;
13
14 const LED._internal(this._id);
15
16 int get _gpio {
17 int gpio = _getLedGpio.icall$1(_id);
18 if (gpio < 0) throw new ArgumentError();
19 return gpio;
20 }
21
22 set state(bool value) => _setGpio.vcall$2(_gpio, value ? 1 : 0);
23
24 bool get state => _getGpio.icall$1(_gpio) == 1 ? true : false;
25
26 toggle() => state = !state;
27 }
28
29 const LED0 = const LED._internal(0);
30 const LED1 = const LED._internal(1);
31 const LED2 = const LED._internal(2);
32 const LED3 = const LED._internal(3);
OLDNEW
« no previous file with comments | « dart/examples/led/led.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698