diff --git a/Firmware/nodemcu-master-20-modules-2018-11-05-09-46-28-float.bin b/Firmware/nodemcu-master-20-modules-2018-11-05-09-46-28-float.bin new file mode 100644 index 0000000..729cccc Binary files /dev/null and b/Firmware/nodemcu-master-20-modules-2018-11-05-09-46-28-float.bin differ diff --git a/Firmware/nodemcu-master-20-modules-2018-11-05-09-46-28-float.pdf b/Firmware/nodemcu-master-20-modules-2018-11-05-09-46-28-float.pdf new file mode 100644 index 0000000..eea179c Binary files /dev/null and b/Firmware/nodemcu-master-20-modules-2018-11-05-09-46-28-float.pdf differ diff --git a/LED_WS2812/Alex/PoC.tar b/LED_WS2812/Alex/PoC.tar new file mode 100644 index 0000000..c782384 Binary files /dev/null and b/LED_WS2812/Alex/PoC.tar differ diff --git a/LED_WS2812/Alex/PoC/cat.lua b/LED_WS2812/Alex/PoC/cat.lua new file mode 100644 index 0000000..7c309b9 --- /dev/null +++ b/LED_WS2812/Alex/PoC/cat.lua @@ -0,0 +1,17 @@ +-- fonction cat() pour afficher le contenu d'un fichier dans la flash +print("\n cat.lua zf180826.1109 \n") + +function cat(zfile) + print("\n"..zfile.."\n-------------------------------") + + zfilei = file.open(zfile, "r") + i=1 + zline=file.readline() + repeat + print(i..": "..string.sub(zline,1,string.len(zline)-1)) + i=i+1 zline=file.readline() + until zline== nil + file.close(zfilei) + + print("-------------------------------") +end diff --git a/LED_WS2812/Alex/PoC/dir.lua b/LED_WS2812/Alex/PoC/dir.lua new file mode 100644 index 0000000..8bf9414 --- /dev/null +++ b/LED_WS2812/Alex/PoC/dir.lua @@ -0,0 +1,15 @@ +-- fonction dir() pour afficher les fichiers dans la flash +print("\n dir.lua zf180826.1019 \n") + +function dir() + print("\n-------------------------------") + l=file.list() i=0 + for k,v in pairs(l) do + i=i+v + print(k..string.rep(" ",19-string.len(k)).." : "..v.." bytes") + end + print("-------------------------------") + print('\nUsed: '..i..' bytes\nusage: dofile("file.lua")\n') +end + +dir() diff --git a/LED_WS2812/Alex/PoC/dossier sans titre/initz.lua b/LED_WS2812/Alex/PoC/dossier sans titre/initz.lua new file mode 100644 index 0000000..17beb40 --- /dev/null +++ b/LED_WS2812/Alex/PoC/dossier sans titre/initz.lua @@ -0,0 +1,15 @@ + +print() +print("starting init.lua...") +print() +print("local files:") +l=file.list() +for k,v in pairs(l) do + print(k.." "..v) +end +print() + +print("starting webleds...") +print() +dofile('webleds.lua') + diff --git a/LED_WS2812/Alex/PoC/index.html b/LED_WS2812/Alex/PoC/index.html new file mode 100644 index 0000000..62283da --- /dev/null +++ b/LED_WS2812/Alex/PoC/index.html @@ -0,0 +1,60 @@ + + + +LED Strip Control + + + + +

LED strip control page

+ +

Choose an effect:

+ + +

Pick a color:

