Esempio n. 1
0
    void Eeprom::writeEeprom(const EepromLocation& location, const Value& val)
    {
        //get the type and location from the EepromLocation object
        ValueType type = location.valueType();
        uint16 eepromLoc = location.location();

        //determine which writeEeprom function to call, based on the valueType
        switch(type)
        {
            case valueType_uint16:
                writeEeprom(eepromLoc, val.as_uint16());
                break;

            case valueType_float:
                writeEeprom_float(eepromLoc, val.as_float());
                break;

            case valueType_uint32:
                writeEeprom_uint32(eepromLoc, val.as_uint32());
                break;

            case valueType_int16:
                writeEeprom_int16(eepromLoc, val.as_int16());
                break;

            default:
                assert(false);    //we are trying to write a value with an invalid type? 
                writeEeprom(eepromLoc, val.as_uint16());    //just default to uint16
        }
    }
Esempio n. 2
0
    Value Eeprom::readEeprom(const EepromLocation& location)
    {
        //get the type and location from the EepromLocation object
        ValueType type = location.valueType();
        uint16 eepromLoc = location.location();

        //determine which readEeprom function to call, based on the valueType
        switch(type)
        {
            case valueType_uint16:
                return Value(type, readEeprom(eepromLoc));

            case valueType_float:
                return Value(type, readEeprom_float(eepromLoc));

            case valueType_uint32:
                return Value(type, readEeprom_uint32(eepromLoc));

            case valueType_int16:
                return Value(type, readEeprom_int16(eepromLoc));

            default:
                assert(false);    //we are trying to read a value with an invalid type? 
                return Value(type, readEeprom(eepromLoc));    //just default to uint16
        }
    }
Esempio n. 3
0
    EepromLocation NodeEepromMap::getOffsetEeprom(const EepromLocation& slopeEeprom)
    {
        //difference between eeprom locations (slope to offset)
        static const uint16 eepromDiff = CH_ACTION_OFFSET_1.location() - CH_ACTION_SLOPE_1.location();

        //difference between ids (slope to offset)
        static const uint16 idDiff = CH_ACTION_OFFSET_1.id() - CH_ACTION_SLOPE_1.id();

        return EepromLocation(slopeEeprom.id() + idDiff, slopeEeprom.location() + eepromDiff, CH_ACTION_OFFSET_1.valueType());
    }