def led_init(pin = pinout.BUILT_IN_LED): from util.led import Led if pin is not None and pinout is not None and (pin == pinout.RXD0 or pin == pinout.TXD0): print("WARNING: PIN {0} is used for UART0. REPL Over serial will be unusable") led = Led(pin if pin is not None and pin > 0 else None) return led
# octopusLAB simple example # ESP32board with "BUILT_IN_LED" and OLED display import machine from time import sleep from util.octopus import Env, w, time_init, get_hhmm, get_hhmmss from util import printTitle isOled = False isDisp7 = True printTitle("examples/deep_sleep1.py") from util.led import Led led = Led(2) if get_hhmm() == "00:00": print("first time setup > ") w() time_init() print(get_hhmmss()) def sendValue(val=0, urlPOST="http://your_server/add_item_to_database.php"): from urequests import post header = {} header["Content-Type"] = "application/x-www-form-urlencoded" deviceID = Env.uID place = "octoPy32" value = int(float(Env.ver) * 100) try: postdata_v = "device={0}&place={1}&value={2}&type={3}".format(
# octopusLAB test - 2019 # web server - ap_setup_wifi # ap = ap_init() #from examples.ap_setup_wifi import * #s = webserver_init() #webserver_run(s) ver = "9.9.2019 - 0.12" from time import sleep from util.octopus import printLog, printFree, get_eui, temp_init, get_temp, w, ap_init from util.pinout import set_pinout pinout = set_pinout() from util.led import Led #?VCh led = Led(pinout.BUILT_IN_LED) wnum = 0 web_wifi = "" ssidTemp = "" passTemp = "" winfo = "" def webserver_init(): printLog("simple web server2 ver: " + ver) print(ver) printFree() try: import usocket as socket except:
from time import sleep from util.pinout import set_pinout pinout = set_pinout() from util.rgb import Rgb ws = Rgb(pinout.PWM3_PIN) ws.simpleTest() print("DCmotors init") from util.dcmotors import Motor, Steering motor_r = Motor(pinout.MOTOR_1A, pinout.MOTOR_2A, pinout.MOTOR_12EN) motor_l = Motor(pinout.MOTOR_3A, pinout.MOTOR_4A, pinout.MOTOR_34EN) steering = Steering(motor_l, motor_r) from util.led import Led led = Led(2) from machine import Pin import util.ble.blesync_server import util.ble.blesync_uart.server @blesync_uart.server.UARTService.on_message def on_message(service, conn_handle, message): if message == b'!B516': steering.center(1000) elif message == b'!B507': steering.center(0) elif message == b'!B615': steering.center(-1000)
# print("runAction() > ERR.pump") # -------------------------------- printLog(2, "init/env.setup >") from hydroponics.config import load_config, load_url_config, print_config, load_env_setup, print_env_setup # test ios = load_env_setup() printTitle("env.setup") print_env_setup(ios) # print(es["relay"]) if ios["led"]: from util.led import Led led = Led(led_numpin) led.blink() isOLED = False if ios["oled"]: print(">>> oled_init") from assets.icons9x9 import ICON_clr, ICON_wifi from util.display_segment import threeDigits isOLED = True try: oled = oled_init() sleep(1) oled.clear() displMessage("version: " + str(ver), 1) for _ in range(5): randval = randint(1, 4000)
# octopusLAB simple example # ESP32board with "BUILT_IN_LED" # parameter: delay [ms] from util.led import Led # from util.octopus import led # short way from util.pinout import set_pinout print("---examples/blink_param.py---") # _ARGS # ToDo parse: delay=1000,pin=25 delay = 1000 try: delay = (int(_ARGS[0])) print("delay = ", str(delay)) except Exception as e: print("Exception: {0}".format(e)) pinout = set_pinout() # set board pinout led = Led(pinout.BUILT_IN_LED) # BUILT_IN_LED = 2 # start main loop while True: led.blink(delay)
except: print("Err.spi") if io_conf.get('oled') or io_conf.get('lcd'): print("I2C | ", end="") try: i2c = i2c_scann(False) except: print("Err.i2c") if io_conf.get('led'): print("Led | ", end="") from util.led import Led if pinout.BUILT_IN_LED is None: print("Warning: BUILD-IN LED not supported on this board") led = Led(None) else: led = Led(pinout.BUILT_IN_LED) # BUILT_IN_LED else: from util.led import Led led = Led(None) piezzo = None if io_conf.get('piezzo'): print("piezzo | ", end="") from util.buzzer import Buzzer piezzo = Buzzer(pinout.PIEZZO_PIN) piezzo.beep(1000, 50) from util.buzzer import Notes # else: # piezzo =Buzzer(None)
# octopusLAB test - 2019 from time import sleep from util.octopus import button_init, button, w, web_server, ap_init from util.led import Led led = Led(2) button0 = button_init(0) debounce = 9 ap = False print("esp32 web server - start >") for id in range(10): print(10 - id) led.blink() if button(button0)[0] >= debounce: print("button > AP_start") ap = True for id in range(5): led.blink(100, 100) break sleep(1) if ap: wc = ap = ap_init() else: wc = w() sleep(1) web_server()