Skip to content

Commit 275b806

Browse files
committed
Adding support for deployment and launching serial monitor
1 parent 52634cc commit 275b806

File tree

4 files changed

+54
-8
lines changed

4 files changed

+54
-8
lines changed

plugin/vim-arduino

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
pde_file=
1414
board="uno"
1515
port=
16+
switch="-c"
1617

1718
while [ $# -gt 0 ]
1819
do
@@ -27,6 +28,14 @@ do
2728
board=$1
2829
shift
2930
;;
31+
-d|--deploy)
32+
switch="-d"
33+
shift
34+
;;
35+
-c|--compile)
36+
switch="-c"
37+
shift
38+
;;
3039
*)
3140
if [ -z "$pde_file" ]
3241
then pde_file="$1"
@@ -66,5 +75,5 @@ java \
6675
-Djava.library.path=/Applications/Arduino.app/Contents/Resources/Java \
6776
-d32 \
6877
-Dfile.encoding=MacRoman \
69-
-classpath /Applications/Arduino.app/Contents/Resources/Java \
70-
-jar "$DIR/vim-arduino-cli.jar" "$pde_file" "$port" "$board"
78+
-Djava.awt.headless=true \
79+
-jar "$DIR/vim-arduino-cli.jar" "$switch" "$pde_file" "$port" "$board"

plugin/vim-arduino-cli.jar

-1.73 MB
Binary file not shown.

plugin/vim-arduino-serial

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
echo "use Ctrl-a, k to exit the screen utility"
4+
5+
port=$(ls /dev/tty.* | grep usb)
6+
# osascript -e 'tell application "Terminal" to do script "screen '.$port'"'
7+
osascript -e \
8+
"tell application \"iTerm\"
9+
activate
10+
set myterm to (make new terminal)
11+
tell myterm
12+
launch session \"Default\"
13+
set _session to current session
14+
tell _session
15+
write text \"screen $port\"
16+
end tell
17+
end tell
18+
end tell"

plugin/vim-arduino.vim

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,31 +57,49 @@ function! s:CheckFile()
5757
endif
5858
endfunction
5959

60-
" Public: Compile the current pde file.
60+
" Private: Compile or deploy code
6161
"
6262
" Returns nothing.
63-
function! ArduinoCompile()
63+
function! s:InvokeArduinoCli(deploy)
64+
let l:flag = a:deploy ? "-d" : "-c"
6465
let l:f_name = s:CheckFile()
6566
if !empty(l:f_name)
66-
echomsg "Compiling..." l:f_name
67-
let l:result = system(s:helper_dir."/vim-arduino " . shellescape(l:f_name))
67+
execute "w"
68+
if a:deploy
69+
echomsg "Compiling and deploying..." l:f_name
70+
else
71+
echomsg "Compiling..." l:f_name
72+
endif
73+
74+
let l:result = system(s:helper_dir."/vim-arduino " . l:flag . " " . shellescape(l:f_name))
6875
if v:shell_error == 0
6976
echomsg "Done"
7077
else
78+
echo l:result
7179
echohl WarningMsg
7280
echomsg "Compilation Failed"
7381
echohl None
74-
echomsg l:result
7582
endif
7683
endif
84+
7785
endfunction
7886

87+
" Public: Compile the current pde file.
88+
"
89+
" Returns nothing.
90+
function! ArduinoCompile()
91+
call s:InvokeArduinoCli(0)
92+
endfunction
7993

8094
" Public: Compile and Deploy the current pde file.
8195
"
8296
" Returns nothing.
8397
function! ArduinoDeploy()
84-
echo "deploy"
98+
call s:InvokeArduinoCli(1)
99+
endfunction
100+
101+
function! ArduinoSerialMonitor()
102+
echo system(s:helper_dir."/vim-arduino-serial")
85103
endfunction
86104

87105
if !exists('g:vim_arduino_map_keys')
@@ -91,4 +109,5 @@ endif
91109
if g:vim_arduino_map_keys
92110
nnoremap <leader>ac :call ArduinoCompile()<CR>
93111
nnoremap <leader>ad :call ArduinoDeploy()<CR>
112+
nnoremap <leader>as :call ArduinoSerialMonitor()<CR>
94113
endif

0 commit comments

Comments
 (0)