-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
42 lines (37 loc) · 1.45 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var gulp = require('gulp');
var shell = require('gulp-shell');
var options = {
projectName: 'firmware',
port: '/dev/ttyUSB0',
speed: 9600,
package: 'arduino',
architecture: 'avr',
board: 'nano',
cpu: 'atmega328',
verbose: true,
noticeOnSuccess: true,
noticeOnFail: true
};
gulp.watch([
'src/' + options.projectName + '/*.cpp',
'src/' + options.projectName + '/*.h',
'src/' + options.projectName + '/*.ino'], ['default']);
gulp.task('upload', function (done) {
shell.task([
'killall -9 -q cat',
'arduino --board ' + options.package + ':' + options.architecture + ':' + options.board + ':cpu=' + options.cpu + ' --port ' + options.port + ' --upload src/' + options.projectName + '/' + options.projectName + '.ino' + (options.verbose ? ' --verbose' : ''),
'stty -F ' + options.port + ' cs8 ' + options.speed + ' ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts'
])(function (err) {
done();
var tasks = [];
if (err) {
options.noticeOnFail && tasks.push('paplay /usr/share/sounds/ubuntu/notifications/Amsterdam.ogg');
} else {
options.noticeOnSuccess && tasks.push('paplay /usr/share/sounds/ubuntu/notifications/Positive.ogg');
tasks.push('cat ' + options.port);
}
shell.task(tasks)();
});
});
gulp.task('default', ['upload'], function () {
});