From e93760abc4fd1850d40c877ae05fcce693173e0c Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 24 Dec 2013 16:07:41 +0100 Subject: [PATCH 01/13] Implemented support for 1.5 libraries specification rev.2 - removed "arch" folder support - allow to optinally use "src" folder - slightly changed metadata For more information see: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification http://goo.gl/gfFJzU --- app/src/processing/app/debug/Compiler.java | 72 ++++----- app/src/processing/app/packages/Library.java | 146 +++++++++---------- 2 files changed, 103 insertions(+), 115 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 5bdb7d2e9..08926e435 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -96,9 +96,8 @@ public class Compiler implements MessageConsumer { if (verbose) System.out.println(I18n .format(_("Using library {0} in folder: {1} {2}"), lib.getName(), - lib.getFolder(), lib.isPre15Lib() ? "(pre-1.5)" : "")); - for (File folder : lib.getSrcFolders(targetArch)) - includePaths.add(folder.getPath()); + lib.getFolder(), lib.isLegacy() ? "(legacy)" : "")); + includePaths.add(lib.getSrcFolder().getPath()); } if (verbose) System.out.println(); @@ -615,47 +614,50 @@ public class Compiler implements MessageConsumer { // 2. compile the libraries, outputting .o files to: // // void compileLibraries(List includePaths) throws RunnerException { - File outputPath = new File(prefs.get("build.path")); for (Library lib : sketch.getImportedLibraries()) { - for (File folder : lib.getSrcFolders(targetArch)) { - if (lib.isPre15Lib()) { - compileLibrary(outputPath, folder, includePaths); - } else { - recursiveCompileLibrary(outputPath, folder, includePaths); - } - } + compileLibrary(lib, includePaths); } } - private void recursiveCompileLibrary(File outputPath, File libraryFolder, List includePaths) throws RunnerException { - File newOutputPath = compileFilesInFolder(outputPath, libraryFolder, includePaths); - for (File subFolder : libraryFolder.listFiles(new OnlyDirs())) { - recursiveCompileLibrary(newOutputPath, subFolder, includePaths); + private void compileLibrary(Library lib, List includePaths) + throws RunnerException { + File libFolder = lib.getSrcFolder(); + File libBuildFolder = new File(prefs.get("build.path"), lib.getName()); + + if (lib.useRecursion()) { + // libBuildFolder == {build.path}/LibName + // libFolder == {lib.path}/src + recursiveCompileFilesInFolder(libBuildFolder, libFolder, includePaths); + + } else { + // libFolder == {lib.path}/ + // utilityFolder == {lib.path}/utility + // libBuildFolder == {build.path}/LibName + // utilityBuildFolder == {build.path}/LibName/utility + File utilityFolder = new File(libFolder, "utility"); + File utilityBuildFolder = new File(libBuildFolder, "utility"); + + includePaths.add(utilityFolder.getAbsolutePath()); + compileFilesInFolder(libBuildFolder, libFolder, includePaths); + compileFilesInFolder(utilityBuildFolder, utilityFolder, includePaths); + + // other libraries should not see this library's utility/ folder + includePaths.remove(utilityFolder.getAbsolutePath()); } } - private File compileFilesInFolder(File outputPath, File libraryFolder, List includePaths) throws RunnerException { - File outputFolder = new File(outputPath, libraryFolder.getName()); - createFolder(outputFolder); - objectFiles.addAll(compileFiles(outputFolder.getAbsolutePath(), libraryFolder, false, includePaths)); - return outputFolder; + private void recursiveCompileFilesInFolder(File srcBuildFolder, File srcFolder, List includePaths) throws RunnerException { + compileFilesInFolder(srcBuildFolder, srcFolder, includePaths); + for (File subFolder : srcFolder.listFiles(new OnlyDirs())) { + File subBuildFolder = new File(srcBuildFolder, subFolder.getName()); + recursiveCompileFilesInFolder(subBuildFolder, subFolder, includePaths); + } } - private void compileLibrary(File outputPath, File libraryFolder, List includePaths) throws RunnerException { - File outputFolder = new File(outputPath, libraryFolder.getName()); - File utilityFolder = new File(libraryFolder, "utility"); - createFolder(outputFolder); - // this library can use includes in its utility/ folder - includePaths.add(utilityFolder.getAbsolutePath()); - - objectFiles.addAll(compileFiles(outputFolder.getAbsolutePath(), - libraryFolder, false, includePaths)); - outputFolder = new File(outputFolder, "utility"); - createFolder(outputFolder); - objectFiles.addAll(compileFiles(outputFolder.getAbsolutePath(), - utilityFolder, false, includePaths)); - // other libraries should not see this library's utility/ folder - includePaths.remove(includePaths.size() - 1); + private void compileFilesInFolder(File buildFolder, File srcFolder, List includePaths) throws RunnerException { + createFolder(buildFolder); + List objects = compileFiles(buildFolder.getAbsolutePath(), srcFolder, false, includePaths); + objectFiles.addAll(objects); } // 3. compile the core, outputting .o files to and then diff --git a/app/src/processing/app/packages/Library.java b/app/src/processing/app/packages/Library.java index a6322ab44..9fc96720f 100644 --- a/app/src/processing/app/packages/Library.java +++ b/app/src/processing/app/packages/Library.java @@ -17,24 +17,23 @@ public class Library { private String name; private String version; private String author; - private String email; - private String url; + private String maintainer; private String sentence; private String paragraph; - private List coreDependencies; - private List dependencies; - private File folder, srcFolder, archFolder; + private String url; private List architectures; - private boolean pre15Lib; + private File folder; + private File srcFolder; + private boolean useRecursion; + private boolean isLegacy; private static final List MANDATORY_PROPERTIES = Arrays - .asList(new String[] { "architectures", "author", "core-dependencies", - "dependencies", "email", "name", "paragraph", "sentence", "url", - "version" }); + .asList(new String[] { "name", "version", "author", "maintainer", + "sentence", "paragraph", "url" }); /** * Scans inside a folder and create a Library object out of it. Automatically - * detects pre-1.5 libraries. Automatically fills metadata from + * detects legacy libraries. Automatically fills metadata from * library.properties file if found. * * @param libFolder @@ -45,7 +44,7 @@ public class Library { // "library.properties" File check = new File(libFolder, "library.properties"); if (!check.exists() || !check.isFile()) - return createPre15Library(libFolder); + return createLegacyLibrary(libFolder); else return createLibrary(libFolder); } @@ -60,14 +59,34 @@ public class Library { // --------------------- // 1. Check mandatory properties + + // provide compatibility with 1.5 rev.1 libs + // ("email" field changed to "maintainer") + if (!properties.containsKey("maintainer")) + properties.put("maintainer", properties.get("email")); + for (String p : MANDATORY_PROPERTIES) if (!properties.containsKey(p)) throw new IOException("Missing '" + p + "' from library"); - // 2. Check mandatory folders + // 2. Check layout + boolean useRecursion; File srcFolder = new File(libFolder, "src"); - if (!srcFolder.exists() || !srcFolder.isDirectory()) - throw new IOException("Missing 'src' folder"); + + if (srcFolder.exists() && srcFolder.isDirectory()) { + // Layout with a single "src" folder and recursive compilation + useRecursion = true; + + File utilFolder = new File(libFolder, "utility"); + if (utilFolder.exists() && utilFolder.isDirectory()) { + throw new IOException( + "Library can't use both 'src' and 'utility' folders."); + } + } else { + // Layout with source code on library's root and "utility" folders + srcFolder = libFolder; + useRecursion = false; + } // 3. Warn if root folder contains development leftovers for (File file : libFolder.listFiles()) { @@ -81,65 +100,38 @@ public class Library { } // Extract metadata info + String architectures = properties.get("architectures"); + if (architectures == null) + architectures = "*"; // defaults to "any" List archs = new ArrayList(); - for (String arch : properties.get("architectures").split(",")) + for (String arch : architectures.split(",")) archs.add(arch.trim()); - List coreDeps = new ArrayList(); - for (String dep : properties.get("core-dependencies").split(",")) - coreDeps.add(dep.trim()); - - List dependencies = new ArrayList(); - for (String dependency : properties.get("dependencies").split(",")) { - dependency = dependency.trim(); - if (!dependency.equals("")) { - dependencies.add(dependency); - } - } - Library res = new Library(); res.folder = libFolder; res.srcFolder = srcFolder; - res.archFolder = new File(libFolder, "arch"); res.name = properties.get("name").trim(); + res.version = properties.get("version").trim(); res.author = properties.get("author").trim(); - res.email = properties.get("email").trim(); + res.maintainer = properties.get("maintainer").trim(); res.sentence = properties.get("sentence").trim(); res.paragraph = properties.get("paragraph").trim(); res.url = properties.get("url").trim(); res.architectures = archs; - res.coreDependencies = coreDeps; - res.dependencies = dependencies; - res.version = properties.get("version").trim(); - res.pre15Lib = false; + res.useRecursion = useRecursion; + res.isLegacy = false; return res; } - private static Library createPre15Library(File libFolder) { + private static Library createLegacyLibrary(File libFolder) { // construct an old style library Library res = new Library(); res.folder = libFolder; res.srcFolder = libFolder; + res.useRecursion = false; res.name = libFolder.getName(); res.architectures = Arrays.asList("*"); - res.pre15Lib = true; - return res; - } - - public List getSrcFolders(String reqArch) { - if (!supportsArchitecture(reqArch)) - return null; - List res = new ArrayList(); - res.add(srcFolder); - File archSpecificFolder = new File(archFolder, reqArch); - if (archSpecificFolder.exists() && archSpecificFolder.isDirectory()) { - res.add(archSpecificFolder); - } else { - // If specific architecture folder is not found try with "default" - archSpecificFolder = new File(archFolder, "default"); - if (archSpecificFolder.exists() && archSpecificFolder.isDirectory()) - res.add(archSpecificFolder); - } + res.isLegacy = true; return res; } @@ -157,18 +149,10 @@ public class Library { } }; - public File getSrcFolder() { - return srcFolder; - } - public String getName() { return name; } - public boolean isPre15Lib() { - return pre15Lib; - } - public File getFolder() { return folder; } @@ -181,18 +165,6 @@ public class Library { return author; } - public List getCoreDependencies() { - return coreDependencies; - } - - public List getDependencies() { - return dependencies; - } - - public String getEmail() { - return email; - } - public String getParagraph() { return paragraph; } @@ -209,19 +181,33 @@ public class Library { return version; } + public String getMaintainer() { + return maintainer; + } + + public boolean useRecursion() { + return useRecursion; + } + + public File getSrcFolder() { + return srcFolder; + } + + public boolean isLegacy() { + return isLegacy; + } + @Override public String toString() { String res = "Library:"; res += " (name=" + name + ")"; - res += " (architectures=" + architectures + ")"; - res += " (author=" + author + ")"; - res += " (core-dependencies=" + coreDependencies + ")"; - res += " (dependencies=" + dependencies + ")"; - res += " (email=" + email + ")"; - res += " (paragraph=" + paragraph + ")"; - res += " (sentence=" + sentence + ")"; - res += " (url=" + url + ")"; res += " (version=" + version + ")"; + res += " (author=" + author + ")"; + res += " (maintainer=" + maintainer + ")"; + res += " (sentence=" + sentence + ")"; + res += " (paragraph=" + paragraph + ")"; + res += " (url=" + url + ")"; + res += " (architectures=" + architectures + ")"; return res; } } From e045cd26ccda700a324409f7e6e13ab3f6670a0e Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 24 Dec 2013 16:23:21 +0100 Subject: [PATCH 02/13] Added a warning for library using the no longer supported "arch" folder --- app/src/processing/app/packages/Library.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/processing/app/packages/Library.java b/app/src/processing/app/packages/Library.java index 9fc96720f..1e95205c6 100644 --- a/app/src/processing/app/packages/Library.java +++ b/app/src/processing/app/packages/Library.java @@ -58,18 +58,24 @@ public class Library { // Library sanity checks // --------------------- - // 1. Check mandatory properties - - // provide compatibility with 1.5 rev.1 libs - // ("email" field changed to "maintainer") + // Compatibility with 1.5 rev.1 libraries: + // "email" field changed to "maintainer" if (!properties.containsKey("maintainer")) properties.put("maintainer", properties.get("email")); + // Compatibility with 1.5 rev.1 libraries: + // "arch" folder no longer supported + File archFolder = new File(libFolder, "arch"); + if (archFolder.isDirectory()) + throw new IOException("'arch' folder is no longer supported! See " + + "http://goo.gl/gfFJzU for more information"); + + // Check mandatory properties for (String p : MANDATORY_PROPERTIES) if (!properties.containsKey(p)) throw new IOException("Missing '" + p + "' from library"); - // 2. Check layout + // Check layout boolean useRecursion; File srcFolder = new File(libFolder, "src"); @@ -88,7 +94,7 @@ public class Library { useRecursion = false; } - // 3. Warn if root folder contains development leftovers + // Warn if root folder contains development leftovers for (File file : libFolder.listFiles()) { if (file.isDirectory()) { if (FileUtils.isSCCSOrHiddenFile(file)) { From 5e7663574bb9a002245e426bdb6199e7bfe09d3b Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 24 Dec 2013 20:08:22 +0100 Subject: [PATCH 03/13] Use Files instead of String to handle paths in Compiler class. --- app/src/processing/app/debug/Compiler.java | 152 +++++++++--------- .../app/helpers/PreferencesMap.java | 33 ++++ 2 files changed, 105 insertions(+), 80 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 08926e435..8abb1ee04 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -88,29 +88,29 @@ public class Compiler implements MessageConsumer { // 0. include paths for core + all libraries sketch.setCompilingProgress(20); - List includePaths = new ArrayList(); - includePaths.add(prefs.get("build.core.path")); - if (prefs.get("build.variant.path").length() != 0) - includePaths.add(prefs.get("build.variant.path")); + List includeFolders = new ArrayList(); + includeFolders.add(prefs.getFile("build.core.path")); + if (prefs.getFile("build.variant.path") != null) + includeFolders.add(prefs.getFile("build.variant.path")); for (Library lib : sketch.getImportedLibraries()) { if (verbose) System.out.println(I18n .format(_("Using library {0} in folder: {1} {2}"), lib.getName(), lib.getFolder(), lib.isLegacy() ? "(legacy)" : "")); - includePaths.add(lib.getSrcFolder().getPath()); + includeFolders.add(lib.getSrcFolder()); } if (verbose) System.out.println(); // 1. compile the sketch (already in the buildPath) sketch.setCompilingProgress(30); - compileSketch(includePaths); + compileSketch(includeFolders); sketchIsCompiled = true; // 2. compile the libraries, outputting .o files to: // // Doesn't really use configPreferences sketch.setCompilingProgress(40); - compileLibraries(includePaths); + compileLibraries(includeFolders); // 3. compile the core, outputting .o files to and then // collecting them into the core.a library file. @@ -119,15 +119,15 @@ public class Compiler implements MessageConsumer { // 4. link it all together into the .elf file sketch.setCompilingProgress(60); - compileLink(includePaths); + compileLink(); // 5. extract EEPROM data (from EEMEM directive) to .eep file. sketch.setCompilingProgress(70); - compileEep(includePaths); + compileEep(); // 6. build the .hex file sketch.setCompilingProgress(80); - compileHex(includePaths); + compileHex(); sketch.setCompilingProgress(90); return true; @@ -217,8 +217,8 @@ public class Compiler implements MessageConsumer { return p; } - private List compileFiles(String outputPath, File sourcePath, - boolean recurse, List includePaths) + private List compileFiles(File outputPath, File sourcePath, + boolean recurse, List includeFolders) throws RunnerException { List sSources = findFilesInFolder(sourcePath, "S", recurse); List cSources = findFilesInFolder(sourcePath, "c", recurse); @@ -226,36 +226,29 @@ public class Compiler implements MessageConsumer { List objectPaths = new ArrayList(); for (File file : sSources) { - String objectPath = outputPath + File.separator + file.getName() + ".o"; - objectPaths.add(new File(objectPath)); - String[] cmd = getCommandCompilerS(includePaths, file.getAbsolutePath(), - objectPath); + File objectFile = new File(outputPath, file.getName() + ".o"); + objectPaths.add(objectFile); + String[] cmd = getCommandCompilerS(includeFolders, file, objectFile); execAsynchronously(cmd); } for (File file : cSources) { - String objectPath = outputPath + File.separator + file.getName() + ".o"; - String dependPath = outputPath + File.separator + file.getName() + ".d"; - File objectFile = new File(objectPath); - File dependFile = new File(dependPath); + File objectFile = new File(outputPath, file.getName() + ".o"); + File dependFile = new File(outputPath, file.getName() + ".d"); objectPaths.add(objectFile); if (isAlreadyCompiled(file, objectFile, dependFile, prefs)) continue; - String[] cmd = getCommandCompilerC(includePaths, file.getAbsolutePath(), - objectPath); + String[] cmd = getCommandCompilerC(includeFolders, file, objectFile); execAsynchronously(cmd); } for (File file : cppSources) { - String objectPath = outputPath + File.separator + file.getName() + ".o"; - String dependPath = outputPath + File.separator + file.getName() + ".d"; - File objectFile = new File(objectPath); - File dependFile = new File(dependPath); + File objectFile = new File(outputPath, file.getName() + ".o"); + File dependFile = new File(outputPath, file.getName() + ".d"); objectPaths.add(objectFile); if (isAlreadyCompiled(file, objectFile, dependFile, prefs)) continue; - String[] cmd = getCommandCompilerCPP(includePaths, - file.getAbsolutePath(), objectPath); + String[] cmd = getCommandCompilerCPP(includeFolders, file, objectFile); execAsynchronously(cmd); } @@ -510,15 +503,15 @@ public class Compiler implements MessageConsumer { System.err.print(s); } - private String[] getCommandCompilerS(List includePaths, - String sourceName, String objectName) + private String[] getCommandCompilerS(List includeFolders, + File sourceFile, File objectFile) throws RunnerException { - String includes = preparePaths(includePaths); + String includes = prepareIncludes(includeFolders); PreferencesMap dict = new PreferencesMap(prefs); dict.put("ide_version", "" + Base.REVISION); dict.put("includes", includes); - dict.put("source_file", sourceName); - dict.put("object_file", objectName); + dict.put("source_file", sourceFile.getAbsolutePath()); + dict.put("object_file", objectFile.getAbsolutePath()); try { String cmd = prefs.get("recipe.S.o.pattern"); @@ -528,16 +521,16 @@ public class Compiler implements MessageConsumer { } } - private String[] getCommandCompilerC(List includePaths, - String sourceName, String objectName) + private String[] getCommandCompilerC(List includeFolders, + File sourceFile, File objectFile) throws RunnerException { - String includes = preparePaths(includePaths); + String includes = prepareIncludes(includeFolders); PreferencesMap dict = new PreferencesMap(prefs); dict.put("ide_version", "" + Base.REVISION); dict.put("includes", includes); - dict.put("source_file", sourceName); - dict.put("object_file", objectName); + dict.put("source_file", sourceFile.getAbsolutePath()); + dict.put("object_file", objectFile.getAbsolutePath()); String cmd = prefs.get("recipe.c.o.pattern"); try { @@ -547,16 +540,16 @@ public class Compiler implements MessageConsumer { } } - private String[] getCommandCompilerCPP(List includePaths, - String sourceName, String objectName) + private String[] getCommandCompilerCPP(List includeFolders, + File sourceFile, File objectFile) throws RunnerException { - String includes = preparePaths(includePaths); + String includes = prepareIncludes(includeFolders); PreferencesMap dict = new PreferencesMap(prefs); dict.put("ide_version", "" + Base.REVISION); dict.put("includes", includes); - dict.put("source_file", sourceName); - dict.put("object_file", objectName); + dict.put("source_file", sourceFile.getAbsolutePath()); + dict.put("object_file", objectFile.getAbsolutePath()); String cmd = prefs.get("recipe.cpp.o.pattern"); try { @@ -605,29 +598,28 @@ public class Compiler implements MessageConsumer { } // 1. compile the sketch (already in the buildPath) - void compileSketch(List includePaths) throws RunnerException { - String buildPath = prefs.get("build.path"); - objectFiles.addAll(compileFiles(buildPath, new File(buildPath), false, - includePaths)); + void compileSketch(List includeFolders) throws RunnerException { + File buildPath = prefs.getFile("build.path"); + objectFiles.addAll(compileFiles(buildPath, buildPath, false, includeFolders)); } // 2. compile the libraries, outputting .o files to: // // - void compileLibraries(List includePaths) throws RunnerException { + void compileLibraries(List includeFolders) throws RunnerException { for (Library lib : sketch.getImportedLibraries()) { - compileLibrary(lib, includePaths); + compileLibrary(lib, includeFolders); } } - private void compileLibrary(Library lib, List includePaths) + private void compileLibrary(Library lib, List includeFolders) throws RunnerException { File libFolder = lib.getSrcFolder(); - File libBuildFolder = new File(prefs.get("build.path"), lib.getName()); + File libBuildFolder = prefs.getFile(("build.path"), lib.getName()); if (lib.useRecursion()) { // libBuildFolder == {build.path}/LibName // libFolder == {lib.path}/src - recursiveCompileFilesInFolder(libBuildFolder, libFolder, includePaths); + recursiveCompileFilesInFolder(libBuildFolder, libFolder, includeFolders); } else { // libFolder == {lib.path}/ @@ -637,26 +629,26 @@ public class Compiler implements MessageConsumer { File utilityFolder = new File(libFolder, "utility"); File utilityBuildFolder = new File(libBuildFolder, "utility"); - includePaths.add(utilityFolder.getAbsolutePath()); - compileFilesInFolder(libBuildFolder, libFolder, includePaths); - compileFilesInFolder(utilityBuildFolder, utilityFolder, includePaths); + includeFolders.add(utilityFolder); + compileFilesInFolder(libBuildFolder, libFolder, includeFolders); + compileFilesInFolder(utilityBuildFolder, utilityFolder, includeFolders); // other libraries should not see this library's utility/ folder - includePaths.remove(utilityFolder.getAbsolutePath()); + includeFolders.remove(utilityFolder); } } - private void recursiveCompileFilesInFolder(File srcBuildFolder, File srcFolder, List includePaths) throws RunnerException { - compileFilesInFolder(srcBuildFolder, srcFolder, includePaths); + private void recursiveCompileFilesInFolder(File srcBuildFolder, File srcFolder, List includeFolders) throws RunnerException { + compileFilesInFolder(srcBuildFolder, srcFolder, includeFolders); for (File subFolder : srcFolder.listFiles(new OnlyDirs())) { File subBuildFolder = new File(srcBuildFolder, subFolder.getName()); - recursiveCompileFilesInFolder(subBuildFolder, subFolder, includePaths); + recursiveCompileFilesInFolder(subBuildFolder, subFolder, includeFolders); } } - private void compileFilesInFolder(File buildFolder, File srcFolder, List includePaths) throws RunnerException { + private void compileFilesInFolder(File buildFolder, File srcFolder, List includeFolders) throws RunnerException { createFolder(buildFolder); - List objects = compileFiles(buildFolder.getAbsolutePath(), srcFolder, false, includePaths); + List objects = compileFiles(buildFolder, srcFolder, false, includeFolders); objectFiles.addAll(objects); } @@ -665,22 +657,22 @@ public class Compiler implements MessageConsumer { void compileCore() throws RunnerException { - String corePath = prefs.get("build.core.path"); - String variantPath = prefs.get("build.variant.path"); - String buildPath = prefs.get("build.path"); + File coreFolder = prefs.getFile("build.core.path"); + File variantFolder = prefs.getFile("build.variant.path"); + File buildFolder = prefs.getFile("build.path"); - List includePaths = new ArrayList(); - includePaths.add(corePath); // include core path only - if (variantPath.length() != 0) - includePaths.add(variantPath); + List includeFolders = new ArrayList(); + includeFolders.add(coreFolder); // include core path only + if (variantFolder != null) + includeFolders.add(variantFolder); - List coreObjectFiles = compileFiles(buildPath, new File(corePath), - true, includePaths); - if (variantPath.length() != 0) - coreObjectFiles.addAll(compileFiles(buildPath, new File(variantPath), - true, includePaths)); + List objectFiles = compileFiles(buildFolder, coreFolder, true, + includeFolders); + if (variantFolder != null) + objectFiles.addAll(compileFiles(buildFolder, variantFolder, true, + includeFolders)); - for (File file : coreObjectFiles) { + for (File file : objectFiles) { PreferencesMap dict = new PreferencesMap(prefs); dict.put("ide_version", "" + Base.REVISION); @@ -699,7 +691,7 @@ public class Compiler implements MessageConsumer { } // 4. link it all together into the .elf file - void compileLink(List includePaths) + void compileLink() throws RunnerException { // TODO: Make the --relax thing in configuration files. @@ -733,7 +725,7 @@ public class Compiler implements MessageConsumer { } // 5. extract EEPROM data (from EEMEM directive) to .eep file. - void compileEep(List includePaths) throws RunnerException { + void compileEep() throws RunnerException { PreferencesMap dict = new PreferencesMap(prefs); dict.put("ide_version", "" + Base.REVISION); @@ -748,7 +740,7 @@ public class Compiler implements MessageConsumer { } // 6. build the .hex file - void compileHex(List includePaths) throws RunnerException { + void compileHex() throws RunnerException { PreferencesMap dict = new PreferencesMap(prefs); dict.put("ide_version", "" + Base.REVISION); @@ -762,10 +754,10 @@ public class Compiler implements MessageConsumer { execAsynchronously(cmdArray); } - private static String preparePaths(List includePaths) { + private static String prepareIncludes(List includeFolders) { String res = ""; - for (String p : includePaths) - res += " \"-I" + p + '"'; + for (File p : includeFolders) + res += " \"-I" + p.getAbsolutePath() + '"'; // Remove first space return res.substring(1); diff --git a/app/src/processing/app/helpers/PreferencesMap.java b/app/src/processing/app/helpers/PreferencesMap.java index cd3bb7dd2..bac942a77 100644 --- a/app/src/processing/app/helpers/PreferencesMap.java +++ b/app/src/processing/app/helpers/PreferencesMap.java @@ -265,4 +265,37 @@ public class PreferencesMap extends LinkedHashMap { public String toString() { return toString(""); } + + /** + * Creates a new File instance by converting the value of the key into an + * abstract pathname. If the the given key doesn't exists or his value is the + * empty string, the result is null. + * + * @param key + * @return + */ + public File getFile(String key) { + if (!containsKey(key)) + return null; + String path = get(key).trim(); + if (path.length() == 0) + return null; + return new File(path); + } + + /** + * Creates a new File instance by converting the value of the key into an + * abstract pathname with the specified sub folder. If the the given key + * doesn't exists or his value is the empty string, the result is null. + * + * @param key + * @param subFolder + * @return + */ + public File getFile(String key, String subFolder) { + File file = getFile(key); + if (file == null) + return null; + return new File(file, subFolder); + } } From 4932831f8b2d8b93e1e11ab670b5bce18e518c16 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 25 Dec 2013 16:16:31 +0100 Subject: [PATCH 04/13] IDE do not hide libraries with incompatible architectures --- app/src/processing/app/Base.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 5f351f764..fd5ab7df6 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1323,8 +1323,6 @@ public class Base { } catch (IOException e) { showWarning(_("Error"), _("Error loading libraries"), e); } - String currentArch = Base.getTargetPlatform().getId(); - libraries = libraries.filterByArchitecture(currentArch); // Populate importToLibraryTable importToLibraryTable = new HashMap(); From ce5ff8c2991fd945c880e80251d073aed43ec620 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 25 Dec 2013 19:20:29 +0100 Subject: [PATCH 05/13] Added "category" field in libraries. --- app/src/processing/app/packages/Library.java | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/src/processing/app/packages/Library.java b/app/src/processing/app/packages/Library.java index 1e95205c6..e94ab3680 100644 --- a/app/src/processing/app/packages/Library.java +++ b/app/src/processing/app/packages/Library.java @@ -21,6 +21,7 @@ public class Library { private String sentence; private String paragraph; private String url; + private String category; private List architectures; private File folder; private File srcFolder; @@ -31,6 +32,11 @@ public class Library { .asList(new String[] { "name", "version", "author", "maintainer", "sentence", "paragraph", "url" }); + private static final List CATEGORIES = Arrays.asList(new String[] { + "Display", "Communication", "Signal Input/Output", "Sensors", + "Device Control", "Timing", "Data Storage", "Data Processing", "Other", + "Uncategorized" }); + /** * Scans inside a folder and create a Library object out of it. Automatically * detects legacy libraries. Automatically fills metadata from @@ -113,6 +119,12 @@ public class Library { for (String arch : architectures.split(",")) archs.add(arch.trim()); + String category = properties.get("category"); + if (category == null) + category = "Uncategorized"; + if (!CATEGORIES.contains(category)) + category = "Uncategorized"; + Library res = new Library(); res.folder = libFolder; res.srcFolder = srcFolder; @@ -123,6 +135,7 @@ public class Library { res.sentence = properties.get("sentence").trim(); res.paragraph = properties.get("paragraph").trim(); res.url = properties.get("url").trim(); + res.category = category.trim(); res.architectures = archs; res.useRecursion = useRecursion; res.isLegacy = false; @@ -183,6 +196,14 @@ public class Library { return url; } + public String getCategory() { + return category; + } + + public static List getCategories() { + return CATEGORIES; + } + public String getVersion() { return version; } From 164da522b6f7e47a39bda5475ee0fcb0fa6b5bfb Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 25 Dec 2013 19:27:09 +0100 Subject: [PATCH 06/13] Added "license" field in libraries. --- app/src/processing/app/packages/Library.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/processing/app/packages/Library.java b/app/src/processing/app/packages/Library.java index e94ab3680..67b8865a3 100644 --- a/app/src/processing/app/packages/Library.java +++ b/app/src/processing/app/packages/Library.java @@ -22,6 +22,7 @@ public class Library { private String paragraph; private String url; private String category; + private String license; private List architectures; private File folder; private File srcFolder; @@ -125,6 +126,10 @@ public class Library { if (!CATEGORIES.contains(category)) category = "Uncategorized"; + String license = properties.get("license"); + if (license == null) + license = "Unspecified"; + Library res = new Library(); res.folder = libFolder; res.srcFolder = srcFolder; @@ -136,6 +141,7 @@ public class Library { res.paragraph = properties.get("paragraph").trim(); res.url = properties.get("url").trim(); res.category = category.trim(); + res.license = license.trim(); res.architectures = archs; res.useRecursion = useRecursion; res.isLegacy = false; @@ -200,6 +206,10 @@ public class Library { return category; } + public String getLicense() { + return license; + } + public static List getCategories() { return CATEGORIES; } From 512925a8128dd9f261d0ee48d7f78043d11268d8 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 25 Dec 2013 20:16:14 +0100 Subject: [PATCH 07/13] IDE warns if a library is compiled with an unsupported architecture --- app/src/processing/app/debug/Compiler.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 8abb1ee04..12641e709 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -101,6 +101,18 @@ public class Compiler implements MessageConsumer { } if (verbose) System.out.println(); + + String arch = Base.getTargetPlatform().getId(); + for (Library lib : sketch.getImportedLibraries()) { + if (!lib.supportsArchitecture(arch)) { + System.err.println(I18n + .format(_("WARNING: library {0} claims to run on {1} " + + "architecture(s) and may be incompatible with your" + + " current board which runs on [{2}] architecture."), lib + .getName(), lib.getArchitectures(), arch)); + System.err.println(); + } + } // 1. compile the sketch (already in the buildPath) sketch.setCompilingProgress(30); From 2b53d6988a6fa093e032a803605aa247fb580a63 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 26 Dec 2013 01:32:30 +0100 Subject: [PATCH 08/13] Added the possibility to override library compatibility check --- app/src/processing/app/debug/Compiler.java | 14 +++++++--- app/src/processing/app/packages/Library.java | 27 +++++++++++++++++--- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 12641e709..ae3f7e763 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -30,6 +30,7 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -102,14 +103,19 @@ public class Compiler implements MessageConsumer { if (verbose) System.out.println(); - String arch = Base.getTargetPlatform().getId(); + List archs = new ArrayList(); + archs.add(Base.getTargetPlatform().getId()); + if (prefs.containsKey("architecture.override_check")) { + String[] overrides = prefs.get("architecture.override_check").split(","); + archs.addAll(Arrays.asList(overrides)); + } for (Library lib : sketch.getImportedLibraries()) { - if (!lib.supportsArchitecture(arch)) { + if (!lib.supportsArchitecture(archs)) { System.err.println(I18n .format(_("WARNING: library {0} claims to run on {1} " + "architecture(s) and may be incompatible with your" - + " current board which runs on [{2}] architecture."), lib - .getName(), lib.getArchitectures(), arch)); + + " current board which runs on {2} architecture(s)."), lib + .getName(), lib.getArchitectures(), archs)); System.err.println(); } } diff --git a/app/src/processing/app/packages/Library.java b/app/src/processing/app/packages/Library.java index 67b8865a3..2ac8e5a43 100644 --- a/app/src/processing/app/packages/Library.java +++ b/app/src/processing/app/packages/Library.java @@ -1,7 +1,5 @@ package processing.app.packages; -import static processing.app.helpers.StringUtils.wildcardMatch; - import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -160,9 +158,30 @@ public class Library { return res; } + /** + * Returns true if the library declares to support the specified + * architecture (through the "architectures" property field). + * + * @param reqArch + * @return + */ public boolean supportsArchitecture(String reqArch) { - for (String arch : architectures) - if (wildcardMatch(reqArch, arch)) + return architectures.contains(reqArch) || architectures.contains("*"); + } + + /** + * Returns true if the library declares to support at least one of the + * specified architectures. + * + * @param reqArchs + * A List of architectures to check + * @return + */ + public boolean supportsArchitecture(List reqArchs) { + if (reqArchs.contains("*")) + return true; + for (String reqArch : reqArchs) + if (supportsArchitecture(reqArch)) return true; return false; } From 6923cc9c3919d67b38c6e1ce893391b9bd184c5d Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 26 Dec 2013 15:11:16 +0100 Subject: [PATCH 09/13] Removed unused import --- app/src/processing/app/Sketch.java | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index c8a2967ec..5d66e18a8 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -38,7 +38,6 @@ import processing.app.preproc.*; import processing.core.*; import static processing.app.I18n._; -import java.awt.*; import java.io.*; import java.util.*; import java.util.List; From d930e224364a1c7fbfeda411cb7dde3d5e1537ef Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 27 Dec 2013 01:21:00 +0100 Subject: [PATCH 10/13] GSM library to format 1.5 rev.2 --- libraries/GSM/library.properties | 18 ++++++++---------- .../{arch/avr => src}/GSM3CircularBuffer.cpp | 0 .../GSM/{arch/avr => src}/GSM3CircularBuffer.h | 0 .../avr => src}/GSM3MobileAccessProvider.cpp | 0 .../avr => src}/GSM3MobileAccessProvider.h | 0 .../avr => src}/GSM3MobileCellManagement.cpp | 0 .../avr => src}/GSM3MobileCellManagement.h | 0 .../avr => src}/GSM3MobileClientProvider.cpp | 0 .../avr => src}/GSM3MobileClientProvider.h | 0 .../avr => src}/GSM3MobileClientService.cpp | 0 .../avr => src}/GSM3MobileClientService.h | 0 .../GSM3MobileDataNetworkProvider.cpp | 0 .../GSM3MobileDataNetworkProvider.h | 0 .../avr => src}/GSM3MobileMockupProvider.cpp | 0 .../avr => src}/GSM3MobileMockupProvider.h | 0 .../avr => src}/GSM3MobileNetworkProvider.cpp | 0 .../avr => src}/GSM3MobileNetworkProvider.h | 0 .../avr => src}/GSM3MobileNetworkRegistry.cpp | 0 .../avr => src}/GSM3MobileNetworkRegistry.h | 0 .../avr => src}/GSM3MobileSMSProvider.cpp | 0 .../{arch/avr => src}/GSM3MobileSMSProvider.h | 0 .../avr => src}/GSM3MobileServerProvider.cpp | 0 .../avr => src}/GSM3MobileServerProvider.h | 0 .../avr => src}/GSM3MobileServerService.cpp | 0 .../avr => src}/GSM3MobileServerService.h | 0 .../avr => src}/GSM3MobileVoiceProvider.cpp | 0 .../avr => src}/GSM3MobileVoiceProvider.h | 0 .../GSM/{arch/avr => src}/GSM3SMSService.cpp | 0 .../GSM/{arch/avr => src}/GSM3SMSService.h | 0 .../GSM/{arch/avr => src}/GSM3ShieldV1.cpp | 0 libraries/GSM/{arch/avr => src}/GSM3ShieldV1.h | 0 .../avr => src}/GSM3ShieldV1AccessProvider.cpp | 0 .../avr => src}/GSM3ShieldV1AccessProvider.h | 0 .../avr => src}/GSM3ShieldV1BandManagement.cpp | 0 .../avr => src}/GSM3ShieldV1BandManagement.h | 0 .../avr => src}/GSM3ShieldV1BaseProvider.cpp | 0 .../avr => src}/GSM3ShieldV1BaseProvider.h | 0 .../avr => src}/GSM3ShieldV1CellManagement.cpp | 0 .../avr => src}/GSM3ShieldV1CellManagement.h | 0 .../avr => src}/GSM3ShieldV1ClientProvider.cpp | 0 .../avr => src}/GSM3ShieldV1ClientProvider.h | 0 .../GSM3ShieldV1DataNetworkProvider.cpp | 0 .../GSM3ShieldV1DataNetworkProvider.h | 0 .../GSM3ShieldV1DirectModemProvider.cpp | 0 .../GSM3ShieldV1DirectModemProvider.h | 0 .../avr => src}/GSM3ShieldV1ModemCore.cpp | 0 .../{arch/avr => src}/GSM3ShieldV1ModemCore.h | 0 .../GSM3ShieldV1ModemVerification.cpp | 0 .../GSM3ShieldV1ModemVerification.h | 0 .../GSM3ShieldV1MultiClientProvider.cpp | 0 .../GSM3ShieldV1MultiClientProvider.h | 0 .../GSM3ShieldV1MultiServerProvider.cpp | 0 .../GSM3ShieldV1MultiServerProvider.h | 0 .../avr => src}/GSM3ShieldV1PinManagement.cpp | 0 .../avr => src}/GSM3ShieldV1PinManagement.h | 0 .../avr => src}/GSM3ShieldV1SMSProvider.cpp | 0 .../avr => src}/GSM3ShieldV1SMSProvider.h | 0 .../avr => src}/GSM3ShieldV1ScanNetworks.cpp | 0 .../avr => src}/GSM3ShieldV1ScanNetworks.h | 0 .../avr => src}/GSM3ShieldV1ServerProvider.cpp | 0 .../avr => src}/GSM3ShieldV1ServerProvider.h | 0 .../avr => src}/GSM3ShieldV1VoiceProvider.cpp | 0 .../avr => src}/GSM3ShieldV1VoiceProvider.h | 0 .../GSM/{arch/avr => src}/GSM3SoftSerial.cpp | 0 .../GSM/{arch/avr => src}/GSM3SoftSerial.h | 0 .../{arch/avr => src}/GSM3VoiceCallService.cpp | 0 .../{arch/avr => src}/GSM3VoiceCallService.h | 0 67 files changed, 8 insertions(+), 10 deletions(-) rename libraries/GSM/{arch/avr => src}/GSM3CircularBuffer.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3CircularBuffer.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileAccessProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileAccessProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileCellManagement.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileCellManagement.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileClientProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileClientProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileClientService.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileClientService.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileDataNetworkProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileDataNetworkProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileMockupProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileMockupProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileNetworkProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileNetworkProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileNetworkRegistry.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileNetworkRegistry.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileSMSProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileSMSProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileServerProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileServerProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileServerService.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileServerService.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileVoiceProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3MobileVoiceProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3SMSService.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3SMSService.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1AccessProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1AccessProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1BandManagement.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1BandManagement.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1BaseProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1BaseProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1CellManagement.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1CellManagement.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1ClientProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1ClientProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1DataNetworkProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1DataNetworkProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1DirectModemProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1DirectModemProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1ModemCore.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1ModemCore.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1ModemVerification.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1ModemVerification.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1MultiClientProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1MultiClientProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1MultiServerProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1MultiServerProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1PinManagement.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1PinManagement.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1SMSProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1SMSProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1ScanNetworks.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1ScanNetworks.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1ServerProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1ServerProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1VoiceProvider.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3ShieldV1VoiceProvider.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3SoftSerial.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3SoftSerial.h (100%) rename libraries/GSM/{arch/avr => src}/GSM3VoiceCallService.cpp (100%) rename libraries/GSM/{arch/avr => src}/GSM3VoiceCallService.h (100%) diff --git a/libraries/GSM/library.properties b/libraries/GSM/library.properties index 1d04524a8..5d20caf7b 100644 --- a/libraries/GSM/library.properties +++ b/libraries/GSM/library.properties @@ -1,10 +1,8 @@ -name=GSM -author=Arduino -email=info@arduino.cc -sentence=With this library you can use the Arduino GSM shield to connect on GSM and GPRS networks -paragraph=Use this library to make/receive voice calls, to send and receive SMS with the Quectel M10 GSM module.
This library also allows you to connect to internet through the GPRS networks. You can either use web Clients and Servers.
-url=http://arduino.cc/en/Reference/GSM -architectures=avr -version=1.0 -dependencies=SoftwareSerial -core-dependencies=arduino (>=1.5.0) +name=GSM +author=Arduino +maintainer=Arduino +sentence=With this library you can use the Arduino GSM shield to connect on GSM and GPRS networks +paragraph=Use this library to make/receive voice calls, to send and receive SMS with the Quectel M10 GSM module.
This library also allows you to connect to internet through the GPRS networks. You can either use web Clients and Servers.
+url=http://arduino.cc/en/Reference/GSM +architectures=avr +version=1.0 diff --git a/libraries/GSM/arch/avr/GSM3CircularBuffer.cpp b/libraries/GSM/src/GSM3CircularBuffer.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3CircularBuffer.cpp rename to libraries/GSM/src/GSM3CircularBuffer.cpp diff --git a/libraries/GSM/arch/avr/GSM3CircularBuffer.h b/libraries/GSM/src/GSM3CircularBuffer.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3CircularBuffer.h rename to libraries/GSM/src/GSM3CircularBuffer.h diff --git a/libraries/GSM/arch/avr/GSM3MobileAccessProvider.cpp b/libraries/GSM/src/GSM3MobileAccessProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileAccessProvider.cpp rename to libraries/GSM/src/GSM3MobileAccessProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3MobileAccessProvider.h b/libraries/GSM/src/GSM3MobileAccessProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileAccessProvider.h rename to libraries/GSM/src/GSM3MobileAccessProvider.h diff --git a/libraries/GSM/arch/avr/GSM3MobileCellManagement.cpp b/libraries/GSM/src/GSM3MobileCellManagement.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileCellManagement.cpp rename to libraries/GSM/src/GSM3MobileCellManagement.cpp diff --git a/libraries/GSM/arch/avr/GSM3MobileCellManagement.h b/libraries/GSM/src/GSM3MobileCellManagement.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileCellManagement.h rename to libraries/GSM/src/GSM3MobileCellManagement.h diff --git a/libraries/GSM/arch/avr/GSM3MobileClientProvider.cpp b/libraries/GSM/src/GSM3MobileClientProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileClientProvider.cpp rename to libraries/GSM/src/GSM3MobileClientProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3MobileClientProvider.h b/libraries/GSM/src/GSM3MobileClientProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileClientProvider.h rename to libraries/GSM/src/GSM3MobileClientProvider.h diff --git a/libraries/GSM/arch/avr/GSM3MobileClientService.cpp b/libraries/GSM/src/GSM3MobileClientService.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileClientService.cpp rename to libraries/GSM/src/GSM3MobileClientService.cpp diff --git a/libraries/GSM/arch/avr/GSM3MobileClientService.h b/libraries/GSM/src/GSM3MobileClientService.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileClientService.h rename to libraries/GSM/src/GSM3MobileClientService.h diff --git a/libraries/GSM/arch/avr/GSM3MobileDataNetworkProvider.cpp b/libraries/GSM/src/GSM3MobileDataNetworkProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileDataNetworkProvider.cpp rename to libraries/GSM/src/GSM3MobileDataNetworkProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3MobileDataNetworkProvider.h b/libraries/GSM/src/GSM3MobileDataNetworkProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileDataNetworkProvider.h rename to libraries/GSM/src/GSM3MobileDataNetworkProvider.h diff --git a/libraries/GSM/arch/avr/GSM3MobileMockupProvider.cpp b/libraries/GSM/src/GSM3MobileMockupProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileMockupProvider.cpp rename to libraries/GSM/src/GSM3MobileMockupProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3MobileMockupProvider.h b/libraries/GSM/src/GSM3MobileMockupProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileMockupProvider.h rename to libraries/GSM/src/GSM3MobileMockupProvider.h diff --git a/libraries/GSM/arch/avr/GSM3MobileNetworkProvider.cpp b/libraries/GSM/src/GSM3MobileNetworkProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileNetworkProvider.cpp rename to libraries/GSM/src/GSM3MobileNetworkProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3MobileNetworkProvider.h b/libraries/GSM/src/GSM3MobileNetworkProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileNetworkProvider.h rename to libraries/GSM/src/GSM3MobileNetworkProvider.h diff --git a/libraries/GSM/arch/avr/GSM3MobileNetworkRegistry.cpp b/libraries/GSM/src/GSM3MobileNetworkRegistry.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileNetworkRegistry.cpp rename to libraries/GSM/src/GSM3MobileNetworkRegistry.cpp diff --git a/libraries/GSM/arch/avr/GSM3MobileNetworkRegistry.h b/libraries/GSM/src/GSM3MobileNetworkRegistry.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileNetworkRegistry.h rename to libraries/GSM/src/GSM3MobileNetworkRegistry.h diff --git a/libraries/GSM/arch/avr/GSM3MobileSMSProvider.cpp b/libraries/GSM/src/GSM3MobileSMSProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileSMSProvider.cpp rename to libraries/GSM/src/GSM3MobileSMSProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3MobileSMSProvider.h b/libraries/GSM/src/GSM3MobileSMSProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileSMSProvider.h rename to libraries/GSM/src/GSM3MobileSMSProvider.h diff --git a/libraries/GSM/arch/avr/GSM3MobileServerProvider.cpp b/libraries/GSM/src/GSM3MobileServerProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileServerProvider.cpp rename to libraries/GSM/src/GSM3MobileServerProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3MobileServerProvider.h b/libraries/GSM/src/GSM3MobileServerProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileServerProvider.h rename to libraries/GSM/src/GSM3MobileServerProvider.h diff --git a/libraries/GSM/arch/avr/GSM3MobileServerService.cpp b/libraries/GSM/src/GSM3MobileServerService.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileServerService.cpp rename to libraries/GSM/src/GSM3MobileServerService.cpp diff --git a/libraries/GSM/arch/avr/GSM3MobileServerService.h b/libraries/GSM/src/GSM3MobileServerService.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileServerService.h rename to libraries/GSM/src/GSM3MobileServerService.h diff --git a/libraries/GSM/arch/avr/GSM3MobileVoiceProvider.cpp b/libraries/GSM/src/GSM3MobileVoiceProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileVoiceProvider.cpp rename to libraries/GSM/src/GSM3MobileVoiceProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3MobileVoiceProvider.h b/libraries/GSM/src/GSM3MobileVoiceProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3MobileVoiceProvider.h rename to libraries/GSM/src/GSM3MobileVoiceProvider.h diff --git a/libraries/GSM/arch/avr/GSM3SMSService.cpp b/libraries/GSM/src/GSM3SMSService.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3SMSService.cpp rename to libraries/GSM/src/GSM3SMSService.cpp diff --git a/libraries/GSM/arch/avr/GSM3SMSService.h b/libraries/GSM/src/GSM3SMSService.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3SMSService.h rename to libraries/GSM/src/GSM3SMSService.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1.cpp b/libraries/GSM/src/GSM3ShieldV1.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1.cpp rename to libraries/GSM/src/GSM3ShieldV1.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1.h b/libraries/GSM/src/GSM3ShieldV1.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1.h rename to libraries/GSM/src/GSM3ShieldV1.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1AccessProvider.cpp b/libraries/GSM/src/GSM3ShieldV1AccessProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1AccessProvider.cpp rename to libraries/GSM/src/GSM3ShieldV1AccessProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1AccessProvider.h b/libraries/GSM/src/GSM3ShieldV1AccessProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1AccessProvider.h rename to libraries/GSM/src/GSM3ShieldV1AccessProvider.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1BandManagement.cpp b/libraries/GSM/src/GSM3ShieldV1BandManagement.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1BandManagement.cpp rename to libraries/GSM/src/GSM3ShieldV1BandManagement.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1BandManagement.h b/libraries/GSM/src/GSM3ShieldV1BandManagement.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1BandManagement.h rename to libraries/GSM/src/GSM3ShieldV1BandManagement.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1BaseProvider.cpp b/libraries/GSM/src/GSM3ShieldV1BaseProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1BaseProvider.cpp rename to libraries/GSM/src/GSM3ShieldV1BaseProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1BaseProvider.h b/libraries/GSM/src/GSM3ShieldV1BaseProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1BaseProvider.h rename to libraries/GSM/src/GSM3ShieldV1BaseProvider.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1CellManagement.cpp b/libraries/GSM/src/GSM3ShieldV1CellManagement.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1CellManagement.cpp rename to libraries/GSM/src/GSM3ShieldV1CellManagement.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1CellManagement.h b/libraries/GSM/src/GSM3ShieldV1CellManagement.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1CellManagement.h rename to libraries/GSM/src/GSM3ShieldV1CellManagement.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1ClientProvider.cpp b/libraries/GSM/src/GSM3ShieldV1ClientProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1ClientProvider.cpp rename to libraries/GSM/src/GSM3ShieldV1ClientProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1ClientProvider.h b/libraries/GSM/src/GSM3ShieldV1ClientProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1ClientProvider.h rename to libraries/GSM/src/GSM3ShieldV1ClientProvider.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1DataNetworkProvider.cpp b/libraries/GSM/src/GSM3ShieldV1DataNetworkProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1DataNetworkProvider.cpp rename to libraries/GSM/src/GSM3ShieldV1DataNetworkProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1DataNetworkProvider.h b/libraries/GSM/src/GSM3ShieldV1DataNetworkProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1DataNetworkProvider.h rename to libraries/GSM/src/GSM3ShieldV1DataNetworkProvider.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1DirectModemProvider.cpp b/libraries/GSM/src/GSM3ShieldV1DirectModemProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1DirectModemProvider.cpp rename to libraries/GSM/src/GSM3ShieldV1DirectModemProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1DirectModemProvider.h b/libraries/GSM/src/GSM3ShieldV1DirectModemProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1DirectModemProvider.h rename to libraries/GSM/src/GSM3ShieldV1DirectModemProvider.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1ModemCore.cpp b/libraries/GSM/src/GSM3ShieldV1ModemCore.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1ModemCore.cpp rename to libraries/GSM/src/GSM3ShieldV1ModemCore.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1ModemCore.h b/libraries/GSM/src/GSM3ShieldV1ModemCore.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1ModemCore.h rename to libraries/GSM/src/GSM3ShieldV1ModemCore.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1ModemVerification.cpp b/libraries/GSM/src/GSM3ShieldV1ModemVerification.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1ModemVerification.cpp rename to libraries/GSM/src/GSM3ShieldV1ModemVerification.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1ModemVerification.h b/libraries/GSM/src/GSM3ShieldV1ModemVerification.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1ModemVerification.h rename to libraries/GSM/src/GSM3ShieldV1ModemVerification.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1MultiClientProvider.cpp b/libraries/GSM/src/GSM3ShieldV1MultiClientProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1MultiClientProvider.cpp rename to libraries/GSM/src/GSM3ShieldV1MultiClientProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1MultiClientProvider.h b/libraries/GSM/src/GSM3ShieldV1MultiClientProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1MultiClientProvider.h rename to libraries/GSM/src/GSM3ShieldV1MultiClientProvider.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1MultiServerProvider.cpp b/libraries/GSM/src/GSM3ShieldV1MultiServerProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1MultiServerProvider.cpp rename to libraries/GSM/src/GSM3ShieldV1MultiServerProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1MultiServerProvider.h b/libraries/GSM/src/GSM3ShieldV1MultiServerProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1MultiServerProvider.h rename to libraries/GSM/src/GSM3ShieldV1MultiServerProvider.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1PinManagement.cpp b/libraries/GSM/src/GSM3ShieldV1PinManagement.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1PinManagement.cpp rename to libraries/GSM/src/GSM3ShieldV1PinManagement.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1PinManagement.h b/libraries/GSM/src/GSM3ShieldV1PinManagement.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1PinManagement.h rename to libraries/GSM/src/GSM3ShieldV1PinManagement.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1SMSProvider.cpp b/libraries/GSM/src/GSM3ShieldV1SMSProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1SMSProvider.cpp rename to libraries/GSM/src/GSM3ShieldV1SMSProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1SMSProvider.h b/libraries/GSM/src/GSM3ShieldV1SMSProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1SMSProvider.h rename to libraries/GSM/src/GSM3ShieldV1SMSProvider.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1ScanNetworks.cpp b/libraries/GSM/src/GSM3ShieldV1ScanNetworks.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1ScanNetworks.cpp rename to libraries/GSM/src/GSM3ShieldV1ScanNetworks.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1ScanNetworks.h b/libraries/GSM/src/GSM3ShieldV1ScanNetworks.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1ScanNetworks.h rename to libraries/GSM/src/GSM3ShieldV1ScanNetworks.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1ServerProvider.cpp b/libraries/GSM/src/GSM3ShieldV1ServerProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1ServerProvider.cpp rename to libraries/GSM/src/GSM3ShieldV1ServerProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1ServerProvider.h b/libraries/GSM/src/GSM3ShieldV1ServerProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1ServerProvider.h rename to libraries/GSM/src/GSM3ShieldV1ServerProvider.h diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1VoiceProvider.cpp b/libraries/GSM/src/GSM3ShieldV1VoiceProvider.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1VoiceProvider.cpp rename to libraries/GSM/src/GSM3ShieldV1VoiceProvider.cpp diff --git a/libraries/GSM/arch/avr/GSM3ShieldV1VoiceProvider.h b/libraries/GSM/src/GSM3ShieldV1VoiceProvider.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3ShieldV1VoiceProvider.h rename to libraries/GSM/src/GSM3ShieldV1VoiceProvider.h diff --git a/libraries/GSM/arch/avr/GSM3SoftSerial.cpp b/libraries/GSM/src/GSM3SoftSerial.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3SoftSerial.cpp rename to libraries/GSM/src/GSM3SoftSerial.cpp diff --git a/libraries/GSM/arch/avr/GSM3SoftSerial.h b/libraries/GSM/src/GSM3SoftSerial.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3SoftSerial.h rename to libraries/GSM/src/GSM3SoftSerial.h diff --git a/libraries/GSM/arch/avr/GSM3VoiceCallService.cpp b/libraries/GSM/src/GSM3VoiceCallService.cpp similarity index 100% rename from libraries/GSM/arch/avr/GSM3VoiceCallService.cpp rename to libraries/GSM/src/GSM3VoiceCallService.cpp diff --git a/libraries/GSM/arch/avr/GSM3VoiceCallService.h b/libraries/GSM/src/GSM3VoiceCallService.h similarity index 100% rename from libraries/GSM/arch/avr/GSM3VoiceCallService.h rename to libraries/GSM/src/GSM3VoiceCallService.h From a80b2b1d53f3e9ab70beadd493437da88fec8891 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 27 Dec 2013 01:30:54 +0100 Subject: [PATCH 11/13] Audio library to format 1.5 rev.2 --- libraries/Audio/library.properties | 18 ++++++++---------- libraries/Audio/{arch/sam => src}/DAC.cpp | 0 libraries/Audio/{arch/sam => src}/DAC.h | 0 3 files changed, 8 insertions(+), 10 deletions(-) rename libraries/Audio/{arch/sam => src}/DAC.cpp (100%) rename libraries/Audio/{arch/sam => src}/DAC.h (100%) diff --git a/libraries/Audio/library.properties b/libraries/Audio/library.properties index a7119b846..e7381cb11 100644 --- a/libraries/Audio/library.properties +++ b/libraries/Audio/library.properties @@ -1,10 +1,8 @@ -name=Audio -author=cmaglie -email=Cristian Maglie -sentence=Play audio files through the DAC outputs of the Arduino Due. -paragraph=With this library you can use the Arduino Due DAC outputs to play audio files.
The audio files must be in the raw .wav format. -url=http://arduino.cc/en/Reference/Audio -architectures=sam -version=1.0 -dependencies= -core-dependencies=arduino (>=1.5.0) +name=Audio +version=1.0 +author=Arduino +maintainer=Arduino +sentence=Play audio files through the DAC outputs of the Arduino Due. +paragraph=With this library you can use the Arduino Due DAC outputs to play audio files.
The audio files must be in the raw .wav format. +url=http://arduino.cc/en/Reference/Audio +architectures=sam diff --git a/libraries/Audio/arch/sam/DAC.cpp b/libraries/Audio/src/DAC.cpp similarity index 100% rename from libraries/Audio/arch/sam/DAC.cpp rename to libraries/Audio/src/DAC.cpp diff --git a/libraries/Audio/arch/sam/DAC.h b/libraries/Audio/src/DAC.h similarity index 100% rename from libraries/Audio/arch/sam/DAC.h rename to libraries/Audio/src/DAC.h From 03a7cf3212c04721296c236279c31abdf268b43e Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 1 Jan 2014 23:45:39 +0100 Subject: [PATCH 12/13] Robot Control library to format 1.5 rev.2 --- libraries/Robot_Control/library.properties | 6 ++---- libraries/Robot_Control/{arch/avr => src}/ArduinoRobot.cpp | 0 libraries/Robot_Control/{arch/avr => src}/Arduino_LCD.cpp | 0 libraries/Robot_Control/{arch/avr => src}/Arduino_LCD.h | 0 libraries/Robot_Control/{arch/avr => src}/Compass.cpp | 0 libraries/Robot_Control/{arch/avr => src}/Compass.h | 0 libraries/Robot_Control/{arch/avr => src}/EEPROM_I2C.cpp | 0 libraries/Robot_Control/{arch/avr => src}/EEPROM_I2C.h | 0 libraries/Robot_Control/{arch/avr => src}/EasyTransfer2.cpp | 0 libraries/Robot_Control/{arch/avr => src}/EasyTransfer2.h | 0 libraries/Robot_Control/{arch/avr => src}/Fat16.cpp | 0 libraries/Robot_Control/{arch/avr => src}/Fat16.h | 0 libraries/Robot_Control/{arch/avr => src}/Fat16Config.h | 0 libraries/Robot_Control/{arch/avr => src}/Fat16mainpage.h | 0 libraries/Robot_Control/{arch/avr => src}/Fat16util.h | 0 libraries/Robot_Control/{arch/avr => src}/FatStructs.h | 0 libraries/Robot_Control/{arch/avr => src}/Melody.cpp | 0 libraries/Robot_Control/{arch/avr => src}/Motors.cpp | 0 libraries/Robot_Control/{arch/avr => src}/Multiplexer.cpp | 0 libraries/Robot_Control/{arch/avr => src}/Multiplexer.h | 0 libraries/Robot_Control/{arch/avr => src}/RobotSdCard.cpp | 0 libraries/Robot_Control/{arch/avr => src}/SPI.cpp | 0 libraries/Robot_Control/{arch/avr => src}/SPI.h | 0 libraries/Robot_Control/{arch/avr => src}/SdCard.cpp | 0 libraries/Robot_Control/{arch/avr => src}/SdCard.h | 0 libraries/Robot_Control/{arch/avr => src}/SdInfo.h | 0 libraries/Robot_Control/{arch/avr => src}/Sensors.cpp | 0 libraries/Robot_Control/{arch/avr => src}/Squawk.cpp | 0 libraries/Robot_Control/{arch/avr => src}/Squawk.h | 0 libraries/Robot_Control/{arch/avr => src}/SquawkSD.cpp | 0 libraries/Robot_Control/{arch/avr => src}/SquawkSD.h | 0 libraries/Robot_Control/{arch/avr => src}/Wire.cpp | 0 libraries/Robot_Control/{arch/avr => src}/Wire.h | 0 libraries/Robot_Control/{arch/avr => src}/communication.cpp | 0 libraries/Robot_Control/{arch/avr => src}/glcdfont.c | 0 libraries/Robot_Control/{arch/avr => src}/helper.cpp | 0 libraries/Robot_Control/{arch/avr => src}/information.cpp | 0 libraries/Robot_Control/{arch/avr => src}/keyboard.cpp | 0 libraries/Robot_Control/{arch/avr => src}/lcd.cpp | 0 .../{arch/avr => src}/utility/Adafruit_GFX.cpp | 0 .../Robot_Control/{arch/avr => src}/utility/Adafruit_GFX.h | 0 .../{arch/avr => src}/utility/RobotTextManager.cpp | 0 .../{arch/avr => src}/utility/RobotTextManager.h | 0 .../{arch/avr => src}/utility/VirtualKeyboard.cpp | 0 .../{arch/avr => src}/utility/VirtualKeyboard.h | 0 .../{arch/avr => src}/utility/scripts_Hello_User.h | 0 libraries/Robot_Control/{arch/avr => src}/utility/twi.c | 0 libraries/Robot_Control/{arch/avr => src}/utility/twi.h | 0 48 files changed, 2 insertions(+), 4 deletions(-) rename libraries/Robot_Control/{arch/avr => src}/ArduinoRobot.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/Arduino_LCD.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/Arduino_LCD.h (100%) rename libraries/Robot_Control/{arch/avr => src}/Compass.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/Compass.h (100%) rename libraries/Robot_Control/{arch/avr => src}/EEPROM_I2C.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/EEPROM_I2C.h (100%) rename libraries/Robot_Control/{arch/avr => src}/EasyTransfer2.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/EasyTransfer2.h (100%) rename libraries/Robot_Control/{arch/avr => src}/Fat16.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/Fat16.h (100%) rename libraries/Robot_Control/{arch/avr => src}/Fat16Config.h (100%) rename libraries/Robot_Control/{arch/avr => src}/Fat16mainpage.h (100%) rename libraries/Robot_Control/{arch/avr => src}/Fat16util.h (100%) rename libraries/Robot_Control/{arch/avr => src}/FatStructs.h (100%) rename libraries/Robot_Control/{arch/avr => src}/Melody.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/Motors.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/Multiplexer.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/Multiplexer.h (100%) rename libraries/Robot_Control/{arch/avr => src}/RobotSdCard.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/SPI.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/SPI.h (100%) rename libraries/Robot_Control/{arch/avr => src}/SdCard.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/SdCard.h (100%) rename libraries/Robot_Control/{arch/avr => src}/SdInfo.h (100%) rename libraries/Robot_Control/{arch/avr => src}/Sensors.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/Squawk.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/Squawk.h (100%) rename libraries/Robot_Control/{arch/avr => src}/SquawkSD.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/SquawkSD.h (100%) rename libraries/Robot_Control/{arch/avr => src}/Wire.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/Wire.h (100%) rename libraries/Robot_Control/{arch/avr => src}/communication.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/glcdfont.c (100%) rename libraries/Robot_Control/{arch/avr => src}/helper.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/information.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/keyboard.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/lcd.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/utility/Adafruit_GFX.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/utility/Adafruit_GFX.h (100%) rename libraries/Robot_Control/{arch/avr => src}/utility/RobotTextManager.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/utility/RobotTextManager.h (100%) rename libraries/Robot_Control/{arch/avr => src}/utility/VirtualKeyboard.cpp (100%) rename libraries/Robot_Control/{arch/avr => src}/utility/VirtualKeyboard.h (100%) rename libraries/Robot_Control/{arch/avr => src}/utility/scripts_Hello_User.h (100%) rename libraries/Robot_Control/{arch/avr => src}/utility/twi.c (100%) rename libraries/Robot_Control/{arch/avr => src}/utility/twi.h (100%) diff --git a/libraries/Robot_Control/library.properties b/libraries/Robot_Control/library.properties index f4d18e818..f1ccf8213 100644 --- a/libraries/Robot_Control/library.properties +++ b/libraries/Robot_Control/library.properties @@ -1,10 +1,8 @@ name=Robot Control +version=1.0 author=Arduino -email=info@arduino.cc +maintainer=Arduino sentence=This is the library for programming the Control Board of the Arduino Robot. paragraph=The Arduino robot is made by two independent boards. The Control Board is the top board of the Arduino Robot, with this library you can easily write sketches to control the robot. url=http://arduino.cc/en/Reference/RobotLibrary architectures=avr -version=1.0 -dependencies= -core-dependencies=arduino (>=1.5.0) diff --git a/libraries/Robot_Control/arch/avr/ArduinoRobot.cpp b/libraries/Robot_Control/src/ArduinoRobot.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/ArduinoRobot.cpp rename to libraries/Robot_Control/src/ArduinoRobot.cpp diff --git a/libraries/Robot_Control/arch/avr/Arduino_LCD.cpp b/libraries/Robot_Control/src/Arduino_LCD.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/Arduino_LCD.cpp rename to libraries/Robot_Control/src/Arduino_LCD.cpp diff --git a/libraries/Robot_Control/arch/avr/Arduino_LCD.h b/libraries/Robot_Control/src/Arduino_LCD.h similarity index 100% rename from libraries/Robot_Control/arch/avr/Arduino_LCD.h rename to libraries/Robot_Control/src/Arduino_LCD.h diff --git a/libraries/Robot_Control/arch/avr/Compass.cpp b/libraries/Robot_Control/src/Compass.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/Compass.cpp rename to libraries/Robot_Control/src/Compass.cpp diff --git a/libraries/Robot_Control/arch/avr/Compass.h b/libraries/Robot_Control/src/Compass.h similarity index 100% rename from libraries/Robot_Control/arch/avr/Compass.h rename to libraries/Robot_Control/src/Compass.h diff --git a/libraries/Robot_Control/arch/avr/EEPROM_I2C.cpp b/libraries/Robot_Control/src/EEPROM_I2C.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/EEPROM_I2C.cpp rename to libraries/Robot_Control/src/EEPROM_I2C.cpp diff --git a/libraries/Robot_Control/arch/avr/EEPROM_I2C.h b/libraries/Robot_Control/src/EEPROM_I2C.h similarity index 100% rename from libraries/Robot_Control/arch/avr/EEPROM_I2C.h rename to libraries/Robot_Control/src/EEPROM_I2C.h diff --git a/libraries/Robot_Control/arch/avr/EasyTransfer2.cpp b/libraries/Robot_Control/src/EasyTransfer2.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/EasyTransfer2.cpp rename to libraries/Robot_Control/src/EasyTransfer2.cpp diff --git a/libraries/Robot_Control/arch/avr/EasyTransfer2.h b/libraries/Robot_Control/src/EasyTransfer2.h similarity index 100% rename from libraries/Robot_Control/arch/avr/EasyTransfer2.h rename to libraries/Robot_Control/src/EasyTransfer2.h diff --git a/libraries/Robot_Control/arch/avr/Fat16.cpp b/libraries/Robot_Control/src/Fat16.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/Fat16.cpp rename to libraries/Robot_Control/src/Fat16.cpp diff --git a/libraries/Robot_Control/arch/avr/Fat16.h b/libraries/Robot_Control/src/Fat16.h similarity index 100% rename from libraries/Robot_Control/arch/avr/Fat16.h rename to libraries/Robot_Control/src/Fat16.h diff --git a/libraries/Robot_Control/arch/avr/Fat16Config.h b/libraries/Robot_Control/src/Fat16Config.h similarity index 100% rename from libraries/Robot_Control/arch/avr/Fat16Config.h rename to libraries/Robot_Control/src/Fat16Config.h diff --git a/libraries/Robot_Control/arch/avr/Fat16mainpage.h b/libraries/Robot_Control/src/Fat16mainpage.h similarity index 100% rename from libraries/Robot_Control/arch/avr/Fat16mainpage.h rename to libraries/Robot_Control/src/Fat16mainpage.h diff --git a/libraries/Robot_Control/arch/avr/Fat16util.h b/libraries/Robot_Control/src/Fat16util.h similarity index 100% rename from libraries/Robot_Control/arch/avr/Fat16util.h rename to libraries/Robot_Control/src/Fat16util.h diff --git a/libraries/Robot_Control/arch/avr/FatStructs.h b/libraries/Robot_Control/src/FatStructs.h similarity index 100% rename from libraries/Robot_Control/arch/avr/FatStructs.h rename to libraries/Robot_Control/src/FatStructs.h diff --git a/libraries/Robot_Control/arch/avr/Melody.cpp b/libraries/Robot_Control/src/Melody.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/Melody.cpp rename to libraries/Robot_Control/src/Melody.cpp diff --git a/libraries/Robot_Control/arch/avr/Motors.cpp b/libraries/Robot_Control/src/Motors.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/Motors.cpp rename to libraries/Robot_Control/src/Motors.cpp diff --git a/libraries/Robot_Control/arch/avr/Multiplexer.cpp b/libraries/Robot_Control/src/Multiplexer.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/Multiplexer.cpp rename to libraries/Robot_Control/src/Multiplexer.cpp diff --git a/libraries/Robot_Control/arch/avr/Multiplexer.h b/libraries/Robot_Control/src/Multiplexer.h similarity index 100% rename from libraries/Robot_Control/arch/avr/Multiplexer.h rename to libraries/Robot_Control/src/Multiplexer.h diff --git a/libraries/Robot_Control/arch/avr/RobotSdCard.cpp b/libraries/Robot_Control/src/RobotSdCard.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/RobotSdCard.cpp rename to libraries/Robot_Control/src/RobotSdCard.cpp diff --git a/libraries/Robot_Control/arch/avr/SPI.cpp b/libraries/Robot_Control/src/SPI.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/SPI.cpp rename to libraries/Robot_Control/src/SPI.cpp diff --git a/libraries/Robot_Control/arch/avr/SPI.h b/libraries/Robot_Control/src/SPI.h similarity index 100% rename from libraries/Robot_Control/arch/avr/SPI.h rename to libraries/Robot_Control/src/SPI.h diff --git a/libraries/Robot_Control/arch/avr/SdCard.cpp b/libraries/Robot_Control/src/SdCard.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/SdCard.cpp rename to libraries/Robot_Control/src/SdCard.cpp diff --git a/libraries/Robot_Control/arch/avr/SdCard.h b/libraries/Robot_Control/src/SdCard.h similarity index 100% rename from libraries/Robot_Control/arch/avr/SdCard.h rename to libraries/Robot_Control/src/SdCard.h diff --git a/libraries/Robot_Control/arch/avr/SdInfo.h b/libraries/Robot_Control/src/SdInfo.h similarity index 100% rename from libraries/Robot_Control/arch/avr/SdInfo.h rename to libraries/Robot_Control/src/SdInfo.h diff --git a/libraries/Robot_Control/arch/avr/Sensors.cpp b/libraries/Robot_Control/src/Sensors.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/Sensors.cpp rename to libraries/Robot_Control/src/Sensors.cpp diff --git a/libraries/Robot_Control/arch/avr/Squawk.cpp b/libraries/Robot_Control/src/Squawk.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/Squawk.cpp rename to libraries/Robot_Control/src/Squawk.cpp diff --git a/libraries/Robot_Control/arch/avr/Squawk.h b/libraries/Robot_Control/src/Squawk.h similarity index 100% rename from libraries/Robot_Control/arch/avr/Squawk.h rename to libraries/Robot_Control/src/Squawk.h diff --git a/libraries/Robot_Control/arch/avr/SquawkSD.cpp b/libraries/Robot_Control/src/SquawkSD.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/SquawkSD.cpp rename to libraries/Robot_Control/src/SquawkSD.cpp diff --git a/libraries/Robot_Control/arch/avr/SquawkSD.h b/libraries/Robot_Control/src/SquawkSD.h similarity index 100% rename from libraries/Robot_Control/arch/avr/SquawkSD.h rename to libraries/Robot_Control/src/SquawkSD.h diff --git a/libraries/Robot_Control/arch/avr/Wire.cpp b/libraries/Robot_Control/src/Wire.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/Wire.cpp rename to libraries/Robot_Control/src/Wire.cpp diff --git a/libraries/Robot_Control/arch/avr/Wire.h b/libraries/Robot_Control/src/Wire.h similarity index 100% rename from libraries/Robot_Control/arch/avr/Wire.h rename to libraries/Robot_Control/src/Wire.h diff --git a/libraries/Robot_Control/arch/avr/communication.cpp b/libraries/Robot_Control/src/communication.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/communication.cpp rename to libraries/Robot_Control/src/communication.cpp diff --git a/libraries/Robot_Control/arch/avr/glcdfont.c b/libraries/Robot_Control/src/glcdfont.c similarity index 100% rename from libraries/Robot_Control/arch/avr/glcdfont.c rename to libraries/Robot_Control/src/glcdfont.c diff --git a/libraries/Robot_Control/arch/avr/helper.cpp b/libraries/Robot_Control/src/helper.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/helper.cpp rename to libraries/Robot_Control/src/helper.cpp diff --git a/libraries/Robot_Control/arch/avr/information.cpp b/libraries/Robot_Control/src/information.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/information.cpp rename to libraries/Robot_Control/src/information.cpp diff --git a/libraries/Robot_Control/arch/avr/keyboard.cpp b/libraries/Robot_Control/src/keyboard.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/keyboard.cpp rename to libraries/Robot_Control/src/keyboard.cpp diff --git a/libraries/Robot_Control/arch/avr/lcd.cpp b/libraries/Robot_Control/src/lcd.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/lcd.cpp rename to libraries/Robot_Control/src/lcd.cpp diff --git a/libraries/Robot_Control/arch/avr/utility/Adafruit_GFX.cpp b/libraries/Robot_Control/src/utility/Adafruit_GFX.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/utility/Adafruit_GFX.cpp rename to libraries/Robot_Control/src/utility/Adafruit_GFX.cpp diff --git a/libraries/Robot_Control/arch/avr/utility/Adafruit_GFX.h b/libraries/Robot_Control/src/utility/Adafruit_GFX.h similarity index 100% rename from libraries/Robot_Control/arch/avr/utility/Adafruit_GFX.h rename to libraries/Robot_Control/src/utility/Adafruit_GFX.h diff --git a/libraries/Robot_Control/arch/avr/utility/RobotTextManager.cpp b/libraries/Robot_Control/src/utility/RobotTextManager.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/utility/RobotTextManager.cpp rename to libraries/Robot_Control/src/utility/RobotTextManager.cpp diff --git a/libraries/Robot_Control/arch/avr/utility/RobotTextManager.h b/libraries/Robot_Control/src/utility/RobotTextManager.h similarity index 100% rename from libraries/Robot_Control/arch/avr/utility/RobotTextManager.h rename to libraries/Robot_Control/src/utility/RobotTextManager.h diff --git a/libraries/Robot_Control/arch/avr/utility/VirtualKeyboard.cpp b/libraries/Robot_Control/src/utility/VirtualKeyboard.cpp similarity index 100% rename from libraries/Robot_Control/arch/avr/utility/VirtualKeyboard.cpp rename to libraries/Robot_Control/src/utility/VirtualKeyboard.cpp diff --git a/libraries/Robot_Control/arch/avr/utility/VirtualKeyboard.h b/libraries/Robot_Control/src/utility/VirtualKeyboard.h similarity index 100% rename from libraries/Robot_Control/arch/avr/utility/VirtualKeyboard.h rename to libraries/Robot_Control/src/utility/VirtualKeyboard.h diff --git a/libraries/Robot_Control/arch/avr/utility/scripts_Hello_User.h b/libraries/Robot_Control/src/utility/scripts_Hello_User.h similarity index 100% rename from libraries/Robot_Control/arch/avr/utility/scripts_Hello_User.h rename to libraries/Robot_Control/src/utility/scripts_Hello_User.h diff --git a/libraries/Robot_Control/arch/avr/utility/twi.c b/libraries/Robot_Control/src/utility/twi.c similarity index 100% rename from libraries/Robot_Control/arch/avr/utility/twi.c rename to libraries/Robot_Control/src/utility/twi.c diff --git a/libraries/Robot_Control/arch/avr/utility/twi.h b/libraries/Robot_Control/src/utility/twi.h similarity index 100% rename from libraries/Robot_Control/arch/avr/utility/twi.h rename to libraries/Robot_Control/src/utility/twi.h From 4b7302692c1c0f5491c05f31e6b84b4087d619e2 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 2 Jan 2014 00:20:31 +0100 Subject: [PATCH 13/13] Servo library to format 1.5 rev.2 --- libraries/Servo/library.properties | 8 +- libraries/Servo/src/Servo.h | 8 +- libraries/Servo/{arch => src}/avr/Servo.cpp | 630 +++++++++--------- .../Servo/{arch => src}/avr/ServoTimers.h | 22 +- libraries/Servo/{arch => src}/sam/Servo.cpp | 567 ++++++++-------- .../Servo/{arch => src}/sam/ServoTimers.h | 11 +- 6 files changed, 626 insertions(+), 620 deletions(-) rename libraries/Servo/{arch => src}/avr/Servo.cpp (71%) rename libraries/Servo/{arch => src}/avr/ServoTimers.h (84%) rename libraries/Servo/{arch => src}/sam/Servo.cpp (76%) rename libraries/Servo/{arch => src}/sam/ServoTimers.h (87%) diff --git a/libraries/Servo/library.properties b/libraries/Servo/library.properties index 0a0cced06..b28a1f90c 100644 --- a/libraries/Servo/library.properties +++ b/libraries/Servo/library.properties @@ -1,10 +1,8 @@ name=Servo -author= -email= +version=1.0 +author=Michael Margolis, Arduino +maintainer=Arduino sentence=Controls a lot of Servos. paragraph=This library can control a great number of servos.
It makes careful use of timers: the library can control 12 servos using only 1 timer.
On the Arduino Due you can control up to 60 servos.
url=http://arduino.cc/en/Reference/Servo architectures=avr,sam -version=1.0 -dependencies= -core-dependencies=arduino (>=1.5.0) diff --git a/libraries/Servo/src/Servo.h b/libraries/Servo/src/Servo.h index 10e79a87e..0a0491396 100644 --- a/libraries/Servo/src/Servo.h +++ b/libraries/Servo/src/Servo.h @@ -59,7 +59,13 @@ */ // Architecture specific include -#include +#if defined(ARDUINO_ARCH_AVR) +#include "avr/ServoTimers.h" +#elif defined(ARDUINO_ARCH_SAM) +#include "sam/ServoTimers.h" +#else +#error "This library only supports boards with an AVR or SAM processor." +#endif #define Servo_VERSION 2 // software version of this library diff --git a/libraries/Servo/arch/avr/Servo.cpp b/libraries/Servo/src/avr/Servo.cpp similarity index 71% rename from libraries/Servo/arch/avr/Servo.cpp rename to libraries/Servo/src/avr/Servo.cpp index e4801b97e..7fdd9d52e 100644 --- a/libraries/Servo/arch/avr/Servo.cpp +++ b/libraries/Servo/src/avr/Servo.cpp @@ -1,313 +1,317 @@ -/* - Servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 - Copyright (c) 2009 Michael Margolis. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -#include "Servo.h" - -#define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009 -#define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds - - -#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays // 12 August 2009 - -//#define NBR_TIMERS (MAX_SERVOS / SERVOS_PER_TIMER) - -static servo_t servos[MAX_SERVOS]; // static array of servo structures -static volatile int8_t Channel[_Nbr_16timers ]; // counter for the servo being pulsed for each timer (or -1 if refresh interval) - -uint8_t ServoCount = 0; // the total number of attached servos - - -// convenience macros -#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo -#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer -#define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel -#define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel - -#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo -#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo - -/************ static functions common to all instances ***********************/ - -static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t *TCNTn, volatile uint16_t* OCRnA) -{ - if( Channel[timer] < 0 ) - *TCNTn = 0; // channel set to -1 indicated that refresh interval completed so reset the timer - else{ - if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive == true ) - digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,LOW); // pulse this channel low if activated - } - - Channel[timer]++; // increment to the next channel - if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) { - *OCRnA = *TCNTn + SERVO(timer,Channel[timer]).ticks; - if(SERVO(timer,Channel[timer]).Pin.isActive == true) // check if activated - digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high - } - else { - // finished all channels so wait for the refresh period to expire before starting over - if( ((unsigned)*TCNTn) + 4 < usToTicks(REFRESH_INTERVAL) ) // allow a few ticks to ensure the next OCR1A not missed - *OCRnA = (unsigned int)usToTicks(REFRESH_INTERVAL); - else - *OCRnA = *TCNTn + 4; // at least REFRESH_INTERVAL has elapsed - Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel - } -} - -#ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform -// Interrupt handlers for Arduino -#if defined(_useTimer1) -SIGNAL (TIMER1_COMPA_vect) -{ - handle_interrupts(_timer1, &TCNT1, &OCR1A); -} -#endif - -#if defined(_useTimer3) -SIGNAL (TIMER3_COMPA_vect) -{ - handle_interrupts(_timer3, &TCNT3, &OCR3A); -} -#endif - -#if defined(_useTimer4) -SIGNAL (TIMER4_COMPA_vect) -{ - handle_interrupts(_timer4, &TCNT4, &OCR4A); -} -#endif - -#if defined(_useTimer5) -SIGNAL (TIMER5_COMPA_vect) -{ - handle_interrupts(_timer5, &TCNT5, &OCR5A); -} -#endif - -#elif defined WIRING -// Interrupt handlers for Wiring -#if defined(_useTimer1) -void Timer1Service() -{ - handle_interrupts(_timer1, &TCNT1, &OCR1A); -} -#endif -#if defined(_useTimer3) -void Timer3Service() -{ - handle_interrupts(_timer3, &TCNT3, &OCR3A); -} -#endif -#endif - - -static void initISR(timer16_Sequence_t timer) -{ -#if defined (_useTimer1) - if(timer == _timer1) { - TCCR1A = 0; // normal counting mode - TCCR1B = _BV(CS11); // set prescaler of 8 - TCNT1 = 0; // clear the timer count -#if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__) - TIFR |= _BV(OCF1A); // clear any pending interrupts; - TIMSK |= _BV(OCIE1A) ; // enable the output compare interrupt -#else - // here if not ATmega8 or ATmega128 - TIFR1 |= _BV(OCF1A); // clear any pending interrupts; - TIMSK1 |= _BV(OCIE1A) ; // enable the output compare interrupt -#endif -#if defined(WIRING) - timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service); -#endif - } -#endif - -#if defined (_useTimer3) - if(timer == _timer3) { - TCCR3A = 0; // normal counting mode - TCCR3B = _BV(CS31); // set prescaler of 8 - TCNT3 = 0; // clear the timer count -#if defined(__AVR_ATmega128__) - TIFR |= _BV(OCF3A); // clear any pending interrupts; - ETIMSK |= _BV(OCIE3A); // enable the output compare interrupt -#else - TIFR3 = _BV(OCF3A); // clear any pending interrupts; - TIMSK3 = _BV(OCIE3A) ; // enable the output compare interrupt -#endif -#if defined(WIRING) - timerAttach(TIMER3OUTCOMPAREA_INT, Timer3Service); // for Wiring platform only -#endif - } -#endif - -#if defined (_useTimer4) - if(timer == _timer4) { - TCCR4A = 0; // normal counting mode - TCCR4B = _BV(CS41); // set prescaler of 8 - TCNT4 = 0; // clear the timer count - TIFR4 = _BV(OCF4A); // clear any pending interrupts; - TIMSK4 = _BV(OCIE4A) ; // enable the output compare interrupt - } -#endif - -#if defined (_useTimer5) - if(timer == _timer5) { - TCCR5A = 0; // normal counting mode - TCCR5B = _BV(CS51); // set prescaler of 8 - TCNT5 = 0; // clear the timer count - TIFR5 = _BV(OCF5A); // clear any pending interrupts; - TIMSK5 = _BV(OCIE5A) ; // enable the output compare interrupt - } -#endif -} - -static void finISR(timer16_Sequence_t timer) -{ - //disable use of the given timer -#if defined WIRING // Wiring - if(timer == _timer1) { - #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__) - TIMSK1 &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt - #else - TIMSK &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt - #endif - timerDetach(TIMER1OUTCOMPAREA_INT); - } - else if(timer == _timer3) { - #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__) - TIMSK3 &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt - #else - ETIMSK &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt - #endif - timerDetach(TIMER3OUTCOMPAREA_INT); - } -#else - //For arduino - in future: call here to a currently undefined function to reset the timer -#endif -} - -static boolean isTimerActive(timer16_Sequence_t timer) -{ - // returns true if any servo is active on this timer - for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) { - if(SERVO(timer,channel).Pin.isActive == true) - return true; - } - return false; -} - - -/****************** end of static functions ******************************/ - -Servo::Servo() -{ - if( ServoCount < MAX_SERVOS) { - this->servoIndex = ServoCount++; // assign a servo index to this instance - servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values - 12 Aug 2009 - } - else - this->servoIndex = INVALID_SERVO ; // too many servos -} - -uint8_t Servo::attach(int pin) -{ - return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); -} - -uint8_t Servo::attach(int pin, int min, int max) -{ - if(this->servoIndex < MAX_SERVOS ) { - pinMode( pin, OUTPUT) ; // set servo pin to output - servos[this->servoIndex].Pin.nbr = pin; - // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128 - this->min = (MIN_PULSE_WIDTH - min)/4; //resolution of min/max is 4 uS - this->max = (MAX_PULSE_WIDTH - max)/4; - // initialize the timer if it has not already been initialized - timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex); - if(isTimerActive(timer) == false) - initISR(timer); - servos[this->servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive - } - return this->servoIndex ; -} - -void Servo::detach() -{ - servos[this->servoIndex].Pin.isActive = false; - timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex); - if(isTimerActive(timer) == false) { - finISR(timer); - } -} - -void Servo::write(int value) -{ - if(value < MIN_PULSE_WIDTH) - { // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds) - if(value < 0) value = 0; - if(value > 180) value = 180; - value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX()); - } - this->writeMicroseconds(value); -} - -void Servo::writeMicroseconds(int value) -{ - // calculate and store the values for the given channel - byte channel = this->servoIndex; - if( (channel < MAX_SERVOS) ) // ensure channel is valid - { - if( value < SERVO_MIN() ) // ensure pulse width is valid - value = SERVO_MIN(); - else if( value > SERVO_MAX() ) - value = SERVO_MAX(); - - value = value - TRIM_DURATION; - value = usToTicks(value); // convert to ticks after compensating for interrupt overhead - 12 Aug 2009 - - uint8_t oldSREG = SREG; - cli(); - servos[channel].ticks = value; - SREG = oldSREG; - } -} - -int Servo::read() // return the value as degrees -{ - return map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180); -} - -int Servo::readMicroseconds() -{ - unsigned int pulsewidth; - if( this->servoIndex != INVALID_SERVO ) - pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION ; // 12 aug 2009 - else - pulsewidth = 0; - - return pulsewidth; -} - -bool Servo::attached() -{ - return servos[this->servoIndex].Pin.isActive ; -} - +/* + Servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 + Copyright (c) 2009 Michael Margolis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#if defined(ARDUINO_ARCH_AVR) + +#include +#include + +#include "Servo.h" + +#define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009 +#define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds + + +#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays // 12 August 2009 + +//#define NBR_TIMERS (MAX_SERVOS / SERVOS_PER_TIMER) + +static servo_t servos[MAX_SERVOS]; // static array of servo structures +static volatile int8_t Channel[_Nbr_16timers ]; // counter for the servo being pulsed for each timer (or -1 if refresh interval) + +uint8_t ServoCount = 0; // the total number of attached servos + + +// convenience macros +#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo +#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer +#define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel +#define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel + +#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo +#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo + +/************ static functions common to all instances ***********************/ + +static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t *TCNTn, volatile uint16_t* OCRnA) +{ + if( Channel[timer] < 0 ) + *TCNTn = 0; // channel set to -1 indicated that refresh interval completed so reset the timer + else{ + if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive == true ) + digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,LOW); // pulse this channel low if activated + } + + Channel[timer]++; // increment to the next channel + if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) { + *OCRnA = *TCNTn + SERVO(timer,Channel[timer]).ticks; + if(SERVO(timer,Channel[timer]).Pin.isActive == true) // check if activated + digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high + } + else { + // finished all channels so wait for the refresh period to expire before starting over + if( ((unsigned)*TCNTn) + 4 < usToTicks(REFRESH_INTERVAL) ) // allow a few ticks to ensure the next OCR1A not missed + *OCRnA = (unsigned int)usToTicks(REFRESH_INTERVAL); + else + *OCRnA = *TCNTn + 4; // at least REFRESH_INTERVAL has elapsed + Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel + } +} + +#ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform +// Interrupt handlers for Arduino +#if defined(_useTimer1) +SIGNAL (TIMER1_COMPA_vect) +{ + handle_interrupts(_timer1, &TCNT1, &OCR1A); +} +#endif + +#if defined(_useTimer3) +SIGNAL (TIMER3_COMPA_vect) +{ + handle_interrupts(_timer3, &TCNT3, &OCR3A); +} +#endif + +#if defined(_useTimer4) +SIGNAL (TIMER4_COMPA_vect) +{ + handle_interrupts(_timer4, &TCNT4, &OCR4A); +} +#endif + +#if defined(_useTimer5) +SIGNAL (TIMER5_COMPA_vect) +{ + handle_interrupts(_timer5, &TCNT5, &OCR5A); +} +#endif + +#elif defined WIRING +// Interrupt handlers for Wiring +#if defined(_useTimer1) +void Timer1Service() +{ + handle_interrupts(_timer1, &TCNT1, &OCR1A); +} +#endif +#if defined(_useTimer3) +void Timer3Service() +{ + handle_interrupts(_timer3, &TCNT3, &OCR3A); +} +#endif +#endif + + +static void initISR(timer16_Sequence_t timer) +{ +#if defined (_useTimer1) + if(timer == _timer1) { + TCCR1A = 0; // normal counting mode + TCCR1B = _BV(CS11); // set prescaler of 8 + TCNT1 = 0; // clear the timer count +#if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__) + TIFR |= _BV(OCF1A); // clear any pending interrupts; + TIMSK |= _BV(OCIE1A) ; // enable the output compare interrupt +#else + // here if not ATmega8 or ATmega128 + TIFR1 |= _BV(OCF1A); // clear any pending interrupts; + TIMSK1 |= _BV(OCIE1A) ; // enable the output compare interrupt +#endif +#if defined(WIRING) + timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service); +#endif + } +#endif + +#if defined (_useTimer3) + if(timer == _timer3) { + TCCR3A = 0; // normal counting mode + TCCR3B = _BV(CS31); // set prescaler of 8 + TCNT3 = 0; // clear the timer count +#if defined(__AVR_ATmega128__) + TIFR |= _BV(OCF3A); // clear any pending interrupts; + ETIMSK |= _BV(OCIE3A); // enable the output compare interrupt +#else + TIFR3 = _BV(OCF3A); // clear any pending interrupts; + TIMSK3 = _BV(OCIE3A) ; // enable the output compare interrupt +#endif +#if defined(WIRING) + timerAttach(TIMER3OUTCOMPAREA_INT, Timer3Service); // for Wiring platform only +#endif + } +#endif + +#if defined (_useTimer4) + if(timer == _timer4) { + TCCR4A = 0; // normal counting mode + TCCR4B = _BV(CS41); // set prescaler of 8 + TCNT4 = 0; // clear the timer count + TIFR4 = _BV(OCF4A); // clear any pending interrupts; + TIMSK4 = _BV(OCIE4A) ; // enable the output compare interrupt + } +#endif + +#if defined (_useTimer5) + if(timer == _timer5) { + TCCR5A = 0; // normal counting mode + TCCR5B = _BV(CS51); // set prescaler of 8 + TCNT5 = 0; // clear the timer count + TIFR5 = _BV(OCF5A); // clear any pending interrupts; + TIMSK5 = _BV(OCIE5A) ; // enable the output compare interrupt + } +#endif +} + +static void finISR(timer16_Sequence_t timer) +{ + //disable use of the given timer +#if defined WIRING // Wiring + if(timer == _timer1) { + #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__) + TIMSK1 &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt + #else + TIMSK &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt + #endif + timerDetach(TIMER1OUTCOMPAREA_INT); + } + else if(timer == _timer3) { + #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__) + TIMSK3 &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt + #else + ETIMSK &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt + #endif + timerDetach(TIMER3OUTCOMPAREA_INT); + } +#else + //For arduino - in future: call here to a currently undefined function to reset the timer +#endif +} + +static boolean isTimerActive(timer16_Sequence_t timer) +{ + // returns true if any servo is active on this timer + for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) { + if(SERVO(timer,channel).Pin.isActive == true) + return true; + } + return false; +} + + +/****************** end of static functions ******************************/ + +Servo::Servo() +{ + if( ServoCount < MAX_SERVOS) { + this->servoIndex = ServoCount++; // assign a servo index to this instance + servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values - 12 Aug 2009 + } + else + this->servoIndex = INVALID_SERVO ; // too many servos +} + +uint8_t Servo::attach(int pin) +{ + return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); +} + +uint8_t Servo::attach(int pin, int min, int max) +{ + if(this->servoIndex < MAX_SERVOS ) { + pinMode( pin, OUTPUT) ; // set servo pin to output + servos[this->servoIndex].Pin.nbr = pin; + // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128 + this->min = (MIN_PULSE_WIDTH - min)/4; //resolution of min/max is 4 uS + this->max = (MAX_PULSE_WIDTH - max)/4; + // initialize the timer if it has not already been initialized + timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex); + if(isTimerActive(timer) == false) + initISR(timer); + servos[this->servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive + } + return this->servoIndex ; +} + +void Servo::detach() +{ + servos[this->servoIndex].Pin.isActive = false; + timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex); + if(isTimerActive(timer) == false) { + finISR(timer); + } +} + +void Servo::write(int value) +{ + if(value < MIN_PULSE_WIDTH) + { // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds) + if(value < 0) value = 0; + if(value > 180) value = 180; + value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX()); + } + this->writeMicroseconds(value); +} + +void Servo::writeMicroseconds(int value) +{ + // calculate and store the values for the given channel + byte channel = this->servoIndex; + if( (channel < MAX_SERVOS) ) // ensure channel is valid + { + if( value < SERVO_MIN() ) // ensure pulse width is valid + value = SERVO_MIN(); + else if( value > SERVO_MAX() ) + value = SERVO_MAX(); + + value = value - TRIM_DURATION; + value = usToTicks(value); // convert to ticks after compensating for interrupt overhead - 12 Aug 2009 + + uint8_t oldSREG = SREG; + cli(); + servos[channel].ticks = value; + SREG = oldSREG; + } +} + +int Servo::read() // return the value as degrees +{ + return map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180); +} + +int Servo::readMicroseconds() +{ + unsigned int pulsewidth; + if( this->servoIndex != INVALID_SERVO ) + pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION ; // 12 aug 2009 + else + pulsewidth = 0; + + return pulsewidth; +} + +bool Servo::attached() +{ + return servos[this->servoIndex].Pin.isActive ; +} + +#endif // ARDUINO_ARCH_AVR + diff --git a/libraries/Servo/arch/avr/ServoTimers.h b/libraries/Servo/src/avr/ServoTimers.h similarity index 84% rename from libraries/Servo/arch/avr/ServoTimers.h rename to libraries/Servo/src/avr/ServoTimers.h index 70cffff48..29c1ae299 100644 --- a/libraries/Servo/arch/avr/ServoTimers.h +++ b/libraries/Servo/src/avr/ServoTimers.h @@ -17,8 +17,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* - * Defines for 16 bit timers used with Servo library +/* + * Defines for 16 bit timers used with Servo library * * If _useTimerX is defined then TimerX is a 16 bit timer on the current board * timer16_Sequence_t enumerates the sequence that the timers should be allocated @@ -33,27 +33,27 @@ // Say which 16 bit timers can be used and in what order #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #define _useTimer5 -#define _useTimer1 +#define _useTimer1 #define _useTimer3 -#define _useTimer4 -typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ; +#define _useTimer4 +typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t; -#elif defined(__AVR_ATmega32U4__) -#define _useTimer1 -typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ; +#elif defined(__AVR_ATmega32U4__) +#define _useTimer1 +typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t; #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) #define _useTimer3 #define _useTimer1 -typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ; +typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t; #elif defined(__AVR_ATmega128__) ||defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__) #define _useTimer3 #define _useTimer1 -typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ; +typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t; #else // everything else #define _useTimer1 -typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ; +typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t; #endif diff --git a/libraries/Servo/arch/sam/Servo.cpp b/libraries/Servo/src/sam/Servo.cpp similarity index 76% rename from libraries/Servo/arch/sam/Servo.cpp rename to libraries/Servo/src/sam/Servo.cpp index dec911019..21f901f0e 100644 --- a/libraries/Servo/arch/sam/Servo.cpp +++ b/libraries/Servo/src/sam/Servo.cpp @@ -1,284 +1,283 @@ -/* - Servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers - Version 2 - Copyright (c) 2009 Michael Margolis. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -#define usToTicks(_us) (( clockCyclesPerMicrosecond() * _us) / 32) // converts microseconds to tick -#define ticksToUs(_ticks) (( (unsigned)_ticks * 32)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds - - -#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays - -static servo_t servos[MAX_SERVOS]; // static array of servo structures - -uint8_t ServoCount = 0; // the total number of attached servos - -static volatile int8_t Channel[_Nbr_16timers ]; // counter for the servo being pulsed for each timer (or -1 if refresh interval) - -// convenience macros -#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo -#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer -#define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel -#define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel - -#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo -#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo - -/************ static functions common to all instances ***********************/ - - -//timer16_Sequence_t timer; - -//------------------------------------------------------------------------------ -/// Interrupt handler for the TC0 channel 1. -//------------------------------------------------------------------------------ -void Servo_Handler(timer16_Sequence_t timer, Tc *pTc, uint8_t channel); -#if defined (_useTimer1) -void HANDLER_FOR_TIMER1(void) { - Servo_Handler(_timer1, TC_FOR_TIMER1, CHANNEL_FOR_TIMER1); -} -#endif -#if defined (_useTimer2) -void HANDLER_FOR_TIMER2(void) { - Servo_Handler(_timer2, TC_FOR_TIMER2, CHANNEL_FOR_TIMER2); -} -#endif -#if defined (_useTimer3) -void HANDLER_FOR_TIMER3(void) { - Servo_Handler(_timer3, TC_FOR_TIMER3, CHANNEL_FOR_TIMER3); -} -#endif -#if defined (_useTimer4) -void HANDLER_FOR_TIMER4(void) { - Servo_Handler(_timer4, TC_FOR_TIMER4, CHANNEL_FOR_TIMER4); -} -#endif -#if defined (_useTimer5) -void HANDLER_FOR_TIMER5(void) { - Servo_Handler(_timer5, TC_FOR_TIMER5, CHANNEL_FOR_TIMER5); -} -#endif - -void Servo_Handler(timer16_Sequence_t timer, Tc *tc, uint8_t channel) -{ - // clear interrupt - tc->TC_CHANNEL[channel].TC_SR; - if (Channel[timer] < 0) { - tc->TC_CHANNEL[channel].TC_CCR |= TC_CCR_SWTRG; // channel set to -1 indicated that refresh interval completed so reset the timer - } else { - if (SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive == true) { - digitalWrite(SERVO(timer,Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated - } - } - - Channel[timer]++; // increment to the next channel - if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) { - tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + SERVO(timer,Channel[timer]).ticks; - if(SERVO(timer,Channel[timer]).Pin.isActive == true) { // check if activated - digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high - } - } - else { - // finished all channels so wait for the refresh period to expire before starting over - if( (tc->TC_CHANNEL[channel].TC_CV) + 4 < usToTicks(REFRESH_INTERVAL) ) { // allow a few ticks to ensure the next OCR1A not missed - tc->TC_CHANNEL[channel].TC_RA = (unsigned int)usToTicks(REFRESH_INTERVAL); - } - else { - tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + 4; // at least REFRESH_INTERVAL has elapsed - } - Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel - } -} - -static void _initISR(Tc *tc, uint32_t channel, uint32_t id, IRQn_Type irqn) -{ - pmc_enable_periph_clk(id); - TC_Configure(tc, channel, - TC_CMR_TCCLKS_TIMER_CLOCK3 | // MCK/32 - TC_CMR_WAVE | // Waveform mode - TC_CMR_WAVSEL_UP_RC ); // Counter running up and reset when equals to RC - - /* 84MHz, MCK/32, for 1.5ms: 3937 */ - TC_SetRA(tc, channel, 2625); // 1ms - - /* Configure and enable interrupt */ - NVIC_EnableIRQ(irqn); - // TC_IER_CPAS: RA Compare - tc->TC_CHANNEL[channel].TC_IER = TC_IER_CPAS; - - // Enables the timer clock and performs a software reset to start the counting - TC_Start(tc, channel); -} - -static void initISR(timer16_Sequence_t timer) -{ -#if defined (_useTimer1) - if (timer == _timer1) - _initISR(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1, ID_TC_FOR_TIMER1, IRQn_FOR_TIMER1); -#endif -#if defined (_useTimer2) - if (timer == _timer2) - _initISR(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2, ID_TC_FOR_TIMER2, IRQn_FOR_TIMER2); -#endif -#if defined (_useTimer3) - if (timer == _timer3) - _initISR(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3, ID_TC_FOR_TIMER3, IRQn_FOR_TIMER3); -#endif -#if defined (_useTimer4) - if (timer == _timer4) - _initISR(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4, ID_TC_FOR_TIMER4, IRQn_FOR_TIMER4); -#endif -#if defined (_useTimer5) - if (timer == _timer5) - _initISR(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5, ID_TC_FOR_TIMER5, IRQn_FOR_TIMER5); -#endif -} - -static void finISR(timer16_Sequence_t timer) -{ -#if defined (_useTimer1) - TC_Stop(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1); -#endif -#if defined (_useTimer2) - TC_Stop(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2); -#endif -#if defined (_useTimer3) - TC_Stop(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3); -#endif -#if defined (_useTimer4) - TC_Stop(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4); -#endif -#if defined (_useTimer5) - TC_Stop(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5); -#endif -} - - -static boolean isTimerActive(timer16_Sequence_t timer) -{ - // returns true if any servo is active on this timer - for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) { - if(SERVO(timer,channel).Pin.isActive == true) - return true; - } - return false; -} - -/****************** end of static functions ******************************/ - -Servo::Servo() -{ - if (ServoCount < MAX_SERVOS) { - this->servoIndex = ServoCount++; // assign a servo index to this instance - servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values - } else { - this->servoIndex = INVALID_SERVO; // too many servos - } -} - -uint8_t Servo::attach(int pin) -{ - return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); -} - -uint8_t Servo::attach(int pin, int min, int max) -{ - timer16_Sequence_t timer; - - if (this->servoIndex < MAX_SERVOS) { - pinMode(pin, OUTPUT); // set servo pin to output - servos[this->servoIndex].Pin.nbr = pin; - // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128 - this->min = (MIN_PULSE_WIDTH - min)/4; //resolution of min/max is 4 uS - this->max = (MAX_PULSE_WIDTH - max)/4; - // initialize the timer if it has not already been initialized - timer = SERVO_INDEX_TO_TIMER(servoIndex); - if (isTimerActive(timer) == false) { - initISR(timer); - } - servos[this->servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive - } - return this->servoIndex; -} - -void Servo::detach() -{ - timer16_Sequence_t timer; - - servos[this->servoIndex].Pin.isActive = false; - timer = SERVO_INDEX_TO_TIMER(servoIndex); - if(isTimerActive(timer) == false) { - finISR(timer); - } -} - -void Servo::write(int value) -{ - // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds) - if (value < MIN_PULSE_WIDTH) - { - if (value < 0) - value = 0; - else if (value > 180) - value = 180; - - value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX()); - } - writeMicroseconds(value); -} - -void Servo::writeMicroseconds(int value) -{ - // calculate and store the values for the given channel - byte channel = this->servoIndex; - if( (channel < MAX_SERVOS) ) // ensure channel is valid - { - if (value < SERVO_MIN()) // ensure pulse width is valid - value = SERVO_MIN(); - else if (value > SERVO_MAX()) - value = SERVO_MAX(); - - value = value - TRIM_DURATION; - value = usToTicks(value); // convert to ticks after compensating for interrupt overhead - servos[channel].ticks = value; - } -} - -int Servo::read() // return the value as degrees -{ - return map(readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180); -} - -int Servo::readMicroseconds() -{ - unsigned int pulsewidth; - if (this->servoIndex != INVALID_SERVO) - pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION; - else - pulsewidth = 0; - - return pulsewidth; -} - -bool Servo::attached() -{ - return servos[this->servoIndex].Pin.isActive; -} - +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#if defined(ARDUINO_ARCH_SAM) + +#include +#include + +#define usToTicks(_us) (( clockCyclesPerMicrosecond() * _us) / 32) // converts microseconds to tick +#define ticksToUs(_ticks) (( (unsigned)_ticks * 32)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds + +#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays + +static servo_t servos[MAX_SERVOS]; // static array of servo structures + +uint8_t ServoCount = 0; // the total number of attached servos + +static volatile int8_t Channel[_Nbr_16timers ]; // counter for the servo being pulsed for each timer (or -1 if refresh interval) + +// convenience macros +#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo +#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer +#define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel +#define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel + +#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo +#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo + +/************ static functions common to all instances ***********************/ + +//------------------------------------------------------------------------------ +/// Interrupt handler for the TC0 channel 1. +//------------------------------------------------------------------------------ +void Servo_Handler(timer16_Sequence_t timer, Tc *pTc, uint8_t channel); +#if defined (_useTimer1) +void HANDLER_FOR_TIMER1(void) { + Servo_Handler(_timer1, TC_FOR_TIMER1, CHANNEL_FOR_TIMER1); +} +#endif +#if defined (_useTimer2) +void HANDLER_FOR_TIMER2(void) { + Servo_Handler(_timer2, TC_FOR_TIMER2, CHANNEL_FOR_TIMER2); +} +#endif +#if defined (_useTimer3) +void HANDLER_FOR_TIMER3(void) { + Servo_Handler(_timer3, TC_FOR_TIMER3, CHANNEL_FOR_TIMER3); +} +#endif +#if defined (_useTimer4) +void HANDLER_FOR_TIMER4(void) { + Servo_Handler(_timer4, TC_FOR_TIMER4, CHANNEL_FOR_TIMER4); +} +#endif +#if defined (_useTimer5) +void HANDLER_FOR_TIMER5(void) { + Servo_Handler(_timer5, TC_FOR_TIMER5, CHANNEL_FOR_TIMER5); +} +#endif + +void Servo_Handler(timer16_Sequence_t timer, Tc *tc, uint8_t channel) +{ + // clear interrupt + tc->TC_CHANNEL[channel].TC_SR; + if (Channel[timer] < 0) { + tc->TC_CHANNEL[channel].TC_CCR |= TC_CCR_SWTRG; // channel set to -1 indicated that refresh interval completed so reset the timer + } else { + if (SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive == true) { + digitalWrite(SERVO(timer,Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated + } + } + + Channel[timer]++; // increment to the next channel + if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) { + tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + SERVO(timer,Channel[timer]).ticks; + if(SERVO(timer,Channel[timer]).Pin.isActive == true) { // check if activated + digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high + } + } + else { + // finished all channels so wait for the refresh period to expire before starting over + if( (tc->TC_CHANNEL[channel].TC_CV) + 4 < usToTicks(REFRESH_INTERVAL) ) { // allow a few ticks to ensure the next OCR1A not missed + tc->TC_CHANNEL[channel].TC_RA = (unsigned int)usToTicks(REFRESH_INTERVAL); + } + else { + tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + 4; // at least REFRESH_INTERVAL has elapsed + } + Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel + } +} + +static void _initISR(Tc *tc, uint32_t channel, uint32_t id, IRQn_Type irqn) +{ + pmc_enable_periph_clk(id); + TC_Configure(tc, channel, + TC_CMR_TCCLKS_TIMER_CLOCK3 | // MCK/32 + TC_CMR_WAVE | // Waveform mode + TC_CMR_WAVSEL_UP_RC ); // Counter running up and reset when equals to RC + + /* 84MHz, MCK/32, for 1.5ms: 3937 */ + TC_SetRA(tc, channel, 2625); // 1ms + + /* Configure and enable interrupt */ + NVIC_EnableIRQ(irqn); + // TC_IER_CPAS: RA Compare + tc->TC_CHANNEL[channel].TC_IER = TC_IER_CPAS; + + // Enables the timer clock and performs a software reset to start the counting + TC_Start(tc, channel); +} + +static void initISR(timer16_Sequence_t timer) +{ +#if defined (_useTimer1) + if (timer == _timer1) + _initISR(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1, ID_TC_FOR_TIMER1, IRQn_FOR_TIMER1); +#endif +#if defined (_useTimer2) + if (timer == _timer2) + _initISR(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2, ID_TC_FOR_TIMER2, IRQn_FOR_TIMER2); +#endif +#if defined (_useTimer3) + if (timer == _timer3) + _initISR(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3, ID_TC_FOR_TIMER3, IRQn_FOR_TIMER3); +#endif +#if defined (_useTimer4) + if (timer == _timer4) + _initISR(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4, ID_TC_FOR_TIMER4, IRQn_FOR_TIMER4); +#endif +#if defined (_useTimer5) + if (timer == _timer5) + _initISR(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5, ID_TC_FOR_TIMER5, IRQn_FOR_TIMER5); +#endif +} + +static void finISR(timer16_Sequence_t timer) +{ +#if defined (_useTimer1) + TC_Stop(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1); +#endif +#if defined (_useTimer2) + TC_Stop(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2); +#endif +#if defined (_useTimer3) + TC_Stop(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3); +#endif +#if defined (_useTimer4) + TC_Stop(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4); +#endif +#if defined (_useTimer5) + TC_Stop(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5); +#endif +} + + +static boolean isTimerActive(timer16_Sequence_t timer) +{ + // returns true if any servo is active on this timer + for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) { + if(SERVO(timer,channel).Pin.isActive == true) + return true; + } + return false; +} + +/****************** end of static functions ******************************/ + +Servo::Servo() +{ + if (ServoCount < MAX_SERVOS) { + this->servoIndex = ServoCount++; // assign a servo index to this instance + servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values + } else { + this->servoIndex = INVALID_SERVO; // too many servos + } +} + +uint8_t Servo::attach(int pin) +{ + return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); +} + +uint8_t Servo::attach(int pin, int min, int max) +{ + timer16_Sequence_t timer; + + if (this->servoIndex < MAX_SERVOS) { + pinMode(pin, OUTPUT); // set servo pin to output + servos[this->servoIndex].Pin.nbr = pin; + // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128 + this->min = (MIN_PULSE_WIDTH - min)/4; //resolution of min/max is 4 uS + this->max = (MAX_PULSE_WIDTH - max)/4; + // initialize the timer if it has not already been initialized + timer = SERVO_INDEX_TO_TIMER(servoIndex); + if (isTimerActive(timer) == false) { + initISR(timer); + } + servos[this->servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive + } + return this->servoIndex; +} + +void Servo::detach() +{ + timer16_Sequence_t timer; + + servos[this->servoIndex].Pin.isActive = false; + timer = SERVO_INDEX_TO_TIMER(servoIndex); + if(isTimerActive(timer) == false) { + finISR(timer); + } +} + +void Servo::write(int value) +{ + // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds) + if (value < MIN_PULSE_WIDTH) + { + if (value < 0) + value = 0; + else if (value > 180) + value = 180; + + value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX()); + } + writeMicroseconds(value); +} + +void Servo::writeMicroseconds(int value) +{ + // calculate and store the values for the given channel + byte channel = this->servoIndex; + if( (channel < MAX_SERVOS) ) // ensure channel is valid + { + if (value < SERVO_MIN()) // ensure pulse width is valid + value = SERVO_MIN(); + else if (value > SERVO_MAX()) + value = SERVO_MAX(); + + value = value - TRIM_DURATION; + value = usToTicks(value); // convert to ticks after compensating for interrupt overhead + servos[channel].ticks = value; + } +} + +int Servo::read() // return the value as degrees +{ + return map(readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180); +} + +int Servo::readMicroseconds() +{ + unsigned int pulsewidth; + if (this->servoIndex != INVALID_SERVO) + pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION; + else + pulsewidth = 0; + + return pulsewidth; +} + +bool Servo::attached() +{ + return servos[this->servoIndex].Pin.isActive; +} + +#endif // ARDUINO_ARCH_SAM + diff --git a/libraries/Servo/arch/sam/ServoTimers.h b/libraries/Servo/src/sam/ServoTimers.h similarity index 87% rename from libraries/Servo/arch/sam/ServoTimers.h rename to libraries/Servo/src/sam/ServoTimers.h index a68ac52ef..13f736a19 100644 --- a/libraries/Servo/arch/sam/ServoTimers.h +++ b/libraries/Servo/src/sam/ServoTimers.h @@ -1,6 +1,5 @@ /* - Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 - Copyright (c) 2009 Michael Margolis. All right reserved. + Copyright (c) 2013 Arduino LLC. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -9,16 +8,16 @@ This library 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* - * Defines for 16 bit timers used with Servo library +/* + * Defines for 16 bit timers used with Servo library * * If _useTimerX is defined then TimerX is a 16 bit timer on the current board * timer16_Sequence_t enumerates the sequence that the timers should be allocated