From b2b632a6cd6fc1d9f7250464378ed735a4fe259d Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Sun, 18 Nov 2018 10:36:16 +0100 Subject: [PATCH] =?UTF-8?q?-=20totalement=20remani=C3=A9=20la=20structure?= =?UTF-8?q?=20de=20mon=20d=C3=A9p=C3=B4t,=20cela=20commen=C3=A7ait=20?= =?UTF-8?q?=C3=A0=20=C3=AAtre=20trop=20le=20foutoire=20;-(?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blink_led1 - copie.lua | 0 blink_led1.lua => Blink_Led/blink_led1.lua | 0 blink_led2.lua => Blink_Led/blink_led2.lua | 0 .../flash_led_xfois.lua | 0 {Hugo => Blink_Led}/led_intensite.lua | 0 .../led_intensite_variable.lua | 0 {Hugo => Blink_Led}/led_press_button.lua | 0 {Hugo => Blink_Led}/test_press_button_1.lua | 0 initz.lua => Boot init.lua/initz.lua | 0 .../start - copie.lua | 0 .../start_boot.lua | 0 .../start_demo1.lua | 0 stop.lua => Boot init.lua/stop.lua | 0 start.lua => Bootstrap/start.lua | 0 btn_led.lua => Btn/btn_led.lua | 0 {Wifi => DeepSleep}/dsleep.lua | 0 fleche.lua => Dojo/fleche.lua | 0 code2file.lua => File/code2file.lua | 0 toto1.lua => Hello World/helloworld1.lua | 0 helloworld.lua => Hello World/helloworld2.lua | 4 + "Hugo/Icon\r" | 0 Hugo/README.md | 37 -- Hugo/init.lua | 13 - Hugo/led_blink_1.lua | 23 -- Hugo/led_blink_2.lua | 39 -- Hugo/luatool.py | 358 ------------------ Hugo/meter_mesure.lua | 31 -- Hugo/oled_first.lua | 71 ---- Hugo/robot_avance_arrete.lua | 62 --- Hugo/robot_mesure_turn_right.lua | 106 ------ Hugo/robot_random_mesure.lua | 108 ------ Hugo/start_EPSlorer.sh | 6 - Hugo/start_screen.sh | 6 - Hugo/test_blink_1.lua | 13 - Hugo/test_blink_2.lua | 19 - Hugo/test_get_ip_1.lua | 18 - Hugo/test_init_1.lua | 26 -- Hugo/test_web_1.lua | 24 -- Hugo/u_dir.lua | 15 - Hugo/u_get_ip.lua | 14 - Hugo/u_start_job.lua | 7 - Hugo/u_telnet_srv.lua | 43 --- Hugo/web_liste_deroulante_led_change.lua | 49 --- Hugo/web_press_button_led.lua | 53 --- Hugo/web_robot_on_off.lua | 49 --- make_ping.lua => Net_utils/make_ping.lua | 0 {Wifi => Net_utils}/ping.lua | 0 show_ip.lua => Net_utils/show_ip.lua | 0 README.md | 28 +- Robot_Lua/README.md | 5 + .../clear_bootstrap.lua | 0 bug1.lua => Timer/tmr1.lua | 0 bug2.lua => Timer/tmr2.lua | 0 {Hugo => WEB}/u_web_stop.lua | 0 web_led_onoff.lua => WEB/web_led_onoff.lua | 0 {Hugo => WEB}/web_oled_decode_url.lua | 0 web_on_off1.lua => WEB/web_on_off1.lua | 0 web_stop.lua => WEB/web_stop.lua | 0 Workshop/181015/hello_world/blink_led1.lua | 6 +- get_ip.lua | 14 - zflash.sh | 23 +- 61 files changed, 56 insertions(+), 1214 deletions(-) rename blink_led1 - copie.lua => Blink_Led/blink_led1 - copie.lua (100%) rename blink_led1.lua => Blink_Led/blink_led1.lua (100%) rename blink_led2.lua => Blink_Led/blink_led2.lua (100%) rename flash_led_xfois.lua => Blink_Led/flash_led_xfois.lua (100%) rename {Hugo => Blink_Led}/led_intensite.lua (100%) rename {Hugo => Blink_Led}/led_intensite_variable.lua (100%) rename {Hugo => Blink_Led}/led_press_button.lua (100%) rename {Hugo => Blink_Led}/test_press_button_1.lua (100%) rename initz.lua => Boot init.lua/initz.lua (100%) rename start - copie.lua => Boot init.lua/start - copie.lua (100%) rename start_boot.lua => Boot init.lua/start_boot.lua (100%) rename start_demo1.lua => Boot init.lua/start_demo1.lua (100%) rename stop.lua => Boot init.lua/stop.lua (100%) rename start.lua => Bootstrap/start.lua (100%) rename btn_led.lua => Btn/btn_led.lua (100%) rename {Wifi => DeepSleep}/dsleep.lua (100%) rename fleche.lua => Dojo/fleche.lua (100%) rename code2file.lua => File/code2file.lua (100%) rename toto1.lua => Hello World/helloworld1.lua (100%) rename helloworld.lua => Hello World/helloworld2.lua (58%) delete mode 100644 "Hugo/Icon\r" delete mode 100755 Hugo/README.md delete mode 100755 Hugo/init.lua delete mode 100755 Hugo/led_blink_1.lua delete mode 100755 Hugo/led_blink_2.lua delete mode 100755 Hugo/luatool.py delete mode 100755 Hugo/meter_mesure.lua delete mode 100755 Hugo/oled_first.lua delete mode 100755 Hugo/robot_avance_arrete.lua delete mode 100755 Hugo/robot_mesure_turn_right.lua delete mode 100755 Hugo/robot_random_mesure.lua delete mode 100755 Hugo/start_EPSlorer.sh delete mode 100755 Hugo/start_screen.sh delete mode 100755 Hugo/test_blink_1.lua delete mode 100755 Hugo/test_blink_2.lua delete mode 100755 Hugo/test_get_ip_1.lua delete mode 100755 Hugo/test_init_1.lua delete mode 100755 Hugo/test_web_1.lua delete mode 100755 Hugo/u_dir.lua delete mode 100755 Hugo/u_get_ip.lua delete mode 100755 Hugo/u_start_job.lua delete mode 100755 Hugo/u_telnet_srv.lua delete mode 100755 Hugo/web_liste_deroulante_led_change.lua delete mode 100755 Hugo/web_press_button_led.lua delete mode 100755 Hugo/web_robot_on_off.lua rename make_ping.lua => Net_utils/make_ping.lua (100%) rename {Wifi => Net_utils}/ping.lua (100%) rename show_ip.lua => Net_utils/show_ip.lua (100%) create mode 100755 Robot_Lua/README.md rename clear_bootstrap.lua => Tests/clear_bootstrap.lua (100%) rename bug1.lua => Timer/tmr1.lua (100%) rename bug2.lua => Timer/tmr2.lua (100%) rename {Hugo => WEB}/u_web_stop.lua (100%) rename web_led_onoff.lua => WEB/web_led_onoff.lua (100%) rename {Hugo => WEB}/web_oled_decode_url.lua (100%) rename web_on_off1.lua => WEB/web_on_off1.lua (100%) rename web_stop.lua => WEB/web_stop.lua (100%) delete mode 100644 get_ip.lua diff --git a/blink_led1 - copie.lua b/Blink_Led/blink_led1 - copie.lua similarity index 100% rename from blink_led1 - copie.lua rename to Blink_Led/blink_led1 - copie.lua diff --git a/blink_led1.lua b/Blink_Led/blink_led1.lua similarity index 100% rename from blink_led1.lua rename to Blink_Led/blink_led1.lua diff --git a/blink_led2.lua b/Blink_Led/blink_led2.lua similarity index 100% rename from blink_led2.lua rename to Blink_Led/blink_led2.lua diff --git a/flash_led_xfois.lua b/Blink_Led/flash_led_xfois.lua similarity index 100% rename from flash_led_xfois.lua rename to Blink_Led/flash_led_xfois.lua diff --git a/Hugo/led_intensite.lua b/Blink_Led/led_intensite.lua similarity index 100% rename from Hugo/led_intensite.lua rename to Blink_Led/led_intensite.lua diff --git a/Hugo/led_intensite_variable.lua b/Blink_Led/led_intensite_variable.lua similarity index 100% rename from Hugo/led_intensite_variable.lua rename to Blink_Led/led_intensite_variable.lua diff --git a/Hugo/led_press_button.lua b/Blink_Led/led_press_button.lua similarity index 100% rename from Hugo/led_press_button.lua rename to Blink_Led/led_press_button.lua diff --git a/Hugo/test_press_button_1.lua b/Blink_Led/test_press_button_1.lua similarity index 100% rename from Hugo/test_press_button_1.lua rename to Blink_Led/test_press_button_1.lua diff --git a/initz.lua b/Boot init.lua/initz.lua similarity index 100% rename from initz.lua rename to Boot init.lua/initz.lua diff --git a/start - copie.lua b/Boot init.lua/start - copie.lua similarity index 100% rename from start - copie.lua rename to Boot init.lua/start - copie.lua diff --git a/start_boot.lua b/Boot init.lua/start_boot.lua similarity index 100% rename from start_boot.lua rename to Boot init.lua/start_boot.lua diff --git a/start_demo1.lua b/Boot init.lua/start_demo1.lua similarity index 100% rename from start_demo1.lua rename to Boot init.lua/start_demo1.lua diff --git a/stop.lua b/Boot init.lua/stop.lua similarity index 100% rename from stop.lua rename to Boot init.lua/stop.lua diff --git a/start.lua b/Bootstrap/start.lua similarity index 100% rename from start.lua rename to Bootstrap/start.lua diff --git a/btn_led.lua b/Btn/btn_led.lua similarity index 100% rename from btn_led.lua rename to Btn/btn_led.lua diff --git a/Wifi/dsleep.lua b/DeepSleep/dsleep.lua similarity index 100% rename from Wifi/dsleep.lua rename to DeepSleep/dsleep.lua diff --git a/fleche.lua b/Dojo/fleche.lua similarity index 100% rename from fleche.lua rename to Dojo/fleche.lua diff --git a/code2file.lua b/File/code2file.lua similarity index 100% rename from code2file.lua rename to File/code2file.lua diff --git a/toto1.lua b/Hello World/helloworld1.lua similarity index 100% rename from toto1.lua rename to Hello World/helloworld1.lua diff --git a/helloworld.lua b/Hello World/helloworld2.lua similarity index 58% rename from helloworld.lua rename to Hello World/helloworld2.lua index c40c4bc..4455c7e 100644 --- a/helloworld.lua +++ b/Hello World/helloworld2.lua @@ -1,6 +1,10 @@ -- blink the blue led builting -- zf180709.2200 +-- ATTENTION, c'est exactement ce qu'il ne faut pas faire en NodeMCU Lua, car cela bloque le NodeMCU pendant plus de 300mS ! +-- Il FAUT travailler en mode événement avec un timer ! + + zpin=0 --led blue builting gpio.mode(zpin, gpio.OUTPUT) diff --git "a/Hugo/Icon\r" "b/Hugo/Icon\r" deleted file mode 100644 index e69de29..0000000 diff --git a/Hugo/README.md b/Hugo/README.md deleted file mode 100755 index bb5d1fa..0000000 --- a/Hugo/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# NodeMCU_Lua -Petit dossier avec des programmes pour apprendre à coder sur un NodeMCU en lua. - -### Faire clignoter une ou plusieurs leds -1.led_blink_1.lua
-2.led_blink_2.lua - -### Modifier l'intensité d'une ou plusieurs leds -1.led_intensite.lua
-2.led_intensite_variable.lua - -### Allumer une led, en pressant un bouton -1.led_press_button.lua - -### Connecter le NodeMCU à un réseau WIFI et créer un serveur web pour contrôler une led -1.web_liste_deroulante_led_change.lua
-2.web_press_button_led.lua - -### Robot -1.robot_avance_arrete.lua
-2.robot_mesure_turn_right.lua
-3.robot_random_mesure.lua - -### Utilitaires -1.u_dir.lua
-2.u_get_ip.lua
-3.u_start_job.lua
-4.u_telnet_srv.lua
-5.u_web_stop.lua - -### Tests -1.test_init_1.lua
-2.test_blink_1.lua
-3.test_blink_2.lua
-4.test_get_ip_1.lua
-5.test_press_button_1.lua
-6.test_web_1.lua diff --git a/Hugo/init.lua b/Hugo/init.lua deleted file mode 100755 index 4a6af29..0000000 --- a/Hugo/init.lua +++ /dev/null @@ -1,13 +0,0 @@ ---Programme qui démarre le robot en appuyant sur le bouton flash et le redémarre si le bouton flash est appuyer pendant 3 secondes -print("\ninit.lua hv180717.1101\n") - -zswitch=3 --switch flash -gpio.mode(zswitch, gpio.INT, gpio.PULLUP) - -function bouton() - print("Start start_job.lua...") - dofile("start_job.lua") -end - -gpio.trig(zswitch, "both", bouton) - diff --git a/Hugo/led_blink_1.lua b/Hugo/led_blink_1.lua deleted file mode 100755 index 8c3e130..0000000 --- a/Hugo/led_blink_1.lua +++ /dev/null @@ -1,23 +0,0 @@ --- programme pour faire clignoter un LED ---hv20180711.1007 - -zpin=1 -valeur=gpio.HIGH -duration = 300 --> en ms - - -function clignoter () - if valeur==gpio.LOW then - valeur=gpio.HIGH - else - valeur=gpio.LOW - end - gpio.write(zpin, valeur) -end - - -gpio.mode(zpin, gpio.OUTPUT) -gpio.write(zpin, valeur) - -tmr.alarm(0,duration, tmr.ALARM_AUTO, clignoter) - diff --git a/Hugo/led_blink_2.lua b/Hugo/led_blink_2.lua deleted file mode 100755 index f695b93..0000000 --- a/Hugo/led_blink_2.lua +++ /dev/null @@ -1,39 +0,0 @@ --- programme pour faire clignoter deux LED ---hv20180711.1008 - -zpin1=1 -zpin2=2 - -valeur1=gpio.HIGH -valeur2=gpio.HIGH - -duration1 = 300 --> en ms -duration2 = 1000 --> en ms - - -function LED1 () - if valeur1==gpio.LOW then - valeur1=gpio.HIGH - else - valeur1=gpio.LOW - end - gpio.write(zpin1, valeur1) -end - -function LED2 () - if valeur2==gpio.LOW then - valeur2=gpio.HIGH - else - valeur2=gpio.LOW - end - gpio.write(zpin2, valeur2) -end - - -gpio.mode(zpin1, gpio.OUTPUT) -gpio.write(zpin1, valeur1) -gpio.mode(zpin2, gpio.OUTPUT) -gpio.write(zpin2, valeur2) - -tmr.alarm(1, duration1, tmr.ALARM_AUTO, LED1) -tmr.alarm(2, duration2, tmr.ALARM_AUTO, LED2) diff --git a/Hugo/luatool.py b/Hugo/luatool.py deleted file mode 100755 index e9db586..0000000 --- a/Hugo/luatool.py +++ /dev/null @@ -1,358 +0,0 @@ -#!/usr/bin/env python2 -# -# ESP8266 luatool -# Author e-mail: 4ref0nt@gmail.com -# Site: http://esp8266.ru -# Contributions from: https://github.com/sej7278 -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin -# Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import sys -import serial -from time import sleep -import socket -import argparse -from os.path import basename - - -tqdm_installed = True -try: - from tqdm import tqdm -except ImportError, e: - if e.message == 'No module named tqdm': - tqdm_installed = False - else: - raise - -version = "0.6.4" - - -class TransportError(Exception): - """Custom exception to represent errors with a transport - """ - def __init__(self, message): - self.message = message - - def __str__(self): - return self.message - -class AbstractTransport: - def __init__(self): - raise NotImplementedError('abstract transports cannot be instantiated.') - - def close(self): - raise NotImplementedError('Function not implemented') - - def read(self, length): - raise NotImplementedError('Function not implemented') - - def writeln(self, data, check=1): - raise NotImplementedError('Function not implemented') - - def writer(self, data): - self.writeln("file.writeline([==[" + data + "]==])\r") - - def performcheck(self, expected): - line = '' - char = '' - i = -1 - while char != chr(62): # '>' - char = self.read(1) - if char == '': - raise Exception('No proper answer from MCU') - if char == chr(13) or char == chr(10): # LF or CR - if line != '': - line = line.strip() - if line+'\r' == expected and not args.bar: - sys.stdout.write(" -> ok") - elif line+'\r' != expected: - if line[:4] == "lua:": - sys.stdout.write("\r\n\r\nLua ERROR: %s" % line) - raise Exception('ERROR from Lua interpreter\r\n\r\n') - else: - expected = expected.split("\r")[0] - sys.stdout.write("\r\n\r\nERROR") - sys.stdout.write("\r\n send string : '%s'" % expected) - sys.stdout.write("\r\n expected echo : '%s'" % expected) - sys.stdout.write("\r\n but got answer : '%s'" % line) - sys.stdout.write("\r\n\r\n") - raise Exception('Error sending data to MCU\r\n\r\n') - line = '' - else: - line += char - if char == chr(62) and expected[i] == char: - char = '' - i += 1 - - -class SerialTransport(AbstractTransport): - def __init__(self, port, baud, delay): - self.port = port - self.baud = baud - self.serial = None - self.delay = delay - - try: - self.serial = serial.Serial(port, baud) - except serial.SerialException as e: - raise TransportError(e.strerror) - - self.serial.timeout = 3 - self.serial.interCharTimeout = 3 - - def writeln(self, data, check=1): - if self.serial.inWaiting() > 0: - self.serial.flushInput() - if len(data) > 0 and not args.bar: - sys.stdout.write("\r\n->") - sys.stdout.write(data.split("\r")[0]) - self.serial.write(data) - sleep(self.delay) - if check > 0: - self.performcheck(data) - elif not args.bar: - sys.stdout.write(" -> send without check") - - def read(self, length): - return self.serial.read(length) - - def close(self): - self.serial.flush() - self.serial.close() - - -class TcpSocketTransport(AbstractTransport): - def __init__(self, host, port): - self.host = host - self.port = port - self.socket = None - - try: - self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - except socket.error as e: - raise TransportError(e.strerror) - - try: - self.socket.connect((host, port)) - except socket.error as e: - raise TransportError(e.strerror) - # read intro from telnet server (see telnet_srv.lua) - self.socket.recv(50) - - def writeln(self, data, check=1): - if len(data) > 0 and not args.bar: - sys.stdout.write("\r\n->") - sys.stdout.write(data.split("\r")[0]) - self.socket.sendall(data) - if check > 0: - self.performcheck(data) - elif not args.bar: - sys.stdout.write(" -> send without check") - - def read(self, length): - return self.socket.recv(length) - - def close(self): - self.socket.close() - - -def decidetransport(cliargs): - if cliargs.ip: - data = cliargs.ip.split(':') - host = data[0] - if len(data) == 2: - port = int(data[1]) - else: - port = 23 - return TcpSocketTransport(host, port) - else: - return SerialTransport(cliargs.port, cliargs.baud, cliargs.delay) - - -if __name__ == '__main__': - # parse arguments or use defaults - parser = argparse.ArgumentParser(description='ESP8266 Lua script uploader.') - parser.add_argument('-p', '--port', default='/dev/ttyUSB0', help='Device name, default /dev/ttyUSB0') - parser.add_argument('-b', '--baud', default=9600, help='Baudrate, default 9600') - parser.add_argument('-f', '--src', default='main.lua', help='Source file on computer, default main.lua') - parser.add_argument('-t', '--dest', default=None, help='Destination file on MCU, default to source file name') - parser.add_argument('-c', '--compile', action='store_true', help='Compile lua to lc after upload') - parser.add_argument('-r', '--restart', action='store_true', help='Restart MCU after upload') - parser.add_argument('-d', '--dofile', action='store_true', help='Run the Lua script after upload') - parser.add_argument('-v', '--verbose', action='store_true', help="Show progress messages.") - parser.add_argument('-a', '--append', action='store_true', help='Append source file to destination file.') - parser.add_argument('-l', '--list', action='store_true', help='List files on device') - parser.add_argument('-w', '--wipe', action='store_true', help='Delete all lua/lc files on device.') - parser.add_argument('-i', '--id', action='store_true', help='Query the modules chip id.') - parser.add_argument('-e', '--echo', action='store_true', help='Echo output of MCU until script is terminated.') - parser.add_argument('--bar', action='store_true', help='Show a progress bar for uploads instead of printing each line') - parser.add_argument('--delay', default=0.3, help='Delay in seconds between each write.', type=float) - parser.add_argument('--delete', default=None, help='Delete a lua/lc file from device.') - parser.add_argument('--ip', default=None, help='Connect to a telnet server on the device (--ip IP[:port])') - args = parser.parse_args() - - transport = decidetransport(args) - - if args.bar and not tqdm_installed: - sys.stdout.write("You must install the tqdm library to use the bar feature\n") - sys.stdout.write("To install, at the prompt type: \"pip install tqdm\"\n") - sys.exit(0) - - - if args.list: - transport.writeln("local l = file.list();for k,v in pairs(l) do print('name:'..k..', size:'..v)end\r", 0) - while True: - char = transport.read(1) - if char == '' or char == chr(62): - break - sys.stdout.write(char) - sys.exit(0) - - if args.id: - transport.writeln("=node.chipid()\r", 0) - id="" - while True: - char = transport.read(1) - if char == '' or char == chr(62): - break - if char.isdigit(): - id += char - print("\n"+id) - sys.exit(0) - - if args.wipe: - transport.writeln("local l = file.list();for k,v in pairs(l) do print(k)end\r", 0) - file_list = [] - fn = "" - while True: - char = transport.read(1) - if char == '' or char == chr(62): - break - if char not in ['\r', '\n']: - fn += char - else: - if fn: - file_list.append(fn.strip()) - fn = '' - for fn in file_list[1:]: # first line is the list command sent to device - if args.verbose: - sys.stderr.write("Delete file {} from device.\r\n".format(fn)) - transport.writeln("file.remove(\"" + fn + "\")\r") - sys.exit(0) - - if args.delete: - transport.writeln("file.remove(\"" + args.delete + "\")\r") - sys.exit(0) - - if args.dest is None: - args.dest = basename(args.src) - - # open source file for reading - try: - try: - f = open(args.src, "rt") - except: - import os - base_dir = os.path.dirname(os.path.realpath(__file__)) - f = open(os.path.join(base_dir, args.src), "rt") - os.chdir(base_dir) - except: - sys.stderr.write("Could not open input file \"%s\"\n" % args.src) - sys.exit(1) - - # Verify the selected file will not exceed the size of the serial buffer. - # The size of the buffer is 256. This script does not accept files with - # lines longer than 230 characters to have some room for command overhead. - num_lines = 0 - for ln in f: - if len(ln) > 230: - sys.stderr.write("File \"%s\" contains a line with more than 240 " - "characters. This exceeds the size of the serial buffer.\n" - % args.src) - f.close() - sys.exit(1) - num_lines += 1 - - # Go back to the beginning of the file after verifying it has the correct - # line length - f.seek(0) - - # set serial timeout - if args.verbose: - sys.stderr.write("Upload starting\r\n") - - # remove existing file on device - if args.append==False: - if args.verbose: - sys.stderr.write("Stage 1. Deleting old file from flash memory") - transport.writeln("file.open(\"" + args.dest + "\", \"w\")\r") - transport.writeln("file.close()\r") - transport.writeln("file.remove(\"" + args.dest + "\")\r") - else: - if args.verbose: - sys.stderr.write("[SKIPPED] Stage 1. Deleting old file from flash memory [SKIPPED]") - - - # read source file line by line and write to device - if args.verbose: - sys.stderr.write("\r\nStage 2. Creating file in flash memory and write first line") - if args.append: - transport.writeln("file.open(\"" + args.dest + "\", \"a+\")\r") - else: - transport.writeln("file.open(\"" + args.dest + "\", \"w+\")\r") - line = f.readline() - if args.verbose: - sys.stderr.write("\r\nStage 3. Start writing data to flash memory...") - if args.bar: - for i in tqdm(range(0, num_lines)): - transport.writer(line.strip()) - line = f.readline() - else: - while line != '': - transport.writer(line.strip()) - line = f.readline() - - # close both files - f.close() - if args.verbose: - sys.stderr.write("\r\nStage 4. Flush data and closing file") - transport.writeln("file.flush()\r") - transport.writeln("file.close()\r") - - # compile? - if args.compile: - if args.verbose: - sys.stderr.write("\r\nStage 5. Compiling") - transport.writeln("node.compile(\"" + args.dest + "\")\r") - transport.writeln("file.remove(\"" + args.dest + "\")\r") - - # restart or dofile - if args.restart: - transport.writeln("node.restart()\r") - if args.dofile: # never exec if restart=1 - transport.writeln("dofile(\"" + args.dest + "\")\r", 0) - - if args.echo: - if args.verbose: - sys.stderr.write("\r\nEchoing MCU output, press Ctrl-C to exit") - while True: - sys.stdout.write(transport.read(1)) - - # close serial port - transport.close() - - # flush screen - sys.stdout.flush() - sys.stderr.flush() - if not args.bar: - sys.stderr.write("\r\n--->>> All done <<<---\r\n") diff --git a/Hugo/meter_mesure.lua b/Hugo/meter_mesure.lua deleted file mode 100755 index 875ba8d..0000000 --- a/Hugo/meter_mesure.lua +++ /dev/null @@ -1,31 +0,0 @@ ---mesure la distance avec un module à ultra son hc-sr04 ---Attention le module doit être alimenter en 5V et il faut mettre une resistance de 100 ohm sur la pin echo ---hv180713.1138 - -ztrig=5 -zecho=6 -ztstart=0 -ztstop=0 -gpio.mode(ztrig, gpio.OUTPUT) -gpio.write(ztrig, gpio.LOW) -gpio.mode(zecho, gpio.INT, gpio.PULLUP) - - -function zmesure_pulse() - gpio.write(ztrig, gpio.HIGH) - tmr.delay(10) - gpio.write(ztrig, gpio.LOW) -end - -function zmesure() - if gpio.read(zecho)==1 then - ztstart=tmr.now() - else - ztstop=tmr.now() - zlength=360*(ztstop-ztstart)/2/10000 - print("distance [cm]: "..math.floor(zlength)) - end -end - -gpio.trig(zecho, "both", zmesure) -tmr.alarm(1, 1000, tmr.ALARM_AUTO, zmesure_pulse) diff --git a/Hugo/oled_first.lua b/Hugo/oled_first.lua deleted file mode 100755 index 2fee777..0000000 --- a/Hugo/oled_first.lua +++ /dev/null @@ -1,71 +0,0 @@ ---Affiche simplement un Hello Wolrd sur le display OLED -print("\nDémarrage hv20180720.1616 \n") - - - - - --- Utilisation : --- pin_sda = 5 --- pin_scl = 6 --- disp_sla = 0x3c --- _dofile("i2c_display") --- disp_add_data(texte) --- avec texte un json du type --- texte = '{ "id": "id_du_texte", --- "column": [0-20], (si omis : 0) --- "row": [0-5], (si omis : 0) --- "text": "abcdef", (si omis : "") --- "angle": [0,90,180,270] }' (si omis 0°) --- --- disp_add_data('{"id":"id_du_texte"}') efface le texte -------------------------------------------------- --- Modules nécessaires dans le firmware : --- i2c, u8g(avec font ssd1306_128x64_i2c), cjson -------------------------------------------------- - -pin_sda = 12 -pin_scl = 11 -disp_sla = 0x3c - - -function init_OLED(sda, scl) --Set up the u8glib lib - - i2c.setup(0, sda, scl, i2c.SLOW) - disp = u8g.ssd1306_128x64_i2c(disp_sla) --- https://github.com/olikraus/u8glib/wiki/fontsize - disp:setFont(u8g.font_6x10) - disp:setFontRefHeightExtendedText() - disp:setDefaultForegroundColor() - disp:setFontPosTop() -end - -function draw() - disp:drawStr(0,0,"Hello Hugo !") - disp:drawStr(0,11,"et zuzu !") -end - -init_OLED(pin_sda, pin_scl) --Run setting up - -disp:firstPage() -repeat - draw() -until disp:nextPage() == false - - - - - - - - - ---print( string.gsub("hello+zuzu+%26+une+belle+%E9cole%5Cun+b%E2teau","+"," ") - ---[[ source OLED: -https://www.google.ch/search?q=nodemcu+lua+oled+display&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjG8ba8ra3cAhVDCpoKHedlDS4Q_AUICigB&biw=1536&bih=828 -https://www.hackster.io/kayakpete/esp8266-oled-display-52ae50 -http://blog.rl.cx/2017/01/08/bien-d%C3%A9buter-avec-nodemcu/ -https://github.com/FredThx/nodemcu_iot/blob/master/i2c_display.lua -https://www.instructables.com/id/NODEMCU-LUA-ESP8266-With-I2C-LCD-128-X-64-OLED-Dis/ -]] diff --git a/Hugo/robot_avance_arrete.lua b/Hugo/robot_avance_arrete.lua deleted file mode 100755 index 0fff969..0000000 --- a/Hugo/robot_avance_arrete.lua +++ /dev/null @@ -1,62 +0,0 @@ ---Programme pour faire tourner aleatoirement le robot à droite ou à gauche tant qu'il soit à moins de 20cm de l'obstacle ---hv20180717.1613 - ---parametres pour le module ultra son -ztrig=5 -zecho=6 -ztstart=0 -ztstop=0 -gpio.mode(ztrig, gpio.OUTPUT) -gpio.write(ztrig, gpio.LOW) -gpio.mode(zecho, gpio.INT, gpio.PULLUP) - ---parametres pour les moteurs -pin_a_speed = 1 -pin_a_dir = 3 -pin_b_speed = 2 -pin_b_dir = 4 -FWD = gpio.LOW -REV = gpio.HIGH -duty = 1023 - ---initialise moteur A -gpio.mode(pin_a_speed,gpio.OUTPUT) -gpio.write(pin_a_speed,gpio.LOW) -pwm.setup(pin_a_speed,1000,duty) --PWM 1KHz, Duty 1023 -pwm.start(pin_a_speed) -pwm.setduty(pin_a_speed,0) -gpio.mode(pin_a_dir,gpio.OUTPUT) - ---initialise moteur B -gpio.mode(pin_b_speed,gpio.OUTPUT) -gpio.write(pin_b_speed,gpio.LOW) -pwm.setup(pin_b_speed,1000,duty) --PWM 1KHz, Duty 1023 -pwm.start(pin_b_speed) -pwm.setduty(pin_b_speed,0) -gpio.mode(pin_b_dir,gpio.OUTPUT) - --- speed is 0 - 100 -function motor(pin_speed, pin_dir, dir, speed) - gpio.write(pin_dir,dir) - pwm.setduty(pin_speed, (speed * duty) / 100) -end - -function motor_a(dir, speed) - motor(pin_a_speed, pin_a_dir, dir, speed) -end - -function motor_b(dir, speed) - motor(pin_b_speed, pin_b_dir, dir, speed) -end - -function avance_robot() - motor_a(FWD, 60) - motor_b(FWD, 60) - -end - -function stop_robot() - motor_a(FWD, 0) - motor_b(FWD, 0) - -end diff --git a/Hugo/robot_mesure_turn_right.lua b/Hugo/robot_mesure_turn_right.lua deleted file mode 100755 index ff0416a..0000000 --- a/Hugo/robot_mesure_turn_right.lua +++ /dev/null @@ -1,106 +0,0 @@ ---Programme pour faire tourner aleatoirement le robot à droite ou à gauche tant qu'il soit à moins de 20cm de l'obstacle ---hv20180717.1613 - ---parametres pour le module ultra son -ztrig=5 -zecho=6 -ztstart=0 -ztstop=0 -gpio.mode(ztrig, gpio.OUTPUT) -gpio.write(ztrig, gpio.LOW) -gpio.mode(zecho, gpio.INT, gpio.PULLUP) - ---parametres pour les moteurs -pin_a_speed = 1 -pin_a_dir = 3 -pin_b_speed = 2 -pin_b_dir = 4 -FWD = gpio.LOW -REV = gpio.HIGH -duty = 1023 - ---initialise moteur A -gpio.mode(pin_a_speed,gpio.OUTPUT) -gpio.write(pin_a_speed,gpio.LOW) -pwm.setup(pin_a_speed,1000,duty) --PWM 1KHz, Duty 1023 -pwm.start(pin_a_speed) -pwm.setduty(pin_a_speed,0) -gpio.mode(pin_a_dir,gpio.OUTPUT) - ---initialise moteur B -gpio.mode(pin_b_speed,gpio.OUTPUT) -gpio.write(pin_b_speed,gpio.LOW) -pwm.setup(pin_b_speed,1000,duty) --PWM 1KHz, Duty 1023 -pwm.start(pin_b_speed) -pwm.setduty(pin_b_speed,0) -gpio.mode(pin_b_dir,gpio.OUTPUT) - --- timer personnelle -hvtimer1=tmr.create() -hvtimer2=tmr.create() - --- speed is 0 - 100 -function motor(pin_speed, pin_dir, dir, speed) - gpio.write(pin_dir,dir) - pwm.setduty(pin_speed, (speed * duty) / 100) -end - -function motor_a(dir, speed) - motor(pin_a_speed, pin_a_dir, dir, speed) -end - -function motor_b(dir, speed) - motor(pin_b_speed, pin_b_dir, dir, speed) -end - ---Robot avance, s'arrete, tourne à droite, tourne à gauche -function avance_robot() - t=math.random(1,2) - --print(t) - motor_a(FWD, 60) - motor_b(FWD, 60) -end -function stop_robot() - motor_a(FWD, 0) - motor_b(FWD, 0) -end - -function turn_right_robot() - motor_a(FWD, 60) - motor_b(REV, 60) -end -function turn_left_robot() - motor_a(REV, 60) - motor_b(FWD, 60) -end - ---start pulse10 us -function zmesure_pulse() - gpio.write(ztrig, gpio.HIGH) - tmr.delay(10) - gpio.write(ztrig, gpio.LOW) -end - --- mesure la distance et il s'arrete si < 20cm -function zmesure() - if gpio.read(zecho)==1 then - ztstart=tmr.now() - else - ztstop=tmr.now() - zlength=360*(ztstop-ztstart)/2/10000 - - if zlength>200 then zlength=0 end - if zlength<20 then - turn_right_robot() - tmr.alarm(hvtimer1, 1000, tmr.ALARM_SINGLE, avance_robot) - end - - print("distance [cm]: "..math.floor(zlength)) - end -end - -gpio.trig(zecho, "both", zmesure) -tmr.alarm(hvtimer2, 1000, tmr.ALARM_AUTO, zmesure_pulse) - - -avance_robot() diff --git a/Hugo/robot_random_mesure.lua b/Hugo/robot_random_mesure.lua deleted file mode 100755 index b75eaf7..0000000 --- a/Hugo/robot_random_mesure.lua +++ /dev/null @@ -1,108 +0,0 @@ ---Programme pour faire tourner aleatoirement le robot à droite ou à gauche tant qu'il soit à moins de 20cm de l'obstacle ---hv20180717.1613 - ---parametres pour le module ultra son -ztrig=5 -zecho=6 -ztstart=0 -ztstop=0 -gpio.mode(ztrig, gpio.OUTPUT) -gpio.write(ztrig, gpio.LOW) -gpio.mode(zecho, gpio.INT, gpio.PULLUP) - ---parametres pour les moteurs -pin_a_speed = 1 -pin_a_dir = 3 -pin_b_speed = 2 -pin_b_dir = 4 -FWD = gpio.LOW -REV = gpio.HIGH -duty = 1023 - ---initialise moteur A -gpio.mode(pin_a_speed,gpio.OUTPUT) -gpio.write(pin_a_speed,gpio.LOW) -pwm.setup(pin_a_speed,1000,duty) --PWM 1KHz, Duty 1023 -pwm.start(pin_a_speed) -pwm.setduty(pin_a_speed,0) -gpio.mode(pin_a_dir,gpio.OUTPUT) - ---initialise moteur B -gpio.mode(pin_b_speed,gpio.OUTPUT) -gpio.write(pin_b_speed,gpio.LOW) -pwm.setup(pin_b_speed,1000,duty) --PWM 1KHz, Duty 1023 -pwm.start(pin_b_speed) -pwm.setduty(pin_b_speed,0) -gpio.mode(pin_b_dir,gpio.OUTPUT) - --- timer personnelle -hvtimer1=tmr.create() -hvtimer2=tmr.create() - --- speed is 0 - 100 -function motor(pin_speed, pin_dir, dir, speed) - gpio.write(pin_dir,dir) - pwm.setduty(pin_speed, (speed * duty) / 100) -end - -function motor_a(dir, speed) - motor(pin_a_speed, pin_a_dir, dir, speed) -end - -function motor_b(dir, speed) - motor(pin_b_speed, pin_b_dir, dir, speed) -end - ---Robot avance, s'arrete, tourne à droite, tourne à gauche -function avance_robot() - t=math.random(1,2) - --print(t) - motor_a(FWD, 60) - motor_b(FWD, 60) -end -function stop_robot() - motor_a(FWD, 0) - motor_b(FWD, 0) -end - -function turn_right_robot() - motor_a(FWD, 60) - motor_b(REV, 60) -end -function turn_left_robot() - motor_a(REV, 60) - motor_b(FWD, 60) -end - ---start pulse10 us -function zmesure_pulse() - gpio.write(ztrig, gpio.HIGH) - tmr.delay(10) - gpio.write(ztrig, gpio.LOW) -end - --- mesure la distance et il s'arrete si < 20cm -function zmesure() - if gpio.read(zecho)==1 then - ztstart=tmr.now() - else - ztstop=tmr.now() - zlength=360*(ztstop-ztstart)/2/10000 - if zlength>200 then zlength=0 end - --print("distance [cm]: "..math.floor(zlength)) - if zlength<20 then - if t==1 then - turn_left_robot() - else - turn_right_robot() - end - tmr.alarm(hvtimer1, 1000, tmr.ALARM_SINGLE, avance_robot) - end - end -end - -gpio.trig(zecho, "both", zmesure) -tmr.alarm(hvtimer2, 1000, tmr.ALARM_AUTO, zmesure_pulse) - - -avance_robot() diff --git a/Hugo/start_EPSlorer.sh b/Hugo/start_EPSlorer.sh deleted file mode 100755 index 27f8316..0000000 --- a/Hugo/start_EPSlorer.sh +++ /dev/null @@ -1,6 +0,0 @@ -# !/bin/bash -# Script pour lancer ESPlorer -# hv 1807010.1538 - -#sudo chmod 666 /dev/ttyUSB0 -java -jar "ESPlorer/ESPlorer.jar" diff --git a/Hugo/start_screen.sh b/Hugo/start_screen.sh deleted file mode 100755 index 21cc375..0000000 --- a/Hugo/start_screen.sh +++ /dev/null @@ -1,6 +0,0 @@ -# !/bin/bash -# Script pour lancer l'émulateur de terminale -# hv 1807010.1555 - -sudo chmod 666 /dev/ttyUSB0 -screen /dev/ttyUSB0 115200 diff --git a/Hugo/test_blink_1.lua b/Hugo/test_blink_1.lua deleted file mode 100755 index f05528e..0000000 --- a/Hugo/test_blink_1.lua +++ /dev/null @@ -1,13 +0,0 @@ --- Clignoter la led bleue. Vieille méthode, pas le faire --- zf180709.2200 - -zpin=0 --led blue builting -gpio.mode(zpin, gpio.OUTPUT) - -for i=1,20 do - print("Hello World "..i) - gpio.write(zpin, gpio.LOW) - tmr.delay(100000) - gpio.write(zpin, gpio.HIGH) - tmr.delay(100000) -end diff --git a/Hugo/test_blink_2.lua b/Hugo/test_blink_2.lua deleted file mode 100755 index 441e1b2..0000000 --- a/Hugo/test_blink_2.lua +++ /dev/null @@ -1,19 +0,0 @@ --- Clignoter les leds. Vieille méthode. Pas le faire --- zf180709.2200 - -zpin1=1--led rouge -zpin2=2--led verte -gpio.mode(zpin1, gpio.OUTPUT) -gpio.mode(zpin2,gpio.OUTPUT) - - -for i=1,10 do - print("Hello World "..i) - gpio.write(zpin1, gpio.LOW) - gpio.write(zpin2, gpio.HIGH) - tmr.delay(300000) - gpio.write(zpin1, gpio.HIGH) - gpio.write(zpin2, gpio.LOW) - tmr.delay(300000) -end -gpio.write(zpin2, gpio.HIGH) diff --git a/Hugo/test_get_ip_1.lua b/Hugo/test_get_ip_1.lua deleted file mode 100755 index 7bc9eb1..0000000 --- a/Hugo/test_get_ip_1.lua +++ /dev/null @@ -1,18 +0,0 @@ --- Enclenche le mode configuration WIFI -print("\nzf180718.1107\n") - -function get_ip() - if wifi.sta.getip() == nil then - print("Connecting to AP...") - else - tmr.stop(0) - print("Connected! IP: ",wifi.sta.getip()) - tmr.alarm(0,3000,tmr.ALARM_SINGLE, function() node.restart() end) - end -end - -wifi.sta.disconnect() -wifi.sta.clearconfig() -print("\nwifi config http://192.168.4.1\n") -tmr.alarm(0, 1000, tmr.ALARM_AUTO , get_ip) -enduser_setup.start() \ No newline at end of file diff --git a/Hugo/test_init_1.lua b/Hugo/test_init_1.lua deleted file mode 100755 index 76b2626..0000000 --- a/Hugo/test_init_1.lua +++ /dev/null @@ -1,26 +0,0 @@ ---Programme qui démarre le robot en appuyant sur le bouton flash et le redémarre si le bouton flash est appuyer pendant 3 secondes ---hv20180716.1349 - -zBTNflash = 3 -- GPIO0 button -function btn_clic() - t1=tmr.now() - tmr.alarm(0,100,tmr.ALARM_AUTO, btn_test) -end -function btn_test() - t2=tmr.now() - t3=(t2-t1)/1000000 - print("t3: "..t3) - if gpio.read(zBTNflash)==1 then - tmr.stop(0) - gpio.trig(zBTNflash) - dofile("robot_1.lua") - end - if t3>2 then - tmr.stop(0) - gpio.trig(zBTNflash) - node.restart() - end -end -gpio.mode(zBTNflash,gpio.INT) -gpio.trig(zBTNflash, "down", btn_clic) - diff --git a/Hugo/test_web_1.lua b/Hugo/test_web_1.lua deleted file mode 100755 index 66a0776..0000000 --- a/Hugo/test_web_1.lua +++ /dev/null @@ -1,24 +0,0 @@ ---Connexion en mode client WIFI ---hv20180711.1501 - -print("Démarrage") -wifi.sta.disconnect() -wifi.setmode(wifi.STATION) -print("set mode=STATION (mode="..wifi.getmode()..")") -wifi.sta.config{ssid="Hugo", pwd="tototutu"} - -tmr.alarm(0, 1000, tmr.ALARM_AUTO , function() - if wifi.sta.getip() == nil then - print("Connecting to AP...") - else - print("Connected! IP: ",wifi.sta.getip()) - tmr.stop(0) - end -end) - - - - - - - diff --git a/Hugo/u_dir.lua b/Hugo/u_dir.lua deleted file mode 100755 index 9c1494e..0000000 --- a/Hugo/u_dir.lua +++ /dev/null @@ -1,15 +0,0 @@ --- fonction dir() pour afficher les fichiers dans la flash --- zf180717.1542 - -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/Hugo/u_get_ip.lua b/Hugo/u_get_ip.lua deleted file mode 100755 index 9e5f642..0000000 --- a/Hugo/u_get_ip.lua +++ /dev/null @@ -1,14 +0,0 @@ --- get_ip.lua --- affiche l'adresse IP --- zf180718.1103 - -wifi.sta.connect() - -tmr.alarm(0, 1000, tmr.ALARM_AUTO , function() - if wifi.sta.getip() == nil then - print("Connecting to AP...") - else - print("Connected! IP: ",wifi.sta.getip()) - tmr.stop(0) - end -end) diff --git a/Hugo/u_start_job.lua b/Hugo/u_start_job.lua deleted file mode 100755 index 2a2607e..0000000 --- a/Hugo/u_start_job.lua +++ /dev/null @@ -1,7 +0,0 @@ ---start job. Démarre le robot et le serveur web -print("\nstart job hv180718.1155\n") - -dofile("wifi_robot_on_off.lua") -dofile("robot3.lua") - - diff --git a/Hugo/u_telnet_srv.lua b/Hugo/u_telnet_srv.lua deleted file mode 100755 index 74809d8..0000000 --- a/Hugo/u_telnet_srv.lua +++ /dev/null @@ -1,43 +0,0 @@ --- a simple telnet server -print("\nzf180718.1105\n") - --- restart server if needed -if telnet_srv ~= nil then - telnet_srv:close() -end -telnet_srv = net.createServer(net.TCP, 180) - -telnet_srv:listen(23, function(socket) - local fifo = {} - local fifo_drained = true - - local function sender(c) - if #fifo > 0 then - c:send(table.remove(fifo, 1)) - else - fifo_drained = true - end - end - - local function s_output(str) - table.insert(fifo, str) - if socket ~= nil and fifo_drained then - fifo_drained = false - sender(socket) - end - end - - node.output(s_output, 0) -- re-direct output to function s_ouput. - - socket:on("receive", function(c, l) - node.input(l) -- works like pcall(loadstring(l)) but support multiple separate line - end) - socket:on("disconnection", function(c) - node.output(nil) -- un-regist the redirect output function, output goes to serial - end) - socket:on("sent", sender) - - print("Welcome to NodeMCU world.") -end) - -print("Telnet server running...") diff --git a/Hugo/web_liste_deroulante_led_change.lua b/Hugo/web_liste_deroulante_led_change.lua deleted file mode 100755 index 74bab98..0000000 --- a/Hugo/web_liste_deroulante_led_change.lua +++ /dev/null @@ -1,49 +0,0 @@ ---Petit serveur WEB pour allumer/éteindre une LED en mode client WIFI ---hv20180711.1606 - -print("Démarrage") -wifi.sta.disconnect() -wifi.setmode(wifi.STATION) -print("set mode=STATION (mode="..wifi.getmode()..")") -wifi.sta.config{ssid="Hugo", pwd="tototutu"} - -tmr.alarm(0, 1000, tmr.ALARM_AUTO , function() - if wifi.sta.getip() == nil then - print("Connecting to AP...") - else - print("Connected! IP: ",wifi.sta.getip()) - tmr.stop(0) - end -end) - -zLED=0 -gpio.mode(zLED, gpio.OUTPUT) -gpio.write(zLED, gpio.HIGH) -srv = net.createServer(net.TCP) -srv:listen(80, function(conn) - conn:on("receive", function(client, request) - local buf = "" - 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+)=(%w+)&*") do - _GET[k] = v - end - end - buf = buf .. "

Hello, this is NodeMCU.

Turn PIN
" - client:send(buf) - end) - conn:on("sent", function(c) c:close() end) -end) diff --git a/Hugo/web_press_button_led.lua b/Hugo/web_press_button_led.lua deleted file mode 100755 index bf09d9d..0000000 --- a/Hugo/web_press_button_led.lua +++ /dev/null @@ -1,53 +0,0 @@ ---Petit serveur WEB pour allumer/éteindre une LED en mode client WIFI -print("\nDémarrage hv20180711.1606\n") - ---wifi.sta.disconnect() ---wifi.setmode(wifi.STATION) ---print("set mode=STATION (mode="..wifi.getmode()..")") ---wifi.sta.config{ssid="Hugo", pwd="tototutu"} - -wifi.sta.connect() -tmr.alarm(0, 1000, tmr.ALARM_AUTO , function() - if wifi.sta.getip() == nil then - print("Connecting to AP...") - else - print("Connected! IP: ",wifi.sta.getip()) - tmr.stop(0) - end -end) - -zLED=0 -gpio.mode(zLED, gpio.OUTPUT) -gpio.write(zLED, gpio.HIGH) -srv = net.createServer(net.TCP) - - -srv:listen(80, function(conn) - conn:on("receive", function(client, request) - local buf = "" - 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+)=(%w+)&*") do - _GET[k] = v - print(k..": "..v) - end - end - buf = buf .. "

