<commit_before>package org.robockets.lib;

import edu.wpi.first.wpilibj.I2C;

/**
 * See https://cdn-shop.adafruit.com/datasheets/L3GD20H.pdf for more info
 * @author <NAME>
 */
public class AdaGyro {

    /**
     * The gyro
     */
    private I2C gyro;

    /**
     * Create the I2C object based on the address provided
     * @param address The device address in hex either 0x6A or 0x6B
     */
    public AdaGyro(int address) {
        gyro = new I2C(I2C.Port.kOnboard, address);
    }

    /**
     * Setup the gyro with the recommended settings
     * - Enable normal power mode
     * - Enable all axes
     * - Enable FIFO
     */
    public void autoSetup() {
        gyro.write(0x20, 0b00001111); // Enables normal power mode and axes
        gyro.write(0x24, 0b01000000); // Enable FIFO
    }

    /**
     * Set CTRL values
     * @param ctrlNum The ctrl register to access
     * @param values The values in binary
     * @throws InvalidInputException Thrown when an invalid ctrl number was entered
     */
    public void setCtrl(int ctrlNum, int values) throws InvalidInputException{
        switch (ctrlNum) {
            case 1:
                gyro.write(0x20, values);
                break;
            case 2:
                gyro.write(0x21, values);
                break;
            case 3:
                gyro.write(0x22, values);
                break;
            case 4:
                gyro.write(0x23, values);
                break;
            case 5:
                gyro.write(0x24, values);
                break;
            default:
                throw new InvalidInputException("That ctrl number does not exist!");
        }
    }

    /**
     * Read CTRL values
     * @param ctrlNum The ctrl register to access
     * @throws InvalidInputException Thrown when an invalid ctrl number was entered
     */
    public byte[] readCtrl(int ctrlNum) throws InvalidInputException{

        byte[] overflow = new byte[1];

        switch (ctrlNum) {
            case 1:
                gyro.read(0x20, 1, overflow);
                break;
            case 2:
                gyro.read(0x21, 1, overflow);
                break;
            case 3:
                gyro.read(0x22, 1, overflow);
                break;
            case 4:
                gyro.read(0x23, 1, overflow);
                break;
            case 5:
                gyro.read(0x24, 1, overflow);
                break;
            default:
                throw new InvalidInputException("That ctrl number does not exist!");
        }

        return overflow;
    }

    /**
     * Read temperature values
     * @return The temperature read from the gyro
     */
    public byte[] readTemp() {
        byte[] overflow = new byte[1];

        gyro.read(0x26, 1, overflow);

        return overflow;
    }

    /**
     * Get the X or yaw gyro value
     * @return The X value
     */
    public double readX() {
        byte[] hOrder = new byte[1];
        byte[] lOrder = new byte[1];
        int x = 0;

        // Stuff goes here

        gyro.read(0x28, 1, lOrder);
        gyro.read(0x29, 1, hOrder);

        x = getDegrees(hOrder[0], lOrder[0]);

        return toUnsigned(x);
    }

    /**
     * Get the Y or pitch gyro value
     * @return The Y value
     */
    public double readY() {
        byte[] hOrder = new byte[1];
        byte[] lOrder = new byte[1];
        int y = 0;

        gyro.read(0x2A, 1, lOrder);
        gyro.read(0x2B, 1, hOrder);

        y = getDegrees(hOrder[0], lOrder[0]);

        return toUnsigned(y);
    }

    /**
     * Get the Z or roll value
     * @return The Z Value
     */
    public double readZ() {
        byte[] hOrder = new byte[1];
        byte[] lOrder = new byte[1];
        int z = 0;

        // Stuff goes here

        gyro.read(0x2C, 1, lOrder);
        gyro.read(0x2D, 1, hOrder);

        z = getDegrees(hOrder[0], lOrder[0]);

        return toUnsigned(z);
    }

    /**
     * Write values to a custom address
     * @param address The register address in hex
     * @param values The values to write in binary
     */
    public void customWrite(int address, int values) throws InvalidInputException{

        for (int i = 0x00; i<0x0E; i++) { // I don't know how well this works
            if (address == i) {
                throw new InvalidInputException("This value can cause problems!! Aborting...");
            }
        }

        for (int i = 0x10; i<0x1F; i++) { // I don't know how well this works
            if (address == i) {
                throw new InvalidInputException("This value can cause problems!! Aborting...");
            }
        }

        gyro.write(address, values);

    }
<commit_msg>Fix values<commit_after>package org.robockets.lib;

import edu.wpi.first.wpilibj.I2C;

/**
 * See https://cdn-shop.adafruit.com/datasheets/L3GD20H.pdf for more info
 * @author <NAME>
 */
public class AdaGyro {

