pico-micropython-examples icon indicating copy to clipboard operation
pico-micropython-examples copied to clipboard

Fix #70

Open lurch opened this issue 10 months ago • 4 comments

Untested, but in https://github.com/raspberrypi/pico-micropython-examples/issues/70#issuecomment-2724378336 @dpgeorge says that this should work :wink:

lurch avatar Mar 17 '25 16:03 lurch

I tested this on a Pico W and it works well.

Might I also suggest the following changes, to make it more user friendly:

  • change the led init line to led = Pin("LED"), so it actually turns the built-in LED on and off
  • add these two lines to the HTML that it sends (after the <p>%s</p>):
        <button onclick="window.location='/light/off'">Turn off</button>
        <button onclick="window.location='/light/on'">Turn on</button>

That gives you buttons to turn on/off via navigation to the correct page.

dpgeorge avatar Mar 18 '25 01:03 dpgeorge

I tested this on a Pico W and it works well.

Thank you! :+1:

Might I also suggest the following changes, to make it more user friendly:

  • change the led init line to led = Pin("LED"), so it actually turns the built-in LED on and off

See #66 and #71

  • add these two lines to the HTML that it sends (after the <p>%s</p>):
        <button onclick="window.location='/light/off'">Turn off</button>
        <button onclick="window.location='/light/on'">Turn on</button>

That gives you buttons to turn on/off via navigation to the correct page.

Surely it's easier to just use a href links, rather than relying on buttons with javascript onclick handlers? EDIT: Which I've just done :wink:

lurch avatar Mar 18 '25 13:03 lurch

Might I also suggest the following changes, to make it more user friendly:

  • change the led init line to led = Pin("LED"), so it actually turns the built-in LED on and off

See #66 and #71

Ah, right, thanks for reminding me!

Surely it's easier to just use a href links, rather than relying on buttons with javascript onclick handlers?

Yes, simpler to use a href. It's just that buttons look better :smile: although you could use CSS for the hrefs.

dpgeorge avatar Mar 19 '25 03:03 dpgeorge

although you could use CSS for the hrefs.

Our examples are deliberately kept simple and bare-bones. They're intended to demonstrate the functionality of the underlying code, not HTML styling :wink:

lurch avatar Mar 19 '25 12:03 lurch