Skip to content

Commit

Permalink
Remove Markdown autodocs
Browse files Browse the repository at this point in the history
Remove Python codes in README files
  • Loading branch information
Mick3DIY committed Apr 24, 2024
1 parent 89400b7 commit b258b0d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 193 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/main.yml

This file was deleted.

2 changes: 1 addition & 1 deletion EasyPicoPCB.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ def blink_all_leds(all_leds):
valueP2 = "pot2:{:.2f}".format(pot2.read_u16() * conversionFactor)
valueP3 = "pot3:{:.2f}".format(pot3.read_u16() * conversionFactor)
print("Min:0", valueP1, valueP2, valueP3, "Max:3.5")
utime.sleep(0.3)
utime.sleep(0.3) #Important !
87 changes: 1 addition & 86 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,92 +20,7 @@ The Fritzing project [EasyPicoPCB_fritzing.fzz](EasyPicoPCB_fritzing.fzz) is a c

The code with Thonny IDE and its plotter window :

```python
# EasyPicoPCB (2024-04-22)
# Raspberry Pi Pico : https://www.raspberrypi.com/products/raspberry-pi-pico/
# Documentation, tutorials : https://projects.raspberrypi.org
# Book1 : https://hackspace.raspberrypi.com/books/micropython-pico
# MicroPython : https://micropython.org
# Thonny IDE : https://thonny.org
import machine
import utime

# External button S1 (GPIO16, pin 21)
buttonS1 = machine.Pin(16, machine.Pin.IN, machine.Pin.PULL_DOWN)
# External button S2 (GPIO17, pin 22)
buttonS2 = machine.Pin(17, machine.Pin.IN, machine.Pin.PULL_DOWN)
# External button S3 (GPIO18, pin 24)
buttonS3 = machine.Pin(18, machine.Pin.IN, machine.Pin.PULL_DOWN)

# External LED LED1 (GPIO15, pin 20)
led1 = machine.Pin(15, machine.Pin.OUT)
# External LED LED2 (GPIO14, pin 19)
led2 = machine.Pin(14, machine.Pin.OUT)
# External LED LED3 (GPIO13, pin 17)
led3 = machine.Pin(13, machine.Pin.OUT)
# Pico on-board LED (GPIO25)
ledOnboard = machine.Pin(25, machine.Pin.OUT)

# Potentiometer P1 (ADC0, GPIO26, pin31)
pot1 = machine.ADC(26)
# Potentiometer P2 (ADC1, GPIO27, pin32)
pot2 = machine.ADC(27)
# Potentiometer P3 (ADC2, GPIO28, pin34)
pot3 = machine.ADC(28)
# 3.3V from Pico (12 bits)
# See page 92, the analogue-to-digital converter in [Book1]
conversionFactor = 3.3 / (65535)

# Handler for buttons IRQ
def buttons_handler(pin):
if buttonS1.value() == 1:
_led1 = led1.value()
if _led1 == 1:
led1.off()
else:
led1.on()
if buttonS2.value() == 1:
_led2 = led2.value()
if _led2 == 1:
led2.off()
else:
led2.on()
if buttonS3.value() == 1:
_led3 = led3.value()
if _led3 == 1:
led3.off()
else:
led3.on()

# Blink LEDs (at startup for example)
def blink_all_leds(all_leds):
for led in all_leds:
# Check if the object is a LED
if hasattr(led, "on"):
led.on()
utime.sleep(0.1)
led.off()

# Buttons triggers
buttonS1.irq(trigger=machine.Pin.IRQ_RISING, handler=buttons_handler)
buttonS2.irq(trigger=machine.Pin.IRQ_RISING, handler=buttons_handler)
buttonS3.irq(trigger=machine.Pin.IRQ_RISING, handler=buttons_handler)

# Check all LEDs
blink_all_leds((led1, led2, led3, ledOnboard))

# Pico Status
ledOnboard.on()

# Show graphics in Thonny plotter with text values
while True:
# https://mkaz.blog/code/python-string-format-cookbook/
valueP1 = "pot1:{:.2f}".format(pot1.read_u16() * conversionFactor)
valueP2 = "pot2:{:.2f}".format(pot2.read_u16() * conversionFactor)
valueP3 = "pot3:{:.2f}".format(pot3.read_u16() * conversionFactor)
print("Min:0", valueP1, valueP2, valueP3, "Max:3.5")
utime.sleep(0.3)
```
[EasyPicoPCB.py](EasyPicoPCB.py)

![](assets/EasyPicoPCB_thonny.png)

Expand Down
14 changes: 13 additions & 1 deletion joystickXL/EasyPicoPCB_JoystickXL.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# EasyPicoPCB code example in CircuitPython and JoystickXL (2024-02-16)
# EasyPicoPCB code example in CircuitPython and JoystickXL (2024-04-24)
# Original project : https://github.com/Mick3DIY/EasyPicoPCB
# Raspberry Pi Pico : https://www.raspberrypi.com/products/raspberry-pi-pico/
# Documentation, tutorials : https://projects.raspberrypi.org
Expand Down Expand Up @@ -48,13 +48,25 @@
# https://docs.circuitpython.org/en/latest/shared-bindings/analogio/index.html#analogio.AnalogIn
conversionFactor = pot1.reference_voltage / (65535)

