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    /**
070     * Modifies this configuration's DisableTemperatureCompensation parameter and returns itself for
071     * method-chaining and easier to use config API.
072     * <p>
073     * Disables using the temperature compensation feature.
074     * 
075     * <ul>
076     *   <li> <b>Default Value:</b> False
077     * </ul>
078     *
079     * @param newDisableTemperatureCompensation Parameter to modify
080     * @return Itself
081     */
082    public Pigeon2FeaturesConfigs withDisableTemperatureCompensation(boolean newDisableTemperatureCompensation)
083    {
084        DisableTemperatureCompensation = newDisableTemperatureCompensation;
085        return this;
086    }
087    
088    /**
089     * Modifies this configuration's DisableNoMotionCalibration parameter and returns itself for
090     * method-chaining and easier to use config API.
091     * <p>
092     * Disables using the no-motion calibration feature.
093     * 
094     * <ul>
095     *   <li> <b>Default Value:</b> False
096     * </ul>
097     *
098     * @param newDisableNoMotionCalibration Parameter to modify
099     * @return Itself
100     */
101    public Pigeon2FeaturesConfigs withDisableNoMotionCalibration(boolean newDisableNoMotionCalibration)
102    {
103        DisableNoMotionCalibration = newDisableNoMotionCalibration;
104        return this;
105    }
106
107    
108
109    @Override
110    public String toString()
111    {
112        String ss = "Config Group: Pigeon2Features\n";
113        ss += "    EnableCompass: " + EnableCompass + "\n";
114        ss += "    DisableTemperatureCompensation: " + DisableTemperatureCompensation + "\n";
115        ss += "    DisableNoMotionCalibration: " + DisableNoMotionCalibration + "\n";
116        return ss;
117    }
118
119    /**
120     *
121     */
122    public StatusCode deserialize(String to_deserialize)
123    {
124        EnableCompass = ConfigJNI.Deserializeboolean(SpnValue.Pigeon2UseCompass.value, to_deserialize);
125        DisableTemperatureCompensation = ConfigJNI.Deserializeboolean(SpnValue.Pigeon2DisableTemperatureCompensation.value, to_deserialize);
126        DisableNoMotionCalibration = ConfigJNI.Deserializeboolean(SpnValue.Pigeon2DisableNoMotionCalibration.value, to_deserialize);
127        return  StatusCode.OK;
128    }
129
130    /**
131     *
132     */
133    public String serialize()
134    {
135        String ss = "";
136        ss += ConfigJNI.Serializeboolean(SpnValue.Pigeon2UseCompass.value, EnableCompass);
137        ss += ConfigJNI.Serializeboolean(SpnValue.Pigeon2DisableTemperatureCompensation.value, DisableTemperatureCompensation);
138        ss += ConfigJNI.Serializeboolean(SpnValue.Pigeon2DisableNoMotionCalibration.value, DisableNoMotionCalibration);
139        return ss;
140    }
141}
142