예제 #1
0
void CurieImuClass::readGyroScaled(float &x, float &y, float &z)
{
    int16_t sx, sy, sz;

    getRotation(&sx, &sy, &sz);

    x = convertRaw(sx, gyro_range);
    y = convertRaw(sy, gyro_range);
    z = convertRaw(sz, gyro_range);
}
예제 #2
0
void CurieImuClass::readAccelerometerScaled(float &x, float &y, float &z)
{
    int16_t sx, sy, sz;

    getAcceleration(&sx, &sy, &sz);

    x = convertRaw(sx, accel_range);
    y = convertRaw(sy, accel_range);
    z = convertRaw(sz, accel_range);
}
예제 #3
0
float CurieImuClass::readGyroScaled(int axis)
{
    int16_t raw;

    if (axis == X_AXIS) {
        raw = getRotationX();
    } else if (axis == Y_AXIS) {
        raw = getRotationY();
    } else if (axis == Z_AXIS) {
        raw = getRotationZ();
    } else {
        return 0;
    }

    return convertRaw(raw, gyro_range);
}
예제 #4
0
float CurieImuClass::readAccelerometerScaled(int axis)
{
    int16_t raw;

    if (axis == X_AXIS) {
        raw = getAccelerationX();
    } else if (axis == Y_AXIS) {
        raw = getAccelerationY();
    } else if (axis == Z_AXIS) {
        raw = getAccelerationZ();
    } else {
        return 0;
    }

    return convertRaw(raw, accel_range);
}
예제 #5
0
void CurieImuClass::readMotionSensorScaled(float &ax, float &ay, float &az,
                                           float &gx, float &gy, float &gz)
{
    int16_t sax, say, saz, sgx, sgy, sgz;

    getMotion6(&sax, &say, &saz, &sgx, &sgy, &sgz);

    ax = convertRaw(sax, accel_range);
    ay = convertRaw(say, accel_range);
    az = convertRaw(saz, accel_range);
    gx = convertRaw(sgx, gyro_range);
    gy = convertRaw(sgy, gyro_range);
    gz = convertRaw(sgz, gyro_range);
}
예제 #6
0
float SimpleSensor::read() {
    int rawValue = readRaw();
    return convertRaw(rawValue);
}
예제 #7
0
    ///////////////////////////////////////////////////////////
    // Member functions
    //
    ///////////////////////////////////////////////////////////
    const QString String::read(const qboy::Rom &rom, UInt32 offset)
    {
        // Firstly, determines whether the given rom is valid
        Q_ASSERT(rom.info().isLoaded() && rom.info().isValid());

        // Declares needed variables for the decoding process
        QList<UInt8> encoded;
        QString decoded;
        UInt8 readByte;

        // Declares the different dynamic tables (some are the same across all roms)
        QMap<UInt32, QString> *mapBuffers = NULL;
        QMap<UInt32, QString> *mapFunctions = NULL;

        // Determines the rom version and depending on that, loads the tables
        if (CONFIG(RomType) == RT_FRLG)
        {
            mapBuffers = &BufferSequencesFRLG;
            mapFunctions = &FunctionSequencesFRLG;
        }
        else if (CONFIG(RomType) == RT_RS)
        {
            mapBuffers = &BufferSequencesRSE;
            mapFunctions = &FunctionSequencesRS;
        }
        else
        {
            mapBuffers = &BufferSequencesRSE;
            mapFunctions = &FunctionSequencesE;
        }


        // Reads the whole Pokémon string, terminated by 0xFF
        if (!rom.seek(offset))
            Q_ASSERT(false);

        while ((readByte = rom.readByte()) != 0xFF)
            encoded.push_back(readByte);

        // Iterates through every encoded character and interprets it
        int length = encoded.size();
        for (int i = 0; i < length;)
        {
            // Fetches the char at the current position
            UInt8 currentChar = encoded.at(i++);
            if (currentChar == 0xF8 || currentChar == 0xF9)
            {
                // Character might be a symbol
                UInt8 arg1 = encoded[i++];
                UInt32 search = ((currentChar << 8) | arg1);

                // Searches for the sequence in the symbol-map
                auto searchResult = SymbolSequences.find(search);
                if (searchResult != SymbolSequences.end())
                    decoded.push_back(searchResult.value());
                else
                    decoded.push_back(convertRaw(search));
            }
            else if (currentChar == 0xFD)
            {
                // Character might be a buffer
                UInt8 arg1 = encoded.at(i++);
                UInt32 search = ((currentChar << 8) | arg1);

                // Searches for the sequence in the dynamic buffer-map
                auto searchResult = mapBuffers->find(search);
                if (searchResult != mapBuffers->end())
                    decoded.push_back(searchResult.value());
                else
                    decoded.push_back(convertRaw(search));
            }
            else if (currentChar == 0xFC)
            {
                // Character might be an escape sequence
                UInt8 arg1 = encoded.at(i++);
                UInt32 search = 0;
                if (arg1 >= 1 && arg1 <= 6)
                {
                    // Might be a multi-byte function
                    UInt8 arg2 = encoded[i++];
                    search = ((currentChar << 16) | (arg1 << 8) | arg2);
                }
                else
                {
                    // Might be a single-byte function
                    search = ((currentChar << 8) | arg1);
                }

                // Searches for the sequence in the dynamic escape-map
                auto searchResult = mapFunctions->find(search);
                if (searchResult != mapFunctions->end())
                    decoded.push_back(searchResult.value());
                else
                    decoded.push_back(convertRaw(search));
            }
            else
            {
                // Is a single character for sure (exception-safe!)
                decoded.push_back(SingleSequences.value(currentChar));
            }
        }

        // Finished
        return decoded;
    }