Registration Notice

Due to increased spam, forum registration must be manually approved by a moderator! Please see this post for instructions.

*

Offline CodeWarrior

  • 29
    • View Profile
  • Detroit suburb, Michigan, USA
Re: Standalone Tank IR
« Reply #30 on: April 11, 2021, 10:01:41 AM »
Luke-  I was able to compile successfully using 1.8.13 IDE and AVR board # 1.6.20.

The memory usage was as follows:
Sketch uses 24238 bytes (78%) of program storage space. Maximum is 30720 bytes.
Global variables use 1450 bytes (70%) of dynamic memory, leaving 598 bytes for local variables. Maximum is 2048 bytes.

Well done and thank you again for looking into, and solving, this.
There are 10 kinds of people:  Those who understand binary and those who don't.

*

Offline LukeZ

  • 1221
    • View Profile
  • France
Re: Standalone Tank IR
« Reply #31 on: April 11, 2021, 12:37:45 PM »
Thank you for reporting back!
NO SUPPORT THROUGH PM - Read why
Need a forum account? Read here
Open Panzer FAQs

*

Offline Rongyos

  • 33
    • View Profile
  • Hungary
Re: Standalone Tank IR
« Reply #32 on: July 07, 2023, 04:16:24 PM »
Hi Luke!

I'm just modifying the code for using relays for disconnect motors (to reduce advantages relating tamiya speed reducing function) and just dont understand the code below. After the "else" statement the HitLEDs_CannonHit object shouldn't be HitLEDs_MGHit? If yes my relay object shouldn't be there :)
Code: [Select]
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);

Thanks and regards!
Rongyos

*

Offline LukeZ

  • 1221
    • View Profile
  • France
Re: Standalone Tank IR
« Reply #33 on: July 08, 2023, 03:29:05 PM »
Hi Rongyos,

I don't know if I understand your question exactly, but I will try to explain this bit of code and maybe that will help you.

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).

By this point we have also already calculated our new damage percentage based on this cannon hit. All that has come before this code.

Now, in the code you posted, we have the first part of the "if" statement: if (DamagePct >= 100.0)

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.

The second part of the "if" statement is the "else" condition: else we have been hit, and our damage has increased, but we are not yet destroyed (in other words, damage is less than 100%).

In that case we flash the LEDs in the apple that indicate a hit was received. We also enable an invulnerability timer, but only a very brief one. This is simply to prevent receiving multiple hits from a single shot of someone's cannon. As you know, the Tamiya signal lasts for a full second - that would be enough time for us to register many hits if we didn't have this brief timer.

I hope that helps!
NO SUPPORT THROUGH PM - Read why
Need a forum account? Read here
Open Panzer FAQs

*

Offline Rongyos

  • 33
    • View Profile
  • Hungary
Re: Standalone Tank IR
« Reply #34 on: July 10, 2023, 02:08:38 AM »

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!

Hi Luke,

Yes, silly me tought that part of code is for determine if the hit is from cannon or MG. Thats why I didn't understand why cannon hit notification sent out to LEDS and not MG hit.
It is now clear for me, thanks.

Rongyos

 

bomber-explosion