-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
65 lines (44 loc) · 1.54 KB
/
Program.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;
using System.Threading;
namespace LCD_I2CFrutten
{
class Program
{
static I2CLcd lcd;
static I2CPort.USB_ISS i2c;
static BME280 bme280;
static void Main(string[] args)
{
i2c = new I2CPort.USB_ISS("Com3");
lcd = new I2CLcd(i2c, 0x4E, I2CLcd.Pin.BL);
bme280 = new BME280(i2c);
List<byte> devices = i2c.ScanBus();
foreach (byte device in devices)
{
Console.WriteLine($"Device found @{device}({device.ToString("x16")})");
}
Thread.Sleep(3000);
Console.WriteLine("");
lcd.Write(0, 0, "Hij dut t...");
SecondTimer timer = new SecondTimer();
timer.SecondElapsed += HandleSecond;
while (true)
{
Thread.Sleep(500);
}
}
private static void HandleSecond(object sender, EventArgs e)
{
WriteToConsoleAndLcd(0, 0, $"{DateTime.Now.ToString("ddd, dd MMM yyy")}");
WriteToConsoleAndLcd(0, 1, $"{DateTime.Now.ToString("HH:mm:ss 'GMT+1'")}");
}
private static void WriteToConsoleAndLcd(int x, int y, string str)
{
Console.SetCursorPosition(x, Console.CursorTop + y);
Console.Write(str);
Console.SetCursorPosition(x, Console.CursorTop - y);
lcd.Write(x, y, str);
}
}
}