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 color ??= _backgroundColor; |
85 _lcdClear.icall$1(color.rgb8888); | 88 _lcdClear.icall$1(color.rgb8888); |
86 } | 89 } |
87 | 90 |
| 91 set backgroundColor(Color color) { |
| 92 _backgroundColor = color; |
| 93 _lcdSetBackgroundColor.icall$1(color.rgb8888); |
| 94 } |
| 95 |
88 set foregroundColor(Color color) { | 96 set foregroundColor(Color color) { |
89 _lcdSetForegroundColor.icall$1(color.rgb8888); | 97 _lcdSetForegroundColor.icall$1(color.rgb8888); |
90 } | 98 } |
91 | 99 |
92 set backgroundColor(Color color) { | |
93 _lcdSetBackgroundColor.icall$1(color.rgb8888); | |
94 } | |
95 | |
96 Color readPixel(int x, int y) { | 100 Color readPixel(int x, int y) { |
97 return new Color.fromRgb8888(_lcdReadPixel.icall$2(x, y)); | 101 return new Color.fromRgb8888(_lcdReadPixel.icall$2(x, y)); |
98 } | 102 } |
99 | 103 |
100 void drawPixel(int x, int y, [Color color = Color.white]) { | 104 void drawPixel(int x, int y, [Color color = Color.white]) { |
101 _lcdDrawPixel.icall$3(x, y, color.rgb8888); | 105 _lcdDrawPixel.icall$3(x, y, color.rgb8888); |
102 } | 106 } |
103 | 107 |
104 void drawLine(int x1, int y1, int x2, int y2, [Color color = Color.white]) { | 108 void drawLine(int x1, int y1, int x2, int y2, [Color color = Color.white]) { |
105 _lcdSetForegroundColor.icall$1(color.rgb8888); | 109 _lcdSetForegroundColor.icall$1(color.rgb8888); |
(...skipping 10 matching lines...) Expand all Loading... |
116 int alignMode; | 120 int alignMode; |
117 switch (align) { | 121 switch (align) { |
118 case TextAlign.left: alignMode = 3; break; | 122 case TextAlign.left: alignMode = 3; break; |
119 case TextAlign.center: alignMode = 1; break; | 123 case TextAlign.center: alignMode = 1; break; |
120 case TextAlign.right: alignMode = 2; break; | 124 case TextAlign.right: alignMode = 2; break; |
121 } | 125 } |
122 _lcdDisplayString.icall$4(x, y, m, alignMode); | 126 _lcdDisplayString.icall$4(x, y, m, alignMode); |
123 m.free(); | 127 m.free(); |
124 } | 128 } |
125 } | 129 } |
OLD | NEW |