-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
82 lines (82 loc) · 2.34 KB
/
main.ts
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
function AfficheMeteo () {
dht11_dht22.queryData(
DHTtype.DHT22,
DigitalPin.P1,
true,
false,
false
)
Temperature = dht11_dht22.readData(dataType.temperature)
Humidite = dht11_dht22.readData(dataType.humidity)
if (dht11_dht22.readDataSuccessful()) {
I2C_LCD1602.ShowString("T:", 0, 0)
I2C_LCD1602.ShowNumber(Math.round(Temperature), 2, 0)
I2C_LCD1602.ShowString("C Hum:", 4, 0)
I2C_LCD1602.ShowNumber(Math.round(Humidite), 10, 0)
I2C_LCD1602.ShowString("%", 12, 0)
I2C_LCD1602.ShowNumber(CalculHauteurNeige(), 14, 0)
I2C_LCD1602.ShowString("m", 15, 0)
}
}
radio.onReceivedString(function (receivedString) {
if (receivedString == "1") {
nom = "Rene Cassin"
strip.showRainbow(1, 360)
}
if (receivedString == "2") {
nom = "Vera Rubin "
strip.showRainbow(1, 360)
}
if (receivedString == "3") {
nom = " "
strip.showColor(neopixel.colors(NeoPixelColors.Black))
}
})
function CalculHauteurNeige () {
capteurNeige = pins.analogReadPin(AnalogPin.P2)
if (capteurNeige < capteurNeigeMax) {
capteurNeige = capteurNeigeMax
}
if (capteurNeige > CapteurNeigeMin) {
capteurNeige = CapteurNeigeMin
}
HauteurNeige = Math.round(9 * ((capteurNeige - CapteurNeigeMin) / (capteurNeigeMax - CapteurNeigeMin)))
if (HauteurNeige > 9) {
HauteurNeige = 9
}
return HauteurNeige
}
let temps = 0
let HauteurNeige = 0
let capteurNeige = 0
let Humidite = 0
let Temperature = 0
let CapteurNeigeMin = 0
let capteurNeigeMax = 0
let nom = ""
let strip: neopixel.Strip = null
basic.showIcon(IconNames.Heart)
I2C_LCD1602.LcdInit(0)
radio.setGroup(97)
strip = neopixel.create(DigitalPin.P0, 8, NeoPixelMode.RGB)
nom = " "
capteurNeigeMax = 199
CapteurNeigeMin = 270
let tempsdebut = input.runningTime() - 2000
basic.clearScreen()
basic.forever(function () {
if (nom != " ") {
I2C_LCD1602.ShowString(nom, 0, 1)
for (let j = 0; j <= 7; j++) {
strip.setPixelColor(j, neopixel.colors(NeoPixelColors.Black))
strip.show()
basic.pause(500)
}
}
temps = input.runningTime()
if (temps - tempsdebut > 2000) {
tempsdebut = temps
AfficheMeteo()
}
I2C_LCD1602.ShowString(nom, 0, 1)
})