rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
malfunction_indicator.cpp File Reference

Detailed Description

We can blink out OBD-II error codes using Malfunction Indicator Light (MIL)

Date
Dec 20, 2013
Author
Konstantin Nikonenko
Andrey Belomutskiy, (c) 2012-2020 we show 4 digit error code - 1,5sec * (4xxx+1) digit + 0,4sec * (x3xxx+1) + .... ATTENTION!!! 0 = 1 blink, 1 = 2 blinks, ...., 9 = 10 blinks sequence is the constant!!!

This file is part of rusEfi - see http://rusefi.com

rusEfi is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file malfunction_indicator.cpp.

Functions

static void blink_digits (int digit, int duration)
 
static int DigitLength (int digit)
 
static void DisplayErrorCode (int length, int code)
 
static void testMil ()
 
bool isMilEnabled ()
 
void initMalfunctionIndicator (void)
 

Variables

static MILController instance
 

Function Documentation

◆ blink_digits()

static void blink_digits ( int  digit,
int  duration 
)
static

Definition at line 43 of file malfunction_indicator.cpp.

43 {
44 for (int iter = 0; iter < digit; iter++) {
45 // todo: why we set LOW and then HIGH? not the other way around?
47 chThdSleepMilliseconds(duration);
49 chThdSleepMilliseconds(MFI_BLINK_SEPARATOR);
50 }
51}
RegisteredOutputPin checkEnginePin
Definition efi_gpio.h:118
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition efi_gpio.cpp:604
EnginePins enginePins
Definition efi_gpio.cpp:24

Referenced by DisplayErrorCode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DigitLength()

static int DigitLength ( int  digit)
static

Definition at line 54 of file malfunction_indicator.cpp.

54 {
55 int i = 0;
56 while (digit > 0) {
57 digit = digit / 10;
58 ++i;
59 }
60 return i;
61}

◆ DisplayErrorCode()

static void DisplayErrorCode ( int  length,
int  code 
)
static

Definition at line 64 of file malfunction_indicator.cpp.

64 {
65 // todo: I suggest we use 'itoa' method to simplify this logic
66 for (int iter = length - 1; iter >= 0; iter--) {
67 int ourDigit = (int) efiPow10(iter); // 10^0 = 1, 10^1 = 10, 10^2=100, 10^3 = 1000, ....
68 int digit = 1; // as we remember "0" we show as one blink
69 while (code >= ourDigit) {
70 code = code - ourDigit;
71 digit++;
72 }
73 if (iter % 2 == 0)
74 blink_digits(digit, MFI_SHORT_BLINK); // even 2,0 - long blink
75 else
76 blink_digits(digit, MFI_LONG_BLINK); // odd 3,1 - short blink
77 }
78}
uint8_t code
Definition bluetooth.cpp:40
int efiPow10(int param)
Definition efilib.cpp:111
static void blink_digits(int digit, int duration)
Here is the call graph for this function:

◆ initMalfunctionIndicator()

void initMalfunctionIndicator ( void  )

Definition at line 120 of file malfunction_indicator.cpp.

120 {
121 if (!isMilEnabled()) {
122 return;
123 }
124 instance.setPeriod(10 /*ms*/);
125 instance.start();
126
127#if TEST_MIL_CODE
128 addConsoleAction("testmil", testMil);
129#endif /* TEST_MIL_CODE */
130}
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
static MILController instance
static void testMil()
bool isMilEnabled()

Referenced by commonInitEngineController().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isMilEnabled()

bool isMilEnabled ( )

Definition at line 116 of file malfunction_indicator.cpp.

116 {
118}
static constexpr engine_configuration_s * engineConfiguration
bool isBrainPinValid(brain_pin_e brainPin)

Referenced by initMalfunctionIndicator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ testMil()

static void testMil ( )
static

Definition at line 110 of file malfunction_indicator.cpp.

110 {
111 addError(ObdCode::OBD_Engine_Coolant_Temperature_Circuit_Malfunction);
112 addError(ObdCode::OBD_Intake_Air_Temperature_Circuit_Malfunction);
113}
void addError(ObdCode errorCode)
Adds an error code into the set of current errors. The error code is placed into the fixed-size data ...

Referenced by initMalfunctionIndicator().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ instance

MILController instance
static

Definition at line 107 of file malfunction_indicator.cpp.

Referenced by initMalfunctionIndicator().

Go to the source code of this file.