learning C++

This commit is contained in:
rusefi 2019-01-15 20:24:36 -05:00
parent de2a196dbc
commit 0ffa05a911
5 changed files with 12 additions and 13 deletions

View File

@ -39,7 +39,7 @@ public:
int fakeAdcValues[MOCK_ADC_SIZE];
void setMockVoltage(int hwChannel, float voltage);
int getMockAdcValue(int hwChannel);
int getMockAdcValue(int hwChannel) const;
};
#define MAX_INJECTION_OUTPUT_COUNT INJECTION_PIN_COUNT
@ -67,8 +67,7 @@ class ThermistorMath {
public:
void setConfig(thermistor_conf_s *config);
void prepareThermistorCurve(thermistor_conf_s *tc);
bool isLinearSensor();
float getKelvinTemperatureByResistance(float resistance);
float getKelvinTemperatureByResistance(float resistance) const;
float s_h_a = 0;
float s_h_b = 0;
float s_h_c = 0;
@ -137,7 +136,7 @@ class WarningCodeState {
public:
WarningCodeState();
void addWarningCode(obd_code_e code);
bool isWarningNow(efitimesec_t now, bool forIndicator DECLARE_ENGINE_PARAMETER_SUFFIX);
bool isWarningNow(efitimesec_t now, bool forIndicator DECLARE_ENGINE_PARAMETER_SUFFIX) const;
void clear();
int warningCounter;
int lastErrorCode;

View File

@ -58,7 +58,7 @@ void WarningCodeState::addWarningCode(obd_code_e code) {
/**
* @param forIndicator if we want to retrieving value for TS indicator, this case a minimal period is applued
*/
bool WarningCodeState::isWarningNow(efitimesec_t now, bool forIndicator DECLARE_ENGINE_PARAMETER_SUFFIX) {
bool WarningCodeState::isWarningNow(efitimesec_t now, bool forIndicator DECLARE_ENGINE_PARAMETER_SUFFIX) const {
int period = forIndicator ? maxI(3, engineConfiguration->warningPeriod) : engineConfiguration->warningPeriod;
return absI(now - timeOfPreviousWarning) < period;
}
@ -229,7 +229,7 @@ SensorsState::SensorsState() {
reset();
}
int MockAdcState::getMockAdcValue(int hwChannel) {
int MockAdcState::getMockAdcValue(int hwChannel) const {
return fakeAdcValues[hwChannel];
}

View File

@ -47,7 +47,7 @@ float getVoutInVoltageDividor(float Vin, float r1, float r2) {
return r2 * Vin / (r1 + r2);
}
float ThermistorMath::getKelvinTemperatureByResistance(float resistance) {
float ThermistorMath::getKelvinTemperatureByResistance(float resistance) const {
if (resistance <= 0) {
//warning("Invalid resistance in getKelvinTemperature=", resistance);
return 0.0f;

View File

@ -120,7 +120,7 @@ efitime_t TriggerState::getTotalEventCounter() {
return totalEventCountBase + currentCycle.current_index;
}
int TriggerState::getTotalRevolutionCounter() {
int TriggerState::getTotalRevolutionCounter() const {
return totalRevolutionCounter;
}
@ -263,7 +263,7 @@ void TriggerState::reset() {
isFirstEvent = true;
}
int TriggerState::getCurrentIndex() {
int TriggerState::getCurrentIndex() const {
return currentCycle.current_index;
}
@ -271,7 +271,7 @@ void TriggerState::incrementTotalEventCounter() {
totalRevolutionCounter++;
}
bool TriggerState::isEvenRevolution() {
bool TriggerState::isEvenRevolution() const {
return totalRevolutionCounter & 1;
}

View File

@ -50,12 +50,12 @@ public:
/**
* current trigger processing index, between zero and #size
*/
int getCurrentIndex();
int getTotalRevolutionCounter();
int getCurrentIndex() const;
int getTotalRevolutionCounter() const;
/**
* this is important for crank-based virtual trigger and VVT magic
*/
bool isEvenRevolution();
bool isEvenRevolution() const;
void incrementTotalEventCounter();
efitime_t getTotalEventCounter();
efitime_t getStartOfRevolutionIndex();