OLD | NEW |
---|---|
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 library stm32.lcd; | 5 library stm32.lcd; |
6 | 6 |
7 import 'dart:dartino.ffi'; | 7 import 'dart:dartino.ffi'; |
8 | 8 |
9 final _lcdHeight = ForeignLibrary.main.lookup('lcd_height'); | 9 final _lcdHeight = ForeignLibrary.main.lookup('lcd_height'); |
10 final _lcdWidth = ForeignLibrary.main.lookup('lcd_width'); | 10 final _lcdWidth = ForeignLibrary.main.lookup('lcd_width'); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 /// Align text to the center. | 74 /// Align text to the center. |
75 center, | 75 center, |
76 /// Align text to the right. | 76 /// Align text to the right. |
77 right, | 77 right, |
78 } | 78 } |
79 | 79 |
80 class FrameBuffer { | 80 class FrameBuffer { |
81 int get height => _lcdHeight.icall$0(); | 81 int get height => _lcdHeight.icall$0(); |
82 int get width => _lcdWidth.icall$0(); | 82 int get width => _lcdWidth.icall$0(); |
83 | 83 |
84 clear([Color color = Color.black]) { | 84 Color _backgroundColor = Color.white; |
85 | |
86 clear([Color color]) { | |
87 if (color == null) { | |
88 color = _backgroundColor; | |
Søren Gjesse
2016/05/19 12:48:27
Just
color ??= _backgrouncColor;
mit
2016/05/19 12:54:37
Done.
| |
89 } | |
85 _lcdClear.icall$1(color.rgb8888); | 90 _lcdClear.icall$1(color.rgb8888); |
86 } | 91 } |
87 | 92 |
93 set backgroundColor(Color color) { | |
94 _backgroundColor = color; | |
95 _lcdSetBackgroundColor.icall$1(color.rgb8888); | |
96 } | |
97 | |
88 set foregroundColor(Color color) { | 98 set foregroundColor(Color color) { |
89 _lcdSetForegroundColor.icall$1(color.rgb8888); | 99 _lcdSetForegroundColor.icall$1(color.rgb8888); |
90 } | 100 } |
91 | 101 |
92 set backgroundColor(Color color) { | |
93 _lcdSetBackgroundColor.icall$1(color.rgb8888); | |
94 } | |
95 | |
96 Color readPixel(int x, int y) { | 102 Color readPixel(int x, int y) { |
97 return new Color.fromRgb8888(_lcdReadPixel.icall$2(x, y)); | 103 return new Color.fromRgb8888(_lcdReadPixel.icall$2(x, y)); |
98 } | 104 } |
99 | 105 |
100 void drawPixel(int x, int y, [Color color = Color.white]) { | 106 void drawPixel(int x, int y, [Color color = Color.white]) { |
101 _lcdDrawPixel.icall$3(x, y, color.rgb8888); | 107 _lcdDrawPixel.icall$3(x, y, color.rgb8888); |
102 } | 108 } |
103 | 109 |
104 void drawLine(int x1, int y1, int x2, int y2, [Color color = Color.white]) { | 110 void drawLine(int x1, int y1, int x2, int y2, [Color color = Color.white]) { |
105 _lcdSetForegroundColor.icall$1(color.rgb8888); | 111 _lcdSetForegroundColor.icall$1(color.rgb8888); |
(...skipping 10 matching lines...) Expand all Loading... | |
116 int alignMode; | 122 int alignMode; |
117 switch (align) { | 123 switch (align) { |
118 case TextAlign.left: alignMode = 3; break; | 124 case TextAlign.left: alignMode = 3; break; |
119 case TextAlign.center: alignMode = 1; break; | 125 case TextAlign.center: alignMode = 1; break; |
120 case TextAlign.right: alignMode = 2; break; | 126 case TextAlign.right: alignMode = 2; break; |
121 } | 127 } |
122 _lcdDisplayString.icall$4(x, y, m, alignMode); | 128 _lcdDisplayString.icall$4(x, y, m, alignMode); |
123 m.free(); | 129 m.free(); |
124 } | 130 } |
125 } | 131 } |
OLD | NEW |