use of io.sloeber.providers.MCUBoard in project arduino-eclipse-plugin by Sloeber.
the class CreateAndCompileLibraryExamplesTest method examples.
@SuppressWarnings("rawtypes")
@Parameters(name = "{index}: {0}")
public static Collection examples() {
WaitForInstallerToFinish();
Preferences.setUseArduinoToolSelection(true);
MCUBoard[] myBoards = { Arduino.leonardo(), Arduino.uno(), Arduino.esplora(), Adafruit.feather(), Arduino.adafruitnCirquitPlayground(), ESP8266.nodeMCU(), ESP8266.wemosD1(), ESP8266.ESPressoLite(), Teensy.Teensy3_6(), Arduino.zero(), Arduino.cirquitPlaygroundExpress(), Arduino.gemma(), Adafruit.trinket8MH(), Arduino.yun() };
LinkedList<Object[]> examples = new LinkedList<>();
TreeMap<String, IPath> exampleFolders = LibraryManager.getAllExamples(null);
for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
String fqn = curexample.getKey().trim();
IPath examplePath = curexample.getValue();
Examples example = new Examples(fqn, null, examplePath);
// with the current amount of examples only do one
MCUBoard curBoard = Examples.pickBestBoard(example, myBoards);
if (curBoard != null) {
Object[] theData = new Object[] { example.getLibName() + ":" + fqn + ":" + curBoard.getName(), curBoard, example };
examples.add(theData);
}
}
return examples;
}
use of io.sloeber.providers.MCUBoard in project arduino-eclipse-plugin by Sloeber.
the class CompileAndUpload method examples.
@SuppressWarnings("rawtypes")
@Parameters(name = "{index}: {0}")
public static Collection examples() {
WaitForInstallerToFinish();
try {
File file = ConfigurationPreferences.getInstallationPath().append("test.properties").toFile();
if (!file.exists()) {
file.createNewFile();
}
Properties properties = new Properties();
try (FileInputStream fileInput = new FileInputStream(file)) {
properties.load(fileInput);
fileInput.close();
}
String key = "Last Used Blink Interval";
interval = properties.getProperty(key);
if ("100".equals(interval)) {
interval = "1500";
} else {
interval = "100";
}
properties.put(key, interval);
try (FileOutputStream fileOutput = new FileOutputStream(file)) {
properties.store(fileOutput, "This is a file with values for unit testing");
fileOutput.close();
}
} catch (IOException e1) {
e1.printStackTrace();
}
MCUBoard[] boards = MySystem.getUploadBoards();
// , new NodeMCUBoard()
LinkedList<Object[]> examples = new LinkedList<>();
for (MCUBoard curBoard : boards) {
examples.add(new Object[] { curBoard.getName(), curBoard });
}
return examples;
}
use of io.sloeber.providers.MCUBoard in project arduino-eclipse-plugin by Sloeber.
the class CreateAndCompileExamplesTest method examples.
@SuppressWarnings("rawtypes")
@Parameters(name = "{index}: {0}")
public static Collection examples() {
WaitForInstallerToFinish();
MCUBoard[] myBoards = { Arduino.leonardo(), Arduino.uno(), Arduino.esplora(), Adafruit.feather(), Arduino.adafruitnCirquitPlayground(), ESP8266.nodeMCU(), Arduino.primo(), Arduino.getMega2560Board(), Arduino.gemma(), Arduino.zero(), Arduino.mkrfox1200(), Arduino.due() };
LinkedList<Object[]> examples = new LinkedList<>();
TreeMap<String, IPath> exampleFolders = LibraryManager.getAllLibraryExamples();
for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
ArrayList<IPath> paths = new ArrayList<>();
paths.add(new Path(curexample.getValue().toString()));
CodeDescriptor codeDescriptor = CodeDescriptor.createExample(false, paths);
String fqn = curexample.getKey();
String libName = "";
if (examples.size() == 82) {
// use this for debugging based on the
// project number
// use this to put breakpoint
int a = 0;
a = a + 1;
}
try {
libName = fqn.split(" ")[0].trim();
} catch (Exception e) {
// ignore error
}
Examples example = new Examples(fqn, libName, curexample.getValue());
// with the current amount of examples only do one
BoardDescriptor curBoard = Examples.pickBestBoard(example, myBoards).getBoardDescriptor();
if (curBoard != null) {
Object[] theData = new Object[] { fqn.trim(), curBoard, codeDescriptor };
examples.add(theData);
}
}
return examples;
}
use of io.sloeber.providers.MCUBoard in project arduino-eclipse-plugin by Sloeber.
the class Examples method pickBestBoard.
/**
* Give a list of boards pick the board that is best to test this code Boards in
* the beginning of the array are prefered (first found ok algorithm)
*
* returns null if this code should not be tested return null if myBoards is
* empty returns the best known boarddescriptor to run this example
*/
public static MCUBoard pickBestBoard(Examples example, MCUBoard[] myBoards) {
String libName = example.getLibName();
String fqn = example.getFQN();
if (myBoards.length == 0) {
return null;
}
/*
* This example does not build out of the box
*/
if (example.getRequiredBoardAttributes().worksOutOfTheBox) {
return null;
}
// if the boardname is in the libname or ino name pick this one
for (MCUBoard curBoard : myBoards) {
String curBoardName = curBoard.getSlangName().toLowerCase();
if (libName.toLowerCase().contains(curBoardName) || fqn.toLowerCase().contains(curBoardName)) {
if (curBoard.isExampleSupported(example)) {
return curBoard;
}
}
}
// If the archtecture is in the libname or boardname pick this one
for (MCUBoard curBoard : myBoards) {
String curArchitectureName = curBoard.getBoardDescriptor().getArchitecture().toLowerCase();
if (libName.toLowerCase().contains(curArchitectureName) || fqn.toLowerCase().contains(curArchitectureName)) {
if (curBoard.isExampleSupported(example)) {
return curBoard;
}
}
}
// Out of guesses based on the name. Take the first ok one
for (MCUBoard curBoard : myBoards) {
if (curBoard.isExampleSupported(example)) {
return curBoard;
}
}
System.out.println("No board found for " + Integer.toString(++noBoardFoundCount) + " " + example.getFQN());
return null;
}
Aggregations