mirror of
https://github.com/Oleg-Stepanenko-owo/IEBUS
synced 2025-06-25 00:36:13 +00:00
Added new lock logic for received commands
This commit is contained in:
parent
a136f6f0e5
commit
406d68ab92
@ -530,7 +530,7 @@ bool AVCLanDrv::isAvcBusFree (void)
|
|||||||
void AVCLanDrv::printMessage(bool incoming)
|
void AVCLanDrv::printMessage(bool incoming)
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
if (!bSDLog.bRedyToLog) return;
|
/* if (!bSDLog.bRedyToLog) return;
|
||||||
|
|
||||||
char sss[15] = {0};
|
char sss[15] = {0};
|
||||||
sprintf(sss, "[%u]", millis());
|
sprintf(sss, "[%u]", millis());
|
||||||
@ -561,7 +561,7 @@ void AVCLanDrv::printMessage(bool incoming)
|
|||||||
for (byte i = 0; i < dataSize; i++) {
|
for (byte i = 0; i < dataSize; i++) {
|
||||||
bSDLog.printHex8((uint8_t)message[i]);
|
bSDLog.printHex8((uint8_t)message[i]);
|
||||||
}
|
}
|
||||||
bSDLog.println();
|
bSDLog.println(); */
|
||||||
// bSDLog._update();
|
// bSDLog._update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -609,3 +609,5 @@ byte AVCLanDrv::getActionID(const AvcInCmdTable messageTable[], byte mtSize)
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
AVCLanDrv avclan;
|
AVCLanDrv avclan;
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,3 +140,5 @@ class AVCLanDrv {
|
|||||||
|
|
||||||
extern AVCLanDrv avclan;
|
extern AVCLanDrv avclan;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
// // 10 680231020200 05 13000000001D0000DE - vol = 1
|
// // 10 680231020200 05 13000000001D0000DE - vol = 1
|
||||||
//};
|
//};
|
||||||
|
|
||||||
|
// { action_name, packed_size, end_off_packege_word(check_sum) }
|
||||||
const AvcInCmdTable mtSearchHead[] PROGMEM = {
|
const AvcInCmdTable mtSearchHead[] PROGMEM = {
|
||||||
{ ACT_BUTTON_PRESS, 0x08, 0xBE}, // Button press
|
{ ACT_BUTTON_PRESS, 0x08, 0xBE}, // Button press
|
||||||
{ ACT_B_DISPOFF, 0x08, 0x2F},
|
{ ACT_B_DISPOFF, 0x08, 0x2F},
|
||||||
@ -33,8 +34,8 @@ const AvcInCmdTable mtSearchHead[] PROGMEM = {
|
|||||||
{ ACT_CAM_OFF, 0x09, 0x30}, // Cam OFF
|
{ ACT_CAM_OFF, 0x09, 0x30}, // Cam OFF
|
||||||
// { ACT_DISP_HULF, 0x09, 0x30}, // display hulf color ???
|
// { ACT_DISP_HULF, 0x09, 0x30}, // display hulf color ???
|
||||||
{ ACT_DISP_OFF, 0x09, 0x2E}, // display off
|
{ ACT_DISP_OFF, 0x09, 0x2E}, // display off
|
||||||
{ ACT_TEL, 0x0A, 0xE3},
|
{ ACT_TEL, 0x0A, 0xE3}, // start Tel Action
|
||||||
{ ACT_TEL_CANCEL, 0x0A, 0xDC}
|
{ ACT_TEL_CANCEL, 0x0A, 0xDC} // Cancel or End Call_ACTION
|
||||||
// { ACT_VOL, 0x0A, 0x06, {0x68, 0x02, 0x31, 0x02, 0x02, 0x00}, 0x00, {0x00}} //0x05 = 1
|
// { ACT_VOL, 0x0A, 0x06, {0x68, 0x02, 0x31, 0x02, 0x02, 0x00}, 0x00, {0x00}} //0x05 = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -52,19 +53,16 @@ void printAvcAction( AvcActionID id )
|
|||||||
// bSDLog.logs( mBuff );
|
// bSDLog.logs( mBuff );
|
||||||
}
|
}
|
||||||
|
|
||||||
// AVCLan Navi & timer1 init,
|
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
void AVCLanHonda::begin()
|
void AVCLanHonda::begin()
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
mVol = 0;
|
|
||||||
avclan.deviceAddress = 0x0131;
|
avclan.deviceAddress = 0x0131;
|
||||||
|
|
||||||
bShowHondaDisp = false;
|
bShowHondaDisp = false;
|
||||||
isHondaDisLast = false;
|
isHondaDisLast = false;
|
||||||
bShowRearCam = false;
|
bShowRearCam = false;
|
||||||
|
|
||||||
setWait( false );
|
|
||||||
setWaitTime( 0L );
|
setWaitTime( 0L );
|
||||||
setLockTime( 0L );
|
setLockTime( 0L );
|
||||||
|
|
||||||
@ -82,9 +80,9 @@ void AVCLanHonda::setWaitTime( const unsigned long mTime )
|
|||||||
{
|
{
|
||||||
waitTime = mTime;
|
waitTime = mTime;
|
||||||
if ( mTime > 0L ) {
|
if ( mTime > 0L ) {
|
||||||
setWait(true);
|
bWait = true;
|
||||||
} else {
|
} else {
|
||||||
setWait(false);
|
bWait = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,13 +91,8 @@ void AVCLanHonda::setLockTime( const unsigned long mTime )
|
|||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
lockTime = mTime;
|
lockTime = mTime;
|
||||||
}
|
bLock = true;
|
||||||
|
setWaitTime(0L);
|
||||||
//--------------------------------------------------------------------------------
|
|
||||||
void AVCLanHonda::setWait( const bool mWait )
|
|
||||||
//--------------------------------------------------------------------------------
|
|
||||||
{
|
|
||||||
bWait = mWait;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the last received message to determine the corresponding action ID, store it in avclan object
|
// Use the last received message to determine the corresponding action ID, store it in avclan object
|
||||||
@ -127,7 +120,7 @@ void AVCLanHonda::processAction(AvcActionID ActionID)
|
|||||||
case ACT_BUTTON_PRESS:
|
case ACT_BUTTON_PRESS:
|
||||||
{
|
{
|
||||||
printAvcAction(ActionID);
|
printAvcAction(ActionID);
|
||||||
if ( !bShowRearCam || !isWait() || ( getLockTime() < millis()) )
|
if ( !bShowRearCam || !isWait() || !isLockTime() )
|
||||||
{
|
{
|
||||||
setWaitTime( (unsigned long)((millis() + BUTT_WAIT)) );
|
setWaitTime( (unsigned long)((millis() + BUTT_WAIT)) );
|
||||||
}
|
}
|
||||||
@ -179,7 +172,7 @@ void AVCLanHonda::tryToShowHondaDisp()
|
|||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
bWait = false;
|
bWait = false;
|
||||||
if ( getLockTime() > millis() ) return;
|
if ( isLockTime() ) return;
|
||||||
bShowHondaDisp = true;
|
bShowHondaDisp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,4 +184,16 @@ void AVCLanHonda::falseHondaDis()
|
|||||||
isHondaDisLast = false;
|
isHondaDisLast = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
bool AVCLanHonda::isLockTime()
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
{
|
||||||
|
if ( bLock ) {
|
||||||
|
bLock = ( getLockTime() > millis() );
|
||||||
|
}
|
||||||
|
return bLock;
|
||||||
|
}
|
||||||
|
|
||||||
AVCLanHonda avclanHonda;
|
AVCLanHonda avclanHonda;
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define DISABLE_TIMER1_INT (cbi(TIMSK1, TOIE1));
|
#define DISABLE_TIMER1_INT (cbi(TIMSK1, TOIE1));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// адреса eeprom
|
// адреса eeprom
|
||||||
#define E_MASTER1 0
|
#define E_MASTER1 0
|
||||||
#define E_MASTER2 1
|
#define E_MASTER2 1
|
||||||
#define E_READONLY 2
|
#define E_READONLY 2
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define AVCLANDEVICE_NAME " Honda Kb1"
|
#define AVCLANDEVICE_NAME " Honda Kb1"
|
||||||
#define AVCLANDEVICE_VERSION "0.0.7"
|
#define AVCLANDEVICE_VERSION "0.0.8"
|
||||||
|
|
||||||
#define BUTT_WAIT 1000
|
#define BUTT_WAIT 1000
|
||||||
#define LOCK_TIME 700
|
#define LOCK_TIME 700
|
||||||
@ -68,8 +68,9 @@ class AVCLanHonda
|
|||||||
|
|
||||||
void setLockTime( const unsigned long mTime );
|
void setLockTime( const unsigned long mTime );
|
||||||
inline unsigned long getLockTime() const;
|
inline unsigned long getLockTime() const;
|
||||||
|
bool isLockTime();
|
||||||
|
|
||||||
|
|
||||||
void setWait( const bool mWait );
|
|
||||||
inline bool isWait() const;
|
inline bool isWait() const;
|
||||||
|
|
||||||
inline bool isShowRearCam() const;
|
inline bool isShowRearCam() const;
|
||||||
@ -78,7 +79,6 @@ class AVCLanHonda
|
|||||||
void checkWait();
|
void checkWait();
|
||||||
void checkLock();
|
void checkLock();
|
||||||
void falseHondaDis();
|
void falseHondaDis();
|
||||||
int mVol;
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -114,3 +114,5 @@ bool AVCLanHonda::isShowHondaDisp() const {
|
|||||||
extern AVCLanHonda avclanHonda;
|
extern AVCLanHonda avclanHonda;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ void setup()
|
|||||||
sbi(LED_DDR, COMMUT_OUT);
|
sbi(LED_DDR, COMMUT_OUT);
|
||||||
cbi(LED_PORT, COMMUT_OUT);
|
cbi(LED_PORT, COMMUT_OUT);
|
||||||
|
|
||||||
bSDLog.begin();
|
// bSDLog.begin();
|
||||||
|
|
||||||
// Serial.begin(250000);
|
// Serial.begin(250000);
|
||||||
// if (Serial) {
|
// if (Serial) {
|
||||||
@ -42,6 +42,14 @@ void setup()
|
|||||||
void loop()
|
void loop()
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
|
if ( avclanHonda.isShowRearCam() ) {
|
||||||
|
HONDA_DIS_ON;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !avclanHonda.isLockTime() )
|
||||||
|
{
|
||||||
|
|
||||||
if ( avclanHonda.isWait() ) {
|
if ( avclanHonda.isWait() ) {
|
||||||
avclanHonda.checkWait();
|
avclanHonda.checkWait();
|
||||||
if (avclanHonda.isWait() == false)
|
if (avclanHonda.isWait() == false)
|
||||||
@ -51,7 +59,7 @@ void loop()
|
|||||||
if ( INPUT_IS_SET ) {
|
if ( INPUT_IS_SET ) {
|
||||||
byte res = avclan.readMessage();
|
byte res = avclan.readMessage();
|
||||||
if ( !res ) {
|
if ( !res ) {
|
||||||
// //LOG
|
//LOG
|
||||||
// avclan.printMessage(true);
|
// avclan.printMessage(true);
|
||||||
avclanHonda.getActionID();
|
avclanHonda.getActionID();
|
||||||
if ( avclan.actionID != ACT_NONE ) {
|
if ( avclan.actionID != ACT_NONE ) {
|
||||||
@ -59,7 +67,9 @@ void loop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//ON a start target
|
//ON a start target
|
||||||
if ( 11500 > millis() ) {
|
if ( 11500 > millis() ) {
|
||||||
HONDA_DIS_ON; // initalize
|
HONDA_DIS_ON; // initalize
|
||||||
@ -79,6 +89,7 @@ void loop()
|
|||||||
HONDA_DIS_OFF;
|
HONDA_DIS_OFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
void EERPOM_read_config()
|
void EERPOM_read_config()
|
||||||
@ -98,3 +109,5 @@ void EERPOM_read_config()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,3 +170,5 @@ void SDLog::println(void)
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
SDLog bSDLog;
|
SDLog bSDLog;
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,3 +38,5 @@ extern SDLog bSDLog;
|
|||||||
|
|
||||||
#endif //#SD_LOG_h
|
#endif //#SD_LOG_h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,3 +44,5 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user