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 .. "