Add more functions

This commit is contained in:
2024-11-13 08:35:32 +07:00
parent 1fe4716bab
commit f7f711d3fe
22 changed files with 1307 additions and 294 deletions

View File

@@ -6,7 +6,6 @@ import org.tinylog.Logger;
import java.nio.file.Files;
import java.nio.file.Path;
@SuppressWarnings("unused")
public class GPIO {
private static final Path gpioPath = Path.of("/sys/class/gpio");
@@ -14,19 +13,15 @@ public class GPIO {
private static final Path gpioUnexportPath = Path.of("/sys/class/gpio/unexport");
public static boolean IsRaspberry64(){
public static boolean HaveGPIO(){
if (Platform.isLinux()){
if (Platform.isARM()){
if (Platform.is64Bit()){
if (gpioPath.toFile().isDirectory()){
if (gpioExportPath.toFile().isFile()){
if (gpioUnexportPath.toFile().isFile()){
return true;
} else Logger.error("GPIO unexport path is not found");
} else Logger.error("GPIO export path is not found");
} else Logger.error("GPIO path is not found");
} else Logger.info("Device is not 64 bit");
} else Logger.info("Device is not ARM");
if (gpioPath.toFile().isDirectory()){
if (gpioExportPath.toFile().isFile()){
if (gpioUnexportPath.toFile().isFile()){
return true;
} else Logger.error("GPIO unexport path is not found");
} else Logger.error("GPIO export path is not found");
} else Logger.error("GPIO path is not found");
} else Logger.info("OS is not Linux");
return false;
}