MCPcopy Index your code
hub / github.com/processing/processing / list

Method list

java/libraries/io/src/processing/io/PWM.java:138–164  ·  view source on GitHub ↗

Lists all available PWM channels @return String array @webref

()

Source from the content-addressed store, hash-verified

136 * @webref
137 */
138 public static String[] list() {
139 if (NativeInterface.isSimulated()) {
140 return new String[]{ "pwmchip0/pwm0", "pwmchip0/pwm1" };
141 }
142
143 ArrayList<String> devs = new ArrayList<String>();
144 File dir = new File("/sys/class/pwm");
145 File[] chips = dir.listFiles();
146 if (chips != null) {
147 for (File chip : chips) {
148 // get the number of supported channels
149 try {
150 Path path = Paths.get("/sys/class/pwm/" + chip.getName() + "/npwm");
151 String tmp = new String(Files.readAllBytes(path));
152 int npwm = Integer.parseInt(tmp.trim());
153 for (int i=0; i < npwm; i++) {
154 devs.add(chip.getName() + "/pwm" + i);
155 }
156 } catch (Exception e) {
157 }
158 }
159 }
160 // listFiles() does not guarantee ordering
161 String[] tmp = devs.toArray(new String[devs.size()]);
162 Arrays.sort(tmp);
163 return tmp;
164 }
165
166
167 /**

Callers

nothing calls this directly

Calls 9

isSimulatedMethod · 0.95
parseIntMethod · 0.80
getMethod · 0.65
listFilesMethod · 0.45
getNameMethod · 0.45
trimMethod · 0.45
addMethod · 0.45
sizeMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected