1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-19 08:52:15 +01:00

Merge branch 'master' into add-file-cache

This commit is contained in:
Martino Facchin 2019-07-18 11:28:46 +02:00 committed by GitHub
commit 9ce5101df1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
65 changed files with 1006 additions and 227 deletions

Binary file not shown.

Binary file not shown.

View File

@ -213,6 +213,7 @@ public class ContributedLibraryTableCellJPanel extends JPanel {
}
}
// TODO Make this a method of Theme
private JTextPane makeNewDescription() {
if (getComponentCount() > 0) {
remove(0);

View File

@ -52,6 +52,7 @@ import cc.arduino.contributions.libraries.ContributedLibrary;
import cc.arduino.contributions.libraries.ContributedLibraryReleases;
import cc.arduino.contributions.libraries.LibraryInstaller;
import cc.arduino.contributions.libraries.LibraryTypeComparator;
import cc.arduino.contributions.libraries.ui.MultiLibraryInstallDialog.Result;
import cc.arduino.contributions.ui.DropdownItem;
import cc.arduino.contributions.ui.FilteredAbstractTableModel;
import cc.arduino.contributions.ui.InstallerJDialog;
@ -85,7 +86,7 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibraryRelease
if (mayInstalledLibrary.isPresent() && selectedLibrary.isIDEBuiltIn()) {
onRemovePressed(mayInstalledLibrary.get());
} else {
onInstallPressed(selectedLibrary, mayInstalledLibrary);
onInstallPressed(selectedLibrary);
}
}
@ -213,12 +214,30 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibraryRelease
installerThread.start();
}
public void onInstallPressed(final ContributedLibrary lib, final Optional<ContributedLibrary> mayReplaced) {
public void onInstallPressed(final ContributedLibrary lib) {
List<ContributedLibrary> deps = BaseNoGui.librariesIndexer.getIndex().resolveDependeciesOf(lib);
boolean depsInstalled = deps.stream().allMatch(l -> l.getInstalledLibrary().isPresent() || l.getName().equals(lib.getName()));
Result installDeps;
if (!depsInstalled) {
MultiLibraryInstallDialog dialog;
dialog = new MultiLibraryInstallDialog(this, lib, deps);
dialog.setLocationRelativeTo(this);
dialog.setVisible(true);
installDeps = dialog.getInstallDepsResult();
if (installDeps == Result.CANCEL)
return;
} else {
installDeps = Result.NONE;
}
clearErrorMessage();
installerThread = new Thread(() -> {
try {
setProgressVisible(true, tr("Installing..."));
installer.install(lib, mayReplaced, this::setProgress);
if (installDeps == Result.ALL) {
installer.install(deps, this::setProgress);
} else {
installer.install(lib, this::setProgress);
}
// TODO: Do a better job in refreshing only the needed element
if (contribTable.getCellEditor() != null) {
contribTable.getCellEditor().stopCellEditing();

View File

@ -0,0 +1,177 @@
/*
* This file is part of Arduino.
*
* Copyright 2017 Arduino LLC (http://www.arduino.cc/)
*
* Arduino is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As a special exception, you may use this file as part of a free software
* library without restriction. Specifically, if other files instantiate
* templates or use macros or inline functions from this file, or you compile
* this file and link it with other files to produce an executable, this
* file does not by itself cause the resulting executable to be covered by
* the GNU General Public License. This exception does not however
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
package cc.arduino.contributions.libraries.ui;
import static processing.app.I18n.format;
import static processing.app.I18n.tr;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Insets;
import java.awt.Window;
import java.awt.event.WindowEvent;
import java.util.List;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.text.Document;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.StyleSheet;
import cc.arduino.contributions.libraries.ContributedLibrary;
import cc.arduino.contributions.libraries.UnavailableContributedLibrary;
import processing.app.Base;
import processing.app.Theme;
public class MultiLibraryInstallDialog extends JDialog {
enum Result {
ALL, NONE, CANCEL
}
private Result result = Result.CANCEL;
public MultiLibraryInstallDialog(Window parent, ContributedLibrary lib,
List<ContributedLibrary> dependencies) {
super(parent, format(tr("Dependencies for library {0}:{1}"), lib.getName(),
lib.getParsedVersion()),
ModalityType.APPLICATION_MODAL);
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
pane.add(Box.createHorizontalStrut(10), BorderLayout.WEST);
pane.add(Box.createHorizontalStrut(10), BorderLayout.EAST);
{
JButton cancel = new JButton(tr("Cancel"));
cancel.addActionListener(ev -> {
result = Result.CANCEL;
setVisible(false);
});
JButton all = new JButton(tr("Install all"));
all.addActionListener(ev -> {
result = Result.ALL;
setVisible(false);
});
JButton none = new JButton(format(tr("Install '{0}' only"), lib.getName()));
none.addActionListener(ev -> {
result = Result.NONE;
setVisible(false);
});
Box buttonsBox = Box.createHorizontalBox();
buttonsBox.add(all);
buttonsBox.add(Box.createHorizontalStrut(5));
buttonsBox.add(none);
buttonsBox.add(Box.createHorizontalStrut(5));
buttonsBox.add(cancel);
JPanel buttonsPanel = new JPanel();
buttonsPanel.setBorder(new EmptyBorder(7, 10, 7, 10));
buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.Y_AXIS));
buttonsPanel.add(buttonsBox);
pane.add(buttonsPanel, BorderLayout.SOUTH);
}
{
String libName = format("<b>{0}:{1}</b>", lib.getName(),
lib.getParsedVersion());
String desc = format(tr("The library {0} needs some other library<br />dependencies currently not installed:"),
libName);
desc += "<br/><br/>";
for (ContributedLibrary l : dependencies) {
if (l.getName().equals(lib.getName()))
continue;
if (l.getInstalledLibrary().isPresent())
continue;
if (l instanceof UnavailableContributedLibrary)
continue;
desc += format("- <b>{0}</b><br/>", l.getName());
}
desc += "<br/>";
desc += tr("Would you like to install also all the missing dependencies?");
JTextPane textArea = makeNewDescription();
textArea.setContentType("text/html");
textArea.setText(desc);
JPanel libsList = new JPanel();
libsList.setLayout(new BoxLayout(libsList, BoxLayout.Y_AXIS));
libsList.add(textArea);
libsList.setBorder(new EmptyBorder(7, 7, 7, 7));
pane.add(libsList, BorderLayout.NORTH);
}
pack();
setResizable(false);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
WindowEvent closing = new WindowEvent(this, WindowEvent.WINDOW_CLOSING);
Base.registerWindowCloseKeys(getRootPane(), e -> dispatchEvent(closing));
}
// TODO Make this a method of Theme
private JTextPane makeNewDescription() {
JTextPane description = new JTextPane();
description.setInheritsPopupMenu(true);
Insets margin = description.getMargin();
margin.bottom = 0;
description.setMargin(margin);
description.setContentType("text/html");
Document doc = description.getDocument();
if (doc instanceof HTMLDocument) {
HTMLDocument html = (HTMLDocument) doc;
StyleSheet s = html.getStyleSheet();
s.addRule("body { margin: 0; padding: 0;"
+ "font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"
+ "color: black;" + "font-size: " + 15 * Theme.getScale() / 100
+ "; }");
}
description.setOpaque(false);
description.setBorder(new EmptyBorder(4, 7, 7, 7));
description.setHighlighter(null);
description.setEditable(false);
add(description, 0);
return description;
}
public Result getInstallDepsResult() {
return result;
}
}

View File

@ -30,24 +30,23 @@
package cc.arduino.packages;
import processing.app.AbstractMonitor;
import processing.app.Base;
import processing.app.NetworkMonitor;
import processing.app.SerialMonitor;
public class MonitorFactory {
public AbstractMonitor newMonitor(Base base, BoardPort port) {
public AbstractMonitor newMonitor(BoardPort port) {
if ("network".equals(port.getProtocol())) {
if ("yes".equals(port.getPrefs().get("ssh_upload"))) {
// the board is SSH capable
return new NetworkMonitor(base, port);
return new NetworkMonitor(port);
} else {
// SSH not supported, no monitor support
return null;
}
}
return new SerialMonitor(base, port);
return new SerialMonitor(port);
}
}

View File

@ -1,6 +1,7 @@
package processing.app;
import cc.arduino.packages.BoardPort;
import cc.arduino.packages.DiscoveryManager;
import processing.app.legacy.PApplet;
import javax.swing.*;
@ -9,6 +10,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.List;
@SuppressWarnings("serial")
public abstract class AbstractMonitor extends JFrame implements ActionListener {
@ -17,6 +19,7 @@ public abstract class AbstractMonitor extends JFrame implements ActionListener {
private StringBuffer updateBuffer;
private Timer updateTimer;
private Timer portExistsTimer;
private BoardPort boardPort;
@ -73,6 +76,26 @@ public abstract class AbstractMonitor extends JFrame implements ActionListener {
updateTimer = new Timer(33, this); // redraw serial monitor at 30 Hz
updateTimer.start();
ActionListener portExists = new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
try {
if (!Base.getDiscoveryManager().discovery().contains(boardPort)) {
if (!closed) {
suspend();
}
} else {
if (closed && (Editor.avoidMultipleOperations == false)) {
resume(boardPort);
}
}
} catch (Exception e) {}
}
};
portExistsTimer = new Timer(1000, portExists); // check if the port is still there every second
portExistsTimer.start();
closed = false;
}
@ -92,6 +115,11 @@ public abstract class AbstractMonitor extends JFrame implements ActionListener {
close();
}
public void dispose() {
super.dispose();
portExistsTimer.stop();
}
public void resume(BoardPort boardPort) throws Exception {
setBoardPort(boardPort);

View File

@ -8,6 +8,8 @@ import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyListener;
import java.awt.event.MouseWheelListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.SimpleDateFormat;
@ -46,12 +48,21 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
protected JComboBox<String> lineEndings;
protected JComboBox<String> serialRates;
public AbstractTextMonitor(Base base, BoardPort boardPort) {
public AbstractTextMonitor(BoardPort boardPort) {
super(boardPort);
}
// Add font size adjustment listeners. This has to be done here due to
// super(boardPort) invoking onCreateWindow(...) before we can store base.
base.addEditorFontResizeListeners(textArea);
@Override
public synchronized void addMouseWheelListener(MouseWheelListener l) {
super.addMouseWheelListener(l);
textArea.addMouseWheelListener(l);
}
@Override
public synchronized void addKeyListener(KeyListener l) {
super.addKeyListener(l);
textArea.addKeyListener(l);
textField.addKeyListener(l);
}
@Override
@ -125,7 +136,7 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
minimumSize.setSize(minimumSize.getWidth() / 3, minimumSize.getHeight());
noLineEndingAlert.setMinimumSize(minimumSize);
lineEndings = new JComboBox<String>(new String[]{tr("No line ending"), tr("Newline"), tr("Carriage return"), tr("Both NL & CR")});
lineEndings = new JComboBox<>(new String[]{tr("No line ending"), tr("Newline"), tr("Carriage return"), tr("Both NL & CR")});
lineEndings.addActionListener((ActionEvent event) -> {
PreferencesData.setInteger("serial.line_ending", lineEndings.getSelectedIndex());
noLineEndingAlert.setForeground(pane.getBackground());
@ -135,7 +146,7 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
lineEndings.setMaximumSize(lineEndings.getMinimumSize());
serialRates = new JComboBox<String>();
serialRates = new JComboBox<>();
for (String rate : serialRateStrings) {
serialRates.addItem(rate + " " + tr("baud"));
}

View File

@ -386,7 +386,7 @@ public class Base {
library, mayInstalled.get().getParsedVersion())));
libraryInstaller.remove(mayInstalled.get(), progressListener);
} else {
libraryInstaller.install(selected, mayInstalled, progressListener);
libraryInstaller.install(selected, progressListener);
}
}
@ -766,7 +766,20 @@ public class Base {
if (!newbieFile.createNewFile()) {
throw new IOException();
}
FileUtils.copyFile(new File(getContentFile("examples"), "01.Basics" + File.separator + "BareMinimum" + File.separator + "BareMinimum.ino"), newbieFile);
// Initialize the pde file with the BareMinimum sketch.
// Apply user-defined tab settings.
String sketch = FileUtils.readFileToString(
new File(getContentFile("examples"), "01.Basics" + File.separator
+ "BareMinimum" + File.separator + "BareMinimum.ino"));
String currentTab = " ";
String newTab = (PreferencesData.getBoolean("editor.tabs.expand")
? StringUtils.repeat(" ",
PreferencesData.getInteger("editor.tabs.size"))
: "\t");
sketch = sketch.replaceAll(
"(?<=(^|\n)(" + currentTab + "){0,50})" + currentTab, newTab);
FileUtils.writeStringToFile(newbieFile, sketch);
return newbieFile;
}
@ -1438,17 +1451,16 @@ public class Base {
boardMenu.add(new JSeparator());
// Generate custom menus for all platforms
Set<String> customMenusTitles = new LinkedHashSet<>();
for (TargetPackage targetPackage : BaseNoGui.packages.values()) {
for (TargetPlatform targetPlatform : targetPackage.platforms()) {
customMenusTitles.addAll(targetPlatform.getCustomMenus().values());
for (String customMenuTitle : targetPlatform.getCustomMenus().values()) {
JMenu customMenu = new JMenu(tr(customMenuTitle));
customMenu.putClientProperty("platform", getPlatformUniqueId(targetPlatform));
customMenu.putClientProperty("removeOnWindowDeactivation", true);
boardsCustomMenus.add(customMenu);
}
}
}
for (String customMenuTitle : customMenusTitles) {
JMenu customMenu = new JMenu(tr(customMenuTitle));
customMenu.putClientProperty("removeOnWindowDeactivation", true);
boardsCustomMenus.add(customMenu);
}
List<JMenuItem> menuItemsToClickAfterStartup = new LinkedList<>();
@ -1497,6 +1509,10 @@ public class Base {
}
}
private String getPlatformUniqueId(TargetPlatform platform) {
return platform.getId() + "_" + platform.getFolder();
}
private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
final List<JMenu> boardsCustomMenus, List<JMenuItem> menuItemsToClickAfterStartup,
Map<String, ButtonGroup> buttonGroupsMap,
@ -1534,7 +1550,7 @@ public class Base {
PreferencesMap customMenus = targetPlatform.getCustomMenus();
for (final String menuId : customMenus.keySet()) {
String title = customMenus.get(menuId);
JMenu menu = getBoardCustomMenu(tr(title));
JMenu menu = getBoardCustomMenu(tr(title), getPlatformUniqueId(targetPlatform));
if (board.hasMenu(menuId)) {
PreferencesMap boardCustomMenu = board.getMenuLabels(menuId);
@ -1542,11 +1558,16 @@ public class Base {
@SuppressWarnings("serial")
Action subAction = new AbstractAction(tr(boardCustomMenu.get(customMenuOption))) {
public void actionPerformed(ActionEvent e) {
PreferencesData.set("custom_" + menuId, ((TargetBoard) getValue("board")).getId() + "_" + getValue("custom_menu_option"));
PreferencesData.set("custom_" + menuId, ((List<TargetBoard>) getValue("board")).get(0).getId() + "_" + getValue("custom_menu_option"));
onBoardOrPortChange();
}
};
subAction.putValue("board", board);
List<TargetBoard> boards = (List<TargetBoard>) subAction.getValue("board");
if (boards == null) {
boards = new ArrayList<TargetBoard>();
}
boards.add(board);
subAction.putValue("board", boards);
subAction.putValue("custom_menu_option", customMenuOption);
if (!buttonGroupsMap.containsKey(menuId)) {
@ -1574,7 +1595,9 @@ public class Base {
JMenu menu = boardsCustomMenus.get(i);
for (int m = 0; m < menu.getItemCount(); m++) {
JMenuItem menuItem = menu.getItem(m);
menuItem.setVisible(menuItem.getAction().getValue("board").equals(board));
for (TargetBoard t_board : (List<TargetBoard>)menuItem.getAction().getValue("board")) {
menuItem.setVisible(t_board.equals(board));
}
}
menu.setVisible(ifThereAreVisibleItemsOn(menu));
@ -1597,9 +1620,9 @@ public class Base {
return false;
}
private JMenu getBoardCustomMenu(String label) throws Exception {
private JMenu getBoardCustomMenu(String label, String platformUniqueId) throws Exception {
for (JMenu menu : boardsCustomMenus) {
if (label.equals(menu.getText())) {
if (label.equals(menu.getText()) && menu.getClientProperty("platform").equals(platformUniqueId)) {
return menu;
}
}
@ -1872,9 +1895,6 @@ public class Base {
getEditors().forEach(Editor::applyPreferences);
}
private MouseWheelListener editorFontResizeMouseWheelListener = null;
private KeyListener editorFontResizeKeyListener = null;
/**
* Adds a {@link MouseWheelListener} and {@link KeyListener} to the given
* component that will make "CTRL scroll" and "CTRL +/-"
@ -1886,8 +1906,8 @@ public class Base {
* @param comp - The component to add the listener to.
*/
public void addEditorFontResizeListeners(Component comp) {
this.addEditorFontResizeMouseWheelListener(comp);
this.addEditorFontResizeKeyListener(comp);
addEditorFontResizeMouseWheelListener(comp);
addEditorFontResizeKeyListener(comp);
}
/**
@ -1899,20 +1919,17 @@ public class Base {
* @param comp - The component to add the listener to.
*/
public void addEditorFontResizeMouseWheelListener(Component comp) {
if (this.editorFontResizeMouseWheelListener == null) {
this.editorFontResizeMouseWheelListener = (MouseWheelEvent e) -> {
if (e.isControlDown()) {
if (e.getWheelRotation() < 0) {
this.handleFontSizeChange(1);
} else {
this.handleFontSizeChange(-1);
}
comp.addMouseWheelListener(e -> {
if (e.isControlDown()) {
if (e.getWheelRotation() < 0) {
this.handleFontSizeChange(1);
} else {
e.getComponent().getParent().dispatchEvent(e);
this.handleFontSizeChange(-1);
}
};
}
comp.addMouseWheelListener(this.editorFontResizeMouseWheelListener);
} else {
e.getComponent().getParent().dispatchEvent(e);
}
});
}
/**
@ -1922,29 +1939,26 @@ public class Base {
* @param comp - The component to add the listener to.
*/
public void addEditorFontResizeKeyListener(Component comp) {
if (this.editorFontResizeKeyListener == null) {
this.editorFontResizeKeyListener = new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK
|| e.getModifiersEx() == (KeyEvent.CTRL_DOWN_MASK
| KeyEvent.SHIFT_DOWN_MASK)) {
switch (e.getKeyCode()) {
case KeyEvent.VK_PLUS:
case KeyEvent.VK_EQUALS:
Base.this.handleFontSizeChange(1);
break;
case KeyEvent.VK_MINUS:
if (!e.isShiftDown()) {
Base.this.handleFontSizeChange(-1);
}
break;
comp.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK
|| e.getModifiersEx() == (KeyEvent.CTRL_DOWN_MASK
| KeyEvent.SHIFT_DOWN_MASK)) {
switch (e.getKeyCode()) {
case KeyEvent.VK_PLUS:
case KeyEvent.VK_EQUALS:
Base.this.handleFontSizeChange(1);
break;
case KeyEvent.VK_MINUS:
if (!e.isShiftDown()) {
Base.this.handleFontSizeChange(-1);
}
break;
}
}
};
}
comp.addKeyListener(this.editorFontResizeKeyListener);
}
});
}
public List<JMenu> getBoardsCustomMenus() {

View File

@ -181,7 +181,7 @@ public class Editor extends JFrame implements RunnerListener {
private int numTools = 0;
public boolean avoidMultipleOperations = false;
static public boolean avoidMultipleOperations = false;
private final EditorToolbar toolbar;
// these menus are shared so that they needn't be rebuilt for all windows
@ -1015,22 +1015,20 @@ public class Editor extends JFrame implements RunnerListener {
//System.out.println(item.getLabel());
BaseNoGui.selectSerialPort(name);
if (serialMonitor != null) {
try {
try {
boolean reopenMonitor = ((serialMonitor != null && serialMonitor.isVisible()) ||
serialPlotter != null && serialPlotter.isVisible());
if (serialMonitor != null) {
serialMonitor.close();
serialMonitor.setVisible(false);
} catch (Exception e) {
// ignore
}
}
if (serialPlotter != null) {
try {
if (serialPlotter != null) {
serialPlotter.close();
serialPlotter.setVisible(false);
} catch (Exception e) {
// ignore
}
if (reopenMonitor) {
handleSerial();
}
} catch (Exception e) {
// ignore
}
onBoardOrPortChange();
@ -2214,7 +2212,7 @@ public class Editor extends JFrame implements RunnerListener {
return;
}
serialMonitor = new MonitorFactory().newMonitor(base, port);
serialMonitor = new MonitorFactory().newMonitor(port);
if (serialMonitor == null) {
String board = port.getPrefs().get("board");
@ -2223,6 +2221,7 @@ public class Editor extends JFrame implements RunnerListener {
return;
}
base.addEditorFontResizeListeners(serialMonitor);
Base.setIcon(serialMonitor);
// If currently uploading, disable the monitor (it will be later

View File

@ -30,8 +30,6 @@ import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseWheelListener;
import java.awt.event.MouseWheelEvent;
import java.io.IOException;

View File

@ -31,8 +31,8 @@ public class NetworkMonitor extends AbstractTextMonitor implements MessageConsum
private Channel channel;
private int connectionAttempts;
public NetworkMonitor(Base base, BoardPort port) {
super(base, port);
public NetworkMonitor(BoardPort port) {
super(port);
onSendCommand(new ActionListener() {
public void actionPerformed(ActionEvent event) {

View File

@ -32,8 +32,8 @@ public class SerialMonitor extends AbstractTextMonitor {
private Serial serial;
private int serialRate;
public SerialMonitor(Base base, BoardPort port) {
super(base, port);
public SerialMonitor(BoardPort port) {
super(port);
serialRate = PreferencesData.getInteger("serial.debug_rate");
serialRates.setSelectedItem(serialRate + " " + tr("baud"));

View File

@ -46,6 +46,7 @@ public class SerialPlotter extends AbstractMonitor {
private static class Graph {
public CircularBuffer buffer;
private Color color;
public String label;
public Graph(int id) {
buffer = new CircularBuffer(BUFFER_CAPACITY);
@ -185,12 +186,24 @@ public class SerialPlotter extends AbstractMonitor {
g.setTransform(AffineTransform.getTranslateInstance(xOffset, 0));
float xstep = (float) (bounds.width - xOffset - xPadding) / (float) BUFFER_CAPACITY;
int legendLength = graphs.size() * 10 + (graphs.size() - 1) * 3;
// draw legend
int legendXOffset = 0;
for(int i = 0; i < graphs.size(); ++i) {
graphs.get(i).paint(g, xstep, minY, maxY, rangeY, bounds.height);
if(graphs.size() > 1) {
g.fillRect(bounds.width - (xOffset + legendLength + 10) + i * 13, 10, 10, 10);
if(graphs.size() > 1) {
//draw legend rectangle
g.fillRect(10 + legendXOffset, 10, 10, 10);
legendXOffset += 13;
//draw label
g.setColor(boundsColor);
String s = graphs.get(i).label;
if(s != null && s.length() > 0) {
Rectangle2D fBounds = fm.getStringBounds(s, g);
int sWidth = (int)fBounds.getWidth();
g.drawString(s, 10 + legendXOffset, 10 + (int)fBounds.getHeight() /2);
legendXOffset += sWidth + 3;
}
}
}
}
@ -282,17 +295,60 @@ public class SerialPlotter extends AbstractMonitor {
}
int validParts = 0;
int validLabels = 0;
for(int i = 0; i < parts.length; ++i) {
try {
double value = Double.valueOf(parts[i]);
Double value = null;
String label = null;
// column formated name value pair
if(parts[i].contains(":")) {
// get label
String[] subString = parts[i].split("[:]+");
if(subString.length > 0) {
int labelLength = subString[0].length();
if(labelLength > 32) {
labelLength = 32;
}
label = subString[0].substring(0, labelLength);
} else {
label = "";
}
if(subString.length > 1) {
parts[i] = subString[1];
} else {
parts[i] = "";
}
}
try {
value = Double.valueOf(parts[i]);
} catch (NumberFormatException e) {
// ignored
}
//CSV header
if(label == null && value == null) {
label = parts[i];
}
if(value != null) {
if(validParts >= graphs.size()) {
graphs.add(new Graph(validParts));
}
graphs.get(validParts).buffer.add(value);
validParts++;
} catch (NumberFormatException e) {
// ignore
}
if(label != null) {
if(validLabels >= graphs.size()) {
graphs.add(new Graph(validLabels));
}
graphs.get(validLabels).label = label;
validLabels++;
}
if(validParts > validLabels) validLabels = validParts;
else if(validLabels > validParts) validParts = validLabels;
}
}

Binary file not shown.

View File

@ -65,4 +65,7 @@ public class VersionHelper {
}
}
public static int compare(String a, String b) {
return valueOf(a).get().compareTo(valueOf(b).get());
}
}

View File

@ -32,12 +32,13 @@ package cc.arduino.contributions.libraries;
import cc.arduino.contributions.DownloadableContribution;
import processing.app.I18n;
import processing.app.packages.UserLibrary;
import static processing.app.I18n.tr;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import static processing.app.I18n.tr;
import cc.arduino.contributions.VersionHelper;
public abstract class ContributedLibrary extends DownloadableContribution {
@ -63,7 +64,7 @@ public abstract class ContributedLibrary extends DownloadableContribution {
public abstract List<String> getTypes();
public abstract List<ContributedLibraryReference> getRequires();
public abstract List<ContributedLibraryDependency> getDependencies();
public abstract List<String> getProvidesIncludes();
@ -145,8 +146,8 @@ public abstract class ContributedLibrary extends DownloadableContribution {
}
res += "\n";
res += " requires :\n";
if (getRequires() != null)
for (ContributedLibraryReference r : getRequires()) {
if (getDependencies() != null)
for (ContributedLibraryDependency r : getDependencies()) {
res += " " + r;
}
res += "\n";
@ -166,7 +167,7 @@ public abstract class ContributedLibrary extends DownloadableContribution {
String thisVersion = getParsedVersion();
String otherVersion = other.getParsedVersion();
boolean versionEquals = (thisVersion != null && otherVersion != null
boolean versionEquals = (thisVersion != null
&& thisVersion.equals(otherVersion));
// Important: for legacy libs, versions are null. Two legacy libs must
@ -176,9 +177,18 @@ public abstract class ContributedLibrary extends DownloadableContribution {
String thisName = getName();
String otherName = other.getName();
boolean nameEquals = thisName == null || otherName == null || thisName.equals(otherName);
boolean nameEquals = thisName != null && thisName.equals(otherName);
return versionEquals && nameEquals;
}
public boolean isBefore(ContributedLibrary other) {
return VersionHelper.compare(getVersion(), other.getVersion()) < 0;
}
@Override
public int hashCode() {
String hashingData = "CONTRIBUTEDLIB" + getName() + getVersion();
return hashingData.hashCode();
}
}

View File

@ -29,16 +29,14 @@
package cc.arduino.contributions.libraries;
public abstract class ContributedLibraryReference {
public abstract class ContributedLibraryDependency {
public abstract String getName();
public abstract String getMaintainer();
public abstract String getVersion();
@Override
public String toString() {
return getName() + " " + getVersion() + " (" + getMaintainer() + ")";
return getName() + " " + getVersion();
}
}

View File

@ -29,6 +29,7 @@
package cc.arduino.contributions.libraries;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@ -37,6 +38,8 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import cc.arduino.contributions.VersionComparator;
public abstract class LibrariesIndex {
public abstract List<ContributedLibrary> getLibraries();
@ -98,4 +101,78 @@ public abstract class LibrariesIndex {
ContributedLibraryReleases rel = new ContributedLibraryReleases(find(name));
return rel.getInstalled();
}
public List<ContributedLibrary> resolveDependeciesOf(ContributedLibrary library) {
List<ContributedLibrary> solution = new ArrayList<>();
solution.add(library);
if (resolveDependeciesOf(solution, library)) {
return solution;
} else {
return null;
}
}
public boolean resolveDependeciesOf(List<ContributedLibrary> solution,
ContributedLibrary library) {
List<ContributedLibraryDependency> requirements = library.getDependencies();
if (requirements == null) {
// No deps for this library, great!
return true;
}
for (ContributedLibraryDependency dep : requirements) {
// If the current solution already contains this dependency, skip over
boolean alreadyInSolution = solution.stream()
.anyMatch(l -> l.getName().equals(dep.getName()));
if (alreadyInSolution)
continue;
// Generate possible matching dependencies
List<ContributedLibrary> possibleDeps = findMatchingDependencies(dep);
// If there are no dependencies available add as "missing" lib
if (possibleDeps.isEmpty()) {
solution.add(new UnavailableContributedLibrary(dep));
continue;
}
// Pick the installed version if available
ContributedLibrary selected;
Optional<ContributedLibrary> installed = possibleDeps.stream()
.filter(l -> l.getInstalledLibrary().isPresent()).findAny();
if (installed.isPresent()) {
selected = installed.get();
} else {
// otherwise pick the latest version
selected = possibleDeps.stream().reduce(VersionComparator::max).get();
}
// Add dependency to the solution and process recursively
solution.add(selected);
if (!resolveDependeciesOf(solution, selected)) {
return false;
}
}
return true;
}
private List<ContributedLibrary> findMatchingDependencies(ContributedLibraryDependency dep) {
List<ContributedLibrary> available = find(dep.getName());
if (dep.getVersion() == null || dep.getVersion().isEmpty())
return available;
// XXX: The following part is actually never reached. The use of version
// constraints requires a much complex backtracking algorithm, the following
// is just a draft placeholder.
// List<ContributedLibrary> match = available.stream()
// // TODO: add more complex version comparators (> >= < <= ~ 1.0.* 1.*...)
// .filter(candidate -> candidate.getParsedVersion()
// .equals(dep.getVersionRequired()))
// .collect(Collectors.toList());
// return match;
return available;
}
}

View File

@ -50,6 +50,8 @@ import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import static processing.app.I18n.tr;
@ -109,15 +111,44 @@ public class LibraryInstaller {
}
public synchronized void install(ContributedLibrary lib, Optional<ContributedLibrary> mayReplacedLib, ProgressListener progressListener) throws Exception {
public void install(ContributedLibrary lib, ProgressListener progressListener) throws Exception {
ArrayList<ContributedLibrary> libs = new ArrayList<>();
libs.add(lib);
install(libs, progressListener);
}
public synchronized void install(List<ContributedLibrary> libs, ProgressListener progressListener) throws Exception {
MultiStepProgress progress = new MultiStepProgress(3 * libs.size() + 1);
for (ContributedLibrary lib : libs) {
// Do install library (3 steps)
performInstall(lib, progressListener, progress);
}
// Rescan index (1 step)
rescanLibraryIndex(progress, progressListener);
}
private void performInstall(ContributedLibrary lib, ProgressListener progressListener, MultiStepProgress progress) throws Exception {
if (lib.isLibraryInstalled()) {
System.out.println(I18n.format(tr("Library is already installed: {0}:{1}"), lib.getName(), lib.getParsedVersion()));
return;
}
DownloadableContributionsDownloader downloader = new DownloadableContributionsDownloader(BaseNoGui.librariesIndexer.getStagingFolder());
File libsFolder = BaseNoGui.getSketchbookLibrariesFolder().folder;
File destFolder = new File(libsFolder, lib.getName().replaceAll(" ", "_"));
final MultiStepProgress progress = new MultiStepProgress(3);
// Check if we are replacing an already installed lib
LibrariesIndex index = BaseNoGui.librariesIndexer.getIndex();
Optional<ContributedLibrary> replacedLib = index.find(lib.getName()).stream() //
.filter(l -> l.getInstalledLibrary().isPresent()) //
.filter(l -> l.getInstalledLibrary().get().getInstalledFolder().equals(destFolder)) //
.findAny();
if (!replacedLib.isPresent() && destFolder.exists()) {
System.out.println(I18n.format(tr("Library {0} is already installed in: {1}"), lib.getName(), destFolder));
return;
}
DownloadableContributionsDownloader downloader = new DownloadableContributionsDownloader(BaseNoGui.librariesIndexer.getStagingFolder());
// Step 1: Download library
try {
@ -126,6 +157,7 @@ public class LibraryInstaller {
// Download interrupted... just exit
return;
}
progress.stepDone();
// TODO: Extract to temporary folders and move to the final destination only
// once everything is successfully unpacked. If the operation fails remove
@ -134,7 +166,6 @@ public class LibraryInstaller {
// Step 2: Unpack library on the correct location
progress.setStatus(I18n.format(tr("Installing library: {0}:{1}"), lib.getName(), lib.getParsedVersion()));
progressListener.onProgress(progress);
File libsFolder = BaseNoGui.getSketchbookLibrariesFolder().folder;
File tmpFolder = FileUtils.createTempFolder(libsFolder);
try {
new ArchiveExtractor(platform).extract(lib.getDownloadedFile(), tmpFolder, 1);
@ -146,15 +177,11 @@ public class LibraryInstaller {
// Step 3: Remove replaced library and move installed one to the correct location
// TODO: Fix progress bar...
if (mayReplacedLib.isPresent()) {
remove(mayReplacedLib.get(), progressListener);
if (replacedLib.isPresent()) {
remove(replacedLib.get(), progressListener);
}
File destFolder = new File(libsFolder, lib.getName().replaceAll(" ", "_"));
tmpFolder.renameTo(destFolder);
progress.stepDone();
// Step 4: Rescan index
rescanLibraryIndex(progress, progressListener);
}
public synchronized void remove(ContributedLibrary lib, ProgressListener progressListener) throws IOException {

View File

@ -0,0 +1,143 @@
/*
* This file is part of Arduino.
*
* Copyright 2017 Arduino LLC (http://www.arduino.cc/)
*
* Arduino is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As a special exception, you may use this file as part of a free software
* library without restriction. Specifically, if other files instantiate
* templates or use macros or inline functions from this file, or you compile
* this file and link it with other files to produce an executable, this
* file does not by itself cause the resulting executable to be covered by
* the GNU General Public License. This exception does not however
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
package cc.arduino.contributions.libraries;
import java.util.ArrayList;
import java.util.List;
public class UnavailableContributedLibrary extends ContributedLibrary {
private String name;
private String version;
public UnavailableContributedLibrary(ContributedLibraryDependency dependency) {
this(dependency.getName(), dependency.getVersion());
}
public UnavailableContributedLibrary(String _name, String _version) {
name = _name;
version = _version;
}
@Override
public String getName() {
return name;
}
@Override
public String getMaintainer() {
return "Unknown";
}
@Override
public String getAuthor() {
return "Unknown";
}
@Override
public String getWebsite() {
return "Unknown";
}
@Override
public String getCategory() {
return "Uncategorized";
}
@Override
public void setCategory(String category) {
// Empty
}
@Override
public String getLicense() {
return "Unknown";
}
@Override
public String getParagraph() {
return "";
}
@Override
public String getSentence() {
return "";
}
@Override
public List<String> getArchitectures() {
return new ArrayList<>();
}
@Override
public List<String> getTypes() {
return new ArrayList<>();
}
@Override
public List<ContributedLibraryDependency> getDependencies() {
return new ArrayList<>();
}
@Override
public String getUrl() {
return "";
}
@Override
public String getVersion() {
return version;
}
@Override
public String getChecksum() {
return "";
}
@Override
public long getSize() {
return 0;
}
@Override
public String getArchiveFileName() {
return "";
}
@Override
public String toString() {
return "!" + super.toString();
}
@Override
public List<String> getProvidesIncludes() {
return new ArrayList<>();
}
}

View File

@ -210,9 +210,9 @@ public class SerialUploader extends Uploader {
// Reuse waitForUploadPort for this task, but this time we are simply waiting
// for one port to reappear. If no port reappears before the timeout, actualUploadPort is selected
finalUploadPort = waitForUploadPort(actualUploadPort, Serial.list(), false);
finalUploadPort = waitForUploadPort(actualUploadPort, Serial.list(), false, 2000);
}
} catch (InterruptedException ex) {
} catch (RunnerException ex) {
// noop
}
}
@ -229,13 +229,13 @@ public class SerialUploader extends Uploader {
}
private String waitForUploadPort(String uploadPort, List<String> before) throws InterruptedException, RunnerException {
return waitForUploadPort(uploadPort, before, verbose);
return waitForUploadPort(uploadPort, before, verbose, 10000);
}
private String waitForUploadPort(String uploadPort, List<String> before, boolean verbose) throws InterruptedException, RunnerException {
private String waitForUploadPort(String uploadPort, List<String> before, boolean verbose, int timeout) throws InterruptedException, RunnerException {
// Wait for a port to appear on the list
int elapsed = 0;
while (elapsed < 10000) {
while (elapsed < timeout) {
List<String> now = Serial.list();
List<String> diff = new ArrayList<>(now);
diff.removeAll(before);

View File

@ -8,6 +8,9 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
@ -146,6 +149,34 @@ public class FileUtils {
}
}
/**
* Writes the given data to the given file, creating the file if it does not exist.
* This method is equivalent to calling {@code writeStringToFile(file, data, StandardCharsets.UTF_8)}.
* @param file - The file to write to.
* @param data - The string to write.
* @throws IOException If an I/O error occurs.
*/
public static void writeStringToFile(File file, String data) throws IOException {
writeStringToFile(file, data, StandardCharsets.UTF_8);
}
/**
* Writes the given data to the given file, creating the file if it does not exist.
* @param file - The file to write to.
* @param data - The string to write.
* @param charset - The charset used to convert the string to bytes.
* @throws IOException If an I/O error occurs.
*/
public static void writeStringToFile(File file, String data, Charset charset) throws IOException {
OutputStream out = null;
try {
out = new FileOutputStream(file);
out.write(data.getBytes(charset));
} finally {
IOUtils.closeQuietly(out);
}
}
/**
* Returns true if the given file has any of the given extensions.
*

View File

@ -44,7 +44,7 @@ import com.github.zafarkhaja.semver.Version;
import cc.arduino.Constants;
import cc.arduino.contributions.VersionHelper;
import cc.arduino.contributions.libraries.ContributedLibraryReference;
import cc.arduino.contributions.libraries.ContributedLibraryDependency;
import processing.app.helpers.PreferencesMap;
import processing.app.packages.UserLibraryFolder.Location;
@ -230,7 +230,7 @@ public class UserLibrary {
return maintainer;
}
public List<ContributedLibraryReference> getRequires() {
public List<ContributedLibraryDependency> getRequires() {
return null;
}

View File

@ -1 +0,0 @@
b921835888c5bf4ad07c10b5e2e19a975528e380

View File

@ -0,0 +1 @@
2a45e470b163c5962aa7aa5531964855ae966f1b

View File

@ -1 +0,0 @@
d9e5fdd0f73d8f62504abddc071dcb6f660c8b6e

View File

@ -0,0 +1 @@
bce6002b0edc86b41f6a3dfc6b9e6a172cdc6b4c

View File

@ -1 +0,0 @@
9ff8b48d3f61e40ecff4bf2e7c14e312302290d7

View File

@ -0,0 +1 @@
d053ef6ee7b544d31dda243a379053e23a1b287f

View File

@ -1 +0,0 @@
19beb0ed3f1dea919b33d7defbe1b05414b69f2b

View File

@ -0,0 +1 @@
0164aa7ca0db10c1d2da4094d2036608acaf5895

View File

@ -1 +0,0 @@
d7006495131ec609d797c0f049a10fe6156751a3

View File

@ -0,0 +1 @@
991f6f0958d44b183dba1f53ac13a53c8e61cbd1

View File

@ -1 +0,0 @@
7cc958e5e96c26408b7396ecf63688eb25894c2c

View File

@ -0,0 +1 @@
049fc8ecbc4d839252ede8bc92f0cd9468ac4891

View File

@ -1 +0,0 @@
3a9383f3f2c8071e024a05b14fb4175e4eb140f6

View File

@ -0,0 +1 @@
4a5f3e31e0f76c7c3409326053a2b26b9f7bf74d

View File

@ -99,12 +99,12 @@
<property name="portable" value="false" />
<property name="ARDUINO-BUILDER-VERSION" value="1.4.4" />
<property name="ARDUINO-BUILDER-VERSION" value="1.4.5" />
<property name="LIBLISTSERIAL-VERSION" value="1.4.2" />
<property name="AVRGCC-VERSION" value="5.4.0-atmel3.6.1-arduino2" />
<property name="AVRDUDE-VERSION" value="6.3.0-arduino14" />
<property name="AVRCORE-VERSION" value="1.6.23" />
<property name="arduinoOTA-VERSION" value="1.2.1" />
<property name="AVRGCC-VERSION" value="7.3.0-atmel3.6.1-arduino5" />
<property name="AVRDUDE-VERSION" value="6.3.0-arduino17" />
<property name="AVRCORE-VERSION" value="1.8.1" />
<property name="arduinoOTA-VERSION" value="1.3.0" />
<!-- Libraries required for running arduino -->
<fileset dir=".." id="runtime.jars">
@ -218,8 +218,8 @@
<!-- Add WiFi101 updater tool -->
<antcall target="unzip">
<param name="archive_file" value="shared/WiFi101-Updater-ArduinoIDE-Plugin-0.10.8.zip" />
<param name="archive_url" value="https://github.com/arduino-libraries/WiFi101-FirmwareUpdater-Plugin/releases/download/v0.10.8/WiFi101-Updater-ArduinoIDE-Plugin-0.10.8.zip" />
<param name="archive_file" value="shared/WiFi101-Updater-ArduinoIDE-Plugin-0.10.9.zip" />
<param name="archive_url" value="https://github.com/arduino-libraries/WiFi101-FirmwareUpdater-Plugin/releases/download/v0.10.9/WiFi101-Updater-ArduinoIDE-Plugin-0.10.9.zip" />
<param name="final_folder" value="${target.path}/tools/WiFi101" />
<param name="dest_folder" value="${target.path}/tools/" />
</antcall>
@ -514,9 +514,9 @@
<target name="macosx-build-avr-toolchain" unless="light_bundle">
<antcall target="avr-toolchain-bundle">
<param name="unpack_target" value="untar-native"/>
<param name="gcc_archive_file" value="avr-gcc-${AVRGCC-VERSION}-i386-apple-darwin11.tar.bz2"/>
<param name="gcc_archive_file" value="avr-gcc-${AVRGCC-VERSION}-x86_64-apple-darwin14.tar.bz2"/>
<param name="gcc_version" value="${AVRGCC-VERSION}"/>
<param name="avrdude_archive_file" value="avrdude-${AVRDUDE-VERSION}-i386-apple-darwin11.tar.bz2"/>
<param name="avrdude_archive_file" value="avrdude-${AVRDUDE-VERSION}-x86_64-apple-darwin12.tar.bz2"/>
<param name="avrdude_version" value="${AVRDUDE-VERSION}"/>
<param name="arduinoOTA_archive_file" value="arduinoOTA-${arduinoOTA-VERSION}-darwin_amd64.tar.bz2"/>
<param name="arduinoOTA_version" value="${arduinoOTA-VERSION}"/>
@ -727,7 +727,7 @@
<antcall target="avr-toolchain-bundle">
<param name="unpack_target" value="untar-native"/>
<param name="gcc_archive_file" value="avr-gcc-${AVRGCC-VERSION}-armhf-pc-linux-gnu.tar.bz2"/>
<param name="gcc_archive_file" value="avr-gcc-${AVRGCC-VERSION}-arm-linux-gnueabihf.tar.bz2"/>
<param name="gcc_version" value="${AVRGCC-VERSION}"/>
<param name="avrdude_archive_file" value="avrdude-${AVRDUDE-VERSION}-armhf-pc-linux-gnu.tar.bz2"/>
<param name="avrdude_version" value="${AVRDUDE-VERSION}"/>
@ -1109,7 +1109,7 @@
<param name="file" value="windows/work/lib/jnidispatch-4.2.2-win32-x86.dll" />
</antcall>
<unzip src="../arduino-core/lib/jssc-2.8.0-arduino3.jar" dest="windows/work/lib">
<unzip src="../arduino-core/lib/jssc-2.8.0-arduino4.jar" dest="windows/work/lib">
<patternset>
<include name="libs/windows/jSSC-2.8_x86.dll"/>
</patternset>
@ -1119,7 +1119,7 @@
<antcall target="make-file-executable">
<param name="file" value="windows/work/lib/jSSC-2.8_x86.dll" />
</antcall>
<unzip src="../arduino-core/lib/jssc-2.8.0-arduino3.jar" dest="windows/work/lib">
<unzip src="../arduino-core/lib/jssc-2.8.0-arduino4.jar" dest="windows/work/lib">
<patternset>
<include name="libs/windows/jSSC-2.8_x86_64.dll"/>
</patternset>

View File

@ -0,0 +1 @@
21848a41ecbec2fa2fa44e5c5402ff641d60a179

View File

@ -0,0 +1 @@
6c7b86b96a2f02042a1595ec097b127345767a7d

View File

@ -0,0 +1 @@
03f63bd8e4298d43f60bec17d4f982db9790854a

View File

@ -0,0 +1 @@
e8cced0815cb5dd2a9e1ba18a0a85f275a5d5d9e

View File

@ -0,0 +1 @@
13e5a5b6aa493e2e81e55fc841185cbd99a1c17e

View File

@ -0,0 +1 @@
5f0590f3f7b9279ed3bcac8f4dd8e8f7bffb5a73

View File

@ -0,0 +1 @@
b7c16cca7784cc5e759e99e17cb61e40df9d8177

View File

@ -0,0 +1 @@
3460e07a73511df2f8f4d0da4e31efe9d0cfa329

View File

@ -0,0 +1 @@
b25477ca8719993bc06343aae6a9c67d2c49c8d8

View File

@ -0,0 +1 @@
1518e80b2e4a9ae433e6b429cd3c299634d2cd60

View File

@ -0,0 +1 @@
66e83e4c8297cdaa5cfb49924c9034140f544ddf

View File

@ -0,0 +1 @@
d98ed13ef192cea946e0c7a3e5d8608915625bfe

View File

@ -0,0 +1 @@
2a2dd53e4d42256106157e0de9b0c72935c45c29

View File

@ -0,0 +1 @@
40ced394dff8ec5381b7cf3708b2ab8dea54a1f6

View File

@ -0,0 +1 @@
dfb2a2a4d380c7fc0dc8e141555ae6c028786a8e

View File

@ -0,0 +1,170 @@
# SerialPlotter protocol
One message can consist of multiply parts.
One part can consist of one label, one label and a value or only a value.
| | |
| --- | --- |
| End of message symbol | \n |
| Part separator symbols | ' '(space), '\t'(tab), ','(comma) |
| Label-value separator symbol | : |
# Valid messages are
## Labels and value messages:
| | | | | | |
|-------------------|----|-------------------|-----|-------------------|----|
| Label : Value | | | | | \n |
| Label 1 : Value 1 | \t | Label 2 : Value 2 | | | \n |
| Label 1 : Value 1 | \t | Label 2 : Value 2 | ... | Label n : Value n | \n |
## Label only messages
| | | | | | |
|-----------|----|-----------|-----|----------|----|
| Label: | | | | | \n |
| Label 1 : | \t | Label 2 : | | | \n |
| Label 1 : | \t | Label 2 | ... | Label n: | \n |
There is a special case, the CSV header style.
| | | | | | |
|-------|----|---------|-----|---------|----|
|Label 1| \t | Label 2 | ... | Label n | \n |
But in this format, labels consisting of only numbers are not recognised as labels.
It is safer to just use the normal label only message.
## Value only messages Value
This is not recommended if you using a board with USB to UART converter.
Because when the label is sent, before you had the SerialPlotter opened, then the label/labels get/gets never set.
| | | | | | |
|---------|----|---------|-----|---------|----|
| Value 1 | \t | Value 2 | | | \n |
| Value 1 | \t | Value 2 | ... | Value n | \n |
# Examples
## Single Trace without label
This example plots on line on serial plotter without setting a label
```ino
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue1 = analogRead(A0);
Serial.println(sensorValue1);
delay(100);
}
```
The output looks like this
```
10\n
11\n
12\n
13\n
14\n
```
## Single Trace with label
This example sends the label once in the setup routine. Afterwards only the value is send.
```ino
void setup() {
Serial.begin(9600);
Serial.println("Label 1:");
}
void loop() {
int sensorValue1 = analogRead(A0);
Serial.println(sensorValue1);
delay(100);
}
```
The output looks like this
```
Label 1:\n
10\n
11\n
12\n
13\n
14\n
```
## Single Trace with label send every time
This example sends the label every time together with the value.
```ino
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue1 = analogRead(A0);
Serial.print("Label 1:"); Serial.println(sensorValue1);
delay(100);
}
```
The output looks like this
```
Label 1:10\n
Label 1:11\n
Label 1:12\n
Label 1:13\n
Label 1:14\n
```
## Two Traces with label send every time
This example sends two values together with the labels.
```ino
void setup() {
Serial.begin(9600);
}
float avg = 0;
void loop() {
int sensorValue1 = analogRead(A0);
// send lable and value seperated by ':'
Serial.print("Value:"); Serial.print(sensorValue1);
avg = (avg * 4 + analogRead(A0)) / 5.0;
// send part devider '\t'
Serial.print("\t");
// send the second lable and value
Serial.print("AVG5:"); Serial.println(avg);
delay(100);
}
```
The output looks like this
```
Value:377 AVG5:431.01
Value:338 AVG5:408.81
Value:392 AVG5:395.85
Value:583 AVG5:427.28
Value:221 AVG5:383.42
Value:195 AVG5:343.74
Value:202 AVG5:314.19
Value:209 AVG5:292.15
```

Binary file not shown.

View File

@ -1 +0,0 @@
5ffdba176b6c2df8c62dc0199f8d0256c82f3053

View File

@ -0,0 +1 @@
27d983813536b2d7fe84913e4fb2ef5cdef62a1b

View File

@ -0,0 +1 @@
7044265e8ebf00ad55655e4b0eb0d2c3330e9391

View File

@ -0,0 +1 @@
488e99b0d5c687823bf4d1a26af0d237eafa20f4

View File

@ -0,0 +1 @@
e3209cba2453fbf76e1ef0a478dec4010cf1ef8e

View File

@ -51,7 +51,7 @@
<cp>%EXEDIR%/lib/jna-4.2.2.jar</cp>
<cp>%EXEDIR%/lib/jna-platform-4.2.2.jar</cp>
<cp>%EXEDIR%/lib/jsch-0.1.50.jar</cp>
<cp>%EXEDIR%/lib/jssc-2.8.0-arduino3.jar</cp>
<cp>%EXEDIR%/lib/jssc-2.8.0-arduino4.jar</cp>
<cp>%EXEDIR%/lib/pde.jar</cp>
<cp>%EXEDIR%/lib/rsyntaxtextarea-3.0.3-SNAPSHOT.jar</cp>
<cp>%EXEDIR%/lib/xml-apis-1.3.04.jar</cp>

View File

@ -51,7 +51,7 @@
<cp>%EXEDIR%/lib/jna-4.2.2.jar</cp>
<cp>%EXEDIR%/lib/jna-platform-4.2.2.jar</cp>
<cp>%EXEDIR%/lib/jsch-0.1.50.jar</cp>
<cp>%EXEDIR%/lib/jssc-2.8.0-arduino3.jar</cp>
<cp>%EXEDIR%/lib/jssc-2.8.0-arduino4.jar</cp>
<cp>%EXEDIR%/lib/pde.jar</cp>
<cp>%EXEDIR%/lib/rsyntaxtextarea-3.0.3-SNAPSHOT.jar</cp>
<cp>%EXEDIR%/lib/xml-apis-1.3.04.jar</cp>

View File

@ -12,15 +12,15 @@
{
"name": "Arduino AVR Boards",
"architecture": "avr",
"version": "1.6.23",
"version": "1.8.1",
"category": "Arduino",
"help": {
"online": "http://www.arduino.cc/en/Reference/HomePage"
},
"url": "http://downloads.arduino.cc/cores/avr-1.6.23.tar.bz2",
"archiveFileName": "avr-1.6.23.tar.bz2",
"checksum": "SHA-256:18618d7f256f26cd77c35f4c888d5d1b2334f07925094fdc99ac3188722284aa",
"size": "5001988",
"url": "http://downloads.arduino.cc/cores/avr-1.8.1.tar.bz2",
"archiveFileName": "avr-1.8.1.tar.bz2",
"checksum": "SHA-256:4791a52fd058f72557af333abc2dea564c8be47fb38fbd7be75ce2fcfdc214b5",
"size": "4941605",
"boards": [
{"name": "Arduino Yún"},
{"name": "Arduino/Genuino Uno"},
@ -53,17 +53,17 @@
{
"packager": "arduino",
"name": "avr-gcc",
"version": "5.4.0-atmel3.6.1-arduino2"
"version": "7.3.0-atmel3.6.1-arduino5"
},
{
"packager": "arduino",
"name": "avrdude",
"version": "6.3.0-arduino14"
"version": "6.3.0-arduino17"
},
{
"packager": "arduino",
"name": "arduinoOTA",
"version": "1.2.1"
"version": "1.3.0"
}
]
}
@ -71,145 +71,145 @@
"tools": [
{
"name": "avr-gcc",
"version": "5.4.0-atmel3.6.1-arduino2",
"version": "7.3.0-atmel3.6.1-arduino5",
"systems": [
{
"size": "31449123",
"checksum": "SHA-256:6741f95cc3182a8729cf9670eb13d8dc5a19e881639ca61e53a2d78346a4e99f",
"size": "34462042",
"checksum": "SHA-256:f4acd5531c6b82c715e2edfa0aadb13fb718b4095b3ea1aa1f7fbde680069639",
"host": "arm-linux-gnueabihf",
"archiveFileName": "avr-gcc-5.4.0-atmel3.6.1-arduino2-armhf-pc-linux-gnu.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avr-gcc-5.4.0-atmel3.6.1-arduino2-armhf-pc-linux-gnu.tar.bz2"
"archiveFileName": "avr-gcc-7.3.0-atmel3.6.1-arduino5-arm-linux-gnueabihf.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avr-gcc-7.3.0-atmel3.6.1-arduino5-arm-linux-gnueabihf.tar.bz2"
},
{
"size": "33141295",
"checksum": "SHA-256:0fa9e4f2d6d09782dbc84dd91a302849cde2f192163cb9f29484c5f32785269a",
"size": "39381972",
"checksum": "SHA-256:dd9c70190be370a44fb47dab1514de6d8852b861dfa527964b65c740d8d50c10",
"host": "aarch64-linux-gnu",
"archiveFileName": "avr-gcc-5.4.0-atmel3.6.1-arduino2-aarch64-pc-linux-gnu.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avr-gcc-5.4.0-atmel3.6.1-arduino2-aarch64-pc-linux-gnu.tar.bz2"
"archiveFileName": "avr-gcc-7.3.0-atmel3.6.1-arduino5-aarch64-pc-linux-gnu.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avr-gcc-7.3.0-atmel3.6.1-arduino5-aarch64-pc-linux-gnu.tar.bz2"
},
{
"size": "31894498",
"checksum": "SHA-256:abc50137543ba73e227b4d1b8510fff50a474bacd24f2c794f852904963849f8",
"host": "i386-apple-darwin11",
"archiveFileName": "avr-gcc-5.4.0-atmel3.6.1-arduino2-i386-apple-darwin11.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avr-gcc-5.4.0-atmel3.6.1-arduino2-i386-apple-darwin11.tar.bz2"
"size": "38492678",
"checksum": "SHA-256:f48706317f04452544ab90e75bd1bb193f8af2cb1002f53aa702f27202c1b38f",
"host": "x86_64-apple-darwin14",
"archiveFileName": "avr-gcc-7.3.0-atmel3.6.1-arduino5-x86_64-apple-darwin14.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avr-gcc-7.3.0-atmel3.6.1-arduino5-x86_64-apple-darwin14.tar.bz2"
},
{
"size": "45923772",
"checksum": "SHA-256:7eb5691a379b547798fae535b05d68bc02d3969f12d051b8a5a5f2f350ab0a7f",
"size": "53727984",
"checksum": "SHA-256:6d4a5d089a36e5b5252befc73da204555b49e376ce7577ee19ca7f028b295830",
"host": "i686-mingw32",
"archiveFileName": "avr-gcc-5.4.0-atmel3.6.1-arduino2-i686-w64-mingw32.zip",
"url": "http://downloads.arduino.cc/tools/avr-gcc-5.4.0-atmel3.6.1-arduino2-i686-w64-mingw32.zip"
"archiveFileName": "avr-gcc-7.3.0-atmel3.6.1-arduino5-i686-w64-mingw32.zip",
"url": "http://downloads.arduino.cc/tools/avr-gcc-7.3.0-atmel3.6.1-arduino5-i686-w64-mingw32.zip"
},
{
"size": "33022916",
"checksum": "SHA-256:51f87e04f3cdaa73565c751051ac118e02904ad8478f1475b300e1bffcd5538f",
"size": "38710087",
"checksum": "SHA-256:2ff12739d7ed09688d6b3c2c126e8df69b5bda1a07ab558799f0e576571e0e1d",
"host": "i686-linux-gnu",
"archiveFileName": "avr-gcc-5.4.0-atmel3.6.1-arduino2-i686-pc-linux-gnu.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avr-gcc-5.4.0-atmel3.6.1-arduino2-i686-pc-linux-gnu.tar.bz2"
"archiveFileName": "avr-gcc-7.3.0-atmel3.6.1-arduino5-i686-pc-linux-gnu.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avr-gcc-7.3.0-atmel3.6.1-arduino5-i686-pc-linux-gnu.tar.bz2"
},
{
"size": "33522375",
"checksum": "SHA-256:05422b0d73b10357c12ea938f02cf50529422b89a4722756e70024aed3e69185",
"size": "39114120",
"checksum": "SHA-256:3effed8ffa1978b6e4a46f1aa2acc629e440b4d77244f71f9b79a916025206fb",
"host": "x86_64-linux-gnu",
"archiveFileName": "avr-gcc-5.4.0-atmel3.6.1-arduino2-x86_64-pc-linux-gnu.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avr-gcc-5.4.0-atmel3.6.1-arduino2-x86_64-pc-linux-gnu.tar.bz2"
"archiveFileName": "avr-gcc-7.3.0-atmel3.6.1-arduino5-x86_64-pc-linux-gnu.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avr-gcc-7.3.0-atmel3.6.1-arduino5-x86_64-pc-linux-gnu.tar.bz2"
}
]
},
{
"name": "avrdude",
"version": "6.3.0-arduino14",
"version": "6.3.0-arduino17",
"systems": [
{
"size": "219616",
"checksum": "SHA-256:d1a06275490d59a431c419788bbc53ffd5a79510dac1a35e63cf488621ba5589",
"size": "219631",
"checksum": "SHA-256:2a8e68c5d803aa6f902ef219f177ec3a4c28275d85cbe272962ad2cd374f50d1",
"host": "arm-linux-gnueabihf",
"archiveFileName": "avrdude-6.3.0-arduino14-armhf-pc-linux-gnu.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-armhf-pc-linux-gnu.tar.bz2"
"archiveFileName": "avrdude-6.3.0-arduino17-armhf-pc-linux-gnu.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino17-armhf-pc-linux-gnu.tar.bz2"
},
{
"size": "229688",
"checksum": "SHA-256:439f5de150695e3732dd598bb182dae6ec1e3a5cdb580f855d9b58e485e84e66",
"size": "229852",
"checksum": "SHA-256:6cf948f751acfe7b96684537f2291c766ec8b54b4f7dc95539864821456fa9fc",
"host": "aarch64-linux-gnu",
"archiveFileName": "avrdude-6.3.0-arduino14-aarch64-pc-linux-gnu.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-aarch64-pc-linux-gnu.tar.bz2"
"archiveFileName": "avrdude-6.3.0-arduino17-aarch64-pc-linux-gnu.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino17-aarch64-pc-linux-gnu.tar.bz2"
},
{
"size": "256917",
"checksum": "SHA-256:47d03991522722ce92120c60c4118685b7861909d895f34575001137961e4a63",
"host": "i386-apple-darwin11",
"archiveFileName": "avrdude-6.3.0-arduino14-i386-apple-darwin12.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-i386-apple-darwin11.tar.bz2"
"size": "279045",
"checksum": "SHA-256:120cc9edaae699e7e9ac50b1b8eb0e7d51fdfa555bac54233c2511e6ee5418c9",
"host": "x86_64-apple-darwin12",
"archiveFileName": "avrdude-6.3.0-arduino17-x86_64-apple-darwin12.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino17-x86_64-apple-darwin12.tar.bz2"
},
{
"size": "253366",
"checksum": "SHA-256:7986e8f3059353dc08f9234f7dbc98d9b2fa2242f046f02a8243a060f7358bfc",
"size": "254271",
"checksum": "SHA-256:accdfb920af2aabf4f7461d2ac73c0751760f525216dc4e7657427a78c60d13d",
"host": "x86_64-linux-gnu",
"archiveFileName": "avrdude-6.3.0-arduino14-x86_64-pc-linux-gnu.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-x86_64-pc-linux-gnu.tar.bz2"
"archiveFileName": "avrdude-6.3.0-arduino17-x86_64-pc-linux-gnu.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino17-x86_64-pc-linux-gnu.tar.bz2"
},
{
"size": "244293",
"checksum": "SHA-256:4f100e3843c635064997df91d2a079ab15cd30d1d7fa227280abe6a7c3bc74ca",
"size": "244550",
"checksum": "SHA-256:5c8cc6c17db9300e1451fe41cd7178b0442b4490ee6fdbc0aed9811aef96c05f",
"host": "i686-linux-gnu",
"archiveFileName": "avrdude-6.3.0-arduino14-i686-pc-linux-gnu.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-i686-pc-linux-gnu.tar.bz2"
"archiveFileName": "avrdude-6.3.0-arduino17-i686-pc-linux-gnu.tar.bz2",
"url": "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino17-i686-pc-linux-gnu.tar.bz2"
},
{
"size": "328363",
"checksum": "SHA-256:69293e0de2eff8de89f553477795c25005f674a320bbba4b0222beb0194aa297",
"size": "328460",
"checksum": "SHA-256:e99188873c7c5ad8f8f906f068c33600e758b2e36cce3adbd518a21bd266749d",
"host": "i686-mingw32",
"archiveFileName": "avrdude-6.3.0-arduino14-i686-w64-mingw32.zip",
"url": "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino14-i686-w64-mingw32.zip"
"archiveFileName": "avrdude-6.3.0-arduino17-i686-w64-mingw32.zip",
"url": "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino17-i686-w64-mingw32.zip"
}
]
},
{
"name": "arduinoOTA",
"version": "1.2.1",
"version": "1.3.0",
"systems": [
{
"size": "2133779",
"checksum": "SHA-256:2ffdf64b78486c1d0bf28dc23d0ca36ab75ca92e84b9487246da01888abea6d4",
"size": "2633516",
"checksum": "SHA-256:3e7f59d6fbc7a724598303f0d3289d0c4fd137a8973437980658379a024887b2",
"host": "i686-linux-gnu",
"archiveFileName": "arduinoOTA-1.2.1-linux_386.tar.bz2",
"url": "http://downloads.arduino.cc/tools/arduinoOTA-1.2.1-linux_386.tar.bz2"
"archiveFileName": "arduinoOTA-1.3.0-linux_386.tar.bz2",
"url": "http://downloads.arduino.cc/tools/arduinoOTA-1.3.0-linux_386.tar.bz2"
},
{
"size": "2257689",
"checksum": "SHA-256:5b82310d53688480f34a916aac31cd8f2dd2be65dd8fa6c2445262262e1948f9",
"size": "2716248",
"checksum": "SHA-256:aa45ee2441ffc3a122daec5802941d1fa2ac47adf5c5c481b5e0daa4dc259ffa",
"host": "x86_64-linux-gnu",
"archiveFileName": "arduinoOTA-1.2.1-linux_amd64.tar.bz2",
"url": "http://downloads.arduino.cc/tools/arduinoOTA-1.2.1-linux_amd64.tar.bz2"
"archiveFileName": "arduinoOTA-1.3.0-linux_amd64.tar.bz2",
"url": "http://downloads.arduino.cc/tools/arduinoOTA-1.3.0-linux_amd64.tar.bz2"
},
{
"size": "2093132",
"checksum": "SHA-256:ad54b3dcd586212941fd992bab573b53d13207a419a3f2981c970a085ae0e9e0",
"size": "2567435",
"checksum": "SHA-256:1888587409b56aef4ba0ab0e6703b3dccba7cc3a022756ba9b908247e5d5a656",
"host": "arm-linux-gnueabihf",
"archiveFileName": "arduinoOTA-1.2.1-linux_arm.tar.bz2",
"url": "http://downloads.arduino.cc/tools/arduinoOTA-1.2.1-linux_arm.tar.bz2"
"archiveFileName": "arduinoOTA-1.3.0-linux_arm.tar.bz2",
"url": "http://downloads.arduino.cc/tools/arduinoOTA-1.3.0-linux_arm.tar.bz2"
},
{
"size": "2093132",
"checksum": "SHA-256:ad54b3dcd586212941fd992bab573b53d13207a419a3f2981c970a085ae0e9e0",
"size": "2472427",
"checksum": "SHA-256:835ed8f37cffac37e979d1b0f6041559592d3d98be52f0e8611b76c4858e4113",
"host": "aarch64-linux-gnu",
"archiveFileName": "arduinoOTA-1.2.1-linux_arm.tar.bz2",
"url": "http://downloads.arduino.cc/tools/arduinoOTA-1.2.1-linux_arm.tar.bz2"
"archiveFileName": "arduinoOTA-1.3.0-linux_arm64.tar.bz2",
"url": "http://downloads.arduino.cc/tools/arduinoOTA-1.3.0-linux_arm64.tar.bz2"
},
{
"size": "2244088",
"checksum": "SHA-256:93a6d9f9c0c765d237be1665bf7a0a8e2b0b6d2a8531eae92db807f5515088a7",
"size": "2766116",
"checksum": "SHA-256:d5d0f82ff829c0e434d12a2ee640a6fbd78f893ab37782edbb8b5bf2359d119e",
"host": "i386-apple-darwin11",
"archiveFileName": "arduinoOTA-1.2.1-darwin_amd64.tar.bz2",
"url": "http://downloads.arduino.cc/tools/arduinoOTA-1.2.1-darwin_amd64.tar.bz2"
"archiveFileName": "arduinoOTA-1.3.0-darwin_amd64.tar.bz2",
"url": "http://downloads.arduino.cc/tools/arduinoOTA-1.3.0-darwin_amd64.tar.bz2"
},
{
"size": "2237511",
"checksum": "SHA-256:e1ebf21f2c073fce25c09548c656da90d4ef6c078401ec6f323e0c58335115e5",
"size": "2768948",
"checksum": "SHA-256:051943844eee442460d2c709edefadca184287fffd2b6c100dd53aa742aa05f6",
"host": "i686-mingw32",
"archiveFileName": "arduinoOTA-1.2.1-windows_386.zip",
"url": "http://downloads.arduino.cc/tools/arduinoOTA-1.2.1-windows_386.zip"
"archiveFileName": "arduinoOTA-1.3.0-windows_386.zip",
"url": "http://downloads.arduino.cc/tools/arduinoOTA-1.3.0-windows_386.zip"
}
]
}