Skip to content

Commit 645243c

Browse files
authored
Wireless, Networking Support for Pico W, Pico 2 W (#416)
* Add StringConfigPoint * Add wifi connection implementation * Add wifi, NTP configurations to `experimental_config` * Add NTP implementation for realtime clock support * Add additional module dependencies needed for NTP * Catch import errors in the wifi and ntp modules as appropriate, re-raising them with our wrapper errors * Update the programming instructions for all pico-family variants, not just the Pico 2 * Add basic HTTP server to `experimental`, HTTP-based `contrib` script * Remove the optional fields from `datetime` tuples; make length consistently 8 to include yearday; this keeps all sources compatible with `machine.RTC` * Divide the experimental configuration editor into sections like the main config editor since the number of options is growing a lot * Add a dedicated text logging class so we can have consistent text output across the firmware * Add Open Sound Control (OSC) module to `experimental` and a basic `contrib` script that uses it * Add TouchOSC setup instructions & screenshots * Add WebREPL support via experimental_config * Add desktop interface program for converting 8mu's MIDI messages to OSC for EuroPi * Fix the default i2c timeout in the config documentation
1 parent 20a4618 commit 645243c

39 files changed

+3300
-662
lines changed

contributing.md

+25
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,31 @@ Changes or additions to public API functions must include the corresponding upda
225225

226226
All existing automated tests must pass. An effort should be made to improve the test suite by adding tests for new or changed functionality.
227227

228+
## Desktop Scripts
229+
230+
Python programs intended to be run on a laptop or desktop computer connected to EuroPi (either via USB or serial communication, or over WiFi) should be located
231+
in the `software/desktop` directory:
232+
233+
```
234+
software
235+
├── contrib/
236+
├── desktop/
237+
│   └── my_desktop_program.md
238+
│   └── my_desktop_program.py
239+
├── firmware/
240+
```
241+
242+
As with `contrib` scripts, you should include a `.md` file explaining how your desktop program operates, any additional libraries it depends on (and how to install them),
243+
and any configuration the user must do to set up your program. Also include whether or not EuroPi requires a specific program to be started or a command to be run
244+
in order to facilitate the communication between the desktop and EuroPi.
245+
246+
Desktop scripts should target Python 3, ideally Python 3.10 or later. If you need a very specific version of Python (e.g. because of a particular dependency that is
247+
only available on some versions) this should be noted in the `.md` file.
248+
249+
Any desktop programs should be written in Python, with only the necessary `.py` files included; do not include IDE-specific project files, Python bytecode (`*.pyc`) files,
250+
or any other generated files. Additional source files, e.g. `.proto` (Protocol Buffer definitions), `.ui` (Qt GUI definitions), and the like may be included if they are
251+
required for the program and have their dependencies explained in the `.md` file.
252+
228253
## License
229254

230255
All software in this repository is licensed under the [Apache 2.0](/software/LICENSE) license. In accordance with this license, please place a comment block at the top of your Python source files indicating the copyright and license:

software/CONFIGURATION.md

+83-19
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ default configuration:
1919
"EXTERNAL_I2C_SCL": 3,
2020
"EXTERNAL_I2C_CHANNEL": 1,
2121
"EXTERNAL_I2C_FREQUENCY": 100000,
22-
"EXTERNAL_I2C_TIMEOUT": 50000,
22+
"EXTERNAL_I2C_TIMEOUT": 1000,
2323
"MAX_OUTPUT_VOLTAGE": 10.0,
2424
"MAX_INPUT_VOLTAGE": 10.0,
2525
"GATE_VOLTAGE": 5.0,
2626
"MENU_AFTER_POWER_ON": false
2727
}
2828
```
2929

30-
System options:
30+
## System
31+
32+
Options:
3133
- `EUROPI_MODEL` specifies the type of EuroPi module. Currently only `"europi"` is supported. Default: `"europi"`
3234
- `PICO_MODEL` must be one of
3335
- `"pico"`,
@@ -41,7 +43,9 @@ System options:
4143
- `MENU_AFTER_POWER_ON` is a boolean indicating whether or not the module should always return to the main menu when
4244
it powers on. By default the EuroPi will re-launch the last-used program instead of returning to the main menu. Default: `false`
4345

44-
Display options:
46+
## Display
47+
48+
Options:
4549
- `ROTATE_DISPLAY` must be one of `false` or `true`. Default: `false`
4650
- `DISPLAY_WIDTH` is the width of the screen in pixels. The standard EuroPi screen is 128 pixels wide. Default: `128`
4751
- `DISPLAY_HEIGHT` is the height of the screen in pixels. The standard EuroPi screen is 32 pixels tall. Default: `32`
@@ -50,14 +54,18 @@ Display options:
5054
- `DISPLAY_CHANNEL` is the I²C channel used for the display, either 0 or 1. Default: `0`
5155
- `DISPLAY_CONTRAST` is a value indicating the display contrast. Higher numbers give higher contrast. `0` to `255`. Default: `255`
5256

53-
External I²C options:
57+
## External I²C
58+
59+
Options:
5460
- `EXTERNAL_I2C_SDA` is the I²C SDA pin used for the external I²C interface. Only SDA capable pis can be selected. Default: `2`
5561
- `EXTERNAL_I2C_SCL` is the I²C SCL pin used for the external I²C interface. Only SCL capable pins can be selected. Default: `3`
5662
- `EXTERNAL_I2C_CHANNEL` is the I²C channel used for the external I²C interface, either 0 or 1. Default: `1`
5763
- `EXTERNAL_I2C_FREQUENCY` is the I²C frequency used for the external I²C interface. Default: `100000`
5864
- `EXTERNAL_I2C_TIMEOUT` is the I²C timeout in milliseconds for the external I²C interface. Default: `1000`
5965

60-
I/O voltage options:
66+
## I/O voltage
67+
68+
Options:
6169
- `MAX_OUTPUT_VOLTAGE` is a float in the range `[0.0, 10.0]` indicating the maximum voltage CV output can generate. Default: `10.0`
6270
The hardware is capable of 10V maximum
6371
- `MAX_INPUT_VOLTAGE` is a float in the range `[0.0, 12.0]` indicating the maximum allowed voltage into the `ain` jack.
@@ -71,36 +79,92 @@ limits are intended for broad compatibility configuration, not for precise tunin
7179
If you assembled your module with the Raspberry Pi Pico 2 (or a clone featuring the RP2350 microcontroller) make sure to
7280
set the `PICO_MODEL` setting to `"pico2"`.
7381

74-
7582
# Experimental configuration
7683

7784
Other configuration properties are used by [experimental features](/software/firmware/experimental/__init__.py)
7885
and can be set using a similar static configuration file. This file is located at `/config/ExperimentalConfig.json`
79-
on the Raspberry Pi Pico. If this file does not exist, default settings will be loaded. The following
80-
shows the default configuration:
86+
on the Raspberry Pi Pico. If this file does not exist, default settings will be loaded.
8187

82-
```json
83-
{
84-
"VOLTS_PER_OCTAVE": 1.0,
85-
"RTC_IMPLEMENTATION": "",
86-
"UTC_OFFSET_HOURS": 0,
87-
"UTC_OFFSET_MINUTES": 0,
88-
}
89-
```
88+
## Quantization
9089

91-
Quantization options:
90+
Options:
9291
- `VOLTS_PER_OCTAVE` must be one of `1.0` (Eurorack standard) or `1.2` (Buchla standard). Default: `1.0`
9392

94-
RTC options:
93+
## Realtime Clock (RTC)
94+
95+
Options:
9596
- `RTC_IMPLEMENTATION` is one of the following, representing the realtime clock enabled on your module:
9697
- `""`: there is no RTC present. (default)
9798
- `"ds3231"`: use a DS3231 module connected to the external I2C interface
9899
- `"ds1307"`: use a DS1307 module connected to the external I2C interface (THIS IS UNTESTED! USE AT YOUR OWN RISK)
100+
- `"ntp"`: use an NTP source as the external clock. Requires wifi-supported Pico (e.g. Rasperry Pi Pico W or Pico 2 W)
101+
and valid network configuration (see [WiFi connection](#wifi-connection), below)
99102

100-
Timezone options:
103+
## Timezone
104+
105+
Options:
101106
- `UTC_OFFSET_HOURS`: The number of hours ahead/behind UTC the local timezone is (-24 to +24)
102107
- `UTC_OFFSET_MINUTES`: The number of minutes ahead/behind UTC the local timezone is (-59 to +59)
103108

109+
## WiFi Connection
110+
111+
Options:
112+
- `WIFI_MODE`: the wireless operation mode, one of:
113+
- `"access_point"` (default): EuroPi acts as a wireless access point for other devices to connect to
114+
-`"client"`: connect EuroPi to an external wireless router or accesspoint (DHCP required)
115+
- `WIFI_SSID`: the SSID of the wireless network to connect to (in `client` mode) or to broadcast
116+
(in `access_point` mode). Default: `"EuroPi"`
117+
- `WIFI_BSSID`: the optional BSSID of the network to connect to (e.g. access point MAC address). Default: `""`
118+
- `WIFI_PASSWORD`: the password of the wireless network. Default: `"europi"`
119+
- `WIFI_CHANNEL`: the WiFi channel 1-13 to use in `access_point` mode; ignored in `client` mode. Default: `10`
120+
- `WIFI_DHCP`: ignored if `WIFI_MODE` is `access_point`. Otherwise this controls whether or not
121+
EuroPi requests a DHCP lease from the external access point. Default: `true`.
122+
- `WIFI_IP`: a static IP address to use in `client` mode if DHCP is disabled. Default: `192.168.4.1`
123+
- `WIFI_GATEWAY`: the static gateway in `client` mode when DHCP is disabled. Default: `0.0.0.0`
124+
- `WIFI_NETMASK`: the netmask to use in `client` mode, if DHCP is disabled. Default: `255.255.255.0`
125+
- `WIFI_DNS`: the IP address of the DNS server to use when DHCP is disabled. Default: `8.8.8.8`
126+
127+
WiFi options are only applicable if EuroPi has the Raspberry Pi Pico W or Raspberry Pi Pico 2 W board;
128+
other Pico models do not contain wireless support.
129+
130+
**NOTE**: At the time of writing, the latest Micropython firmware for the Raspberry Pi Pico 2 W has a bug in
131+
which the wireless card will not reliably work if the CPU is overclocked. If you have problems using wifi please
132+
try changing `CPU_FREQ` to `normal` in `EuroPiConfig.json`.
133+
134+
### WiFi Security
135+
136+
If `WIFI_PASSWORD` is empty EuroPi will assume the network is _unencrypted_. This applies to both `client` and
137+
`access_point` modes. If `WIFI_PASSWORD` contains any text, WPA/WPA2 will be used (WPA2 is preferred, but
138+
in `client` mode WPA will be used if the router requires it).
139+
140+
Other wireless authentication models, including the use of cerfificates, VPN connections, etc... are not supported
141+
at this time on the Raspberry Pi Pico (2) W.
142+
143+
## WebREPL Configuration
144+
145+
`WebREPL` allows accessing the Python shell over WiFi, as well as enabling sending/receiving files wirelessly.
146+
This can be useful if you lack a USB cable long enought to reach from your computer to your EuroPi.
147+
148+
Enabling `WebREPL` requires a Raspberry Pi Pico W or Pico 2 W, as well as a valid wifi configuration (see above).
149+
150+
When enabled, `WebREPL` will use the password `EuroPi` by default. To change this password you will need to modify
151+
`/webrepl_cfg.py` to enter your new password.
152+
153+
To access `WebREPL`, direct your computer's browser to `http://<EuroPi's IP address>:8622`, e.g.
154+
`http://192.168.4.1:8622`. Alternatively you can configure Thonny's terminal to connect via `WebREPL`
155+
by selecting Run > Configure Interpreter, selecting `WebREPL` from the drop-down, and entering
156+
EuroPi's IP address and port 8622.
157+
158+
Options:
159+
- `ENABLE_WEBREPL`: enable or disable `WebREPL`. Default: `false`
160+
161+
### `WebREPL` Security
162+
163+
Enabling `WebREPL` can be a security risk: it potentially allows anyone to access the Python interpreter of
164+
your EuroPi, giving them complete access to run code, modify files, etc.... If you choose to enable `WebREPL`
165+
it is highly recommended that you choose a strong password and that you make sure your wifi connection is
166+
using WPA2 (see [WiFi Security](#wifi-security), above).
167+
104168
# Accessing config members in Python code
105169

106170
The firmware converts the JSON file into a `ConfigSettings` object, where the JSON keys are converted

software/contrib/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@ The division of the master clock that each LFO runs at, as well as each of their
167167
<i>Author: [roryjamesallen](https://github.com/roryjamesallen)</i>
168168
<br><i>Labels: LFO</i>
169169

170+
### HTTP Interface \[ [documentation](/software/contrib/http_control.md) | [script](/software/contrib/http_control.py) \]
171+
172+
Control the levels of CV1-6 using sliders in a web interface. Requires installation and configuration
173+
of a Raspberry Pi Pico W or Pico 2 W.
174+
175+
<i>Author: [chrisib](https://github.com/chrisib)</i>
176+
<br><i>Labels: cv, http, wifi</i>
177+
170178
### Itty Bitty \[ [documentation](/software/contrib/itty_bitty.md) | [script](/software/contrib/itty_bitty.py) \]
171179

172180
Dual-channel 8-bit trigger+gate+cv sequencer based on the binary representation of an 8-bit number.
@@ -221,6 +229,16 @@ Users have a copy of the original trigger signal, a sample and hold and a track
221229
<i>Author: [seanbechhofer](https://github.com/seanbechhofer)</i>
222230
<br><i>Labels: gates, sample&hold, track&hold</i>
223231

232+
### OSC Interface \[ [documentation](/software/contrib/osc_control.md) | [script](/software/contrib/osc_control.py) \]
233+
234+
Interface program for sending & receiving Open Sound Control (OSC) packets over UDP. Compatible with TouchOSC and
235+
other programs that support OSC over UDP.
236+
237+
Requires a Raspberry Pi Pico W or Pico 2 W with a properly-configured wifi connection to your other devices.
238+
239+
<i>Author: [chrisib](https://github.com/chrisib)</i>
240+
<br><i>Labels: osc, wifi</i>
241+
224242
### Pam's "EuroPi" Workout \[ [documentation](/software/contrib/pams.md) | [script](/software/contrib/pams.py) \]
225243

226244
A re-imaging of [ALM/Busy Circuit's Pamela's "NEW" Workout](https://busycircuits.com/alm017/). Turns the EuroPi into a clocked modulation

software/contrib/http_control.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# HTTP Interface
2+
3+
This program provides a simple HTTP interface to control the levels of CV1-6.
4+
5+
It requires that your EuroPi have a Raspberry Pi Pico W or Pico 2 W. See
6+
[wireless configuration](/software/CONFIGURATION.md#wifi-connection) for
7+
instructions on configuring the Pico W/Pico 2 W's wifi.
8+
9+
## Accessing the web interface
10+
11+
To access the web interface, connect your device (phone/tablet/desktop/laptop/etc...)
12+
to the same wifi network at EuroPi (or to EuroPi's access point if you have
13+
the wifi interface set up in AP mode). Then navigate to the IP address
14+
displayed on the screen, e.g. `http://192.168.4.1`.
15+
16+
The web interface has six sliders. Each of these can be moved to set the output voltage
17+
of one of the corresponding outputs.
18+
19+
## I/O Summary
20+
21+
CV1-6 will output voltages as specified by the web interface.
22+
23+
The buttons, knobs, `ain`, and `din` are not used by this program.
24+
25+
## Note on concurrent users
26+
27+
There is no authentication no restriction on the number of concurrent
28+
browser connections. It is recommended to only use one device at a time
29+
to control EuroPi over HTTP.

0 commit comments

Comments
 (0)