diff --git a/src/main/java/frc/robot/util/drivers/MitoCANdriaSensor.java b/src/main/java/frc/robot/util/drivers/MitoCANdriaSensor.java new file mode 100644 index 0000000..494db29 --- /dev/null +++ b/src/main/java/frc/robot/util/drivers/MitoCANdriaSensor.java @@ -0,0 +1,53 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.util.drivers; + +import au.grapplerobotics.MitoCANdria; + +/** Add your docs here. */ +public class MitoCANdriaSensor { + + public MitoCANdriaSensor(int ID) + { + try (MitoCANdria mito = new MitoCANdria(ID)) { + // Get and print USB1 current + mito.getChannelCurrent(MitoCANdria.MITOCANDRIA_CHANNEL_USB1) + .ifPresentOrElse( + current -> System.out.println("USB1 current: " + current + " A"), + () -> System.out.println("Couldn't get USB1 current")); + + // Get and print 5VA voltage + mito.getChannelVoltage(MitoCANdria.MITOCANDRIA_CHANNEL_5VA) + .ifPresentOrElse( + voltage -> System.out.println("5VA voltage: " + voltage + " V"), + () -> System.out.println("Couldn't get 5VA voltage")); + + // Enable USB2 channel + mito.setChannelEnabled(MitoCANdria.MITOCANDRIA_CHANNEL_USB2, true); + System.out.println("USB2 channel enabled"); + + // Set ADJ channel voltage + mito.setChannelVoltage(MitoCANdria.MITOCANDRIA_CHANNEL_ADJ, 3.3); + System.out.println("ADJ channel voltage set to 3.3V"); + + // Get and print ADJ channel setpoint + mito.getChannelVoltageSetpoint(MitoCANdria.MITOCANDRIA_CHANNEL_ADJ) + .ifPresentOrElse( + setpoint -> System.out.println("ADJ channel setpoint: " + setpoint + " V"), + () -> System.out.println("Couldn't get ADJ channel setpoint")); + + // Check if 5VB channel is enabled + mito.getChannelEnabled(MitoCANdria.MITOCANDRIA_CHANNEL_5VB) + .ifPresentOrElse( + enabled -> System.out.println("5VB channel enabled: " + (enabled == 1)), + () -> System.out.println("Couldn't check if 5VB channel is enabled")); + + } catch (Exception e) { + System.out.println("An error occurred: " + e.getMessage()); + } + + + } +} diff --git a/vendordeps/ThriftyLib.json b/vendordeps/ThriftyLib.json new file mode 100644 index 0000000..00d3f73 --- /dev/null +++ b/vendordeps/ThriftyLib.json @@ -0,0 +1,20 @@ +{ + "fileName": "ThriftyLib.json", + "name": "ThriftyLib", + "version": "2025.0.2", + "frcYear": "2025", + "uuid": "60b2694b-9e6e-4026-81ee-6f167946f4b0", + "mavenUrls": [ + "https://docs.home.thethriftybot.com" + ], + "jsonUrl": "https://docs.home.thethriftybot.com/ThriftyLib.json", + "javaDependencies": [ + { + "groupId": "com.thethriftybot.frc", + "artifactId": "ThriftyLib-java", + "version": "2025.0.2" + } + ], + "jniDependencies": [], + "cppDependencies": [] +} \ No newline at end of file