I am a little confused on how exactly VirtualWire's "send" function works. After looking at the code, the process I gathered is the following.
- In the Arduino IDE, call
vw_send()with the right parameters.
- Inside this method, it will start to encode the message and create the packet.
- Then before the function returns, it calls
- Inside that function, it enables the transmitter hardware and sets the variable "vw_tx_enabled" equal to true. Then this function returns, followed by the immediate return of
vw_send(). So there is no where in this flow where the message is actually being sent.
However, the actual transmission of the message happens inside
vw_Int_Handler(). But this function is never called in
vw_tx_start(). So the only way this could be happening is if there was some sort of multi-threading correct? Because by setting vw_tx_enabled to true, the transmission process would begin inside vw_Int_Handler.
Can someone explain/clarify this?
Moreover, this library uses digitalWrite to transmit the bits. Wouldn't it just be faster to toggle the bits at the registry level?
Lastly, in VirtualWire, they send a 36 bit preamble, I assume this is for synchorinzation purposes. So if I want to send 128 byte packet length, how much of a preamble should I use? I believe the reason for VirtualWire only transmitting 27 byte packet length is because the 36 bit preamble will only keep the data synchronized for that long. So is there a certain formula used to determine the preamble size?