|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
|
|
|
2
|
+# wifi portal
|
|
|
3
|
+if wifi settings are set in settings.toml, the cardputer is accessible via the ip address shown in the top bar of the repl (might need to disable any infinitely running code to see it, or boot into safe mode.)
|
|
|
4
|
+
|
|
|
5
|
+at the time of writing the ip address is `192.168.0.92` but this can easily change. also, if there are any other circuitpy wifi devices, they will need to be using a different port (or this one will) either way, default is `80` and any different may have to be specified to work. e.g. `192.168.0.92:1337` if using port 1337.
|
|
|
6
|
+
|
|
|
7
|
+```toml
|
|
|
8
|
+
|
|
|
9
|
+CIRCUITPY_WIFI_SSID = "SSID"
|
|
|
10
|
+CIRCUITPY_WIFI_PASSWORD = "PASSWORD"
|
|
|
11
|
+CIRCUITPY_WEB_API_PASSWORD = "passw0rd"
|
|
|
12
|
+CIRCUITPY_WEB_API_PORT = 80
|
|
|
13
|
+```
|
|
|
14
|
+
|
|
|
15
|
+# read only mode
|
|
|
16
|
+if the board is removed from usb without safely ejecting, the next time it is tried to use it enters read only mode. it seems a full restart (power off) is the only way to get it out of the read only state.
|
|
|
17
|
+
|
|
|
18
|
+# reading the keyboard
|
|
|
19
|
+the code snippet is [here](https://github.com/adafruit/circuitpython/commit/090f330ad5e30acf2030900b45386d784cbcc1da) , to read key codes. some day i will write a full map for easier coding.
|
|
|
20
|
+
|
|
|
21
|
+```python
|
|
|
22
|
+while True:
|
|
|
23
|
+ print(hex(ord(sys.stdin.read(1))))
|
|
|
24
|
+```
|
|
|
25
|
+
|
|
|
26
|
+this produces a hex value such as 0x35 (key number 5). every key stroke including fn, shift and ctrl, produces a different result, as long as it is shown on the sticker it has a unique hex value, so its relatively trivial to implement into a project.
|
|
|
27
|
+## keyboard library
|
|
|
28
|
+I am developing a library that decodes the codes. [Check it out here](https://tea.cubes.link/cube/BOARDS/src/branch/master/CARDPUTER%20CircuitPython/keyboard.py)
|
|
|
29
|
+
|
|
|
30
|
+With that, simply use the following code to type text into the terminal. Expand it to your needs!
|
|
|
31
|
+
|
|
|
32
|
+```python
|
|
|
33
|
+from keyboard import Keyboard
|
|
|
34
|
+
|
|
|
35
|
+keyb=Keyboard()
|
|
|
36
|
+while True:
|
|
|
37
|
+ print(keyb.scan(), end="")
|
|
|
38
|
+```
|
|
|
39
|
+
|
|
|
40
|
+currently keymaps are organised into the type of thing they are. the number row is conveniently indexable. the rest are dictionaries for easy lookup.
|
|
|
41
|
+
|
|
|
42
|
+should it be saved in both directions for when you have the code but you dont know what the key is? I think there are Python ways of doing it in reverse, unless it is noticeably slow on a small device like this.
|
|
|
43
|
+## Issues
|
|
|
44
|
+Some key combinations produce two codes in quick succession - the FN + Direction keys are a good example of this. Need to run experiments to figure out how to isolate these codes accurately. Also, some codes don't seem to properly register? OPT + D being a combination that I couldn't get the code to work for, even though that is what the Serial registers.
|
|
|
45
|
+
|
|
|
46
|
+# SD Card access
|
|
|
47
|
+need to put this code in github, but for now it's here
|
|
|
48
|
+
|
|
|
49
|
+```python
|
|
|
50
|
+import board
|
|
|
51
|
+import busio
|
|
|
52
|
+import sdcardio
|
|
|
53
|
+import storage
|
|
|
54
|
+
|
|
|
55
|
+spi = busio.SPI(board.SD_SCK, MOSI=board.SD_MOSI, MISO=board.SD_MISO)
|
|
|
56
|
+cs = board.SD_CS
|
|
|
57
|
+
|
|
|
58
|
+try:
|
|
|
59
|
+ sdcard = sdcardio.SDCard(spi, cs)
|
|
|
60
|
+ vfs = storage.VfsFat(sdcard)
|
|
|
61
|
+
|
|
|
62
|
+ storage.mount(vfs, "/sd") # access files on sd card here
|
|
|
63
|
+except OSError:
|
|
|
64
|
+ pass # SD card not inserted/found
|
|
|
65
|
+```
|
|
|
66
|
+
|
|
|
67
|
+then, for example
|
|
|
68
|
+
|
|
|
69
|
+```python
|
|
|
70
|
+with open("/sd/data.txt") as f:
|
|
|
71
|
+ lines = f.readlines()
|
|
|
72
|
+```
|
|
|
73
|
+
|
|
|
74
|
+Currently, there seems to be an issue with CircuitPython filesystem being readonly, making it impossible to write files. Opening a file as "w" produces an OSError.
|
|
|
75
|
+
|
|
|
76
|
+**FIXED**: CircuitPython prevents both device and user from writing to the device at the same time over USB, since this can cause problems, corruption etc. A workaround is using the `boot.py` file to alternate between read/write access using a pin grounding. Adafruit has an explanation but their instruction is unclear for Cardputer specifically.
|
|
|
77
|
+
|
|
|
78
|
+[This Github user](https://github.com/RetiredWizard/PyDOS/blob/main/cpython/boot.py) wrote a `boot.py` file that works for the Cardputer. This is a necessary addition to the root drive if you want to be able to write files to the drive or the SD card. I have a version of this file [saved here](https://tea.cubes.link/cube/BOARDS/src/branch/master/CARDPUTER%20CircuitPython/boot.py), without the PyDOS specific comments/print statements.
|
|
|
79
|
+
|
|
|
80
|
+# QR (barcode) scanner
|
|
|
81
|
+address is 0x21
|
|
|
82
|
+
|
|
|
83
|
+Need to be able to read (and write in some cases) to registers as outlined in the
|
|
|
84
|
+Not achieved anything useful with the qr code scanner/i2c in CircuitPy yet
|
|
|
85
|
+# Todo
|
|
|
86
|
+- the next step is to make a library for gui elements such as labels, menus, popup boxes/dialogs/alerts,
|