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 that affect audible components of the device.
015 * <p>
016 * Includes configuration for the beep on boot.
017 */
018public class AudioConfigs implements ParentConfiguration
019{
020    /**
021     * If true, the TalonFX will beep during boot-up.  This is useful for
022     * general debugging, and defaults to true.  If rotor is moving during
023     * boot-up, the beep will not occur regardless of this setting.
024     * 
025     * <ul>
026     *   <li> <b>Default Value:</b> True
027     * </ul>
028     */
029    public boolean BeepOnBoot = true;
030    /**
031     * If true, the TalonFX will beep during configuration API calls if
032     * device is disabled.  This is useful for general debugging, and
033     * defaults to true.  Note that if the rotor is moving, the beep will
034     * not occur regardless of this setting.
035     * 
036     * <ul>
037     *   <li> <b>Default Value:</b> True
038     * </ul>
039     */
040    public boolean BeepOnConfig = true;
041    /**
042     * If true, the TalonFX will allow Orchestra and MusicTone requests
043     * during disabled state.  This can be used to address corner cases
044     * when music features are needed when disabled.  This setting
045     * defaults to false.  Note that if the rotor is moving, music
046     * features are always disabled regardless of this setting.
047     * 
048     * <ul>
049     *   <li> <b>Default Value:</b> False
050     * </ul>
051     */
052    public boolean AllowMusicDurDisable = false;
053    
054    /**
055     * Modifies this configuration's BeepOnBoot parameter and returns itself for
056     * method-chaining and easier to use config API.
057     * <p>
058     * If true, the TalonFX will beep during boot-up.  This is useful for
059     * general debugging, and defaults to true.  If rotor is moving during
060     * boot-up, the beep will not occur regardless of this setting.
061     * 
062     * <ul>
063     *   <li> <b>Default Value:</b> True
064     * </ul>
065     *
066     * @param newBeepOnBoot Parameter to modify
067     * @return Itself
068     */
069    public AudioConfigs withBeepOnBoot(boolean newBeepOnBoot)
070    {
071        BeepOnBoot = newBeepOnBoot;
072        return this;
073    }
074    /**
075     * Modifies this configuration's BeepOnConfig parameter and returns itself for
076     * method-chaining and easier to use config API.
077     * <p>
078     * If true, the TalonFX will beep during configuration API calls if
079     * device is disabled.  This is useful for general debugging, and
080     * defaults to true.  Note that if the rotor is moving, the beep will
081     * not occur regardless of this setting.
082     * 
083     * <ul>
084     *   <li> <b>Default Value:</b> True
085     * </ul>
086     *
087     * @param newBeepOnConfig Parameter to modify
088     * @return Itself
089     */
090    public AudioConfigs withBeepOnConfig(boolean newBeepOnConfig)
091    {
092        BeepOnConfig = newBeepOnConfig;
093        return this;
094    }
095    /**
096     * Modifies this configuration's AllowMusicDurDisable parameter and returns itself for
097     * method-chaining and easier to use config API.
098     * <p>
099     * If true, the TalonFX will allow Orchestra and MusicTone requests
100     * during disabled state.  This can be used to address corner cases
101     * when music features are needed when disabled.  This setting
102     * defaults to false.  Note that if the rotor is moving, music
103     * features are always disabled regardless of this setting.
104     * 
105     * <ul>
106     *   <li> <b>Default Value:</b> False
107     * </ul>
108     *
109     * @param newAllowMusicDurDisable Parameter to modify
110     * @return Itself
111     */
112    public AudioConfigs withAllowMusicDurDisable(boolean newAllowMusicDurDisable)
113    {
114        AllowMusicDurDisable = newAllowMusicDurDisable;
115        return this;
116    }
117
118    
119
120    @Override
121    public String toString()
122    {
123        String ss = "Config Group: Audio\n";
124        ss += "Name: \"BeepOnBoot\" Value: \"" + BeepOnBoot + "\"" + "\n";
125        ss += "Name: \"BeepOnConfig\" Value: \"" + BeepOnConfig + "\"" + "\n";
126        ss += "Name: \"AllowMusicDurDisable\" Value: \"" + AllowMusicDurDisable + "\"" + "\n";
127        return ss;
128    }
129
130    /**
131     *
132     */
133    public StatusCode deserialize(String to_deserialize)
134    {
135        BeepOnBoot = ConfigJNI.Deserializeboolean(SpnValue.Config_BeepOnBoot.value, to_deserialize);
136        BeepOnConfig = ConfigJNI.Deserializeboolean(SpnValue.Config_BeepOnConfig.value, to_deserialize);
137        AllowMusicDurDisable = ConfigJNI.Deserializeboolean(SpnValue.Config_AllowMusicDurDisable.value, to_deserialize);
138        return  StatusCode.OK;
139    }
140
141    /**
142     *
143     */
144    public String serialize()
145    {
146        String ss = "";
147        ss += ConfigJNI.Serializeboolean(SpnValue.Config_BeepOnBoot.value, BeepOnBoot);
148        ss += ConfigJNI.Serializeboolean(SpnValue.Config_BeepOnConfig.value, BeepOnConfig);
149        ss += ConfigJNI.Serializeboolean(SpnValue.Config_AllowMusicDurDisable.value, AllowMusicDurDisable);
150        return ss;
151    }
152}
153