• Система автоматизации с открытым исходным кодом на базе esp8266/esp32 микроконтроллеров и приложения IoT Manager. Наша группа в Telegram

the password accepts and is further Disconnected

lp85d

New member
WebREPL connection from: ('192.168.0.133', 60202)
dupterm: EOF received, deactivating

I use MicroPython v1.20.0 on 2023-04-26; ESP module with ESP8266
Android Chrome version 114.0.5735.196
 

lp85d

New member
пароль принимается и далее отключается
с ошибкой
dupterm: EOF received, deactivating
Я использую MicroPython v1.20.0 on 2023-04-26; ESP module with ESP8266
Android Chrome версия 114.0.5735.196
На ПК всё работает исправно Версия 101.0.4951.41 (Официальная сборка), (64 бит)
 

lp85d

New member
Что мне для работы с Android устройства необходимо использовать Micro REPL - MicroPython IDE ?
Или устанавливать эмулятор Desktop операционных систем и таким образом работать в Desktop браузерах?
 

lp85d

New member
А ещё такую особенность заметил
Когда boot.py
Python:
def do_connect(ssid, pwd):
    import network
    sta_if = network.WLAN(network.STA_IF)
    if not sta_if.isconnected():
        print('connecting to network...')
        sta_if.active(True)
        sta_if.connect(ssid, pwd)
        while not sta_if.isconnected():
            pass
    print('network config:', sta_if.ifconfig())
 
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
 
# Attempt to connect to WiFi network
do_connect('123', '123')
 
import webrepl
webrepl.start()
Ошибка
Код:
Started webrepl in normal mode
Traceback (most recent call last):
  File "main.py", line 4, in <module>
NameError: name 'machine' isn't defined
Но если boot.py
Python:
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
import uos, machine
#uos.dupterm(None, 1) # disable REPL on UART(0)
import gc
import webrepl
Ошибки на запуске нет
WhatsApp Image 2023-06-29 at 11.29.48.jpeg
 

lp85d

New member
Ну и сам код файла main.py
Python:
from machine import Pin, SPI
from tft import TFT_GREEN

machine.freq(160000000)

dc  = Pin(4, Pin.OUT)
cs  = Pin(2, Pin.OUT)
rst = Pin(5, Pin.OUT)
spi = SPI(1, baudrate=40000000, polarity=0, phase=0)

tft = TFT_GREEN(128, 160, spi, dc, cs, rst, rotate=0)

Map = [
    [1,1,0,1,1,1,0,1],
    [0,1,1,1,1,1,1,0],
    [1,1,0,0,0,1,1,1],
    [0,1,0,1,0,1,0,1],
    [0,1,0,0,0,1,0,1],
    [1,1,1,1,0,0,0,1],
    [1,0,0,0,0,0,0,1],
    [1,0,0,0,1,0,0,1],
    [1,0,0,0,1,1,1,1],
    [1,1,1,1,1,0,0,0]
]

Gates = []
Boxes = []

class Box:
    def __init__(self, tft, x, y):
        self.tft = tft
        self.x = x
        self.y = y
        self.picture = 'box.bmp'
        self.picture_onGate = 'boxngate.bmp'
        self.onGate = False
        self.draw()

    def draw(self):
        if (self.onGate):
            self.tft.draw_bmp(self.x * 16,self.y * 16,  self.picture_onGate)
        else:
            self.tft.draw_bmp(self.x * 16,self.y * 16, self.picture)

    def setOnGate(self, state):
        self.onGate = state

    def getOnGate(self):
        return self.onGate

    def getPos(self):
        return (self.x, self.y)

    def setPos(self, x, y):
        self.x = x
        self.y = y
        self.draw()

class Gate:
    def __init__(self, tft, x, y):
        self.tft = tft
        self.x = x
        self.y = y
        self.picture = 'gate.bmp'
        self.draw()

    def draw(self):
        self.tft.draw_bmp(self.x * 16,self.y * 16, self.picture)

    def getPos(self):
        return (self.x, self.y)

