From 19bdb9a35f940931ff440bcc4202cbadc418bbf4 Mon Sep 17 00:00:00 2001 From: rusefi Date: Tue, 19 Nov 2019 18:17:03 -0500 Subject: [PATCH] docs & code formatting --- firmware/console/binary/tunerstudio.cpp | 2 +- firmware/controllers/algo/nmea.c | 12 +++++++----- firmware/controllers/core/efi_wave.cpp | 2 +- .../controllers/scheduling/single_timer_executor.cpp | 2 +- firmware/controllers/system/dc_motor.cpp | 6 ++---- firmware/controllers/system_fsio.h | 2 +- .../controllers/trigger/decoders/trigger_structure.h | 2 +- firmware/hw_layer/adc_inputs.cpp | 5 +---- firmware/hw_layer/drivers/gpio/tle8888.c | 2 +- firmware/hw_layer/mc33816.cpp | 4 ++-- firmware/hw_layer/sensors/cj125_logic.cpp | 4 ++-- firmware/util/datalogging.cpp | 2 +- 12 files changed, 21 insertions(+), 24 deletions(-) diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index ee7efbc621..9c56285e1c 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -720,7 +720,7 @@ static void handleExecuteCommand(ts_channel_s *tsChannel, char *data, int incomi */ bool handlePlainCommand(ts_channel_s *tsChannel, uint8_t command) { // Bail fast if guaranteed not to be a plain command - if(command == 0) + if (command == 0) { return false; } diff --git a/firmware/controllers/algo/nmea.c b/firmware/controllers/algo/nmea.c index ce815c64ff..2f843c9d51 100644 --- a/firmware/controllers/algo/nmea.c +++ b/firmware/controllers/algo/nmea.c @@ -108,7 +108,9 @@ void nmea_parse_gpgga(char *nmea, loc_t *loc) { p = strchr(p, ',') + 1; // in p string started with searching address str_till_comma(p, dStr); // str to float till comma saved modified string - if(strlen(p) == 0) return; // if no data in field - empty data - we return + if (strlen(p) == 0) { + return; // if no data in field - empty data - we return + } loc->latitude = atoff(dStr); // fulfil data @@ -182,7 +184,7 @@ void nmea_parse_gprmc(char *nmea, loc_t *loc) { p = strchr(p, ',') + 1; //read time str_till_comma(p, dStr); - if(strlen(dStr) > 5){ + if (strlen(dStr) > 5) { timp.tm_hour = str2int(dStr,2); timp.tm_min = str2int(dStr+2,2); timp.tm_sec = str2int(dStr+4,2); @@ -191,7 +193,7 @@ void nmea_parse_gprmc(char *nmea, loc_t *loc) { p = strchr(p, ',') + 1; //read field Valid status str_till_comma(p, dStr); - if(dStr[0] == 'V') { // if field is invalid + if (dStr[0] == 'V') { // if field is invalid loc->quality = 0; return; } @@ -242,13 +244,13 @@ void nmea_parse_gprmc(char *nmea, loc_t *loc) { p = strchr(p, ',') + 1; //read date str_till_comma(p, dStr); - if(strlen(dStr) > 5){ + if (strlen(dStr) > 5) { timp.tm_mday = str2int(dStr,2); timp.tm_mon = str2int(dStr+2,2); timp.tm_year = str2int(dStr+4,2)+100; // we receive -200, but standard wait -1900 = add correction } - if( timp.tm_year > 0 ) { // check if date field is valid + if (timp.tm_year > 0 ) { // check if date field is valid memcpy(&loc->GPStm, &timp, sizeof(timp)); } } diff --git a/firmware/controllers/core/efi_wave.cpp b/firmware/controllers/core/efi_wave.cpp index 64ff58ac30..037402ff22 100644 --- a/firmware/controllers/core/efi_wave.cpp +++ b/firmware/controllers/core/efi_wave.cpp @@ -36,7 +36,7 @@ MultiWave::MultiWave() { reset(); } -MultiWave::MultiWave(float *switchTimes, SingleWave *waves) : MultiWave(){ +MultiWave::MultiWave(float *switchTimes, SingleWave *waves) : MultiWave() { init(switchTimes, waves); } diff --git a/firmware/controllers/scheduling/single_timer_executor.cpp b/firmware/controllers/scheduling/single_timer_executor.cpp index 5ee285ca2d..141e443dbd 100644 --- a/firmware/controllers/scheduling/single_timer_executor.cpp +++ b/firmware/controllers/scheduling/single_timer_executor.cpp @@ -52,7 +52,7 @@ static void executorCallback(void *arg) { efiAssertVoid(CUSTOM_ERR_6624, getCurrentRemainingStack() > 256, "lowstck#2y"); // callbackTime = getTimeNowNt(); -// if((callbackTime > nextEventTimeNt) && (callbackTime - nextEventTimeNt > US2NT(5000))) { +// if ((callbackTime > nextEventTimeNt) && (callbackTime - nextEventTimeNt > US2NT(5000))) { // timerIsLate++; // } diff --git a/firmware/controllers/system/dc_motor.cpp b/firmware/controllers/system/dc_motor.cpp index d9420d747c..4dbc6959c7 100644 --- a/firmware/controllers/system/dc_motor.cpp +++ b/firmware/controllers/system/dc_motor.cpp @@ -32,16 +32,14 @@ bool TwoPinDcMotor::Set(float duty) bool isPositive = duty > 0; - if(!isPositive) - { + if (!isPositive) { duty = -duty; } // below here 'duty' is a not negative // Clamp to 100% - if(duty > 1.0f) - { + if (duty > 1.0f) { duty = 1.0f; } // Disable for very small duty diff --git a/firmware/controllers/system_fsio.h b/firmware/controllers/system_fsio.h index 255199481f..4b808a71b9 100644 --- a/firmware/controllers/system_fsio.h +++ b/firmware/controllers/system_fsio.h @@ -73,5 +73,5 @@ // Human-readable: fsio_table (3, rpm, map) / 100 #define BOOST_CONTROLLER "3 rpm map fsio_table 100 /" -// Human-readable: if(fsio_setting (0) > 20, 0, 10) +// Human-readable: if (fsio_setting (0) > 20, 0, 10) #define ANALOG_CONDITION "0 fsio_setting 20 > 0 10 if" diff --git a/firmware/controllers/trigger/decoders/trigger_structure.h b/firmware/controllers/trigger/decoders/trigger_structure.h index ad6b4d9546..d3cb3e1c0c 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.h +++ b/firmware/controllers/trigger/decoders/trigger_structure.h @@ -16,7 +16,7 @@ #define FOUR_STROKE_ENGINE_CYCLE 720 #if EFI_ENABLE_ASSERTS -#define assertAngleRange(angle, msg, code) if(angle > 10000000 || angle < -10000000) { firmwareError(code, "angle range %s %.2f", msg, angle);angle = 0;} +#define assertAngleRange(angle, msg, code) if (angle > 10000000 || angle < -10000000) { firmwareError(code, "angle range %s %.2f", msg, angle);angle = 0;} #else #define assertAngleRange(angle, msg, code) {} #endif diff --git a/firmware/hw_layer/adc_inputs.cpp b/firmware/hw_layer/adc_inputs.cpp index 50e7c62f08..20d4bc8cca 100644 --- a/firmware/hw_layer/adc_inputs.cpp +++ b/firmware/hw_layer/adc_inputs.cpp @@ -422,8 +422,7 @@ static void printFullAdcReport(Logging *logger) { adc_channel_e hwIndex = slowAdc.getAdcHardwareIndexByInternalIndex(index); - if(hwIndex != EFI_ADC_NONE && hwIndex != EFI_ADC_ERROR) - { + if (hwIndex != EFI_ADC_NONE && hwIndex != EFI_ADC_ERROR) { ioportid_t port = getAdcChannelPort("print", hwIndex); int pin = getAdcChannelPin(hwIndex); @@ -600,8 +599,6 @@ void initAdcInputs() { #endif /* HAL_USE_PWM */ } - //if(slowAdcChannelCount > ADC_MAX_SLOW_CHANNELS_COUNT) // todo: do we need this logic? do we need this check - addConsoleActionI("adc", (VoidInt) printAdcValue); #else printMsg(&logger, "ADC disabled"); diff --git a/firmware/hw_layer/drivers/gpio/tle8888.c b/firmware/hw_layer/drivers/gpio/tle8888.c index 5178d53ee7..e5df81e037 100644 --- a/firmware/hw_layer/drivers/gpio/tle8888.c +++ b/firmware/hw_layer/drivers/gpio/tle8888.c @@ -433,7 +433,7 @@ int tle8888SpiStartupExchange(void * data) { if (response == 253) { // I've seen this response on red board initResponsesAccumulator += 4; - } else if (response == 2408){ + } else if (response == 2408) { // and I've seen this response on red board initResponsesAccumulator += 100; } diff --git a/firmware/hw_layer/mc33816.cpp b/firmware/hw_layer/mc33816.cpp index da099f007a..b904e16a84 100644 --- a/firmware/hw_layer/mc33816.cpp +++ b/firmware/hw_layer/mc33816.cpp @@ -234,7 +234,7 @@ static void download_register(int r_target) { // retrieve data, send it, increase pointer // increase - if(r_size > MAX_SPI_MODE_A_TRANSFER_SIZE) //if size is too large, split into two sections ... MULTIPLE sections.. + if (r_size > MAX_SPI_MODE_A_TRANSFER_SIZE) //if size is too large, split into two sections ... MULTIPLE sections.. { remainder_size = r_size - MAX_SPI_MODE_A_TRANSFER_SIZE; // creates remaining size r_size = MAX_SPI_MODE_A_TRANSFER_SIZE; // sets first size @@ -249,7 +249,7 @@ static void download_register(int r_target) { spiSend(driver, r_size, reg_ptr); - if(remainder_size > 0) // if remainder size is greater than 0, download the rest + if (remainder_size > 0) // if remainder size is greater than 0, download the rest { r_start_address += r_size; // new start address r_command = r_start_address << 5; // start address diff --git a/firmware/hw_layer/sensors/cj125_logic.cpp b/firmware/hw_layer/sensors/cj125_logic.cpp index b5d4e0e88f..22ee2198d4 100644 --- a/firmware/hw_layer/sensors/cj125_logic.cpp +++ b/firmware/hw_layer/sensors/cj125_logic.cpp @@ -11,7 +11,7 @@ EXTERN_ENGINE; CJ125::CJ125() : wboHeaterControl("wbo"), - heaterPid(&heaterPidConfig){ + heaterPid(&heaterPidConfig) { } void CJ125::SetHeater(float value DECLARE_ENGINE_PARAMETER_SUFFIX) { @@ -109,7 +109,7 @@ bool CJ125::isValidState() const { } void CJ125::cjInitPid(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - if(engineConfiguration->cj125isLsu49) { + if (engineConfiguration->cj125isLsu49) { heaterPidConfig.pFactor = CJ125_PID_LSU49_P; heaterPidConfig.iFactor = CJ125_PID_LSU49_I; } else { diff --git a/firmware/util/datalogging.cpp b/firmware/util/datalogging.cpp index 46f05a9bcf..10c91b0d87 100644 --- a/firmware/util/datalogging.cpp +++ b/firmware/util/datalogging.cpp @@ -298,7 +298,7 @@ void Logging::appendPrintf(const char *fmt, ...) { Logging::Logging() { } -Logging::Logging(char const *name, char *buffer, int bufferSize) : Logging(){ +Logging::Logging(char const *name, char *buffer, int bufferSize) : Logging() { #if ! EFI_UNIT_TEST initLoggingExt(name, buffer, bufferSize); #else