ソースを参照

added code snippet for display bmp and png

cube 1 ヶ月 前
コミット
e72f00690f
共有1 個のファイルを変更した20 個の追加3 個の削除を含む
  1. 20
    3
      CARDPUTER CircuitPython/README.md

+ 20
- 3
CARDPUTER CircuitPython/README.md ファイルの表示

@@ -24,6 +24,7 @@ while True:
24 24
 ```
25 25
 
26 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
+
27 28
 ## keyboard library
28 29
 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
 
@@ -40,6 +41,7 @@ while True:
40 41
 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
 
42 43
 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. 
44
+
43 45
 ## Issues
44 46
 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 47
 
@@ -71,11 +73,26 @@ with open("/sd/data.txt") as f:
71 73
     lines = f.readlines()
72 74
 ```
73 75
 
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.
76
+# Display BMP
77
+```
78
+bmp = displayio.OnDiskBitmap("/barcodes/HERA.bmp")
79
+tile_grid = displayio.TileGrid(bmp, pixel_shader=bmp.pixel_shader)
80
+tile_grid.x = 30
81
+tile_grid.y = 15
82
+display_group.append(tile_grid)
75 83
 
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.
84
+```
77 85
 
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.
86
+# Display PNG
87
+Uses the `adafruit_imageload` library, which requires installing from the bundle or with circup. `display_group` here is whatever group you are using for the display. 
88
+
89
+```
90
+bmp, palette = adafruit_imageload.load("/sd/platinum/25.png")
91
+tile_grid = displayio.TileGrid(bmp, pixel_shader=palette)
92
+tile_grid.x = 30
93
+tile_grid.y = 5
94
+display_group.append(tile_grid)
95
+```
79 96
 
80 97
 # QR (barcode) scanner
81 98
 address is 0x21