The file for controlling all I/O, storing items, managing damage and buffs, and storing stats has been started. The file can be found on our GitHub under PlayerControl.ino. The code currently works by polling the RF and IR trigger pins and checking for input from the IR and RF devices. However, that will soon be replaced by ISRs. Both IRremote and VirtualWire (the IR and RF control libraries, respectively) check for input throughout the main program, and they process and store any input which can be checked at a later time in the program. This allows us to go through the main program without having to worry about missing a signal.
The codes for damage/healing/buffers for both RF and IR devices have been set to 4 byte codes - The first byte is a header for ensuring the signal is good, the second byte holds team information (are you on Team A or Team B) and carrier type (damage, healing, etc.), and the last two bytes hold the value of the carrier (e.i. how much damage is inflicted or how much you are healed). The code first checks to make sure the message received is 16 bits, then the signal is parsed (not yet implemented) and the first byte is checked to see if the signal is valid.
As mentioned before, shooting and AoE weapons are activated by triggers, which are continuously polled. If the IR trigger is activated, a signal 0xA0z is sent, where z is the damage amount stored in the stats array. If the RF trigger is activated, the analog value on pin A0 (connected to a potentiometer knob) is grabbed and used to determine which of the three items the player wants to use. The signal to be sent is grabbed from the items array and sent through the RF transmitter.
The codes for damage/healing/buffers for both RF and IR devices have been set to 4 byte codes - The first byte is a header for ensuring the signal is good, the second byte holds team information (are you on Team A or Team B) and carrier type (damage, healing, etc.), and the last two bytes hold the value of the carrier (e.i. how much damage is inflicted or how much you are healed). The code first checks to make sure the message received is 16 bits, then the signal is parsed (not yet implemented) and the first byte is checked to see if the signal is valid.
As mentioned before, shooting and AoE weapons are activated by triggers, which are continuously polled. If the IR trigger is activated, a signal 0xA0z is sent, where z is the damage amount stored in the stats array. If the RF trigger is activated, the analog value on pin A0 (connected to a potentiometer knob) is grabbed and used to determine which of the three items the player wants to use. The signal to be sent is grabbed from the items array and sent through the RF transmitter.