1 package com.neuronrobotics.bowlerstudio.scripting;
4 import java.io.InputStreamReader;
5 import java.util.ArrayList;
6 import java.util.Arrays;
7 import java.util.HashMap;
11 private static String
ARDUINO =
"arduino";
13 HashMap<String, HashMap<String, Object>> database;
19 @SuppressWarnings(
"unchecked")
21 public Object
inlineScriptRun(File code, ArrayList<Object> args)
throws Exception {
23 args =
new ArrayList<>();
25 if (database ==
null) {
27 .gitScriptRun(
"https://github.com/madhephaestus/Arduino-Boards-JSON.git",
32 if (args.size() > 0) {
37 if (args.size() > 1) {
50 execString +=
" --upload " + ino.getAbsolutePath().replaceAll(
" ",
"\\ ");
63 public static void installBoard(String product, String arch)
throws Exception {
71 public static void run(String execString)
throws Exception {
72 System.out.println(
"Running:\n" + execString);
74 java.lang.Runtime rt = java.lang.Runtime.getRuntime();
76 java.lang.Process p = rt.exec(execString);
80 java.io.InputStream is = p.getInputStream();
81 java.io.InputStream err = p.getInputStream();
82 java.io.BufferedReader reader =
new java.io.BufferedReader(
new InputStreamReader(is));
83 java.io.BufferedReader readerErr =
new java.io.BufferedReader(
new InputStreamReader(err));
87 while ((s = reader.readLine()) !=
null) {
88 System.out.println(s);
92 while ((s = readerErr.readLine()) !=
null) {
93 System.out.println(s);
103 if (start.getName().endsWith(
".ino")) {
106 File dir = start.getParentFile();
108 for (File f : dir.listFiles()) {
158 +
" Turns an LED on for one second, then off for one second, repeatedly.\n"
160 +
" Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO\n"
161 +
" it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to\n"
162 +
" the correct LED pin independent of which board is used.\n"
163 +
" If you want to know what pin the on-board LED is connected to on your Arduino\n"
164 +
" model, check the Technical Specs of your board at:\n"
165 +
" https://www.arduino.cc/en/Main/Products\n"
167 +
" modified 8 May 2014\n"
168 +
" by Scott Fitzgerald\n"
169 +
" modified 2 Sep 2016\n"
170 +
" by Arturo Guadalupi\n"
171 +
" modified 8 Sep 2016\n"
172 +
" by Colby Newman\n"
174 +
" This example code is in the public domain.\n"
176 +
" https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink\n"
179 +
"// the setup function runs once when you press reset or power the board\n"
181 +
" // initialize digital pin LED_BUILTIN as an output.\n"
182 +
" pinMode(LED_BUILTIN, OUTPUT);\n"
185 +
"// the loop function runs over and over again forever\n"
187 +
" digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)\n"
188 +
" delay(1000); // wait for a second\n"
189 +
" digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW\n"
190 +
" delay(1000); // wait for a second\n"
206 return new ArrayList<>(Arrays.asList(
".ino",
".c",
".h",
".cpp",
".hpp"));
static String getDefaultPort()
static void run(String execString)
static void setDefaultPort(String defaultPort)
static String getDefaultBoard()
static String defaultBoard
static String getARDUINOExec()
static void installBoard(String product, String arch)
static void setDefaultBoard(String defaultBoard)
static boolean loadedBowler
String getDefaultContents()
static String defaultPort
Object inlineScriptRun(File code, ArrayList< Object > args)
ArrayList< String > getFileExtenetion()
static void installLibrary(String lib)
static void setARDUINOExec(String aRDUINO)
Object inlineScriptRun(String code, ArrayList< Object > args)