Avancé sur le projet Timetable d'Alexandre. Cela ne fonctionne pas encore ;-(
This commit is contained in:
@@ -1 +1,13 @@
|
||||
# Affiche l'horaire du train Cheseaux à Lausanne sur un ruban de LED's RGB
|
||||
|
||||
zf190408.2100
|
||||
## ATTENTION, cela ne fonctionne pas encore !
|
||||
|
||||
## Ce n'est pas encore automatique, il faut lancer à la main boot.lua et timetable.Lausanne
|
||||
|
||||
## Il y a un problème d'arrondi dans le calcul du nombre de 3 minutes, il ne faut pas arrondir 2mn31 à 3 minutes !<br>
|
||||
Si c'est < 3 minutes il faut décompte moins un pour les clignotements car même pour 10 secondes on va rater le train !
|
||||
|
||||
## Il y a un très gros problème de raisonnement, car quand on se trouve entre -1 et 3 minutes du prochain train, l'horaire du train, que l'on va chercher sur Internet, ne va changer qu'une minute après le départ du train. Il faut donc prendre le prochain train indiqué et non le train actuel quand on se trouve à < 3 minutes du départ !
|
||||
|
||||
## A cause du problème de raisonnement, cela boucle en continu quand on se trouve entre -1 et 3 minutes du départ du train !
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
-- tout sur la couleur: https://www.w3schools.com/colors/default.asp
|
||||
-- roue des couleurs: https://iro.js.org/?ref=oldsite
|
||||
|
||||
print("\n jflash_2rgb.lua jv190227.1628 \n")
|
||||
print("\n jflash_2rgb.lua jv190408.1815 \n")
|
||||
|
||||
dofile("jled_rgb.lua")
|
||||
|
||||
@@ -19,7 +19,7 @@ ztmr_Flash_LED1 = tmr.create() ztmr_Flash_LED2 = tmr.create()
|
||||
|
||||
function flash_LED1 ()
|
||||
if nbfois1 >= xfois1 then
|
||||
print(nbfois1)
|
||||
print("nbfois1: "..nbfois1)
|
||||
nbfois1 = 0
|
||||
jled_rgb(zLED1,R1,G1,B1,0)
|
||||
tmr.alarm(ztmr_Flash_LED1, zTm_Pause, tmr.ALARM_SINGLE, flash_LED1)
|
||||
@@ -39,7 +39,7 @@ end
|
||||
|
||||
function flash_LED2 ()
|
||||
if nbfois2 >= xfois2 then
|
||||
print(nbfois2)
|
||||
print("nbfois2: "..nbfois2)
|
||||
nbfois2 = 0
|
||||
jled_rgb(zLED2,R2,G2,B2,0)
|
||||
tmr.alarm(ztmr_Flash_LED2, zTm_Pause, tmr.ALARM_SINGLE, flash_LED2)
|
||||
@@ -57,9 +57,9 @@ function flash_LED2 ()
|
||||
end
|
||||
end
|
||||
|
||||
xfois1 =5
|
||||
xfois1 = 5
|
||||
flash_LED1 ()
|
||||
xfois2 =2
|
||||
xfois2 = 2
|
||||
flash_LED2 ()
|
||||
|
||||
|
||||
|
||||
80
Timetable/JLEB/time_table.lua
Normal file
80
Timetable/JLEB/time_table.lua
Normal file
@@ -0,0 +1,80 @@
|
||||
-- Rafraichissement du diff time et du web_cli
|
||||
print("\n time_table.lua aj190408.1924 \n")
|
||||
|
||||
function get_timetable()
|
||||
-- http.get("http://192.168.4.1/?line1="..zlength.."m", nil, function(code, data)
|
||||
print("get_timetable: ")
|
||||
http.get("http://transport.opendata.ch/v1/connections?from=Cheseaux&to=Lausanne-Flon&fields[]=connections/from/departure", nil, function(code, data)
|
||||
if (code < 0) then
|
||||
print("HTTP request failed")
|
||||
else
|
||||
print(code, data)
|
||||
jp= 50 h1=string.sub (data,jp,jp+7)
|
||||
jp= 100 h2=string.sub (data,jp,jp+7)
|
||||
jp= 150 h3=string.sub (data,jp,jp+7)
|
||||
jp= 200 h4=string.sub (data,jp,jp+7)
|
||||
print(h1,h2,h3,h4)
|
||||
refresh_display()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function refresh_display()
|
||||
print("coucou 1")
|
||||
-- tm = rtctime.epoch2cal(rtctime.get() + 3600) -- heure d'été
|
||||
tm = rtctime.epoch2cal(rtctime.get() + 7200) -- heure d'hiver
|
||||
|
||||
h0 = string.format("%02d:%02d:%02d", tm["hour"], tm["min"], tm["sec"])
|
||||
print("Il est "..h0)
|
||||
print("h2, h3",h2,h3)
|
||||
d1=zround((diff_time(h2, h0)/180),0)
|
||||
d2=zround((diff_time(h3, h0)/180),0)
|
||||
print(d1,d2)
|
||||
xfois1 = d2 xfois2 =d1
|
||||
if d1==0 then
|
||||
print("coucou 2")
|
||||
get_timetable()
|
||||
print("coucou 3")
|
||||
-- refresh_display()
|
||||
print("coucou 4")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function start_refresh_display()
|
||||
tm = rtctime.epoch2cal(rtctime.get() + 7200)
|
||||
h0 = string.format("%02d:%02d:%02d", tm["hour"], tm["min"], tm["sec"])
|
||||
print("Il est "..h0)
|
||||
tm = time2sec(h0)
|
||||
print("tm: ",tm)
|
||||
if tm >= 71000 then
|
||||
ztmr_start_refresh_display:unregister()
|
||||
get_timetable()
|
||||
-- refresh_display()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
zTm_start_refresh_display = 1*1000
|
||||
ztmr_start_refresh_display = tmr.create()
|
||||
tmr.alarm(ztmr_start_refresh_display, zTm_start_refresh_display, tmr.ALARM_AUTO, start_refresh_display)
|
||||
|
||||
|
||||
zTm_refresh_display = 10*1000
|
||||
ztmr_refresh_display = tmr.create()
|
||||
|
||||
|
||||
--get_timetable()
|
||||
--refresh_display()
|
||||
|
||||
--tmr.alarm(ztmr_refresh_display, zTm_refresh_display, tmr.ALARM_AUTO, refresh_display)
|
||||
|
||||
--[[
|
||||
get_timetable()
|
||||
refresh_display()
|
||||
|
||||
]]
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Petit script pour envoyer quelque chose sur un serveur WEB
|
||||
print("\n web_cli.lua zf190227.1838 \n")
|
||||
print("\n web_cli.lua zf190408.1823 \n")
|
||||
|
||||
|
||||
function disp_send()
|
||||
@@ -15,8 +15,11 @@ function disp_send()
|
||||
jp= 150 h3=string.sub (data,jp,jp+7)
|
||||
jp= 200 h4=string.sub (data,jp,jp+7)
|
||||
print(h1,h2,h3,h4)
|
||||
tm = rtctime.epoch2cal(rtctime.get() + 3600)
|
||||
-- tm = rtctime.epoch2cal(rtctime.get() + 3600) -- heure d'été
|
||||
tm = rtctime.epoch2cal(rtctime.get() + 7200) -- heure d'hiver
|
||||
|
||||
h0 = string.format("%02d:%02d:%02d", tm["hour"], tm["min"], tm["sec"])
|
||||
print("Il est "..h0)
|
||||
d1=zround((diff_time(h2, h0)/180),0)
|
||||
d2=zround((diff_time(h3, h0)/180),0)
|
||||
print(d1,d2)
|
||||
@@ -34,4 +37,4 @@ h0 = string.format("%02d:%02d:%02d", tm["hour"], tm["min"], tm["sec"])
|
||||
print(h0)
|
||||
|
||||
|
||||
]]
|
||||
]]
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
-- Petit script pour configurer le client WIFI du NodeMCU
|
||||
|
||||
print("\n wifi_cli_conf.lua zf190227.1723 \n")
|
||||
print("\n wifi_cli_conf.lua zf190408.1953 \n")
|
||||
|
||||
--credentials par défaut
|
||||
--cli_ssid="3g-s7"
|
||||
cli_ssid="AlexIphone"
|
||||
cli_pwd="q1w2abcdfH&"
|
||||
|
||||
cli_ssid="3g-s7"
|
||||
cli_pwd="12234567"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user