rp2040js 0.17.8 → 0.17.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -2
- package/dist/cjs/peripherals/pwm.js +1 -1
- package/dist/esm/peripherals/pwm.js +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ npm install
|
|
|
37
37
|
npm run start:micropython
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
and enjoy the MicroPython REPL! Quit the REPL with Ctrl+X. A different UF2 image can be loaded by supplying the `--image` option:
|
|
40
|
+
and enjoy the MicroPython REPL! Quit the REPL with Ctrl+X. A different MicroPython UF2 image can be loaded by supplying the `--image` option:
|
|
41
41
|
|
|
42
42
|
```
|
|
43
43
|
npm run start:micropython -- --image=my_image.uf2
|
|
@@ -53,7 +53,7 @@ For using the MicroPython demo code in tests, the `--expect-text` can come handy
|
|
|
53
53
|
|
|
54
54
|
#### Filesystem support
|
|
55
55
|
|
|
56
|
-
With MicroPython
|
|
56
|
+
With MicroPython, you can use the filesystem on the Pico. This becomes useful as more than one script file is used in your code. Just put a [LittleFS](https://github.com/littlefs-project/littlefs) formatted filesystem image called `littlefs.img` into the rp2040js root directory, and your `main.py` will be automatically started from there.
|
|
57
57
|
|
|
58
58
|
A simple way to create a suitable LittleFS image containing your script files is outlined in [create_littlefs_image.py](https://github.com/tomods/GrinderController/blob/358ad3e0f795d8cc0bdf4f21bb35f806871d433f/tools/create_littlefs_image.py).
|
|
59
59
|
So, using [littlefs-python](https://pypi.org/project/littlefs-python/), you can do the following:
|
|
@@ -74,6 +74,39 @@ Other ways of creating LittleFS images can be found [here](https://github.com/wo
|
|
|
74
74
|
|
|
75
75
|
Currently, the filesystem is not writeable, as the SSI peripheral required for flash writing is not implemented yet. If you're interested in hacking, see the discussion in https://github.com/wokwi/rp2040js/issues/88 for a workaround.
|
|
76
76
|
|
|
77
|
+
### CircuitPython code
|
|
78
|
+
|
|
79
|
+
To run the CircuitPython demo, you can follow the directions above for MicroPython, except download [adafruit-circuitpython-raspberry_pi_pico-en_US-8.0.2.uf2](https://adafruit-circuit-python.s3.amazonaws.com/bin/raspberry_pi_pico/en_US/adafruit-circuitpython-raspberry_pi_pico-en_US-8.0.2.uf2) instead of the MicroPython UF2 file. Place it in the rp2040js root directory, then run:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
npm install
|
|
83
|
+
npm run start:circuitpython
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
and start the CircuitPython REPL! The rest of the experience is the same as the MicroPython demo (Ctrl+X to exit, using the `--image` and
|
|
87
|
+
`--gdb` options, etc).
|
|
88
|
+
|
|
89
|
+
#### Filesystem support
|
|
90
|
+
|
|
91
|
+
For CircuitPython, you can create a FAT12 filesystem in Linux using the `truncate` and `mkfs.vfat` utilities:
|
|
92
|
+
|
|
93
|
+
```shell
|
|
94
|
+
truncate fat12.img -s 1M # make the image file
|
|
95
|
+
mkfs.vfat -F12 -S512 fat12.img # create the FAT12 filesystem
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
You can then mount the filesystem image and add files to it:
|
|
99
|
+
|
|
100
|
+
```shell
|
|
101
|
+
mkdir fat12 # create the mounting folder if needed
|
|
102
|
+
sudo mount -o loop fat12.img fat12/ # mount the filesystem to the folder
|
|
103
|
+
sudo cp code.py fat12/ # copy code.py to the filesystem
|
|
104
|
+
sudo umount fat12/ # unmount the filesystem
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
While CircuitPython does not typically use a writeable filesystem, note that this functionality is unavailable (see MicroPython filesystem
|
|
108
|
+
support section for more details).
|
|
109
|
+
|
|
77
110
|
## Learn more
|
|
78
111
|
|
|
79
112
|
- [Live-coding stream playlist](https://www.youtube.com/playlist?list=PLLomdjsHtJTxT-vdJHwa3z62dFXZnzYBm)
|
|
@@ -78,7 +78,7 @@ class PWMChannel {
|
|
|
78
78
|
// GPIO pin indices: Table 525. Mapping of PWM channels to GPIO pins on RP2040
|
|
79
79
|
this.pinA1 = this.index * 2;
|
|
80
80
|
this.pinB1 = this.index * 2 + 1;
|
|
81
|
-
this.pinA2 = this.index < 7 ? 16 + this.index * 2
|
|
81
|
+
this.pinA2 = this.index < 7 ? 16 + this.index * 2 : -1;
|
|
82
82
|
this.pinB2 = this.index < 7 ? 16 + this.index * 2 + 1 : -1;
|
|
83
83
|
this.alarmA.enable = true;
|
|
84
84
|
this.alarmB.enable = true;
|
|
@@ -75,7 +75,7 @@ class PWMChannel {
|
|
|
75
75
|
// GPIO pin indices: Table 525. Mapping of PWM channels to GPIO pins on RP2040
|
|
76
76
|
this.pinA1 = this.index * 2;
|
|
77
77
|
this.pinB1 = this.index * 2 + 1;
|
|
78
|
-
this.pinA2 = this.index < 7 ? 16 + this.index * 2
|
|
78
|
+
this.pinA2 = this.index < 7 ? 16 + this.index * 2 : -1;
|
|
79
79
|
this.pinB2 = this.index < 7 ? 16 + this.index * 2 + 1 : -1;
|
|
80
80
|
this.alarmA.enable = true;
|
|
81
81
|
this.alarmB.enable = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rp2040js",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.9",
|
|
4
4
|
"description": "Raspberry Pi Pico (RP2040) Emulator",
|
|
5
5
|
"repository": "https://github.com/wokwi/rp2040js",
|
|
6
6
|
"keywords": [
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"lint": "eslint . --ext .ts",
|
|
35
35
|
"start": "ts-node demo/emulator-run.ts",
|
|
36
36
|
"start:micropython": "ts-node demo/micropython-run.ts",
|
|
37
|
+
"start:circuitpython": "ts-node demo/micropython-run.ts --circuitpython",
|
|
37
38
|
"start:gdbdiff": "ts-node debug/gdbdiff.ts",
|
|
38
39
|
"test": "jest"
|
|
39
40
|
},
|