File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ const connectButton = document.getElementById('connect');
2
2
const refreshButton = document . getElementById ( 'refresh' ) ;
3
3
const startButton = document . getElementById ( 'start' ) ;
4
4
const disconnectButton = document . getElementById ( 'disconnect' ) ;
5
+ const saveImageButton = document . getElementById ( 'save-image' ) ;
5
6
const canvas = document . getElementById ( 'bitmapCanvas' ) ;
6
7
const ctx = canvas . getContext ( '2d' ) ;
7
8
@@ -211,6 +212,14 @@ refreshButton.addEventListener('click', () => {
211
212
renderFrame ( currentPort ) ;
212
213
} ) ;
213
214
215
+ saveImageButton . addEventListener ( 'click' , ( ) => {
216
+ const link = document . createElement ( 'a' ) ;
217
+ link . download = 'image.png' ;
218
+ link . href = canvas . toDataURL ( ) ;
219
+ link . click ( ) ;
220
+ link . remove ( ) ;
221
+ } ) ;
222
+
214
223
navigator . serial . addEventListener ( "connect" , ( e ) => {
215
224
// Connect to `e.target` or add it to a list of available ports.
216
225
console . log ( '🔌 Serial port became available. VID: 0x' + e . target . getInfo ( ) . usbVendorId . toString ( 16 ) ) ;
Original file line number Diff line number Diff line change 12
12
< div id ="controls ">
13
13
< button id ="connect "> Connect</ button >
14
14
< button id ="disconnect "> Disconnect</ button >
15
+ < button id ="save-image "> Save Image</ button >
15
16
< button id ="refresh "> Refresh</ button >
16
17
< button id ="start "> Start</ button >
17
18
</ div >
You can’t perform that action at this time.
0 commit comments