mirror of
https://github.com/Oleg-Stepanenko-owo/IEBUS
synced 2025-07-04 05:06:41 +00:00
fix checcking error block
This commit is contained in:
parent
5e1905e4ad
commit
7ba8949a34
@ -38,7 +38,7 @@ void AVCLanHonda::begin()
|
|||||||
avclan.deviceAddress = 0x0131;
|
avclan.deviceAddress = 0x0131;
|
||||||
|
|
||||||
bShowHondaDisp = true;
|
bShowHondaDisp = true;
|
||||||
bHondaDisLast = true;
|
setHondaDisLast(true);
|
||||||
bShowRearCam = false;
|
bShowRearCam = false;
|
||||||
bFirstStart_20 = true;
|
bFirstStart_20 = true;
|
||||||
bFreeze = false;
|
bFreeze = false;
|
||||||
@ -76,15 +76,18 @@ void AVCLanHonda::getActionID()
|
|||||||
void AVCLanHonda::processAction( AvcActionID ActionID )
|
void AVCLanHonda::processAction( AvcActionID ActionID )
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
if ( bFirstStart_20 && (20000 > millis()) && (ACT_CAM_ON == ActionID) ) {
|
if ( bFirstStart_20 ) {
|
||||||
|
if ( (INIT2_TIME > millis()) && (ACT_CAM_ON == ActionID) ) {
|
||||||
bShowRearCam = true;
|
bShowRearCam = true;
|
||||||
if ( 11500 > millis() ) bHondaDisLast = true;
|
setHondaDisLast(false);
|
||||||
else bHondaDisLast = false;
|
|
||||||
bShowHondaDisp = true;
|
bShowHondaDisp = true;
|
||||||
|
bFirstStart_20 = false;
|
||||||
|
setWaitTime(0L);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ( INIT2_TIME < millis() ) bFirstStart_20 = false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( bFirstStart_20 && (20000 < millis()) ) bFirstStart_20 = false;
|
|
||||||
|
|
||||||
switch ( ActionID ) {
|
switch ( ActionID ) {
|
||||||
case ACT_BUTTON_UP:
|
case ACT_BUTTON_UP:
|
||||||
@ -99,7 +102,7 @@ void AVCLanHonda::processAction( AvcActionID ActionID )
|
|||||||
break;
|
break;
|
||||||
case ACT_CAM_ON:
|
case ACT_CAM_ON:
|
||||||
bShowRearCam = true;
|
bShowRearCam = true;
|
||||||
bHondaDisLast = isShowHondaDisp();
|
setHondaDisLast( isShowHondaDisp() );
|
||||||
bShowHondaDisp = true;
|
bShowHondaDisp = true;
|
||||||
setWaitTime(0L);
|
setWaitTime(0L);
|
||||||
break;
|
break;
|
||||||
@ -109,7 +112,7 @@ void AVCLanHonda::processAction( AvcActionID ActionID )
|
|||||||
if ( !bShowRearCam ) {
|
if ( !bShowRearCam ) {
|
||||||
// need freeze on 2000 sec after code receiving.
|
// need freeze on 2000 sec after code receiving.
|
||||||
bShowHondaDisp = false;
|
bShowHondaDisp = false;
|
||||||
bHondaDisLast = false;
|
setHondaDisLast( false );
|
||||||
setWaitTime(0L);
|
setWaitTime(0L);
|
||||||
bFreeze = true;
|
bFreeze = true;
|
||||||
freezeTime = (millis() + FREEZE_TIME);
|
freezeTime = (millis() + FREEZE_TIME);
|
||||||
@ -143,7 +146,7 @@ bool AVCLanHonda::getCommute()
|
|||||||
void AVCLanHonda::tryToShowHondaDisp()
|
void AVCLanHonda::tryToShowHondaDisp()
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
bHondaDisLast = bShowHondaDisp;
|
setHondaDisLast( bShowHondaDisp );
|
||||||
bShowHondaDisp = true;
|
bShowHondaDisp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +155,7 @@ void AVCLanHonda::setHondaDis( bool val )
|
|||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
bShowHondaDisp = val;
|
bShowHondaDisp = val;
|
||||||
bHondaDisLast = val;
|
setHondaDisLast( val );
|
||||||
setWaitTime(0L);
|
setWaitTime(0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ class AVCLanHonda
|
|||||||
|
|
||||||
inline bool isShowRearCam() const;
|
inline bool isShowRearCam() const;
|
||||||
inline bool isShowHondaDisp() const;
|
inline bool isShowHondaDisp() const;
|
||||||
|
inline void setHondaDisLast( bool val );
|
||||||
|
|
||||||
void checkWait();
|
void checkWait();
|
||||||
void checkLock();
|
void checkLock();
|
||||||
@ -96,16 +97,23 @@ class AVCLanHonda
|
|||||||
unsigned long AVCLanHonda::getWaitTime() const {
|
unsigned long AVCLanHonda::getWaitTime() const {
|
||||||
return waitTime;
|
return waitTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AVCLanHonda::isWait() const {
|
bool AVCLanHonda::isWait() const {
|
||||||
return bWait;
|
return bWait;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool AVCLanHonda::isShowRearCam() const {
|
bool AVCLanHonda::isShowRearCam() const {
|
||||||
return bShowRearCam;
|
return bShowRearCam;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool AVCLanHonda::isShowHondaDisp() const {
|
bool AVCLanHonda::isShowHondaDisp() const {
|
||||||
return bShowHondaDisp;
|
return bShowHondaDisp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AVCLanHonda::setHondaDisLast( bool val ) {
|
||||||
|
bHondaDisLast = val;
|
||||||
|
}
|
||||||
|
|
||||||
extern AVCLanHonda avclanHonda;
|
extern AVCLanHonda avclanHonda;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,11 +12,12 @@
|
|||||||
#define HONDA_DIS_ON sbi(COMMUT_PORT, COMMUT_OUT);
|
#define HONDA_DIS_ON sbi(COMMUT_PORT, COMMUT_OUT);
|
||||||
#define HONDA_DIS_OFF cbi(COMMUT_PORT, COMMUT_OUT);
|
#define HONDA_DIS_OFF cbi(COMMUT_PORT, COMMUT_OUT);
|
||||||
|
|
||||||
|
|
||||||
char BUFFF[15];
|
char BUFFF[15];
|
||||||
int len = 0; //stores the length of the commands
|
int len = 0; //stores the length of the commands
|
||||||
|
|
||||||
//------ Error time updating -----------------------------------------------------
|
//------ Error time updating -----------------------------------------------------
|
||||||
unsigned long waitErrorTime;
|
// unsigned long waitErrorTime;
|
||||||
bool beforeErrorComute;
|
bool beforeErrorComute;
|
||||||
static int MAX_ERROR_COUNT = 10;
|
static int MAX_ERROR_COUNT = 10;
|
||||||
byte errorID;
|
byte errorID;
|
||||||
@ -37,7 +38,7 @@ void setup()
|
|||||||
errorID = 0;
|
errorID = 0;
|
||||||
error_count = 0;
|
error_count = 0;
|
||||||
beforeErrorComute = 0;
|
beforeErrorComute = 0;
|
||||||
waitErrorTime = 0;
|
// waitErrorTime = 0;
|
||||||
|
|
||||||
avclanBT.begin();
|
avclanBT.begin();
|
||||||
avclanBT.print("Start HONDA avclan.#");
|
avclanBT.print("Start HONDA avclan.#");
|
||||||
@ -55,7 +56,7 @@ void loop()
|
|||||||
for (int i = 0; i < len; i++) avclanBT.checkCommand(avclanBT.read());
|
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
|
avclanHonda.setHondaDis( false ); //Show GVN screen
|
||||||
}
|
}
|
||||||
@ -75,7 +76,6 @@ void loop()
|
|||||||
error_count = 0;
|
error_count = 0;
|
||||||
|
|
||||||
avclan.printMessage(true);
|
avclan.printMessage(true);
|
||||||
error_count = 0;
|
|
||||||
avclanHonda.getActionID();
|
avclanHonda.getActionID();
|
||||||
|
|
||||||
if ( avclanHonda.bFirstStart_20 && (avclan.actionID == ACT_CAM_ON) )
|
if ( avclanHonda.bFirstStart_20 && (avclan.actionID == ACT_CAM_ON) )
|
||||||
@ -83,30 +83,32 @@ void loop()
|
|||||||
avclanBT.printAction( (AvcActionID)avclan.actionID );
|
avclanBT.printAction( (AvcActionID)avclan.actionID );
|
||||||
avclanHonda.processAction( (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);
|
avclanBT.printAction((AvcActionID)avclan.actionID);
|
||||||
avclanHonda.processAction( (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<<");
|
// if ( avclanHonda.bFirstStart_20 ) avclanBT.println(">>FIRST_SKIP<<");
|
||||||
else if ( avclanHonda.bFreeze ) avclanBT.println(">>FREEZE_SKIP<<");
|
// else if ( avclanHonda.bFreeze ) avclanBT.println(">>FREEZE_SKIP<<");
|
||||||
}
|
}
|
||||||
|
|
||||||
LED_ON;
|
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() )
|
if ( !avclanHonda.isShowRearCam() )
|
||||||
avclanHonda.setHondaDis( beforeErrorComute );
|
avclanHonda.setHondaDis( beforeErrorComute );
|
||||||
|
else avclanHonda.setHondaDisLast( false ); //after error and rear cam off - try to show GVN display
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( errorID == res ) error_count++;
|
if ( errorID == res ) error_count++;
|
||||||
else error_count = 1;
|
else error_count = 0;
|
||||||
|
|
||||||
errorID = res;
|
errorID = res;
|
||||||
}
|
}
|
||||||
@ -130,14 +132,12 @@ void loop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------- ERROR CHECKING BLOCK ----------------------------------
|
//------- ERROR CHECKING BLOCK ----------------------------------
|
||||||
if ( error_count > MAX_ERROR_COUNT ) {
|
if ( (error_count > MAX_ERROR_COUNT) && !avclanHonda.isShowHondaDisp() ) {
|
||||||
avclanHonda.bFirstStart_20 = false;
|
// avclanHonda.bFirstStart_20 = false;
|
||||||
error_count = 0;
|
error_count = 0;
|
||||||
|
|
||||||
beforeErrorComute = avclanHonda.getCommute();
|
beforeErrorComute = avclanHonda.getCommute();
|
||||||
avclanHonda.setHondaDis(true); // Show Honda displ
|
avclanHonda.setHondaDis(true); // Show Honda display
|
||||||
|
|
||||||
waitErrorTime = millis() + ERROR_TIME;
|
|
||||||
|
|
||||||
LED_OFF;
|
LED_OFF;
|
||||||
HONDA_DIS_ON;
|
HONDA_DIS_ON;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#define IEBUS_VERSION "0.6"
|
#define IEBUS_VERSION "0.7"
|
||||||
|
|
||||||
// type of AVCLan hardwire driver
|
// type of AVCLan hardwire driver
|
||||||
#define AVCLAN_PCA82C250
|
#define AVCLAN_PCA82C250
|
||||||
@ -34,6 +34,8 @@
|
|||||||
#define LED_PIN PINB
|
#define LED_PIN PINB
|
||||||
#define LED_OUT 5
|
#define LED_OUT 5
|
||||||
|
|
||||||
|
#define INIT_TIME 13000
|
||||||
|
#define INIT2_TIME 20000
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user