I think that might be the problem on one of my projects Mike, I will try chamnging it just setting a flag to be picked up in the loop.
Meanwhile I have just done a test with a simple sketch to count secs and minutes . Without the libraries it keeps perfect time compared to my pc clock,
With VW running I lose about 2 seconds in 30 minutes, even if I send nothing to the RX pin.
Is there an easy way of making millis or VW use the other clock?
#include <SPI.h>
#include <VirtualWire.h>
#include <MemoryFree.h>
unsigned long currentMillis;
unsigned long previousMillis = 0;
int secU=0;
int minU=0;
void setup(){
Serial.begin(19200);
vw_set_rx_pin(19); // set Rx
vw_setup(2000); // Bits per sec
vw_rx_start();
}
void loop (){
currentMillis = millis() ;
if(currentMillis > previousMillis)
{
previousMillis = currentMillis +1000; secU ++ ;
if (secU >= 60 ) { secU = 0 ; minU ++ ;}
Serial.print(" min= "); Serial.println(minU); Serial.print(" sec = "); Serial.println(secU);
}
uint8_t buf[VW_MAX_MESSAGE_LEN]; // get message
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
Serial.println("Got: "); // Show on PC for debugging
} // end of if message
}