Examples
Use-Case
Mounting Examples
Code Example
import com.andymark.jni.AM_CAN_Mag_Switch.AM_MagSwitchData;
import com.andymark.jni.AM_CAN_Mag_Switch;
//Initialize Device
//The device's default CAN is 0. Change it using AndyMark CAN interface utility
AM_CAN_Mag_Switch magSwitch = new AM_CAN_Mag_Switch(0);
//Reset Report Period to the default of 100ms
magSwitch.resetReportPeriod();
//Get data put it on the smart dashboard
AM_MagSwitchData d = magSwitch.getData();
SmartDashboard.putBoolean("MagDetected?", d.magnetDetected);
SmartDashboard.putNumber("Timestamp", d.timeStamp);//File to include
#include "AM_CAN_Mag_Switch.h"
//Initialize device
//The device's default CAN is 0. Change it using AndyMark CAN interface utility
AM_CAN_Mag_Switch myMagSwitch{0};
//Reset Report Period to the default of 100ms
myMagSwitch.ResetReportPeriod();
//Get data put it on the smart dashboard
AM_MagSwitchData d = myMagSwitch.GetData();
frc::SmartDashboard::PutBoolean("MagDetected?",d.magnetDetected);
frc::SmartDashboard::PutNumber("Timestamp",d.timeStamp);Last updated
Was this helpful?