Browse Source

generate pcb 3d files and visualize in docs

Thomas Buck 11 months ago
parent
commit
3ef7ed6884

+ 1
- 1
.github/workflows/docs.yml View File

54
         run: |
54
         run: |
55
           sudo add-apt-repository --yes ppa:kicad/kicad-7.0-releases
55
           sudo add-apt-repository --yes ppa:kicad/kicad-7.0-releases
56
           sudo apt update
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
       - name: Install latest mdbook
59
       - name: Install latest mdbook
60
         run: |
60
         run: |

+ 3
- 0
.gitmodules View File

1
 [submodule "docs/svg-pan-zoom"]
1
 [submodule "docs/svg-pan-zoom"]
2
 	path = docs/svg-pan-zoom
2
 	path = docs/svg-pan-zoom
3
 	url = https://github.com/bumbu/svg-pan-zoom
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 View File

13
 
13
 
14
 The docs are built using [mdbook](https://github.com/rust-lang/mdBook), licensed as `MPL-2.0`.
14
 The docs are built using [mdbook](https://github.com/rust-lang/mdBook), licensed as `MPL-2.0`.
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`.
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
 Please also take a look at the `README.md` files in the subfolders of this project for more info.
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 View File

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

+ 1
- 0
docs/README.md View File

6
 ## Dependencies
6
 ## Dependencies
7
 
7
 
8
 The PCB SVG files are displayed using [svg-pan-zoom](https://github.com/bumbu/svg-pan-zoom), licensed as `BSD-2-Clause`.
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
 Fetch the included git submodules after cloning this repository before working on the docs.
10
 Fetch the included git submodules after cloning this repository before working on the docs.
10
 
11
 
11
     git submodule update --init
12
     git submodule update --init

+ 8
- 0
docs/generate_docs.sh View File

52
     echo >> src/inc_dispensy_sch.md
52
     echo >> src/inc_dispensy_sch.md
53
 done
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
 echo "Generating docs"
63
 echo "Generating docs"
56
 if [ "$1" = "serve" ] ; then
64
 if [ "$1" = "serve" ] ; then
57
     mdbook serve --open
65
     mdbook serve --open

+ 1
- 0
docs/modelview

1
+Subproject commit d3f2ffd2cd04e263b4db3910023b6c028bd0eb64

+ 1
- 0
docs/src/js/modelview.js View File

1
+../../modelview/modelview.js

+ 36
- 1
docs/src/main_board_pcb.md View File

4
 
4
 
5
 You can also view the [Main-Board PCB layout as PDF](./plot/dispensy_pcb.pdf).
5
 You can also view the [Main-Board PCB layout as PDF](./plot/dispensy_pcb.pdf).
6
 
6
 
7
+## 2D PCB Layout
8
+
7
 <script src="js/svg-pan-zoom.js" charset="UTF-8"></script>
9
 <script src="js/svg-pan-zoom.js" charset="UTF-8"></script>
8
 <div style="background-color: white;">
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
     <script>
12
     <script>
11
         document.getElementById('pz_dispensy').addEventListener('load', function(){
13
         document.getElementById('pz_dispensy').addEventListener('load', function(){
12
             svgPanZoom(document.getElementById('pz_dispensy'), {controlIconsEnabled: true});
14
             svgPanZoom(document.getElementById('pz_dispensy'), {controlIconsEnabled: true});
13
         })
15
         })
14
     </script>
16
     </script>
15
 </div>
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 View File

37
 for VAR in pdf svg
37
 for VAR in pdf svg
38
 do
38
 do
39
     echo "Exporting schematic $VAR"
39
     echo "Exporting schematic $VAR"
40
-    rm -rf dispensy_sch.$VAR
40
+    rm -rf $OUTDIR/dispensy_sch.$VAR
41
     kicad-cli sch export $VAR \
41
     kicad-cli sch export $VAR \
42
         -t "KiCad Default" \
42
         -t "KiCad Default" \
43
         -o $OUTDIR/dispensy_sch.$VAR \
43
         -o $OUTDIR/dispensy_sch.$VAR \
44
         dispensy.kicad_sch
44
         dispensy.kicad_sch
45
 
45
 
46
     echo "Exporting board $VAR"
46
     echo "Exporting board $VAR"
47
-    rm -rf dispensy_pcb.$VAR
47
+    rm -rf $OUTDIR/dispensy_pcb.$VAR
48
     kicad-cli pcb export $VAR \
48
     kicad-cli pcb export $VAR \
49
         -t "KiCad Classic"  \
49
         -t "KiCad Classic"  \
50
         -l $LAYER \
50
         -l $LAYER \
52
         dispensy.kicad_pcb
52
         dispensy.kicad_pcb
53
     echo
53
     echo
54
 done
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…
Cancel
Save