if (DamagePct >= 100.0) { // Don't let damage go above 100% DamagePct = 100.0; // After destruction, the tank becomes inoperative for some period of time (15 seconds is the Tamiya spec - NOT the same as recovery/invulnerability time!) // After that time it will automatically recover itself. During invulnerability time, the tank can fire but is impervious to enemy fire. // Invulnerabilty time is dependent on the weight class. isDestroyed = true; TankTimer->setTimeout(DESTROYED_INOPERATIVE_TIME_mS, ResetBattle); // DESTROYED_INOPERATIVE_TIME_mS is defined in OP_BattleTimes.h // Start the destroyed light effect HitLEDs_CannonHit(); // After the cannon hit effect, because isDestroyed is true, the subsequent HitLEDs_Destroyed effect will start automatically HitRelay(); //After the cannon hit effect the relay disconnect the motors. Tank cannot move ClearHitRelay(); } else { // Flash the hit notification LEDs HitLEDs_CannonHit(); HitRelay(); ClearHitRelay(); // Start a brief invulnerability timer. Each IR signal is sent multiple times, but we only want to count // one hit per shot. For the next second after being hit, we ignore further hits TankTimer->setTimeout(HIT_FILTER_mS, EnableHitReception);
First of all, if we reach the code you have posted, we already know that we have received a cannon hit (not a machine gun hit). [...]This means that we've added up all our damage and it's equal to or over 100%, therefore the tank is "destroyed" and must be disabled. [...]I hope that helps!
if (jumperState == LOW) { WEIGHT_CLASS = WC_HEAVY; } else { WEIGHT_CLASS = WC_MEDIUM; }
#define pin_WeightJumper 7unsigned char WC;pinMode(pin_WeightJumper, INPUT_PULLUP); if (digitalRead(pin_WeightJumper) == LOW) { WC = WC_HEAVY;}else { WC = WC_MEDIUM;}
BattleSettings.WeightClass = WC;
Let me know if it works!
An other question. Do you know where can I get constant 5V from the Taigen V3 MFU? It seems the CN2 is only providing around 1.8V
I have a suspicion this is related to the Arduino IDE version issue that was discussed earlier in this thread. With certain versions of the IDE the code will compile but without enough memory available, and the sketch will operate very erratically, if at all.
void OP_Tank::HitLEDs_Reloaded(void){ if (CannonReloaded) { HitLEDs_Toggle(); } else { if (TankTimer->isEnabled(HitLED_TimerID)) TankTimer->deleteTimer(HitLED_TimerID); HitLEDs_Off(); }
19:07:13.025 -> BATTLE INFO19:07:13.025 -> ---------------------------------------------19:07:13.025 -> Is Repair Tank? No19:07:13.025 -> Fire Protocol: Tamiya19:07:13.025 -> Hit Protocol 2: Heng Long19:07:13.025 -> Repaired by: Clark Repair19:07:13.025 -> Send MG IR Code: No19:07:13.025 -> Accept MG Damage: No19:07:13.071 -> Damage Profile: Tamiya Spec19:07:13.071 -> Weight Class: Medium19:07:13.071 -> (6 cannon hits, 5.0 sec reload, 12.0 sec recovery)19:07:13.071 -> 19:07:13.071 -> 19:07:13.071 -> 19:07:15.205 -> Fire Cannon19:07:31.516 -> CANNON HIT! (Tamiya)19:07:31.516 -> Health Level: 83%19:07:41.921 -> CANNON HIT! (Tamiya)19:07:41.921 -> Health Level: 67%19:07:52.162 -> CANNON HIT! (Tamiya)19:07:52.162 -> Health Level: 50%19:08:02.223 -> CANNON HIT! (Tamiya)19:08:02.223 -> Health Level: 33%19:08:12.900 -> CANNON HIT! (Tamiya)19:08:12.900 -> Health Level: 17%19:08:23.038 -> CANNON HIT! (Tamiya)19:08:23.038 -> Health Level: 0%19:08:33.440 -> CANNON HIT! (Tamiya)19:08:33.440 -> Health Level: 0%19:08:33.440 -> TANK DESTROYED19:08:48.467 -> TANK RESTORED
Can I ask something? Can you add a simple led blink on HitLeds when cannon reloaded and a little bit longer blinking when tank destroyed?
// NOTIFICATION LED // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->> // #define CANNON_RELOAD_NOTIFY false // << --- SET ME - set to True to blink the IR apple notification LEDs when canon reload time has transpired (CUSTOM_CANNON_RELOAD below)
//------------------------------------------------------------------------------------------------------------------------>>// HIT NOTIFICATION LEDs CANON RELOADED - Short blink to notify user the canon reload time has completed// Can be enabled/disabled with setting CANNON_RELOAD_NOTIFY on the A_Setup.h tab//------------------------------------------------------------------------------------------------------------------------>>void OP_Tank::HitLEDs_ReloadNotify(void){ HitLEDs_Blink(250);}
// Tanks is dead for 15 seconds #define DESTROYED_INOPERATIVE_TIME_mS 15000 // How long is the vehicle immobilized after being destroyed. 15 seconds is the Tamiya spec. After this, // the vehicle will automatically re-generate with full health restored.
As for increasing the length of the tank destroyed period, it is set to 15 seconds because that is the Tamiya standard. However if you want to change it, modify this value near the top of the Tank.h tab: Code: [Select]// Tanks is dead for 15 seconds #define DESTROYED_INOPERATIVE_TIME_mS 15000 // How long is the vehicle immobilized after being destroyed. 15 seconds is the Tamiya spec. After this, // the vehicle will automatically re-generate with full health restored.
// Now set a timer to keep coming back here after a short interval so we can blink the lights DestroyedBlinkerID = TankTimer->setInterval(5450, HitLEDs_Destroyed); // This is a slow blink, about half a second
I guess you are using the manual pushbutton method to trigger the canon fire? Most people probably use the signal input so I suppose that is why we haven't caught this issue before. I will update the documentation to make this more clear.
No, maybe I was not understandable, sorry if my English is not perfect. For me the "tankdestroyed" notify LED effects were very similar to simple hit notification. I just wanted some longer blinking after destroy to make it more clear for the user that the tank is out. If I modify this can I reach my goal? (More blinking time, significantly longer than simple hit notification, the value was 450ms before thats what your comment also said )Code: [Select] // Now set a timer to keep coming back here after a short interval so we can blink the lights DestroyedBlinkerID = TankTimer->setInterval(450, HitLEDs_Destroyed); // This is a slow blink, about half a second
// Now set a timer to keep coming back here after a short interval so we can blink the lights DestroyedBlinkerID = TankTimer->setInterval(450, HitLEDs_Destroyed); // This is a slow blink, about half a second
Thanks Luke, my plan was to use the 4th pin of the regular 8pin connector which is the airsoft signal pin. It sends out gnd signal, so thats why I used INPUT_PULLUP function to trigger the cannon fire. I don't need the 5V receiving pin because of this. Achieving my plan will let the users use this unit with older Heng Long and Taigen boards (they just need to extend the 4th wire and connect to relevant connector to the battle unit). I also have 2 Taigens and my test were good except the "phantom firing", but with the simple solution from my friend it disappeared!