Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use constants for PWM and CPU frequency #167

Merged
merged 11 commits into from
Dec 1, 2022
3 changes: 0 additions & 3 deletions software/contrib/bernoulli_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ def regular_maneuver(self):

class BernoulliGates(EuroPiScript):
def __init__(self):
# Overclock the Pico for improved performance.
machine.freq(250_000_000)

self.toss_flg = 0
self.first_gate = SingleBernoulliGate(control_knob = k1,
control_port = ain,
Expand Down
5 changes: 0 additions & 5 deletions software/contrib/coin_toss.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ def __init__(self):
self._tempo = 0
self._deadline = 0

# Overclock the Pico for improved performance.
machine.freq(250_000_000)
# machine.freq(125_000_000) # Default clock speed.


@b1.handler
def toggle_clock():
"""Toggle between internal clock and external clock from digital in."""
Expand Down
3 changes: 0 additions & 3 deletions software/contrib/consequencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@

class Consequencer(EuroPiScript):
def __init__(self):
# Overclock the Pico for improved performance.
machine.freq(250_000_000)

# Initialize sequencer pattern arrays
p = pattern()
self.BD=p.BD
Expand Down
3 changes: 0 additions & 3 deletions software/contrib/cvecorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ def __init__(self):
# Needed if using europi_script
super().__init__()

# Overclock the Pico for improved performance.
machine.freq(250_000_000)

# Micropython heap fragmentation notes:
# - The pico has very limited memory and in some cases needs to be managed carefully
# - In some cases you can get a MemoryError even if there is enough free memory, this is because micropython could not find enough contiguous memory because the heap has become fragmented
Expand Down
3 changes: 0 additions & 3 deletions software/contrib/hamlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ def __init__(self):
self.gate_2 = cv4
self.cv_2 = cv5

# Overclock the Pico for improved performance.
machine.freq(250_000_000)

# Initialize sequencer pattern arrays
p = pattern()
self.BD=p.BD
Expand Down
3 changes: 0 additions & 3 deletions software/contrib/harmonic_lfos.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ def __init__(self):
#Retreive saved state information from file
state = self.load_state_json()

#Overclock the Pico for improved performance
freq(250_000_000)

#Use the saved values for the LFO divisions and mode if found in the save state file, using defaults if not
self.divisions = state.get("divisions", [1, 3, 5, 7, 11, 13])
self.modes = state.get("modes", [0, 0, 0, 0, 0, 0])
Expand Down
3 changes: 0 additions & 3 deletions software/contrib/noddy_holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@

class NoddyHolder(EuroPiScript):
def __init__(self):
# Overclock the Pico for improved performance.
machine.freq(250_000_000)

self.gate = False
# Keep track of values for display, S&H and T&H for each
# channel
Expand Down
2 changes: 0 additions & 2 deletions software/contrib/poly_square.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ def __init__(self, k1, k2):

class PolySquare(EuroPiScript):
def __init__(self):
# Settings for improved performance
machine.freq(250_000_000)
k1.set_samples(256)
k2.set_samples(256)
# PIO settings
Expand Down
2 changes: 0 additions & 2 deletions software/contrib/polyrhythmic_sequencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ class PolyrhythmSeq(EuroPiScript):

def __init__(self):
super().__init__()
# Overclock the Pico for improved performance.
machine.freq(250000000)

# Configure EuroPi options to improve performance.
b2.debounce_delay = 200
Expand Down
3 changes: 0 additions & 3 deletions software/contrib/probapoly.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ def __init__(self):
# Needed if using europi_script
super().__init__()

# Overclock the Pico for improved performance.
machine.freq(250_000_000)

# Variables
self.step = 1
self.clockStep = 0
Expand Down
3 changes: 0 additions & 3 deletions software/contrib/strange_attractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,6 @@ def get_attractors():
class StrangeAttractor(EuroPiScript):
def __init__(self):

# Overclock the Pico for improved performance.
machine.freq(250_000_000)

# Initialise and calculate ranges.
# This will take around 30 seconds per unsaved attractor.
self.attractors = get_attractors()
Expand Down
3 changes: 0 additions & 3 deletions software/firmware/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ def display_name(cls):
return "~Calibrate"

def main(self):
# Overclock for faster calibration
freq(250_000_000)

ain = ADC(Pin(26, Pin.IN, Pin.PULL_DOWN))
cv1 = PWM(Pin(21))
usb = Pin(24, Pin.IN)
Expand Down
11 changes: 10 additions & 1 deletion software/firmware/europi.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
from machine import PWM
from machine import Pin

# Overclock the Pico for improved performance.
from machine import freq

freq(250_000_000)
awonak marked this conversation as resolved.
Show resolved Hide resolved
# freq(125_000_000) # Default clock speed.

from ssd1306 import SSD1306_I2C

from version import __version__
Expand Down Expand Up @@ -68,6 +74,9 @@
MIN_OUTPUT_VOLTAGE = 0
MAX_OUTPUT_VOLTAGE = 10

# PWM Frequency
PWM_FREQ = 2_500_000

# Default font is 8x8 pixel monospaced font.
CHAR_WIDTH = 8
CHAR_HEIGHT = 8
Expand Down Expand Up @@ -470,7 +479,7 @@ class Output:
def __init__(self, pin, min_voltage=MIN_OUTPUT_VOLTAGE, max_voltage=MAX_OUTPUT_VOLTAGE):
self.pin = PWM(Pin(pin))
# Set freq to 1kHz as the default is too low and creates audible PWM 'hum'.
self.pin.freq(100_000)
self.pin.freq(PWM_FREQ)
self._duty = 0
self.MIN_VOLTAGE = min_voltage
self.MAX_VOLTAGE = max_voltage
Expand Down