mirror of https://github.com/ArduPilot/ardupilot
Fixed casting issues with EEPROM Registry
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1371 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
parent
b9f3fb7d64
commit
b3089a9c73
|
@ -19,13 +19,19 @@ public:
|
|||
virtual void setF(const float & val) = 0;
|
||||
|
||||
/// Get the variable value as a float
|
||||
virtual const float & getF() = 0;
|
||||
virtual const float getF() = 0;
|
||||
|
||||
/// Set the variable value as an Int16
|
||||
/// Set the variable value as an int16
|
||||
virtual void setI(const int16_t & val) = 0;
|
||||
|
||||
/// Get the variable value as an Int16
|
||||
virtual const int16_t & getI() = 0;
|
||||
/// Get the variable value as an int16
|
||||
virtual const int16_t getI() = 0;
|
||||
|
||||
/// Set the variable value as a bool
|
||||
virtual void setB(const bool & val) = 0;
|
||||
|
||||
/// Get the variable value as an bool
|
||||
virtual const bool getB() = 0;
|
||||
|
||||
/// Save a variable to eeprom
|
||||
virtual void save() = 0;
|
||||
|
@ -41,7 +47,7 @@ public:
|
|||
virtual const bool & getSync() = 0;
|
||||
|
||||
/// Set the sync property
|
||||
virtual void setSync(bool sync) = 0;
|
||||
virtual void setSync(const bool & sync) = 0;
|
||||
};
|
||||
|
||||
/// The variable template class. This class
|
||||
|
@ -81,7 +87,7 @@ public:
|
|||
}
|
||||
|
||||
/// Get the variable as a float
|
||||
virtual const float & getF() {
|
||||
virtual const float getF() {
|
||||
return get();
|
||||
}
|
||||
|
||||
|
@ -91,7 +97,7 @@ public:
|
|||
}
|
||||
|
||||
/// Get the variable value as an Int16
|
||||
virtual const int16_t & getI() {
|
||||
virtual const int16_t getI() {
|
||||
return get();
|
||||
}
|
||||
|
||||
|
@ -101,7 +107,7 @@ public:
|
|||
}
|
||||
|
||||
/// Get the variable value as an Int16
|
||||
virtual const bool & getB() {
|
||||
virtual const bool getB() {
|
||||
return get();
|
||||
}
|
||||
|
||||
|
@ -124,7 +130,7 @@ public:
|
|||
/// If sync is true the a load will always occure before a get and a save will always
|
||||
/// occure before a set.
|
||||
virtual const bool & getSync() { return _sync; }
|
||||
virtual void setSync(bool sync) { _sync = sync; }
|
||||
virtual void setSync(const bool & sync) { _sync = sync; }
|
||||
|
||||
protected:
|
||||
type _data; /// The data that is stored on the heap */
|
||||
|
|
|
@ -22,12 +22,12 @@ void AP_EEPromRegistry::print(BetterStream & stream)
|
|||
stream.printf("\nEEPROM Registry\n");
|
||||
for (int i=0;i<getSize();i++)
|
||||
{
|
||||
stream.printf("%s\t%s\tid:\t%d\taddr:\t%d\tval:\t%f\t\n",
|
||||
stream.printf("id:\t%u\t%s\t%s\tval:\t%10.4f\taddr:\t%u\t\n",
|
||||
(*this)[i]->getEntryId(),
|
||||
(*this)[i]->getEntryParentName(),
|
||||
(*this)[i]->getEntryName(),
|
||||
(*this)[i]->getEntryId(),
|
||||
(*this)[i]->getEntryAddress(),
|
||||
(*this)[i]->getEntry());
|
||||
(*this)[i]->getEntry(),
|
||||
(*this)[i]->getEntryAddress());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,12 +32,12 @@ public:
|
|||
/// Pure virtual function for setting the data value
|
||||
/// as a float. The function must handle the cast to
|
||||
/// the stored variable types.
|
||||
virtual void setEntry(float val) = 0;
|
||||
virtual void setEntry(const float & val) = 0;
|
||||
|
||||
/// Pure virtual function for getting data as a float.
|
||||
/// The function must handle the cast from the
|
||||
/// stored variable types.
|
||||
virtual float getEntry() = 0;
|
||||
virtual const float getEntry() = 0;
|
||||
|
||||
/// Pure virtual function for getting entry name.
|
||||
virtual const char * getEntryName() = 0;
|
||||
|
@ -46,10 +46,10 @@ public:
|
|||
virtual const char * getEntryParentName() = 0;
|
||||
|
||||
/// Get the id of the variable.
|
||||
virtual uint16_t getEntryId() = 0;
|
||||
virtual const uint16_t & getEntryId() = 0;
|
||||
|
||||
/// Get the address of the variable.
|
||||
virtual uint16_t getEntryAddress() = 0;
|
||||
virtual const uint16_t & getEntryAddress() = 0;
|
||||
};
|
||||
|
||||
///The main EEProm Registry class.
|
||||
|
@ -92,16 +92,16 @@ public:
|
|||
eepromRegistry.add(this,_id,_address,sizeof(type));
|
||||
}
|
||||
|
||||
virtual void setEntry(float val) { this->setF(val); }
|
||||
virtual float getEntry() { return this->getF(); }
|
||||
virtual void setEntry(const float & val) { this->setF(val); }
|
||||
virtual const float getEntry() { return this->getF(); }
|
||||
virtual const char * getEntryName() { return this->getName(); }
|
||||
virtual const char * getEntryParentName() { return this->getParentName(); }
|
||||
|
||||
/// Get the id of the variable.
|
||||
virtual uint16_t getEntryId() { return _id; }
|
||||
virtual const uint16_t & getEntryId() { return _id; }
|
||||
|
||||
/// Get the address of the variable.
|
||||
virtual uint16_t getEntryAddress() { return _address; }
|
||||
virtual const uint16_t & getEntryAddress() { return _address; }
|
||||
|
||||
private:
|
||||
uint16_t _id; /// Variable identifier
|
||||
|
|
|
@ -39,27 +39,29 @@ void setup()
|
|||
Serial.begin(115200);
|
||||
Serial.println("ArduPilot RC Channel test");
|
||||
|
||||
eepromRegistry.print(Serial); // show eeprom map
|
||||
APM_RC.Init(); // APM Radio initialization
|
||||
|
||||
for (int i=0;i<nChannels;i++)
|
||||
{
|
||||
Serial.printf("ch:\t%d\tscale:\t%f\tcenter:\t%f\tpwmMin:\t%d\tpwmNeutral:\t%d\tpwmMax:\t%d\t",
|
||||
rcCh[i].getCh(),rcCh[i].getScale(),rcCh[i].getCenter(),
|
||||
rcCh[i].getPwmMin(),rcCh[i].getPwmNeutral(),rcCh[i].getPwmMax());
|
||||
}
|
||||
eepromRegistry.print(Serial); // show eeprom map
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// set channel positions
|
||||
for (int i=0;i<nChannels;i++) rcCh[i].setNormalized(testPosition);
|
||||
|
||||
// print test position
|
||||
Serial.printf("\ntestPosition (%f)\n\t\t",testPosition);
|
||||
|
||||
// print channgel names
|
||||
for (int i=0;i<nChannels;i++) Serial.printf("%7s\t",rcCh[i].getName());
|
||||
Serial.println();
|
||||
|
||||
// print pwm
|
||||
Serial.printf("pwm :\t");
|
||||
for (int i=0;i<nChannels;i++) Serial.printf("%7d\t",rcCh[i].getPwm());
|
||||
Serial.println();
|
||||
|
||||
// print position
|
||||
Serial.printf("position :\t");
|
||||
for (int i=0;i<nChannels;i++) Serial.printf("%7.2f\t",rcCh[i].getPosition());
|
||||
Serial.println();
|
||||
|
@ -77,5 +79,5 @@ void loop()
|
|||
testSign = 1;
|
||||
}
|
||||
|
||||
delay(500);
|
||||
delay(100);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue