Skip to content

Commit

Permalink
Merge branch 'main' into display-contrast
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisib authored Jan 8, 2025
2 parents a2650a2 + 8924ba2 commit c2cd04d
Show file tree
Hide file tree
Showing 12 changed files with 309 additions and 79 deletions.
2 changes: 1 addition & 1 deletion hardware/EuroPi/bill_of_materials.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ If buying in bulk there are likely other suppliers that are cheaper - this BOM i
| | 2 | T18 Shaft | Knobs | [Thonk](https://www.thonk.co.uk/shop/1900h-t18/)<br>**NOTE: If you buy D-Shaft potentiometers, the knobs must be 'Reverse-D-Shaft' type.<br>Any knobs which fit may be chosen, but Mouser does not stock the standard suggestion sold by Thonk**
| | 1 | 10 - 16 Pin | Eurorack Power Cable | [Thonk](https://www.thonk.co.uk/shop/eurorack-power-cables/)<br>**Note: Mouser does not stock the correct cable at time of writing. Other suppliers will provide the correct part, but always double check that the polarity is correct (red stripe is always -12V)**
| | 1 | | Micro USB Cable (Capable of Data Transfer) | [CPC](https://cpc.farnell.com/pro-signal/psg91562/lead-usb-a-male-micro-b-male-black/dp/CS32732), [The Pi Hut](https://thepihut.com/products/usb-to-micro-usb-cable-0-5m)<br>[Mouser](https://www.mouser.co.uk/ProductDetail/Teltonika/PR2US08M?qs=9vOqFld9vZXl90mLcdqZXQ%3D%3D)
| | 1 | | Raspberry Pi Pico | [The Pi Hut](https://thepihut.com/products/raspberry-pi-pico)<br>[CPC](https://cpc.farnell.com/raspberry-pi/raspberry-pi-pico/raspberry-pi-pico-rp2040-mcu-board/dp/SC17106)<br>[Mouser](https://www.mouser.co.uk/ProductDetail/Raspberry-Pi/SC0915?qs=T%252BzbugeAwjgnLi4azxXVFA%3D%3D)<br>**Note: Any official version of the Raspberry Pi Pico will work (W, H, or WH). Third party RP2040 boards may work, but there is no guarantee - always double check the pinout**
| | 1 | | Raspberry Pi Pico | [The Pi Hut](https://thepihut.com/products/raspberry-pi-pico)<br>[CPC](https://cpc.farnell.com/raspberry-pi/raspberry-pi-pico/raspberry-pi-pico-rp2040-mcu-board/dp/SC17106)<br>[Mouser](https://www.mouser.co.uk/ProductDetail/Raspberry-Pi/SC0915?qs=T%252BzbugeAwjgnLi4azxXVFA%3D%3D)<br>The Raspberry Pi Pico 2 is also usable [with additional configuration](/software/CONFIGURATION.md)<br>**Note: Any official version of the Raspberry Pi Pico will work (W, H, or WH). Third party RP2040 or RP2350 boards may work, but there is no guarantee - always double check the pinout. RP2350 boards should be [configured like the Pico 2](/software/CONFIGURATION.md)**

#### Note about OLED
The OLED has two suppliers listed, each with different pin configurations. The module supports either of these two configurations (the most common), but no others, so make sure that the one you buy, wherever you source it, has one of these two configurations.
Expand Down
16 changes: 13 additions & 3 deletions software/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ default configuration:
{
"EUROPI_MODEL": "europi",
"PICO_MODEL": "pico",
"CPU_FREQ": 250000000,
"CPU_FREQ": "overclocked",
"ROTATE_DISPLAY": false,
"DISPLAY_WIDTH": 128,
"DISPLAY_HEIGHT": 32,
Expand All @@ -29,8 +29,15 @@ default configuration:

CPU & Pico options:
- `EUROPI_MODEL` specifies the type of EuroPi module. Currently only `"europi"` is supported. Default: `"europi"`
- `PICO_MODEL` must be one of `"pico"` or `"pico w"`. Default: `"pico"`
- `CPU_FREQ` must be one of `250000000` or `125000000`. Default: `"250000000"`
- `PICO_MODEL` must be one of
- `"pico"`,
- `"pico h"`,
- `"pico w"`,
- `"pico 2"`, or
- `"pico 2w"`.
Default: `"pico"`.
- `CPU_FREQ` specifies whether or not the CPU should be overclocked. Must be one of `"overclocked"` or `"normal"`.
Default: `"overclocked"`

Display options:
- `ROTATE_DISPLAY` must be one of `false` or `true`. Default: `false`
Expand Down Expand Up @@ -60,6 +67,9 @@ Power options:
- `MENU_AFTER_POWER_ON` is a boolean indicating whether or not the module should always return to the main menu when
it powers on. By default the EuroPi will re-launch the last-used program instead of returning to the main menu. Default: `false`

If you assembled your module with the Raspberry Pi Pico 2 (or a clone featuring the RP2350 microcontroller) make sure to
set the `PICO_MODEL` setting to `"pico2"`.


# Experimental configuration

Expand Down
52 changes: 45 additions & 7 deletions software/contrib/bezier.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,52 @@ def on_b2_release():
def config_points(cls):
"""Return the static configuration options for this class
"""
def restrict_input_voltage(v):
if v > europi_config.MAX_INPUT_VOLTAGE:
return europi_config.MAX_INPUT_VOLTAGE
return v

return [
configuration.floatingPoint(name="MAX_INPUT_VOLTAGE", minimum=0.0, maximum=europi_config.MAX_INPUT_VOLTAGE, default=10.0),
configuration.floatingPoint(name="MIN_VOLTAGE", minimum=0.0, maximum=europi_config.MAX_OUTPUT_VOLTAGE, default=0.0),
configuration.floatingPoint(name="MAX_VOLTAGE", minimum=0.0, maximum=europi_config.MAX_OUTPUT_VOLTAGE, default=europi_config.MAX_OUTPUT_VOLTAGE),
configuration.floatingPoint(name="MIN_FREQUENCY", minimum=0.001, maximum=10.0, default=0.01),
configuration.floatingPoint(name="MAX_FREQUENCY", minimum=0.001, maximum=10.0, default=1.0),
configuration.choice(name="AIN_MODE", choices=["frequency", "curve"], default="frequency"),
configuration.choice(name="LOGIC_MODE", choices=["and", "or", "xor", "nand", "nor", "xnor"], default="xor")
configuration.floatingPoint(
name="MAX_INPUT_VOLTAGE",
minimum=0.0,
maximum=europi_config.MAX_INPUT_VOLTAGE,
default=restrict_input_voltage(10.0)
),
configuration.floatingPoint(
name="MIN_VOLTAGE",
minimum=0.0,
maximum=europi_config.MAX_OUTPUT_VOLTAGE,
default=0.0
),
configuration.floatingPoint(
name="MAX_VOLTAGE",
minimum=0.0,
maximum=europi_config.MAX_OUTPUT_VOLTAGE,
default=europi_config.MAX_OUTPUT_VOLTAGE
),
configuration.floatingPoint(
name="MIN_FREQUENCY",
minimum=0.001,
maximum=10.0,
default=0.01
),
configuration.floatingPoint(
name="MAX_FREQUENCY",
minimum=0.001,
maximum=10.0,
default=1.0
),
configuration.choice(
name="AIN_MODE",
choices=["frequency", "curve"],
default="frequency"
),
configuration.choice(
name="LOGIC_MODE",
choices=["and", "or", "xor", "nand", "nor", "xnor"],
default="xor"
)
]

def save(self):
Expand Down
5 changes: 3 additions & 2 deletions software/contrib/diagnostic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
k1,
k2,
oled,
europi_config,
thermometer,
)
from europi_script import EuroPiScript
import configuration
Expand All @@ -40,7 +42,6 @@
class Diagnostic(EuroPiScript):
def __init__(self):
super().__init__()
self.temp_sensor = ADC(4)
self.voltages = [
0, # min
0.5, # not 0 but still below DI's threshold
Expand All @@ -58,7 +59,7 @@ def config_points(cls):

def calc_temp(self):
# see the pico's datasheet for the details of this calculation
t = 27 - ((self.temp_sensor.read_u16() * TEMP_CONV_FACTOR) - 0.706) / 0.001721
t = thermometer.read_temperature()
if self.use_fahrenheit:
t = (t * 1.8) + 32
return t
Expand Down
13 changes: 8 additions & 5 deletions software/contrib/lutra.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,12 @@ def gui_render_thread(self):
"""A thread function that handles drawing the GUI
"""
SHOW_WAVE_TIMEOUT = 3000
while True:

# To prevent the module locking up when we connect the USB for e.g. debugging, kill this thread
# if the USB state changes. Otherwise the second core will continue being busy, which makes connecting
# to the Python terminal impossible
usb_connected_at_start = usb_connected.value()
while usb_connected.value() == usb_connected_at_start:
now = time.ticks_ms()
oled.fill(0)
with self.pixel_lock:
Expand All @@ -283,11 +288,9 @@ def gui_render_thread(self):
def wave_generation_thread(self):
"""A thread function that handles the underlying math of generating the waveforms
"""
usb_connected_at_start = usb_connected.value()

# To prevent the module locking up when we connect the USB for e.g. debugging, kill this thread
# if the USB state changes. Otherwise the second core will continue being busy, which makes connecting
# to the Python terminal impossible
# if the USB state changes
usb_connected_at_start = usb_connected.value()
while usb_connected.value() == usb_connected_at_start:
# Read the digital inputs
self.digital_input_state.update()
Expand Down
50 changes: 44 additions & 6 deletions software/contrib/volts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,55 @@ class OffsetVoltages(EuroPiScript):
def __init__(self):
super().__init__()


@classmethod
def config_points(cls):
"""Return the static configuration options for this class
"""
def restrict_voltage(v):
"""If the max output voltage has been lowered, disable the too-high output
"""
if v > europi_config.MAX_OUTPUT_VOLTAGE:
return 0.0
return v

return [
configuration.floatingPoint(name="CV1", minimum=0.0, maximum=europi_config.MAX_OUTPUT_VOLTAGE, default=0.5),
configuration.floatingPoint(name="CV2", minimum=0.0, maximum=europi_config.MAX_OUTPUT_VOLTAGE, default=1.0),
configuration.floatingPoint(name="CV3", minimum=0.0, maximum=europi_config.MAX_OUTPUT_VOLTAGE, default=2.0),
configuration.floatingPoint(name="CV4", minimum=0.0, maximum=europi_config.MAX_OUTPUT_VOLTAGE, default=2.5),
configuration.floatingPoint(name="CV5", minimum=0.0, maximum=europi_config.MAX_OUTPUT_VOLTAGE, default=5.0),
configuration.floatingPoint(name="CV6", minimum=0.0, maximum=europi_config.MAX_OUTPUT_VOLTAGE, default=10.0),
configuration.floatingPoint(
name="CV1",
minimum=0.0,
maximum=europi_config.MAX_OUTPUT_VOLTAGE,
default=restrict_voltage(0.5)
),
configuration.floatingPoint(
name="CV2",
minimum=0.0,
maximum=europi_config.MAX_OUTPUT_VOLTAGE,
default=restrict_voltage(1.0)
),
configuration.floatingPoint(
name="CV3",
minimum=0.0,
maximum=europi_config.MAX_OUTPUT_VOLTAGE,
default=restrict_voltage(2.0)
),
configuration.floatingPoint(
name="CV4",
minimum=0.0,
maximum=europi_config.MAX_OUTPUT_VOLTAGE,
default=restrict_voltage(2.5)
),
configuration.floatingPoint(
name="CV5",
minimum=0.0,
maximum=europi_config.MAX_OUTPUT_VOLTAGE,
default=restrict_voltage(5.0)
),
configuration.floatingPoint(
name="CV6",
minimum=0.0,
maximum=europi_config.MAX_OUTPUT_VOLTAGE,
default=restrict_voltage(10.0)
),
]

def main(self):
Expand Down
26 changes: 5 additions & 21 deletions software/firmware/calibrate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from machine import Pin, ADC, PWM, freq
from time import sleep
from europi import oled, b1, b2, PIN_USB_CONNECTED, PIN_CV1, PIN_AIN
from europi import oled, b1, b2, ain, cv1, usb_connected
from europi_script import EuroPiScript
from os import stat, mkdir

Expand All @@ -12,14 +11,10 @@ def display_name(cls):
return "~Calibrate"

def main(self):
ain = ADC(Pin(PIN_AIN, Pin.IN, Pin.PULL_DOWN))
cv1 = PWM(Pin(PIN_CV1))
usb = Pin(PIN_USB_CONNECTED, Pin.IN)

def sample():
readings = []
for reading in range(256):
readings.append(ain.read_u16())
readings.append(ain.pin.read_u16())
return round(sum(readings) / 256)

def wait_for_voltage(voltage):
Expand All @@ -38,17 +33,6 @@ def text_wait(text, wait):
oled.centre_text(text)
sleep(wait)

def fill_show(colour):
oled.fill(colour)
oled.show()

def flash(flashes, period):
for flash in range(flashes):
fill_show(1)
sleep(period / 2)
fill_show(0)
sleep(period / 2)

def wait_for_b1(value):
while b1.value() != value:
sleep(0.05)
Expand All @@ -62,7 +46,7 @@ def wait_for_b1(value):

# Calibration start

if usb.value() == 1:
if usb_connected.value() == 1:
oled.centre_text("Make sure rack\npower is on\nDone: Button 1")
wait_for_b1(1)
wait_for_b1(0)
Expand Down Expand Up @@ -109,11 +93,11 @@ def wait_for_b1(value):

output_duties = [0]
duty = 0
cv1.duty_u16(duty)
cv1.pin.duty_u16(duty)
reading = sample()
for index, expected_reading in enumerate(readings[1:]):
while abs(reading - expected_reading) > 0.002 and reading < expected_reading:
cv1.duty_u16(duty)
cv1.pin.duty_u16(duty)
duty += 10
reading = sample()
output_duties.append(duty)
Expand Down
Loading

0 comments on commit c2cd04d

Please sign in to comment.