1
0
mirror of https://github.com/Oleg-Stepanenko-owo/IEBUS synced 2025-07-03 12:46:16 +00:00

fix checcking error block

This commit is contained in:
Oleg Stepanenko 2016-04-11 11:34:21 +03:00
parent 5e1905e4ad
commit 7ba8949a34
4 changed files with 44 additions and 31 deletions

View File

@ -38,7 +38,7 @@ void AVCLanHonda::begin()
avclan.deviceAddress = 0x0131;
bShowHondaDisp = true;
bHondaDisLast = true;
setHondaDisLast(true);
bShowRearCam = false;
bFirstStart_20 = true;
bFreeze = false;
@ -76,15 +76,18 @@ void AVCLanHonda::getActionID()
void AVCLanHonda::processAction( AvcActionID ActionID )
//--------------------------------------------------------------------------------
{
if ( bFirstStart_20 && (20000 > millis()) && (ACT_CAM_ON == ActionID) ) {
bShowRearCam = true;
if ( 11500 > millis() ) bHondaDisLast = true;
else bHondaDisLast = false;
bShowHondaDisp = true;
return;
}
if ( bFirstStart_20 ) {
if ( (INIT2_TIME > millis()) && (ACT_CAM_ON == ActionID) ) {
bShowRearCam = true;
setHondaDisLast(false);
bShowHondaDisp = true;
bFirstStart_20 = false;
setWaitTime(0L);
return;
}
if ( INIT2_TIME < millis() ) bFirstStart_20 = false;
}
if ( bFirstStart_20 && (20000 < millis()) ) bFirstStart_20 = false;
switch ( ActionID ) {
case ACT_BUTTON_UP:
@ -99,7 +102,7 @@ void AVCLanHonda::processAction( AvcActionID ActionID )
break;
case ACT_CAM_ON:
bShowRearCam = true;
bHondaDisLast = isShowHondaDisp();
setHondaDisLast( isShowHondaDisp() );
bShowHondaDisp = true;
setWaitTime(0L);
break;
@ -109,7 +112,7 @@ void AVCLanHonda::processAction( AvcActionID ActionID )
if ( !bShowRearCam ) {
// need freeze on 2000 sec after code receiving.
bShowHondaDisp = false;
bHondaDisLast = false;
setHondaDisLast( false );
setWaitTime(0L);
bFreeze = true;
freezeTime = (millis() + FREEZE_TIME);
@ -143,7 +146,7 @@ bool AVCLanHonda::getCommute()
void AVCLanHonda::tryToShowHondaDisp()
//--------------------------------------------------------------------------------
{
bHondaDisLast = bShowHondaDisp;
setHondaDisLast( bShowHondaDisp );
bShowHondaDisp = true;
}
@ -152,7 +155,7 @@ void AVCLanHonda::setHondaDis( bool val )
//--------------------------------------------------------------------------------
{
bShowHondaDisp = val;
bHondaDisLast = val;
setHondaDisLast( val );
setWaitTime(0L);
}

View File

@ -70,6 +70,7 @@ class AVCLanHonda
inline bool isShowRearCam() const;
inline bool isShowHondaDisp() const;
inline void setHondaDisLast( bool val );
void checkWait();
void checkLock();
@ -96,16 +97,23 @@ class AVCLanHonda
unsigned long AVCLanHonda::getWaitTime() const {
return waitTime;
}
bool AVCLanHonda::isWait() const {
return bWait;
};
bool AVCLanHonda::isShowRearCam() const {
return bShowRearCam;
};
bool AVCLanHonda::isShowHondaDisp() const {
return bShowHondaDisp;
}
void AVCLanHonda::setHondaDisLast( bool val ) {
bHondaDisLast = val;
}
extern AVCLanHonda avclanHonda;
#endif

View File

@ -12,11 +12,12 @@
#define HONDA_DIS_ON sbi(COMMUT_PORT, COMMUT_OUT);
#define HONDA_DIS_OFF cbi(COMMUT_PORT, COMMUT_OUT);
char BUFFF[15];
int len = 0; //stores the length of the commands
//------ Error time updating -----------------------------------------------------
unsigned long waitErrorTime;
// unsigned long waitErrorTime;
bool beforeErrorComute;
static int MAX_ERROR_COUNT = 10;
byte errorID;
@ -37,7 +38,7 @@ void setup()
errorID = 0;
error_count = 0;
beforeErrorComute = 0;
waitErrorTime = 0;
// waitErrorTime = 0;
avclanBT.begin();
avclanBT.print("Start HONDA avclan.#");
@ -55,7 +56,7 @@ void loop()
for (int i = 0; i < len; i++) avclanBT.checkCommand(avclanBT.read());
}
if ( avclanHonda.bFirstStart_20 && !avclanHonda.isShowRearCam() && (11500 < millis()) )
if ( avclanHonda.bFirstStart_20 && !avclanHonda.isShowRearCam() && (INIT_TIME < millis()) )
{
avclanHonda.setHondaDis( false ); //Show GVN screen
}
@ -75,38 +76,39 @@ void loop()
error_count = 0;
avclan.printMessage(true);
error_count = 0;
avclanHonda.getActionID();
if ( avclanHonda.bFirstStart_20 && (avclan.actionID == ACT_CAM_ON) )
{
avclanBT.printAction((AvcActionID)avclan.actionID);
avclanBT.printAction( (AvcActionID)avclan.actionID );
avclanHonda.processAction( (AvcActionID)avclan.actionID );
}
else if ( (avclan.actionID != ACT_NONE) && ( 20000 < millis() ) && (!avclanHonda.bFreeze))
else if ( (avclan.actionID != ACT_NONE) && ( INIT2_TIME < millis() ) && (!avclanHonda.bFreeze))
{
avclanBT.printAction((AvcActionID)avclan.actionID);
avclanHonda.processAction( (AvcActionID)avclan.actionID );
}
else
else // first 20 sek we should react only on rear cam on/off
{
if ( avclanHonda.bFirstStart_20 ) avclanBT.println(">>FIRST_SKIP<<");
else if ( avclanHonda.bFreeze ) avclanBT.println(">>FREEZE_SKIP<<");
// if ( avclanHonda.bFirstStart_20 ) avclanBT.println(">>FIRST_SKIP<<");
// else if ( avclanHonda.bFreeze ) avclanBT.println(">>FREEZE_SKIP<<");
}
LED_ON;
if ( (0 != waitErrorTime) && (waitErrorTime < millis()) )
// back to screeen that was before Error:
if ( error_count >= MAX_ERROR_COUNT )
{
waitErrorTime = 0;
error_count = 0;
if ( !avclanHonda.isShowRearCam() )
avclanHonda.setHondaDis( beforeErrorComute );
else avclanHonda.setHondaDisLast( false ); //after error and rear cam off - try to show GVN display
}
}
else
{
if ( errorID == res ) error_count++;
else error_count = 1;
else error_count = 0;
errorID = res;
}
@ -130,14 +132,12 @@ void loop()
}
//------- ERROR CHECKING BLOCK ----------------------------------
if ( error_count > MAX_ERROR_COUNT ) {
avclanHonda.bFirstStart_20 = false;
if ( (error_count > MAX_ERROR_COUNT) && !avclanHonda.isShowHondaDisp() ) {
// avclanHonda.bFirstStart_20 = false;
error_count = 0;
beforeErrorComute = avclanHonda.getCommute();
avclanHonda.setHondaDis(true); // Show Honda displ
waitErrorTime = millis() + ERROR_TIME;
avclanHonda.setHondaDis(true); // Show Honda display
LED_OFF;
HONDA_DIS_ON;

View File

@ -1,4 +1,4 @@
#define IEBUS_VERSION "0.6"
#define IEBUS_VERSION "0.7"
// type of AVCLan hardwire driver
#define AVCLAN_PCA82C250
@ -34,6 +34,8 @@
#define LED_PIN PINB
#define LED_OUT 5
#define INIT_TIME 13000
#define INIT2_TIME 20000
#endif