From 731a7dabe69405c9bd810888ccecdc95ed66480d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Ricart?= Date: Fri, 16 Feb 2018 01:03:02 +0100 Subject: [PATCH] first night at MIPS --- esp8266/ConfigParser.py | 40 ++++++++++++++++++++++++++++++++++++++++ esp8266/boot.py | 19 +++++++++++++++++++ esp8266/main.py | 13 +++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 esp8266/ConfigParser.py diff --git a/esp8266/ConfigParser.py b/esp8266/ConfigParser.py new file mode 100644 index 0000000..07ea309 --- /dev/null +++ b/esp8266/ConfigParser.py @@ -0,0 +1,40 @@ +class RawConfigParser: + def __init__(self): + pass + + def sections(self): + """Return a list of section names, excluding [DEFAULT]""" + pass + + def add_section(self, section): + pass + + def has_section(self, section): + pass + + def options(self, section): + pass + + def read(self, filename = None, fp = None): + pass + + def get(self, section, option): + + def items(self, section): + + def getboolean(self, section, option): + + def has_option(self, section, option): + """Check for the existence of a given option in a given section.""" + + def set(self, section, option, value=None): + """Set an option.""" + + def write(self, fp): + """Write an .ini-format representation of the configuration state.""" + + def remove_option(self, section, option): + """Remove an option.""" + + def remove_section(self, section): + """Remove a file section.""" diff --git a/esp8266/boot.py b/esp8266/boot.py index e69de29..abe5771 100644 --- a/esp8266/boot.py +++ b/esp8266/boot.py @@ -0,0 +1,19 @@ +def do_connect(): + import network + wlan = network.WLAN(network.STA_IF) + wlan.active(True) + if not wlan.isconnected(): + print('connecting to network...') + wlan.connect("MIPS", "importthis") + while not wlan.isconnected(): + pass + print('network config:', wlan.ifconfig()) + +do_connect() + +import gc +import webrepl +webrepl.start() +gc.collect() + + diff --git a/esp8266/main.py b/esp8266/main.py index e69de29..aefe102 100644 --- a/esp8266/main.py +++ b/esp8266/main.py @@ -0,0 +1,13 @@ +from machine import Pin +from urequests import get +from time import sleep_ms +from gc import collect + +pin = Pin(2, Pin.IN) +pin_value = pin.value() +while True: + current_value = pin.value() + if pin_value != current_value: + get('http://192.168.44.174:6543/value/%s' % current_value) + pin_value = current_value + collect()