    /**
     * The gyro
     */
    private I2C gyro;

    /**
     * Create the I2C object based on the address provided
     * @param address The device address in hex either 0x6A or 0x6B
     */
    public AdaGyro(int address) {
        gyro = new I2C(I2C.Port.kOnboard, address);
    }

    /**
     * Setup the gyro with the recommended settings
     * - Enable normal power mode
     * - Enable all axes
     * - Enable FIFO
     */
    public void autoSetup() {
        gyro.write(0x20, 0b00001111); // Enables normal power mode and axes
        gyro.write(0x24, 0b01000000); // Enable FIFO
    }

    /**
     * Set CTRL values
     * @param ctrlNum The ctrl register to access
     * @param values The values in binary
     * @throws InvalidInputException Thrown when an invalid ctrl number was entered
     */
    public void setCtrl(int ctrlNum, int values) throws InvalidInputException{
        switch (ctrlNum) {
            case 1:
                gyro.write(0x20, values);
                break;
            case 2:
                gyro.write(0x21, values);
                break;
            case 3:
                gyro.write(0x22, values);
                break;
            case 4:
                gyro.write(0x23, values);
                break;
            case 5:
                gyro.write(0x24, values);
                break;
            default:
                throw new InvalidInputException("That ctrl number does not exist!");
        }
    }

    /**
     * Read CTRL values
     * @param ctrlNum The ctrl register to access
     * @throws InvalidInputException Thrown when an invalid ctrl number was entered
     */
    public byte[] readCtrl(int ctrlNum) throws InvalidInputException{

        byte[] overflow = new byte[1];

        switch (ctrlNum) {
            case 1:
                gyro.read(0x20, 1, overflow);
                break;
            case 2:
                gyro.read(0x21, 1, overflow);
                break;
            case 3:
                gyro.read(0x22, 1, overflow);
                break;
            case 4:
                gyro.read(0x23, 1, overflow);
                break;
            case 5:
                gyro.read(0x24, 1, overflow);
                break;
            default:
                throw new InvalidInputException("That ctrl number does not exist!");
        }

        return overflow;
    }

    /**
     * Read temperature values
     * @return The temperature read from the gyro
     */
    public byte[] readTemp() {
        byte[] overflow = new byte[1];

        gyro.read(0x26, 1, overflow);

        return overflow;
    }

    /**
     * Get the X or yaw gyro value
     * @return The X value
     */
    public double readX() {
        byte[] hOrder = new byte[1];
        byte[] lOrder = new byte[1];
        int x = 0;

        // Stuff goes here

        gyro.read(0x28, 1, lOrder);
        gyro.read(0x29, 1, hOrder);

        x = getDegrees(lOrder[0], hOrder[0]);

        return toUnsigned(x);
    }

    /**
     * Get the Y or pitch gyro value
     * @return The Y value
     */
    public double readY() {
        byte[] hOrder = new byte[1];
        byte[] lOrder = new byte[1];
        int y = 0;

        gyro.read(0x2A, 1, lOrder);
        gyro.read(0x2B, 1, hOrder);

        y = getDegrees(lOrder[0], hOrder[0]);

        return toUnsigned(y);
    }

    /**
     * Get the Z or roll value
     * @return The Z Value
     */
    public double readZ() {
        byte[] hOrder = new byte[1];
        byte[] lOrder = new byte[1];
        int z = 0;

        // Stuff goes here

        gyro.read(0x2C, 1, lOrder);
        gyro.read(0x2D, 1, hOrder);

        z = getDegrees(lOrder[0], hOrder[0]);

        return toUnsigned(z);
    }

    /**
     * Write values to a custom address
     * @param address The register address in hex
     * @param values The values to write in binary
     */
    public void customWrite(int address, int values) throws InvalidInputException{

        for (int i = 0x00; i<0x0E; i++) { // I don't know how well this works
            if (address == i) {
                throw new InvalidInputException("This value can cause problems!! Aborting...");
            }
        }

        for (int i = 0x10; i<0x1F; i++) { // I don't know how well this works
            if (address == i) {
                throw new InvalidInputException("This value can cause problems!! Aborting...");
            }
        }

        gyro.write(address, values);

    }

{'fraction_non_alphanumeric': 0.10268948655256724, 'fraction_numerical': 0.02806420750504943, 'mean_word_length': 1.5551330798479088, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3391007', 'n_tokens_mistral': 3022, 'n_tokens_neox': 2751, 'n_words': 869}