Lists all available LED devices @return String array @webref
()
| 156 | * @webref |
| 157 | */ |
| 158 | public static String[] list() { |
| 159 | if (NativeInterface.isSimulated()) { |
| 160 | // as on the Raspberry Pi |
| 161 | return new String[]{ "led0", "led1" }; |
| 162 | } |
| 163 | |
| 164 | ArrayList<String> devs = new ArrayList<>(); |
| 165 | File dir = new File("/sys/class/leds"); |
| 166 | File[] files = dir.listFiles(); |
| 167 | if (files != null) { |
| 168 | for (File file : files) { |
| 169 | devs.add(file.getName()); |
| 170 | } |
| 171 | } |
| 172 | // listFiles() does not guarantee ordering |
| 173 | String[] tmp = devs.toArray(new String[devs.size()]); |
| 174 | Arrays.sort(tmp); |
| 175 | return tmp; |
| 176 | } |
| 177 | } |
no test coverage detected