class Man:
    def __init__(self, tft, x, y):
        self.tft = tft
        self.x = x
        self.y = y
        self.picture = 'man.bmp'
        self.draw()

    def draw(self):
        self.tft.draw_bmp(self.x * 16,self.y * 16, self.picture)

    def getPos(self):
        return (self.x, self.y)

    def setPos(self, x, y):
        self.tft.rect(self.x * 16, self.y * 16, 16, 16, tft.COLOR_BLACK)
        self.x = x
        self.y = y
        self.draw()

class Button:
    def __init__(self, p, pressSate):
        self.pin = Pin(p, Pin.IN)
        self.pressSate = pressSate
        self.oldState = 0
    
    def onPress(self):
        state = self.pin.value()
        if state != self.oldState:
            self.oldState = state
            if state == self.pressSate:
                return True
        return False

tft.initr(tft.BGR) # tft.initr(tft.RGB) #Если вместо синего цвета отображается красный, а вместо красного синий
tft.clear(tft.COLOR_BLACK)

x = 0
y = 0

for row in Map:
    for col in row:
        if col:
            tft.draw_bmp(x * 16, y * 16,'brick.bmp')
        x+=1
    x=0
    y+=1

Boxes.append(Box(tft, 3,4))
Boxes.append(Box(tft, 4,6))
Boxes.append(Box(tft, 2,7))

Gates.append(Gate(tft, 6,3))
Gates.append(Gate(tft, 6,4))
Gates.append(Gate(tft, 6,5))

man = Man(tft, 5, 6)

btnUp = Button(16, 1)
btnDown = Button(15, 1)
btnLeft = Button(12, 1)
btnRight = Button(0, 0)

def canMove(x,y):
    if (Map[y][x]):
        return False
    else:
        return True

def feelBox(x,y):
    for B in Boxes:
        if B.getPos() == (x,y):
            return B
    return False

def boxFeelGate(x,y):
    for G in Gates:
        if G.getPos() == (x,y):
            return True
    return False

while True:
    mPos = man.getPos()
    newPos = (-1,-1)

    if btnUp.onPress():
        newPos = (mPos[0], mPos[1]-1)
        newPosNext = (mPos[0], mPos[1]-2)

    if btnDown.onPress():
        newPos = (mPos[0], mPos[1]+1)
        newPosNext = (mPos[0], mPos[1]+2)

    if btnLeft.onPress():
        newPos = (mPos[0]-1, mPos[1])
        newPosNext = (mPos[0]-2, mPos[1])

    if btnRight.onPress():
        newPos = (mPos[0]+1, mPos[1])
        newPosNext = (mPos[0]+2, mPos[1])

    if newPos != (-1,-1):
        B = feelBox(newPos[0], newPos[1])
        if B and canMove(newPosNext[0], newPosNext[1]):
            if boxFeelGate(newPosNext[0], newPosNext[1]):
                B.setOnGate(True)
            else:
                B.setOnGate(False)
            B.setPos(newPosNext[0], newPosNext[1])
            man.setPos(newPos[0], newPos[1])
        if not B and canMove(newPos[0], newPos[1]):
            man.setPos(newPos[0], newPos[1])

        for G in Gates:
            gPos = G.getPos()
            if not (feelBox(gPos[0], gPos[1])) and gPos != man.getPos():
                G.draw()

        win = 1
        for B in Boxes:
            if (not B.getOnGate()):
                win = 0
                break
        
        if (win):
            tft.draw_bmp(0, 0,  'win.bmp')
            raise SystemExit
 

lp85d

New member
Python:
from machine import Pin, SPI
from tft import TFT_GREEN
import font
dc  = Pin(4, Pin.OUT)
cs  = Pin(2, Pin.OUT)
rst = Pin(5, Pin.OUT)
spi = SPI(1, baudrate=40000000, polarity=0, phase=0)
tft = TFT_GREEN(128, 160, spi, dc, cs, rst, rotate=0)
tft.initr()
tft.clear(tft.rgbcolor(0, 0, 0))
tft.text(0,130,"------------------", font.terminalfont, tft.rgbcolor(255,255,43), 1)
tft.text(0,0,"DenisDenisDenisDenis", font.terminalfont, tft.rgbcolor(0,255,43), 4)
Только в thonny-4.1.1.exe запускается
Снимок.PNG
В EsPy.1.0.0.12.7z ошибка
Код:
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
MemoryError: memory allocation failed, allocating 2320 bytes
1Снимок.PNG
 
Сверху Снизу