From fe5ccfae16d12e0f736cd99f2fc98f8eff770814 Mon Sep 17 00:00:00 2001 From: Anton Date: Thu, 6 Sep 2018 22:39:38 +0300 Subject: [PATCH 01/11] JIRA: STL-1 Add new timings. --- ModeMenu.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ModeMenu.h b/ModeMenu.h index b21dde0..64a8c93 100644 --- a/ModeMenu.h +++ b/ModeMenu.h @@ -69,6 +69,8 @@ enum ModeType : char { ModeTempMedic05_5, ModeTempMedic1_5, ModeTempMedic1_10, + ModeTempMedic1_20, + ModeTempMedic1_30, #endif #if MODE_TEMP_ALIVE_MEDIC @@ -173,6 +175,10 @@ 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); #endif #if MODE_TEMP_ALIVE_MEDIC @@ -240,6 +246,10 @@ 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"; #endif #if MODE_TEMP_ALIVE_MEDIC From bf8c2c17372b3551f338ef5b21e2ea5e1b94a7d8 Mon Sep 17 00:00:00 2001 From: Anton Date: Thu, 6 Sep 2018 22:43:21 +0300 Subject: [PATCH 02/11] JIRA: STL-1 Improve support for new timings. --- MBSmartMedic.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MBSmartMedic.h b/MBSmartMedic.h index fad5bf3..3b76be1 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() { @@ -125,7 +126,8 @@ class TempMedicBox : public MedicBox device->showStatusText(" Ready! "); } } else { - device->showTimeInterval(((long)timeLeft*100/60)*10, " Waiting... "); + // minutes left (exclude current) + device->showTimerNumber(timeLeft/60, " Waiting... "); } device->preventSleep(2000); } From 25a6ecf22667669e820271508f98d621f21bf135 Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 7 Sep 2018 02:09:33 +0300 Subject: [PATCH 03/11] JIRA: STL-1 Improve waiting display. --- MBSmartMedic.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/MBSmartMedic.h b/MBSmartMedic.h index 3b76be1..5541745 100644 --- a/MBSmartMedic.h +++ b/MBSmartMedic.h @@ -126,8 +126,14 @@ class TempMedicBox : public MedicBox device->showStatusText(" Ready! "); } } else { - // minutes left (exclude current) - device->showTimerNumber(timeLeft/60, " Waiting... "); + // minutes left (current minute included) + if(timeLeft > 60) { + device->showTimerNumber(timeLeft/60 + 1, " Waiting(min) "); + } + // second left (in last minute) + else { + device->showTimerNumber(timeLeft, " Waiting(sec) "); + } } device->preventSleep(2000); } From dd3e830f5b9680deab8816d1a1cb6119df9272b5 Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 7 Sep 2018 02:10:42 +0300 Subject: [PATCH 04/11] JIRA: STL-1 Fix grammar error in comment --- MBSmartMedic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MBSmartMedic.h b/MBSmartMedic.h index 5541745..9e52955 100644 --- a/MBSmartMedic.h +++ b/MBSmartMedic.h @@ -130,7 +130,7 @@ class TempMedicBox : public MedicBox if(timeLeft > 60) { device->showTimerNumber(timeLeft/60 + 1, " Waiting(min) "); } - // second left (in last minute) + // seconds left (in last minute) else { device->showTimerNumber(timeLeft, " Waiting(sec) "); } From cb6dc51e8246b1d48381b244ff4516cfca8c8da6 Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 8 Sep 2018 00:07:07 +0300 Subject: [PATCH 05/11] JIRA: STL-1 Add processCommand realization. --- MBSmartMedic.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/MBSmartMedic.h b/MBSmartMedic.h index 9e52955..e538ecc 100644 --- a/MBSmartMedic.h +++ b/MBSmartMedic.h @@ -102,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() { From 9789045d0e8c1a2e2a8b9e4cae3afbdf11f5e328 Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 8 Sep 2018 00:16:47 +0300 Subject: [PATCH 06/11] JIRA: STL-1 Extend mlt_command type with last byte value. --- mlt_core.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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); From f0dd76cc3bbe052a4cfd4087dcb2e6470252300a Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 8 Sep 2018 00:18:55 +0300 Subject: [PATCH 07/11] JIRA: STL-1 Use extended mlt_command structure in sentCommand. --- mlt_core.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlt_core.cpp b/mlt_core.cpp index cf7802b..e6e3f78 100644 --- a/mlt_core.cpp +++ b/mlt_core.cpp @@ -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); } } From aa7d9deade89816f6c9fe097dd64981ac050b28c Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 8 Sep 2018 00:24:42 +0300 Subject: [PATCH 08/11] JIRA: STL-1 Add color specific modes. --- ModeMenu.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ModeMenu.h b/ModeMenu.h index 64a8c93..69d5297 100644 --- a/ModeMenu.h +++ b/ModeMenu.h @@ -71,6 +71,9 @@ enum ModeType : char { ModeTempMedic1_10, ModeTempMedic1_20, ModeTempMedic1_30, + ModeTempMedicGreen1_30, + ModeTempMedicRed1_30, + #endif #if MODE_TEMP_ALIVE_MEDIC @@ -179,6 +182,11 @@ class ModeMenu 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); + #endif #if MODE_TEMP_ALIVE_MEDIC @@ -250,6 +258,11 @@ class ModeMenu 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"; + #endif #if MODE_TEMP_ALIVE_MEDIC From 160923bdbb05561b8343707e197a238f87d61e27 Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 8 Sep 2018 00:28:34 +0300 Subject: [PATCH 09/11] JIRA: STL-1 Add color specific behavior to smart medic. --- MedicBox.ino | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/MedicBox.ino b/MedicBox.ino index 2af98d0..7af4ffb 100644 --- a/MedicBox.ino +++ b/MedicBox.ino @@ -126,7 +126,20 @@ 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 { + medic->processButton(); + } } else { medic->updateTime(); } From 319809be7d9e8b0244daea5f334711ed600890da Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 13 Oct 2018 14:32:55 +0300 Subject: [PATCH 10/11] JIRA: STL-1 Fix old generation. --- mlt_core.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlt_core.cpp b/mlt_core.cpp index e6e3f78..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 From 50ae5f2c2b19e351e74ea24f38f401a5c2a567e9 Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 13 Oct 2018 23:49:17 +0300 Subject: [PATCH 11/11] JIRA: STL-1 Add blue and test modes. --- MedicBox.ino | 13 ++++++++++++- ModeMenu.h | 14 +++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/MedicBox.ino b/MedicBox.ino index 7af4ffb..8a3611f 100644 --- a/MedicBox.ino +++ b/MedicBox.ino @@ -137,7 +137,18 @@ void loop() { respawnCmd.cmd_data = MLT_CLR_RED; respawnCmd.package_end = MLT_END_RED; medic->processCommand(&respawnCmd); - } else { + } 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 { diff --git a/ModeMenu.h b/ModeMenu.h index 69d5297..adab288 100644 --- a/ModeMenu.h +++ b/ModeMenu.h @@ -73,7 +73,8 @@ enum ModeType : char { ModeTempMedic1_30, ModeTempMedicGreen1_30, ModeTempMedicRed1_30, - + ModeTempMedicBlue1_30, + ModeTempMedicRedTest1_01, #endif #if MODE_TEMP_ALIVE_MEDIC @@ -186,7 +187,11 @@ class ModeMenu 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 @@ -262,7 +267,10 @@ class ModeMenu 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