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.phoenixpro.configs; 008 009import com.ctre.phoenixpro.StatusCode; 010import com.ctre.phoenixpro.configs.jni.ConfigJNI; 011import com.ctre.phoenixpro.spns.*; 012 013/** 014 * Configs to trim the Pigeon2's gyroscope. 015 * <p> 016 * Pigeon2 allows the user to trim the gyroscope's sensitivity. While 017 * this isn't necessary for the Pigeon2, as it comes calibrated 018 * out-of-the-box, users can make use of this to make the Pigeon2 019 * even more accurate for their application. 020 */ 021public class GyroTrimConfigs implements ParentConfiguration 022{ 023 /** 024 * The gyro scalar component for the X axis 025 * 026 * <ul> 027 * <li> <b>Minimum Value:</b> -180 028 * <li> <b>Maximum Value:</b> 180 029 * <li> <b>Default Value:</b> 0 030 * <li> <b>Units:</b> deg per rotation 031 * </ul> 032 */ 033 public double GyroScalarX = 0; 034 /** 035 * The gyro scalar component for the Y axis 036 * 037 * <ul> 038 * <li> <b>Minimum Value:</b> -180 039 * <li> <b>Maximum Value:</b> 180 040 * <li> <b>Default Value:</b> 0 041 * <li> <b>Units:</b> deg per rotation 042 * </ul> 043 */ 044 public double GyroScalarY = 0; 045 /** 046 * The gyro scalar component for the Z axis 047 * 048 * <ul> 049 * <li> <b>Minimum Value:</b> -180 050 * <li> <b>Maximum Value:</b> 180 051 * <li> <b>Default Value:</b> 0 052 * <li> <b>Units:</b> deg per rotation 053 * </ul> 054 */ 055 public double GyroScalarZ = 0; 056 057 @Override 058 public String toString() 059 { 060 String ss = "Config Group: GyroTrim\n"; 061 ss += "Name: \"GyroScalarX\" Value: \"" + GyroScalarX + "deg per rotation\"" + "\n"; 062 ss += "Name: \"GyroScalarY\" Value: \"" + GyroScalarY + "deg per rotation\"" + "\n"; 063 ss += "Name: \"GyroScalarZ\" Value: \"" + GyroScalarZ + "deg per rotation\"" + "\n"; 064 return ss; 065 } 066 067 /** 068 * 069 */ 070 public StatusCode deserialize(String string) 071 { 072 GyroScalarX = ConfigJNI.Deserializedouble(SpnValue.Pigeon2GyroScalarX.value, string); 073 GyroScalarY = ConfigJNI.Deserializedouble(SpnValue.Pigeon2GyroScalarY.value, string); 074 GyroScalarZ = ConfigJNI.Deserializedouble(SpnValue.Pigeon2GyroScalarZ.value, string); 075 return StatusCode.OK; 076 } 077 078 /** 079 * 080 */ 081 public String serialize() 082 { 083 String ss = ""; 084 ss += ConfigJNI.Serializedouble(958, GyroScalarX); 085 ss += ConfigJNI.Serializedouble(959, GyroScalarY); 086 ss += ConfigJNI.Serializedouble(960, GyroScalarZ); 087 return ss; 088 } 089} 090