001/* 002 * Copyright (C) Cross The Road Electronics. All rights reserved. 003 * License information can be found in CTRE_LICENSE.txt 004 * For support and suggestions contact support@ctr-electronics.com or file 005 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases 006 */ 007package com.ctre.phoenix6.configs; 008 009import com.ctre.phoenix6.StatusCode; 010import com.ctre.phoenix6.configs.jni.ConfigJNI; 011import com.ctre.phoenix6.spns.*; 012 013/** 014 * Configs to enable/disable various features of the Pigeon2. 015 * <p> 016 * These configs allow the user to enable or disable various aspects 017 * of the Pigeon2. 018 */ 019public class Pigeon2FeaturesConfigs implements ParentConfiguration 020{ 021 /** 022 * Turns on or off the magnetometer fusing for 9-axis. FRC users are 023 * not recommended to turn this on, as the magnetic influence of the 024 * robot will likely negatively affect the performance of the Pigeon2. 025 * 026 * <ul> 027 * <li> <b>Default Value:</b> False 028 * </ul> 029 */ 030 public boolean EnableCompass = false; 031 /** 032 * Disables using the temperature compensation feature 033 * 034 * <ul> 035 * <li> <b>Default Value:</b> False 036 * </ul> 037 */ 038 public boolean DisableTemperatureCompensation = false; 039 /** 040 * Disables using the no-motion calibration feature 041 * 042 * <ul> 043 * <li> <b>Default Value:</b> False 044 * </ul> 045 */ 046 public boolean DisableNoMotionCalibration = false; 047 048 /** 049 * Modifies this configuration's EnableCompass parameter and returns itself for 050 * method-chaining and easier to use config API. 051 * <p> 052 * Turns on or off the magnetometer fusing for 9-axis. FRC users are 053 * not recommended to turn this on, as the magnetic influence of the 054 * robot will likely negatively affect the performance of the Pigeon2. 055 * 056 * <ul> 057 * <li> <b>Default Value:</b> False 058 * </ul> 059 * 060 * @param newEnableCompass Parameter to modify 061 * @return Itself 062 */ 063 public Pigeon2FeaturesConfigs withEnableCompass(boolean newEnableCompass) 064 { 065 EnableCompass = newEnableCompass; 066 return this; 067 } 068 /** 069 * Modifies this configuration's DisableTemperatureCompensation parameter and returns itself for 070 * method-chaining and easier to use config API. 071 * <p> 072 * Disables using the temperature compensation feature 073 * 074 * <ul> 075 * <li> <b>Default Value:</b> False 076 * </ul> 077 * 078 * @param newDisableTemperatureCompensation Parameter to modify 079 * @return Itself 080 */ 081 public Pigeon2FeaturesConfigs withDisableTemperatureCompensation(boolean newDisableTemperatureCompensation) 082 { 083 DisableTemperatureCompensation = newDisableTemperatureCompensation; 084 return this; 085 } 086 /** 087 * Modifies this configuration's DisableNoMotionCalibration parameter and returns itself for 088 * method-chaining and easier to use config API. 089 * <p> 090 * Disables using the no-motion calibration feature 091 * 092 * <ul> 093 * <li> <b>Default Value:</b> False 094 * </ul> 095 * 096 * @param newDisableNoMotionCalibration Parameter to modify 097 * @return Itself 098 */ 099 public Pigeon2FeaturesConfigs withDisableNoMotionCalibration(boolean newDisableNoMotionCalibration) 100 { 101 DisableNoMotionCalibration = newDisableNoMotionCalibration; 102 return this; 103 } 104 105 106 107 @Override 108 public String toString() 109 { 110 String ss = "Config Group: Pigeon2Features\n"; 111 ss += "Name: \"EnableCompass\" Value: \"" + EnableCompass + "\"" + "\n"; 112 ss += "Name: \"DisableTemperatureCompensation\" Value: \"" + DisableTemperatureCompensation + "\"" + "\n"; 113 ss += "Name: \"DisableNoMotionCalibration\" Value: \"" + DisableNoMotionCalibration + "\"" + "\n"; 114 return ss; 115 } 116 117 /** 118 * 119 */ 120 public StatusCode deserialize(String to_deserialize) 121 { 122 EnableCompass = ConfigJNI.Deserializeboolean(SpnValue.Pigeon2UseCompass.value, to_deserialize); 123 DisableTemperatureCompensation = ConfigJNI.Deserializeboolean(SpnValue.Pigeon2DisableTemperatureCompensation.value, to_deserialize); 124 DisableNoMotionCalibration = ConfigJNI.Deserializeboolean(SpnValue.Pigeon2DisableNoMotionCalibration.value, to_deserialize); 125 return StatusCode.OK; 126 } 127 128 /** 129 * 130 */ 131 public String serialize() 132 { 133 String ss = ""; 134 ss += ConfigJNI.Serializeboolean(SpnValue.Pigeon2UseCompass.value, EnableCompass); 135 ss += ConfigJNI.Serializeboolean(SpnValue.Pigeon2DisableTemperatureCompensation.value, DisableTemperatureCompensation); 136 ss += ConfigJNI.Serializeboolean(SpnValue.Pigeon2DisableNoMotionCalibration.value, DisableNoMotionCalibration); 137 return ss; 138 } 139} 140