-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDisplayBase.cs
45 lines (36 loc) · 1.1 KB
/
DisplayBase.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using Meadow;
using Meadow.Foundation.Graphics;
using Meadow.Logging;
using Meadow.Peripherals.Displays;
namespace CoreComputeBreakout;
public abstract class DisplayBase
{
private MicroGraphics _canvas;
private RotationType _rotation;
protected Logger Logger { get; private set; }
protected abstract IPixelDisplay Display { get; }
public DisplayBase(Logger logger, RotationType rotation = RotationType.Default)
{
Logger = logger;
_rotation = rotation;
}
private void CheckCanvas()
{
if (_canvas == null)
{
_canvas = new MicroGraphics(Display);
_canvas.Clear(true);
_canvas.CurrentFont = new Font12x20();
_canvas.Rotation = _rotation;
}
}
public void ShowText(string text, int line = 1)
{
CheckCanvas();
var lineheight = 20;
var y = 5 + (line * lineheight);
_canvas.DrawRectangle(0, y, _canvas.Width, 20, Color.Black, true);
_canvas.DrawText(5, y, text, Color.White);
_canvas.Show();
}
}