001/* Copyright (C) Cross The Road Electronics 2024 */
002package com.ctre.phoenix.sensors;
003
004import java.util.HashMap;
005
006/**
007 * @deprecated This device's Phoenix 5 API is deprecated for removal in the
008 * 2025 season. Users should update to Phoenix 6 firmware and migrate to the
009 * Phoenix 6 API. A migration guide is available at
010 * https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html.
011 * <p>
012 * If the Phoenix 5 API must be used for this device, the device must have 22.X
013 * firmware. This firmware is available in Tuner X after selecting Phoenix 5 in
014 * the firmware year dropdown.
015 */
016@Deprecated(since = "2024", forRemoval = true)
017public enum MagnetFieldStrength {
018    /** Magnet Field strength cannot be determined */
019    Invalid_Unknown (0),
020    /** Magnet field is far too low (too far) or far too high (too close). */
021    BadRange_RedLED (1),
022    /** Magnet field is adequate, sensor can be used in this range with slightly reduced accuracy. */
023    Adequate_OrangeLED (2),
024    /** Magnet field is ideal */
025    Good_GreenLED (3);
026
027    public final int value;
028
029    /**
030         * Create MagnetFieldStrength of initValue
031         * @param initValue Value of MagnetFieldStrength
032         */
033        MagnetFieldStrength(int initValue)
034        {
035                this.value = initValue;
036    }
037
038    /** Keep singleton map to quickly lookup enum via int */
039    private static HashMap<Integer, MagnetFieldStrength> _map = null;
040        /** static c'tor, prepare the map */
041    static {
042        _map = new HashMap<Integer, MagnetFieldStrength>();
043                for (MagnetFieldStrength type : MagnetFieldStrength.values()) {
044                        _map.put(type.value, type);
045                }
046    }
047    /** public lookup to convert int to enum */
048        public static MagnetFieldStrength valueOf(int value) {
049                MagnetFieldStrength retval = _map.get(value);
050                if (retval != null)
051                        return retval;
052                return Invalid_Unknown;
053        }
054}