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 /** 076 * Modifies this configuration's BeepOnConfig parameter and returns itself for 077 * method-chaining and easier to use config API. 078 * <p> 079 * If true, the TalonFX will beep during configuration API calls if 080 * device is disabled. This is useful for general debugging, and 081 * defaults to true. Note that if the rotor is moving, the beep will 082 * not occur regardless of this setting. 083 * 084 * <ul> 085 * <li> <b>Default Value:</b> True 086 * </ul> 087 * 088 * @param newBeepOnConfig Parameter to modify 089 * @return Itself 090 */ 091 public AudioConfigs withBeepOnConfig(boolean newBeepOnConfig) 092 { 093 BeepOnConfig = newBeepOnConfig; 094 return this; 095 } 096 097 /** 098 * Modifies this configuration's AllowMusicDurDisable parameter and returns itself for 099 * method-chaining and easier to use config API. 100 * <p> 101 * If true, the TalonFX will allow Orchestra and MusicTone requests 102 * during disabled state. This can be used to address corner cases 103 * when music features are needed when disabled. This setting 104 * defaults to false. Note that if the rotor is moving, music 105 * features are always disabled regardless of this setting. 106 * 107 * <ul> 108 * <li> <b>Default Value:</b> False 109 * </ul> 110 * 111 * @param newAllowMusicDurDisable Parameter to modify 112 * @return Itself 113 */ 114 public AudioConfigs withAllowMusicDurDisable(boolean newAllowMusicDurDisable) 115 { 116 AllowMusicDurDisable = newAllowMusicDurDisable; 117 return this; 118 } 119 120 121 122 @Override 123 public String toString() 124 { 125 String ss = "Config Group: Audio\n"; 126 ss += " BeepOnBoot: " + BeepOnBoot + "\n"; 127 ss += " BeepOnConfig: " + BeepOnConfig + "\n"; 128 ss += " AllowMusicDurDisable: " + AllowMusicDurDisable + "\n"; 129 return ss; 130 } 131 132 /** 133 * 134 */ 135 public StatusCode deserialize(String to_deserialize) 136 { 137 BeepOnBoot = ConfigJNI.Deserializeboolean(SpnValue.Config_BeepOnBoot.value, to_deserialize); 138 BeepOnConfig = ConfigJNI.Deserializeboolean(SpnValue.Config_BeepOnConfig.value, to_deserialize); 139 AllowMusicDurDisable = ConfigJNI.Deserializeboolean(SpnValue.Config_AllowMusicDurDisable.value, to_deserialize); 140 return StatusCode.OK; 141 } 142 143 /** 144 * 145 */ 146 public String serialize() 147 { 148 String ss = ""; 149 ss += ConfigJNI.Serializeboolean(SpnValue.Config_BeepOnBoot.value, BeepOnBoot); 150 ss += ConfigJNI.Serializeboolean(SpnValue.Config_BeepOnConfig.value, BeepOnConfig); 151 ss += ConfigJNI.Serializeboolean(SpnValue.Config_AllowMusicDurDisable.value, AllowMusicDurDisable); 152 return ss; 153 } 154} 155