# Blink LEDs (at startup for example)
def blink_all_leds(all_leds):
for led in all_leds:
# Check if the object is a LED
if hasattr(led, "direction"):
led.value = True
time.sleep(0.1)
led.value = False

js = Joystick()

js.add_input(
Button(buttonS1, active_low=False), Button(buttonS2, active_low=False), Button(buttonS3, active_low=False),
Axis(pot1), Axis(pot2), Axis(pot3),
)

# Check all LEDs
blink_all_leds((led1, led2, led3, ledOnboard))

# Pico Status
ledOnboard.value = True

Expand Down
92 changes: 1 addition & 91 deletions joystickXL/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,97 +34,7 @@ Then create a new file *code.py* in the Pico board with Thonny IDE with the code

![](assets/EasyPicoPCB_joystickXL_directories.png)

```python
# EasyPicoPCB code example in CircuitPython and JoystickXL (2024-02-16)
# Original project : https://github.com/Mick3DIY/EasyPicoPCB
# Raspberry Pi Pico : https://www.raspberrypi.com/products/raspberry-pi-pico/
# Documentation, tutorials : https://projects.raspberrypi.org
# CircuitPython : https://learn.adafruit.com/welcome-to-circuitpython
# JoystickXL : https://circuitpython-joystickxl.readthedocs.io
# Thonny IDE : https://thonny.org
import board
import time
import digitalio
import analogio

from joystick_xl.inputs import Axis, Button
from joystick_xl.joystick import Joystick

# External button S1 (GPIO16, pin 21)
buttonS1 = digitalio.DigitalInOut(board.GP16)
buttonS1.direction = digitalio.Direction.INPUT
buttonS1.pull = digitalio.Pull.DOWN
# External button S2 (GPIO17, pin 22)
buttonS2 = digitalio.DigitalInOut(board.GP17)
buttonS2.direction = digitalio.Direction.INPUT
buttonS2.pull = digitalio.Pull.DOWN
# External button S3 (GPIO18, pin 24)
buttonS3 = digitalio.DigitalInOut(board.GP18)
buttonS3.direction = digitalio.Direction.INPUT
buttonS3.pull = digitalio.Pull.DOWN

# External LED LED1 (GPIO15, pin 20)
led1 = digitalio.DigitalInOut(board.GP15)
led1.direction = digitalio.Direction.OUTPUT
# External LED LED2 (GPIO14, pin 19)
led2 = digitalio.DigitalInOut(board.GP14)
led2.direction = digitalio.Direction.OUTPUT
# External LED LED3 (GPIO13, pin 17)
led3 = digitalio.DigitalInOut(board.GP13)
led3.direction = digitalio.Direction.OUTPUT
# Pico on-board LED (GPIO25)
ledOnboard = digitalio.DigitalInOut(board.GP25)
ledOnboard.direction = digitalio.Direction.OUTPUT

# Potentiometer P1 (ADC0, GPIO26, pin31)
pot1 = analogio.AnalogIn(board.GP26)
# Potentiometer P2 (ADC1, GPIO27, pin32)
pot2 = analogio.AnalogIn(board.GP27)
# Potentiometer P3 (ADC2, GPIO28, pin34)
pot3 = analogio.AnalogIn(board.GP28)
# https://docs.circuitpython.org/en/latest/shared-bindings/analogio/index.html#analogio.AnalogIn
conversionFactor = pot1.reference_voltage / (65535)

js = Joystick()

js.add_input(
Button(buttonS1, active_low=False), Button(buttonS2, active_low=False), Button(buttonS3, active_low=False),
Axis(pot1), Axis(pot2), Axis(pot3),
)

# Pico Status
ledOnboard.value = True

# Show axis values or graphic lines in Thonny plotter with text values
while True:
# External button S1
if js.button[0].is_pressed:
led1.value = True
else:
led1.value = False
# External button S2
if js.button[1].is_pressed:
led2.value = True
else:
led2.value = False
# External button S3
if js.button[2].is_pressed:
led3.value = True
else:
led3.value = False

# Values from axis
#print("Min:0", js.axis[0].value, js.axis[1].value, js.axis[2].value, "Max:255")

# https://mkaz.blog/code/python-string-format-cookbook/
valueP1 = "pot1:{:.2f}".format(pot1.value * conversionFactor)
valueP2 = "pot2:{:.2f}".format(pot2.value * conversionFactor)
valueP3 = "pot3:{:.2f}".format(pot3.value * conversionFactor)
print("Min:0", valueP1, valueP2, valueP3, "Max:3.5")

js.update()
time.sleep(0.3) #Important !
```
[EasyPicoPCB_JoystickXL.py](EasyPicoPCB_JoystickXL.py)

Finally run this code to see some values :

Expand Down

0 comments on commit b258b0d

Please sign in to comment.