Пример #1
0
/**\brief
* Return the event variable for a specific event
* @param eventIdx is the event index starting on 0.
* @param index indicates the variable position startin on 0
* @return FAILED_INDEX if index out of bounds
*/
byte MergMemoryManagement::getEventVar(uint8_t eventIdx,uint8_t index){
    byte val;
    lasterror = 0;
    if (eventIdx > numEvents){
        lasterror = FAILED_INDEX;
        return FAILED_INDEX;
    }

    if (index > MAX_VAR_PER_EVENT){
        lasterror = FAILED_INDEX;
        return FAILED_INDEX;
    }

    //position in the array
    int i = resolveEvVarArrayPos(eventIdx,index);
    val = EEPROM.read(i);
    /*
    Serial.print(F("ev "));
    Serial.print (eventIdx);
    Serial.print (" var:"));
    Serial.print (index);
    Serial.print (" val:"));
    Serial.println(val);
    */
    return val;
}
Пример #2
0
/**\brief
* Get all variables of an specific event
* @param eventIdx is the event index starting on 0.
* @param len indicates how many variables
*/
byte* MergMemoryManagement::getEventVars(uint8_t eventIdx,uint8_t *len){
    //populate the array to return
    *len=0;
    int j = resolveEvVarArrayPos(eventIdx,0);
    for (uint8_t i = 0; i< MAX_VAR_PER_EVENT; i++){
        return_eventVars[i] = EEPROM.read(j);
        j++;
    }
    *len = MAX_VAR_PER_EVENT;
    return return_eventVars;
}
Пример #3
0
/**\brief
* Update the variable of an event
* @param eventIdx Event index starting on 0.
* @param varIdx Variable index starting on 0.
* @param val Value of the variable.
* @return if success return the varIdx. if not return varIdx+1
*/
uint8_t MergMemoryManagement::setEventVar(unsigned int eventIdx,uint8_t varIdx,uint8_t val){

    if (eventIdx > numEvents){
        return (varIdx + 1);
    }

    if (varIdx > MAX_VAR_PER_EVENT){
        return (varIdx + 1);
    }
    //look the var in the array vars
    //eventVars[eventIdx*MAX_VAR_PER_EVENT+varIdx]=val;
    EEPROM.write(resolveEvVarArrayPos(eventIdx,varIdx),val);

    return varIdx;
}
Пример #4
0
/**\brief
* Return the event variable for a specific event
* @return FAILED_INDEX if index out of bounds
*/
byte MergMemoryManagement::getEventVar(unsigned int eventIdx,unsigned int index){

    if (eventIdx>numEvents){
        return FAILED_INDEX;
    }

    if (index>MAX_VAR_PER_EVENT){
        return FAILED_INDEX;
    }

    //position in the array
    int i=resolveEvVarArrayPos(eventIdx,index);
    return EEPROM.read(i);
    //return FAILED_INDEX;
}