Hello, this is NodeMCU.

Turn PIN :

" - local _on, _off = "", "" - if (_GET.pin == "ON") then - _on = " selected=true" - gpio.write(zLED, gpio.LOW) - elseif (_GET.pin == "OFF") then - _off = " selected=\"true\"" - gpio.write(zLED, gpio.HIGH) - end - buf = buf .. " " - client:send(buf) - end) - conn:on("sent", function(c) c:close() end) -end) - diff --git a/Hugo/web_robot_on_off.lua b/Hugo/web_robot_on_off.lua deleted file mode 100755 index 6246bfd..0000000 --- a/Hugo/web_robot_on_off.lua +++ /dev/null @@ -1,49 +0,0 @@ ---Petit serveur WEB pour allumer/éteindre une LED en mode client WIFI -print("\nDémarrage hv20180711.1606\n") - -hvtime=tmr.create() -wifi.sta.connect() -tmr.alarm(hvtime, 1000, tmr.ALARM_AUTO , function() - if wifi.sta.getip() == nil then - print("Connecting to AP...") - else - print("Connected! IP: ",wifi.sta.getip()) - tmr.stop(hvtime) - end -end) - -zLED=0 -gpio.mode(zLED, gpio.OUTPUT) -gpio.write(zLED, gpio.HIGH) -srv = net.createServer(net.TCP) - -srv:listen(80, function(conn) - conn:on("receive", function(client, request) - local buf = "" - 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+)=(%w+)&*") do - _GET[k] = v - end - end - buf = buf .. "

Faire avancer ou arreter le robot



" - local _on, _off = "", "" - if (_GET.pin == "Forward") then - _on = " selected=true" - avance_robot() - gpio.write(zLED, gpio.LOW) - elseif (_GET.pin == "Backward") then - _off = " selected=\"true\"" - stop_robot() - gpio.write(zLED, gpio.HIGH) - end - buf = buf .. " " - client:send(buf) - end) - conn:on("sent", function(c) c:close() end) -end) - diff --git a/make_ping.lua b/Net_utils/make_ping.lua similarity index 100% rename from make_ping.lua rename to Net_utils/make_ping.lua diff --git a/Wifi/ping.lua b/Net_utils/ping.lua similarity index 100% rename from Wifi/ping.lua rename to Net_utils/ping.lua diff --git a/show_ip.lua b/Net_utils/show_ip.lua similarity index 100% rename from show_ip.lua rename to Net_utils/show_ip.lua diff --git a/README.md b/README.md index 0fef6a9..31de3a6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,28 @@ # NodeMCU_Lua -Ma petite caisse à outils pour le NodeMCU en Lua ;-) +## Ma petite caisse à outils pour le NodeMCU en Lua ;-) + +J'y mets, pour l'instant tous mes petits projets en NodeMCU Lua afin de me faire une panoplie d'outils pour pouvoir utiliser très facilement les modules ESP8266. + +J'essaie de les trier de manière logique, mais des fois ce n'est pas possible, donc il est bien de se laisser balader de temps en temps dans la structure de dossiers afin d'y trouver quelques perles ;-) + +Et bien entendu, cette structure est vivante, donc elle peut changer au cours du temps ! + + + +## Ma petite documentation perso +Ma petite documentation pense bête où je mets pour l'instant pleins de choses que j'ai trouvées sur le NodeMCU ou ESP8266 en Lua + +### NodeMCU ESP8286, mais c'est si simple ;-) +[https://docs.google.com/document/d/1q64uK3IMOgEDdKaIAttbYuFt4GuLQ06k3FLeyfCsWLg/edit?usp=sharing](https://docs.google.com/document/d/1q64uK3IMOgEDdKaIAttbYuFt4GuLQ06k3FLeyfCsWLg/edit?usp=sharing) + + +## La communauté Leman-IoT +Une communauté regroupant les utilisateurs de NodeMCU Lua et bien d'autres IoT s'est crée à Lausanne (Switzerland) !
+N'hésitez pas a y faire un petit tour et aussi a y participer car on est toujours plus fort à plusieurs ;-)
+ +[https://zuzu59.github.io/leman-iot/](https://zuzu59.github.io/leman-iot/) + + + +zf181118.1016 -Encore en bordel pour l'instant, mais j'y travail :-) diff --git a/Robot_Lua/README.md b/Robot_Lua/README.md new file mode 100755 index 0000000..42fb6c2 --- /dev/null +++ b/Robot_Lua/README.md @@ -0,0 +1,5 @@ +# ATTENTION le code du Robot en Lua se trouve ici: +https://github.com/strikerpt/NodeMCU_Lua_robot + +zf181118.1027 + diff --git a/clear_bootstrap.lua b/Tests/clear_bootstrap.lua similarity index 100% rename from clear_bootstrap.lua rename to Tests/clear_bootstrap.lua diff --git a/bug1.lua b/Timer/tmr1.lua similarity index 100% rename from bug1.lua rename to Timer/tmr1.lua diff --git a/bug2.lua b/Timer/tmr2.lua similarity index 100% rename from bug2.lua rename to Timer/tmr2.lua diff --git a/Hugo/u_web_stop.lua b/WEB/u_web_stop.lua similarity index 100% rename from Hugo/u_web_stop.lua rename to WEB/u_web_stop.lua diff --git a/web_led_onoff.lua b/WEB/web_led_onoff.lua similarity index 100% rename from web_led_onoff.lua rename to WEB/web_led_onoff.lua diff --git a/Hugo/web_oled_decode_url.lua b/WEB/web_oled_decode_url.lua similarity index 100% rename from Hugo/web_oled_decode_url.lua rename to WEB/web_oled_decode_url.lua diff --git a/web_on_off1.lua b/WEB/web_on_off1.lua similarity index 100% rename from web_on_off1.lua rename to WEB/web_on_off1.lua diff --git a/web_stop.lua b/WEB/web_stop.lua similarity index 100% rename from web_stop.lua rename to WEB/web_stop.lua diff --git a/Workshop/181015/hello_world/blink_led1.lua b/Workshop/181015/hello_world/blink_led1.lua index 41e9bef..43a0e80 100644 --- a/Workshop/181015/hello_world/blink_led1.lua +++ b/Workshop/181015/hello_world/blink_led1.lua @@ -1,10 +1,10 @@ -- programme pour faire clignoter une LED avec un rapport on/off -print("\n blink_led1.lua zf181105.1114 \n") +print("\n blink_led1.lua zf181116.0014 \n") zLED=0 -zTm_On_LED = 200 --> en ms -zTm_Off_LED = 200 --> en ms +zTm_On_LED = 50 --> en ms +zTm_Off_LED = 500 --> en ms zFlag_LED = 0 function blink_LED () diff --git a/get_ip.lua b/get_ip.lua deleted file mode 100644 index 018b75c..0000000 --- a/get_ip.lua +++ /dev/null @@ -1,14 +0,0 @@ --- get_ip.lua --- branche le wifi et affiche l'adresse IP --- zf180719.1039 - -wifi.sta.connect() - -tmr.alarm(0, 1000, tmr.ALARM_AUTO , function() - if wifi.sta.getip() == nil then - print("Connecting to AP...") - else - print("Connected! IP: ",wifi.sta.getip()) - tmr.stop(0) - end -end) diff --git a/zflash.sh b/zflash.sh index 255ab21..e7c3d8d 100755 --- a/zflash.sh +++ b/zflash.sh @@ -1,11 +1,24 @@ #!/bin/bash -#Petit script pour flasher facilement les NodeMCU -#zf181015.1147 +#Petit script pour flasher facilement les NodeMCU avec un firmware + +#ATTENTION: c'est pour ma structure, il faudra donc l'adapter + +#zf181118.1022 + + +#test si l'argument est vide +if [ -z "$1" ] + then + echo -e "\nSyntax: ./zflash.sh ../../Firmware/nodemcu-master-13-modules-2018-10-11-16-35-53-float.bin \n\n" + exit +fi + +echo ---------- start zflash.sh cd ./Tools/esptool-master python esptool.py erase_flash -sleep -python esptool.py write_flash -fm dio 0x00000 ../../Firmware/nodemcu-master-13-modules-2018-10-11-16-35-53-float.bin -sleep 1 +sleep 2 +python esptool.py write_flash -fm dio 0x00000 $1 +sleep 2 screen /dev/cu.wchusbserial1410 115200