-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from WHS-FRC-3467/mitocandria-driver
mitocandria implementation
- Loading branch information
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/main/java/frc/robot/util/drivers/MitoCANdriaSensor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": [] | ||
} |