Picoware (Open-Source Custom Firmware)

Ok, debugging aside…
I choose Python editor, give it a name, then have to choose if it’s a python script or a picoware app. What’s the difference?.
How does that then get put into Applications?
My past life programming would have me do some step after saving the source in order to make it runnable - hence my earlier mention of “compiling”.

Anyway I’m afraid that once again I’m just not understanding how to use very much of this.

As another “how do I use this “ I tried to sign up for your news application. I went to your web site, made an account, got an api.
How in the world am I supposed to get that very long api key into the Picocalc? I’m just have a lot of these “this looks interesting but how do I actually do something interesting with it” moments.

The app choice adds a template to the code on-creation.

It’s saved to the applications if you choose the Picoware App route.

Character-by-character

Well you just need to take some time using and exploring the system. The guides folder I shared earlier has just about everything you need.

@jblanked I’m having difficulties getting the AP features to work, think you could help me with it?
I’m using the most recent version, on the 2w.

from picoware.system.vector import Vector
from picoware.system.colors import TFT_CYAN, TFT_WHITE, TFT_YELLOW, TFT_GREEN, TFT_RED
from picoware.system.buttons import BUTTON_BACK
import time

def start(view_manager) -> bool:
draw = view_manager.draw
wifi = view_manager.wifi

draw.erase()
y = 4
draw.text(Vector(6, y), "AP Method Tests", TFT_CYAN, 1)
y += 16

def show(msg, color=TFT_WHITE):
    nonlocal y
    draw.text(Vector(6, y), msg[:36], color)
    y += 13
    draw.swap()

# ---------- Test 1: reset / connect ----------
show("1. reset + connect...", TFT_YELLOW)
try:
    wifi.reset()
    time.sleep_ms(300)
    result = wifi.connect("PicoShare", "picoware", sta_mode=False)
    show("   result: " + str(result), TFT_GREEN if result else TFT_RED)
    show("   state: " + str(wifi.state))
    show("   IP: " + str(wifi.device_ip))
except Exception as e:
    show("   EXC: " + str(e)[:30], TFT_RED)

y += 4

# ---------- Test 2: open network ----------
show("2. open network...", TFT_YELLOW)
try:
    wifi.reset()
    time.sleep_ms(300)
    result = wifi.connect("PicoShareOpen", "", sta_mode=False)
    show("   result: " + str(result), TFT_GREEN if result else TFT_RED)
    show("   state: " + str(wifi.state))
    show("   IP: " + str(wifi.device_ip))
except Exception as e:
    show("   EXC: " + str(e)[:30], TFT_RED)

y += 4

# ---------- Test 3: connect_async ----------
show("3. connect_async...", TFT_YELLOW)
try:
    wifi.reset()
    time.sleep_ms(300)
    result = wifi.connect_async("PicoShare", "picoware", sta_mode=False)
    show("   async started: " + str(result), TFT_GREEN if result else TFT_RED)
    time.sleep_ms(1500)          # give it time
    show("   state: " + str(wifi.state))
    show("   IP: " + str(wifi.device_ip))
except Exception as e:
    show("   EXC: " + str(e)[:30], TFT_RED)

y += 6
show("Press BACK to exit", TFT_WHITE)
return True

def run(view_manager) -> None:
if view_manager.button == BUTTON_BACK:
view_manager.back()

def stop(view_manager) -> None:
try:
view_manager.wifi.disconnect()
view_manager.wifi.reset()
except:
pass
1 Like

Yes glad to help! Here’s what I got when I ran your code in ThonnyIDE:

from picoware.system.vector import Vector
from picoware.system.colors import TFT_CYAN, TFT_WHITE, TFT_YELLOW, TFT_GREEN, TFT_RED
from picoware.system.buttons import BUTTON_BACK
import time

def start(view_manager) -> bool:
    draw = view_manager.draw
    wifi = view_manager.wifi

    draw.erase()
    y = 4
    draw.text(Vector(6, y), "AP Method Tests", TFT_CYAN, 1)
    y += 16

    def show(msg, color=TFT_WHITE):
        nonlocal y
        draw.text(Vector(6, y), msg[:36], color)
        y += 13
        draw.swap()

    # ---------- Test 1: reset / connect ----------
    show("1. reset + connect...", TFT_YELLOW)
    try:
        wifi.reset()
        time.sleep_ms(300)
        result = wifi.connect("PicoShare", "picoware", sta_mode=False)
        show("   result: " + str(result), TFT_GREEN if result else TFT_RED)
        show("   state: " + str(wifi.state))
        show("   IP: " + str(wifi.device_ip))
    except Exception as e:
        show("   EXC: " + str(e)[:30], TFT_RED)

    y += 4

    # ---------- Test 2: open network ----------
    show("2. open network...", TFT_YELLOW)
    try:
        wifi.reset()
        time.sleep_ms(300)
        result = wifi.connect("PicoShareOpen", "", sta_mode=False)
        show("   result: " + str(result), TFT_GREEN if result else TFT_RED)
        show("   state: " + str(wifi.state))
        show("   IP: " + str(wifi.device_ip))
    except Exception as e:
        show("   EXC: " + str(e)[:30], TFT_RED)

    y += 4

    # ---------- Test 3: connect_async ----------
    show("3. connect_async...", TFT_YELLOW)
    try:
        wifi.reset()
        time.sleep_ms(300)
        result = wifi.connect_async("PicoShare", "picoware", sta_mode=False)
        show("   async started: " + str(result), TFT_GREEN if result else TFT_RED)
        time.sleep_ms(1500)          # give it time
        show("   state: " + str(wifi.state))
        show("   IP: " + str(wifi.device_ip))
    except Exception as e:
        show("   EXC: " + str(e)[:30], TFT_RED)

    y += 6
    show("Press BACK to exit", TFT_WHITE)
    return True

def run(view_manager) -> None:
    if view_manager.button == BUTTON_BACK:
        view_manager.back()

def stop(view_manager) -> None:
    try:
        view_manager.wifi.disconnect()
        view_manager.wifi.reset()
    except:
        pass
    
from picoware.system.view_manager import ViewManager
from picoware.system.view import View

vm = None

try:
    vm = ViewManager()
    vm.add(
        View(
            "app_tester",
            run,
            start,
            stop,
        )
    )
    vm.switch_to("app_tester")
    while True:
        vm.run()
finally:
    del vm
    vm = None

OK, not sure if this has been brought up on this thread before. It seems the AP feature of the pico is incappable of hosting itself as a server. I got it to work on Basic IDK why I can’t get it to work here. You should’ve gotten an IP address as a result on the test, I didn’t either hence why I requested you to try it. Any idea on how to fix/implement it?

Hey, Picoware already has a built in AP server, maybe that’s something you’d be interested in?

Go to Library -> WiFi -> Server. From there you can add and edit pages. Then when you go back to Run, it’ll display the IP address and the server will be active.

Outside of that, Picoware is built on top of MicroPython, so all of the networking libraries are included within Picoware too.

Let me know if that’s help or if you need more guidance

Alright. I’ve made a proper browser-ish app for picoware. And have requested to merge all my applications with the main branch of picoware. For now, you can get the app @ PiBrowser

1 Like