+ + + + + diff --git a/LED_WS2812/Alex/PoC/initz.lua b/LED_WS2812/Alex/PoC/initz.lua new file mode 100644 index 0000000..97951ca --- /dev/null +++ b/LED_WS2812/Alex/PoC/initz.lua @@ -0,0 +1,23 @@ +--Script de bootstrap, en appuyant sur le bouton ça démarre start_boot, +-- autrement en attendant 8 secondes cela démarre start_boot + +print("\n init.lua zf181017.1026\n") + +zswitch=3 --switch flash +gpio.mode(zswitch, gpio.INT, gpio.PULLUP) +initalarme=tmr.create() + +function hvbouton() + gpio.trig(zswitch, "none") + tmr.unregister(initalarme) + dofile("start_boot.lua") +-- dofile("start_job.lua") +end + +gpio.trig(zswitch, "both", hvbouton) + +tmr.alarm(initalarme, 8000, tmr.ALARM_SINGLE, function() + print("\nStart\n") + dofile("start_boot.lua") +-- dofile("start_job.lua") +end) diff --git a/LED_WS2812/Alex/PoC/just_test_3x.lua b/LED_WS2812/Alex/PoC/just_test_3x.lua new file mode 100644 index 0000000..c04c64a --- /dev/null +++ b/LED_WS2812/Alex/PoC/just_test_3x.lua @@ -0,0 +1,17 @@ +-- Scripts juste pour tester 3x LED RGB +-- tout sur la couleur: https://www.w3schools.com/colors/default.asp +-- roue des couleurs: https://iro.js.org/?ref=oldsite + +print("\n just_test_3x.lua zf181105.1428 \n") + + +print("Initializing LED strip...") +ws2812.init() +ws2812_effects.stop() +strip_buffer = ws2812.newBuffer(3, 3) +ws2812.write(string.char(0, 255, 0, 255, 0, 0, 0, 0, 255)) +ws2812.write(string.char(255, 0, 255, 0, 255, 255, 255, 255, 0)) +ws2812.write(string.char(128, 255, 64, 255, 200, 200, 200, 200, 255)) +ws2812.write(string.char(255, 255, 255, 40, 40, 40, 5, 5, 5)) +ws2812.write(string.char(0, 0, 0, 0, 0, 0, 0, 0, 0)) + diff --git a/LED_WS2812/Alex/PoC/rm_files.lua b/LED_WS2812/Alex/PoC/rm_files.lua new file mode 100644 index 0000000..81241cb --- /dev/null +++ b/LED_WS2812/Alex/PoC/rm_files.lua @@ -0,0 +1,12 @@ +-- pour effacer TOUS les fichiers qui se trouve dans la flash du NodeMCU + +print("\n rm_files.lua zf180907.1511 \n") + + +l=file.list() i=0 +for k,v in pairs(l) do + i=i+v + file.remove(k) +end +print("-------------------------------") +print("\nC'est tout effaced :-) \n") diff --git a/LED_WS2812/Alex/PoC/start_boot.lua b/LED_WS2812/Alex/PoC/start_boot.lua new file mode 100644 index 0000000..c651d1d --- /dev/null +++ b/LED_WS2812/Alex/PoC/start_boot.lua @@ -0,0 +1,8 @@ +-- Scripts à charger au moment du boot + +print("\n start_boot.lua zf181105.1122 \n") + +print("starting webleds...") +print() +dofile('webleds.lua') + diff --git a/LED_WS2812/Alex/PoC/webleds.lua b/LED_WS2812/Alex/PoC/webleds.lua new file mode 100644 index 0000000..6ef5da6 --- /dev/null +++ b/LED_WS2812/Alex/PoC/webleds.lua @@ -0,0 +1,63 @@ +-- initially based on https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/webap_toggle_pin.lua + +-- start wifi client or AP mode +--dofile('wificlient.lua') +dofile('wifiap.lua') + +-- LED init (strip with 72 leds) +print("Initializing LED strip...") +ws2812.init() +strip_buffer = ws2812.newBuffer(3, 3) +ws2812_effects.init(strip_buffer) +-- initially all leds off +ws2812_effects.set_speed(200) +ws2812_effects.set_brightness(0) +ws2812_effects.set_color(0,0,0) +ws2812_effects.start() +print("done.") +print() + +-- helper functions +-- send a file from memory to the client; max. line length = 1024 bytes! +function send_file(client, filename) + if file.open(filename, "r") then + repeat + local line=file.read('\n') + if line then + client:send(line) + end + until not line + file.close() + end +end + +-- web server +srv = net.createServer(net.TCP) +srv:listen(80, function(conn) + conn:on("receive", function(client, request) + local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP") + if (method == nil) then + _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP") + end + local _GET = {} + if (vars ~= nil) then + for k, v in string.gmatch(vars, "(%w+)=([a-z0-9_]+)&*") do + _GET[k] = v + end + end + if (_GET.set == "effect") then + print("setting effect", _GET.effect) + ws2812_effects.set_mode(_GET.effect) + ws2812_effects.set_speed(200) + ws2812_effects.set_brightness(50) + ws2812_effects.start() + end + if (_GET.set == "color") then + print("setting color (RGB)", _GET.r, _GET.g, _GET.b) + ws2812_effects.set_color(_GET.g, _GET.r, _GET.b) -- obviously our strip is GRB and not RGB + end + send_file(client, 'index.html') + end) + conn:on("sent", function(c) c:close() end) +end) + diff --git a/LED_WS2812/Alex/PoC/wifiap.lua b/LED_WS2812/Alex/PoC/wifiap.lua new file mode 100644 index 0000000..13f559a --- /dev/null +++ b/LED_WS2812/Alex/PoC/wifiap.lua @@ -0,0 +1,18 @@ + +-- set AP mode +wifi.setmode(wifi.SOFTAP) +wifi.ap.config({ ssid = "webleds", pwd = "12345678" }) +print("Started AP mode") + +-- get and display our IP addr. +tmr.alarm(0, 1000, 1, function() + if wifi.ap.getip() == nil then + print("Getting AP info...") + else + print('IP: ', wifi.ap.getip()) + tmr.stop(0) + end +end) + +print() + diff --git a/LED_WS2812/WS2813_18031509433725.pdf b/LED_WS2812/WS2813_18031509433725.pdf new file mode 100644 index 0000000..68c3207 Binary files /dev/null and b/LED_WS2812/WS2813_18031509433725.pdf differ diff --git a/Workshop/181015/hello_world/blink_led1.lua b/Workshop/181015/hello_world/blink_led1.lua index f5f5249..41e9bef 100644 --- a/Workshop/181015/hello_world/blink_led1.lua +++ b/Workshop/181015/hello_world/blink_led1.lua @@ -1,9 +1,10 @@ -- programme pour faire clignoter une LED avec un rapport on/off ---zf20180717.1118 + +print("\n blink_led1.lua zf181105.1114 \n") zLED=0 -zTm_On_LED = 500 --> en ms -zTm_Off_LED = 500 --> en ms +zTm_On_LED = 200 --> en ms +zTm_Off_LED = 200 --> en ms zFlag_LED = 0 function blink_LED () diff --git a/Workshop/181015/hello_world/flash_led_xfois.lua b/Workshop/181015/hello_world/flash_led_xfois.lua new file mode 100644 index 0000000..76e62b2 --- /dev/null +++ b/Workshop/181015/hello_world/flash_led_xfois.lua @@ -0,0 +1,32 @@ +-- programme pour faire clignoter x fois une LED avec un rapport on/off +print("\n flash_led_xfois.lua zf181105.1111 \n") + +zLED=0 +zTm_On_LED = 50 --> en ms +zTm_Off_LED = 100 --> en ms +nbfois = 0 +gpio.write(zLED, gpio.HIGH) +gpio.mode(zLED, gpio.OUTPUT) +ztmr_Flash_LED = tmr.create() + +function blink_LED () + if nbfois >= xfois then + print(nbfois) + nbfois = 0 + else + if gpio.read(zLED)==gpio.HIGH then + gpio.write(zLED, gpio.LOW) + tmr.alarm(ztmr_Flash_LED, zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED) + else + gpio.write(zLED, gpio.HIGH) + nbfois = nbfois+1 + tmr.alarm(ztmr_Flash_LED, zTm_On_LED, tmr.ALARM_SINGLE, blink_LED) + end + end +end + +xfois =2 +blink_LED () + + + diff --git a/blink_led1.lua b/blink_led1.lua index 902bbdc..41e9bef 100644 --- a/blink_led1.lua +++ b/blink_led1.lua @@ -1,9 +1,10 @@ -- programme pour faire clignoter une LED avec un rapport on/off ---zf20180717.1118 + +print("\n blink_led1.lua zf181105.1114 \n") zLED=0 -zTm_On_LED = 900 --> en ms -zTm_Off_LED = 900 --> en ms +zTm_On_LED = 200 --> en ms +zTm_Off_LED = 200 --> en ms zFlag_LED = 0 function blink_LED () diff --git a/flash_led_xfois.lua b/flash_led_xfois.lua new file mode 100644 index 0000000..76e62b2 --- /dev/null +++ b/flash_led_xfois.lua @@ -0,0 +1,32 @@ +-- programme pour faire clignoter x fois une LED avec un rapport on/off +print("\n flash_led_xfois.lua zf181105.1111 \n") + +zLED=0 +zTm_On_LED = 50 --> en ms +zTm_Off_LED = 100 --> en ms +nbfois = 0 +gpio.write(zLED, gpio.HIGH) +gpio.mode(zLED, gpio.OUTPUT) +ztmr_Flash_LED = tmr.create() + +function blink_LED () + if nbfois >= xfois then + print(nbfois) + nbfois = 0 + else + if gpio.read(zLED)==gpio.HIGH then + gpio.write(zLED, gpio.LOW) + tmr.alarm(ztmr_Flash_LED, zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED) + else + gpio.write(zLED, gpio.HIGH) + nbfois = nbfois+1 + tmr.alarm(ztmr_Flash_LED, zTm_On_LED, tmr.ALARM_SINGLE, blink_LED) + end + end +end + +xfois =2 +blink_LED () + + + diff --git a/initz.lua b/initz.lua new file mode 100644 index 0000000..97951ca --- /dev/null +++ b/initz.lua @@ -0,0 +1,23 @@ +--Script de bootstrap, en appuyant sur le bouton ça démarre start_boot, +-- autrement en attendant 8 secondes cela démarre start_boot + +print("\n init.lua zf181017.1026\n") + +zswitch=3 --switch flash +gpio.mode(zswitch, gpio.INT, gpio.PULLUP) +initalarme=tmr.create() + +function hvbouton() + gpio.trig(zswitch, "none") + tmr.unregister(initalarme) + dofile("start_boot.lua") +-- dofile("start_job.lua") +end + +gpio.trig(zswitch, "both", hvbouton) + +tmr.alarm(initalarme, 8000, tmr.ALARM_SINGLE, function() + print("\nStart\n") + dofile("start_boot.lua") +-- dofile("start_job.lua") +end) diff --git a/start_boot.lua b/start_boot.lua new file mode 100644 index 0000000..84a84f4 --- /dev/null +++ b/start_boot.lua @@ -0,0 +1,7 @@ +-- Scripts à charger au moment du boot + +print("\n start_boot.lua zf181017.1021 \n") + +dofile("blink_led1.lua") + +