diff --git a/MBSmartMedic.h b/MBSmartMedic.h index fad5bf3..e538ecc 100644 --- a/MBSmartMedic.h +++ b/MBSmartMedic.h @@ -82,7 +82,8 @@ class TempMedicBox : public MedicBox TempMedicBox(Device* aDevice, int aliveTime, int stunTime) : MedicBox(aDevice) { this->aliveTime = aliveTime; - this->stunTime = stunTime < 10*60 ? stunTime : 10*60-1; + //reason for it ? TODO very strange bug with changing stun time value + this->stunTime = stunTime < 30*60 ? stunTime : 30*60; } virtual void reset() { @@ -101,8 +102,21 @@ class TempMedicBox : public MedicBox } updateTime(); } - + + /** + * Send specific mlt protocol command. + * Required for execute specific command via medic button. + * Main target - extended S.L.K.E.R.T.A.G. support. + * + * @author Anton Karasev + * @param cmd mlt command + */ virtual void processCommand(mlt_command* cmd) { + if(alive) { + sendCommand(*cmd); + delay(300); + } + updateTime(); } virtual void updateTime() { @@ -125,7 +139,14 @@ class TempMedicBox : public MedicBox device->showStatusText(" Ready! "); } } else { - device->showTimeInterval(((long)timeLeft*100/60)*10, " Waiting... "); + // minutes left (current minute included) + if(timeLeft > 60) { + device->showTimerNumber(timeLeft/60 + 1, " Waiting(min) "); + } + // seconds left (in last minute) + else { + device->showTimerNumber(timeLeft, " Waiting(sec) "); + } } device->preventSleep(2000); } diff --git a/MedicBox.ino b/MedicBox.ino index 2af98d0..8a3611f 100644 --- a/MedicBox.ino +++ b/MedicBox.ino @@ -126,7 +126,31 @@ void loop() { } else if ( IsValidCmd(cmd) ) { medic->processCommand(&cmd); } else if (btnPressed) { - medic->processButton(); + mlt_command respawnCmd; // how about memory + if ((ModeType)config->getMenuMode() == ModeTempMedicGreen1_30 /* Freedom base e.g. */ ) { + respawnCmd.command_type = MLT_CT_RESPAWN; + respawnCmd.cmd_data = MLT_CLR_GREEN; + respawnCmd.package_end = MLT_END_GREEN; + medic->processCommand(&respawnCmd); + } else if ((ModeType)config->getMenuMode() == ModeTempMedicRed1_30 /* Dept base e.g. */ ) { + respawnCmd.command_type = MLT_CT_RESPAWN; + respawnCmd.cmd_data = MLT_CLR_RED; + respawnCmd.package_end = MLT_END_RED; + medic->processCommand(&respawnCmd); + } else if ((ModeType)config->getMenuMode() == ModeTempMedicBlue1_30 /* Merc base e.g. */ ) { + respawnCmd.command_type = MLT_CT_RESPAWN; + respawnCmd.cmd_data = MLT_CLR_BLUE; + respawnCmd.package_end = MLT_END_BLUE; + medic->processCommand(&respawnCmd); + } else if ((ModeType)config->getMenuMode() == ModeTempMedicRedTest1_01 /* Quick test */ ) { + respawnCmd.command_type = MLT_CT_RESPAWN; + respawnCmd.cmd_data = MLT_CLR_RED; + respawnCmd.package_end = MLT_END_RED; + medic->processCommand(&respawnCmd); + } + else { + medic->processButton(); + } } else { medic->updateTime(); } diff --git a/ModeMenu.h b/ModeMenu.h index b21dde0..adab288 100644 --- a/ModeMenu.h +++ b/ModeMenu.h @@ -69,6 +69,12 @@ enum ModeType : char { ModeTempMedic05_5, ModeTempMedic1_5, ModeTempMedic1_10, + ModeTempMedic1_20, + ModeTempMedic1_30, + ModeTempMedicGreen1_30, + ModeTempMedicRed1_30, + ModeTempMedicBlue1_30, + ModeTempMedicRedTest1_01, #endif #if MODE_TEMP_ALIVE_MEDIC @@ -173,6 +179,19 @@ class ModeMenu return new TempMedicBox(device, 1*60, 5*60); case ModeTempMedic1_10: return new TempMedicBox(device, 1*60, 10*60); + case ModeTempMedic1_20: + return new TempMedicBox(device, 1*60, 20*60); + case ModeTempMedic1_30: + return new TempMedicBox(device, 1*60, 30*60); + case ModeTempMedicGreen1_30: + return new TempMedicBox(device, 1*60, 30*60); + case ModeTempMedicRed1_30: + return new TempMedicBox(device, 1*60, 30*60); + case ModeTempMedicBlue1_30: + return new TempMedicBox(device, 1*60, 30*60); + //Test mode for quick test compatibility with colored respawn + case ModeTempMedicRedTest1_01: + return new TempMedicBox(device, 1*60, 1); #endif #if MODE_TEMP_ALIVE_MEDIC @@ -240,6 +259,18 @@ class ModeMenu return "Temp Medic 1/5"; case ModeTempMedic1_10: return "Temp Medic 1/10"; + case ModeTempMedic1_20: + return "Temp Medic 1/20"; + case ModeTempMedic1_30: + return "Temp Medic 1/30"; + case ModeTempMedicGreen1_30: + return "Temp Medic Green 1/30"; + case ModeTempMedicRed1_30: + return "Temp Medic Red 1/30"; + case ModeTempMedicBlue1_30: + return "Temp Medic Blue 1/30"; + case ModeTempMedicRedTest1_01: + return "Temp Medic Red 1/01"; #endif #if MODE_TEMP_ALIVE_MEDIC diff --git a/mlt_core.cpp b/mlt_core.cpp index cf7802b..7c905dd 100644 --- a/mlt_core.cpp +++ b/mlt_core.cpp @@ -31,7 +31,7 @@ // half cycle period: T/2 = 8.93 µs // assuming carrier_interval_delay + instructions_delay = T/2 -#define CARRIER_INTERVAL 4 // adjusted experimentally +#define CARRIER_INTERVAL 5 // adjusted experimentally // MilesTag definitions @@ -199,7 +199,7 @@ void sendCommand(mlt_command cmd) { sendHeader(); sendByte(cmd.command_type, 8); sendByte(cmd.cmd_data, 8); - sendByte(0xE8, 8); + sendByte(cmd.package_end, 8); } } diff --git a/mlt_core.h b/mlt_core.h index 752c04b..4a6df31 100644 --- a/mlt_core.h +++ b/mlt_core.h @@ -32,6 +32,7 @@ enum mlt_command_type : uint8_t { MLT_CT_INVALID = 0, MLT_CT_SHOT = 1, MLT_CT_SYSTEM = 0x83, + MLT_CT_RESPAWN = 0xB4,//0xA9, }; enum mlt_team_color : uint8_t { @@ -86,8 +87,25 @@ enum mlt_system_command : uint8_t { MLT_SC_DOUBLE_HEALTH = 0x22, // LW extension }; +/** + * LASERWAR protocol supports different package ends. + * Current values received from LW tech director https://vk.com/sempertenebris + */ +enum mlt_package_end : uint8_t { + MLT_END_COMMON = 0xE8, + MLT_END_RED = 0xB4, + MLT_END_BLUE = 0xB5, + MLT_END_YELLOW = 0xB6, + MLT_END_GREEN = 0xB7, +}; + struct mlt_command { + + /** + * First byte + */ mlt_command_type command_type; + union { mlt_shot_data shot_data; union { @@ -95,8 +113,12 @@ struct mlt_command { uint8_t cmd_data; }; }; -}; + /** + * Last byte, MLT_END_COMMON (0xE8) by default, c++ 11 feature + */ + mlt_package_end package_end = mlt_package_end::MLT_END_COMMON; +}; void mltSetup(uint8_t emitter_pin, uint8_t sensor_pin);