Esempio n. 1
0
void EEPROM::update(GCode *com)
{
#if EEPROM_MODE!=0
    if(com->hasT() && com->hasP()) switch(com->T)
        {
        case 0:
            if(com->hasS()) HAL::epr_set_byte(com->P,(byte)com->S);
            break;
        case 1:
            if(com->hasS()) HAL::epr_set_int(com->P,(int)com->S);
            break;
        case 2:
            if(com->hasS()) HAL::epr_set_long(com->P,(long)com->S);
            break;
        case 3:
            if(com->hasX()) HAL::epr_set_float(com->P,com->X);
            break;
        }
    byte newcheck = computeChecksum();
    if(newcheck!=HAL::epr_get_byte(EPR_INTEGRITY_BYTE))
        HAL::epr_set_byte(EPR_INTEGRITY_BYTE,newcheck);
    readDataFromEEPROM();
#else
    Com::printErrorF(tNoEEPROMSupport);
#endif
}
Esempio n. 2
0
void EEPROM::update(GCode *com)
{
#if EEPROM_MODE!=0
    if(com->hasT() && com->hasP()) switch(com->T)
        {
        case 0:
            if(com->hasS()) HAL::eprSetByte(com->P,(uint8_t)com->S);
            break;
        case 1:
            if(com->hasS()) HAL::eprSetInt16(com->P,(int)com->S);
            break;
        case 2:
            if(com->hasS()) HAL::eprSetInt32(com->P,(long)com->S);
            break;
        case 3:
            if(com->hasX()) HAL::eprSetFloat(com->P,com->X);
            break;
        }
    uint8_t newcheck = computeChecksum();
    if(newcheck!=HAL::eprGetByte(EPR_INTEGRITY_BYTE))
        HAL::eprSetByte(EPR_INTEGRITY_BYTE,newcheck);
    readDataFromEEPROM();
    Extruder::selectExtruderById(Extruder::current->id);
#else
    Com::printErrorF(Com::tNoEEPROMSupport);
#endif
}
Esempio n. 3
0
void EEPROM::init()
{
#if EEPROM_MODE != 0
    uint8_t check = computeChecksum();
    uint8_t storedcheck = HAL::eprGetByte(EPR_INTEGRITY_BYTE);
    if(HAL::eprGetByte(EPR_MAGIC_BYTE) == EEPROM_MODE && storedcheck == check)
    {
        readDataFromEEPROM();
        if (USE_CONFIGURATION_BAUD_RATE)
        {
            // Used if eeprom gets unusable baud rate set and communication wont work at all.
            if(HAL::eprGetInt32(EPR_BAUDRATE) != BAUDRATE)
            {
                HAL::eprSetInt32(EPR_BAUDRATE,BAUDRATE);
                baudrate = BAUDRATE;
                uint8_t newcheck = computeChecksum();
                if(newcheck != HAL::eprGetByte(EPR_INTEGRITY_BYTE))
                    HAL::eprSetByte(EPR_INTEGRITY_BYTE,newcheck);
            }
            Com::printFLN(PSTR("EEprom baud rate restored from configuration."));
            Com::printFLN(PSTR("RECOMPILE WITH USE_CONFIGURATION_BAUD_RATE == 0 to alter baud rate via EEPROM"));
        }
    }
    else
    {
        HAL::eprSetByte(EPR_MAGIC_BYTE,EEPROM_MODE); // Make datachange permanent
        initalizeUncached();
        storeDataIntoEEPROM(storedcheck != check);
    }
#endif
}
//internal usage of update value
void EEPROM:: update(long P,uint8_t T,long S,float X)
{
#if EEPROM_MODE!=0
    if(T>=0 &&T<=3 && P>0 && P<=2048) //SDEEPROM_SIZE =2048 // Minimum size used by Eeprom.cpp
    switch(T)
        {
        case EPR_TYPE_BYTE:
            HAL::eprSetByte(P,(uint8_t)S);
            break;
        case EPR_TYPE_INT:
           HAL::eprSetInt16(P,(int)S);
            break;
        case EPR_TYPE_LONG:
            HAL::eprSetInt32(P,(int32_t)S);
            break;
        case EPR_TYPE_FLOAT:
           HAL::eprSetFloat(P,X);
            break;
        }
    uint8_t newcheck = computeChecksum();
    if(newcheck != HAL::eprGetByte(EPR_INTEGRITY_BYTE))
        HAL::eprSetByte(EPR_INTEGRITY_BYTE,newcheck);
    readDataFromEEPROM();
    Extruder::selectExtruderById(Extruder::current->id);
#else
    Com::printErrorF(Com::tNoEEPROMSupport);
#endif
}
Esempio n. 5
0
void EEPROM::init()
{
#if EEPROM_MODE!=0
    byte check = computeChecksum();
    byte storedcheck = HAL::epr_get_byte(EPR_INTEGRITY_BYTE);
    if(HAL::epr_get_byte(EPR_MAGIC_BYTE)==EEPROM_MODE && storedcheck==check)
    {
        readDataFromEEPROM();
    }
    else
    {
        HAL::epr_set_byte(EPR_MAGIC_BYTE,EEPROM_MODE); // Make datachange permanent
        storeDataIntoEEPROM(storedcheck!=check);
    }
#endif
}
Esempio n. 6
0
void EEPROM::init()
{
#if EEPROM_MODE!=0
    uint8_t check = computeChecksum();
    uint8_t storedcheck = HAL::eprGetByte(EPR_INTEGRITY_BYTE);
    if(HAL::eprGetByte(EPR_MAGIC_BYTE)==EEPROM_MODE && storedcheck==check)
    {
        readDataFromEEPROM();
    }
    else
    {
        HAL::eprSetByte(EPR_MAGIC_BYTE,EEPROM_MODE); // Make datachange permanent
        initalizeUncached();
        storeDataIntoEEPROM(storedcheck!=check);
    }
#endif
}
Esempio n. 7
0
void EEPROM::update(GCode *com)
{
#if EEPROM_MODE != 0
    if(com->hasT() && com->hasP()) switch(com->T)
        {
        case 0:
            if(com->hasS())
                HAL::eprSetByte(com->P, (uint8_t)com->S);
            break;
        case 1:
            if(com->hasS())
                HAL::eprSetInt16(com->P, (int16_t)com->S);
            break;
        case 2:
            if(com->hasS())
                HAL::eprSetInt32(com->P, (int32_t)com->S);
            break;
        case 3:
            if(com->hasX())
                HAL::eprSetFloat(com->P, com->X);
            break;
        }
    uint8_t newcheck = computeChecksum();
    if(newcheck != HAL::eprGetByte(EPR_INTEGRITY_BYTE))
        HAL::eprSetByte(EPR_INTEGRITY_BYTE, newcheck);
    bool includesEeprom = com->P >= EEPROM_EXTRUDER_OFFSET && com->P < EEPROM_EXTRUDER_OFFSET + 6 * EEPROM_EXTRUDER_LENGTH;
    readDataFromEEPROM(includesEeprom);
#if MIXING_EXTRUDER
    Extruder::selectExtruderById(Extruder::activeMixingExtruder);
#else
    Extruder::selectExtruderById(Extruder::current->id);
#endif
#else
    Com::printErrorF(Com::tNoEEPROMSupport);
#endif
}