Explorar el Código

generate pcb 3d files and visualize in docs

Thomas Buck hace 11 meses
padre
commit
3ef7ed6884

+ 1
- 1
.github/workflows/docs.yml Ver fichero

@@ -54,7 +54,7 @@ jobs:
54 54
         run: |
55 55
           sudo add-apt-repository --yes ppa:kicad/kicad-7.0-releases
56 56
           sudo apt update
57
-          sudo apt install -y --install-recommends kicad
57
+          sudo apt install -y --install-recommends kicad prusa-slicer
58 58
 
59 59
       - name: Install latest mdbook
60 60
         run: |

+ 3
- 0
.gitmodules Ver fichero

@@ -1,3 +1,6 @@
1 1
 [submodule "docs/svg-pan-zoom"]
2 2
 	path = docs/svg-pan-zoom
3 3
 	url = https://github.com/bumbu/svg-pan-zoom
4
+[submodule "docs/modelview"]
5
+	path = docs/modelview
6
+	url = https://github.com/jschobben/modelview

+ 1
- 0
README.md Ver fichero

@@ -13,6 +13,7 @@ This project is licensed under the [CERN Open Hardware Licence Version 2 - Stron
13 13
 
14 14
 The docs are built using [mdbook](https://github.com/rust-lang/mdBook), licensed as `MPL-2.0`.
15 15
 The PCB SVG files in the documentation are displayed using [svg-pan-zoom](https://github.com/bumbu/svg-pan-zoom), licensed as `BSD-2-Clause`.
16
+The 3D PCB files in the documentation are displayed using [modelview](https://github.com/jschobben/modelview), licensed as `MIT`.
16 17
 
17 18
 Please also take a look at the `README.md` files in the subfolders of this project for more info.
18 19
 

+ 1
- 0
docs/.gitignore Ver fichero

@@ -1,3 +1,4 @@
1 1
 book
2 2
 src/plot
3 3
 src/inc_*.md
4
+src/js/deps

+ 1
- 0
docs/README.md Ver fichero

@@ -6,6 +6,7 @@ This file is intended for contributors that want to modify this website!
6 6
 ## Dependencies
7 7
 
8 8
 The PCB SVG files are displayed using [svg-pan-zoom](https://github.com/bumbu/svg-pan-zoom), licensed as `BSD-2-Clause`.
9
+The 3D PCB files are displayed using [modelview](https://github.com/jschobben/modelview), licensed as `MIT`.
9 10
 Fetch the included git submodules after cloning this repository before working on the docs.
10 11
 
11 12
     git submodule update --init

+ 8
- 0
docs/generate_docs.sh Ver fichero

@@ -52,6 +52,14 @@ for f in `ls src/plot/dispensy_sch.svg/*.svg | sort -r`; do
52 52
     echo >> src/inc_dispensy_sch.md
53 53
 done
54 54
 
55
+echo "Preparing modelview dependencies"
56
+cd modelview
57
+sed -i 's/info\.inner/info_elem\.inner/g' modelview.js
58
+./fetch_deps.sh
59
+cd ..
60
+rm -rf src/js/deps
61
+cp -r modelview/deps src/js
62
+
55 63
 echo "Generating docs"
56 64
 if [ "$1" = "serve" ] ; then
57 65
     mdbook serve --open

+ 1
- 0
docs/modelview

@@ -0,0 +1 @@
1
+Subproject commit d3f2ffd2cd04e263b4db3910023b6c028bd0eb64

+ 1
- 0
docs/src/js/modelview.js Ver fichero

@@ -0,0 +1 @@
1
+../../modelview/modelview.js

+ 36
- 1
docs/src/main_board_pcb.md Ver fichero

@@ -4,12 +4,47 @@ This page shows the current version of the PCB layout as SVG graphics.
4 4
 
5 5
 You can also view the [Main-Board PCB layout as PDF](./plot/dispensy_pcb.pdf).
6 6
 
7
+## 2D PCB Layout
8
+
7 9
 <script src="js/svg-pan-zoom.js" charset="UTF-8"></script>
8 10
 <div style="background-color: white;">
9
-    <embed type="image/svg+xml" src="./plot/dispensy_pcb.svg" id="pz_dispensy" style="width:100%;"/>
11
+    <embed type="image/svg+xml" src="./plot/dispensy_pcb.svg" id="pz_dispensy" style="width: 100%;"/>
10 12
     <script>
11 13
         document.getElementById('pz_dispensy').addEventListener('load', function(){
12 14
             svgPanZoom(document.getElementById('pz_dispensy'), {controlIconsEnabled: true});
13 15
         })
14 16
     </script>
15 17
 </div>
18
+
19
+## 3D PCB Model
20
+
21
+<p>Status: "<span id="3d_info">Preparing 3D model...</span>"</p>
22
+<div id="3d_viewer" style="width: 100%; height: 100%;" />
23
+<script type="module">
24
+    var view = document.getElementById('3d_viewer');
25
+    view.style.height = (view.clientWidth / 2) + "px";
26
+    var info = document.getElementById('3d_info');
27
+    import * as View from './js/modelview.js';
28
+    View.init(view, info);
29
+    const file = './plot/dispensy_pcb.3mf';
30
+    var xhttp = new XMLHttpRequest();
31
+    xhttp.responseType = 'arraybuffer';
32
+    xhttp.onload = function() {
33
+        if (this.status != 200) {
34
+            info.textContent = "Download of " + file + " failed: " + this.status + " " + this.statusText;
35
+            return;
36
+        }
37
+        info.textContent = "Downloaded: " + file;
38
+        var file_parts = file.split(".");
39
+        var ext = file_parts.pop().toLowerCase();
40
+        if (ext == "zip") {
41
+            ext = file_parts.pop().toLowerCase();
42
+        }
43
+        info.textContent = "Loaded file with extension: " + ext;
44
+        var model_data = this.response;
45
+        View.view(ext, model_data);
46
+    };
47
+    info.textContent = "Fetching: " + file;
48
+    xhttp.open("GET", file);
49
+    xhttp.send();
50
+</script>

+ 15
- 2
hardware/generate_plot.sh Ver fichero

@@ -37,14 +37,14 @@ mkdir -p $OUTDIR
37 37
 for VAR in pdf svg
38 38
 do
39 39
     echo "Exporting schematic $VAR"
40
-    rm -rf dispensy_sch.$VAR
40
+    rm -rf $OUTDIR/dispensy_sch.$VAR
41 41
     kicad-cli sch export $VAR \
42 42
         -t "KiCad Default" \
43 43
         -o $OUTDIR/dispensy_sch.$VAR \
44 44
         dispensy.kicad_sch
45 45
 
46 46
     echo "Exporting board $VAR"
47
-    rm -rf dispensy_pcb.$VAR
47
+    rm -rf $OUTDIR/dispensy_pcb.$VAR
48 48
     kicad-cli pcb export $VAR \
49 49
         -t "KiCad Classic"  \
50 50
         -l $LAYER \
@@ -52,3 +52,16 @@ do
52 52
         dispensy.kicad_pcb
53 53
     echo
54 54
 done
55
+
56
+echo "Exporting board step file"
57
+rm -rf $OUTDIR/dispensy_pcb.step
58
+kicad-cli pcb export step \
59
+    -o $OUTDIR/dispensy_pcb.step \
60
+    dispensy.kicad_pcb
61
+
62
+echo "Converting step to 3mf"
63
+rm -rf $OUTDIR/dispensy_pcb.3mf
64
+prusa-slicer --export-3mf $OUTDIR/dispensy_pcb.step
65
+
66
+echo "Deleting step file"
67
+rm -rf $OUTDIR/dispensy_pcb.step

Loading…
Cancelar
Guardar