compressor.start() won't start the compressor every time you call it.
It is designed to be called once for every time you stop it.
(it defaults to off)
When you call start, a semaphore is set to true.
This flag is checked twice a second by another thread, and if enabled (from the semaphore) and enabled (from the driver station) and the pressure switch pulls the IO pin to ground it sets the compressor's spike to turn on forward.
The line
is the semaphore that is set by calling start (and stop)
This is the thread that turns on and off the compressor (In C++, the Java version is very similar):
Code:
static void compressorChecker(Compressor *c)
{
while (1)
{
if (c->Enabled())
{
c->SetRelayValue( c->GetPressureSwitchValue() == 0 ? Relay::kOn : Relay::kOff );
}
else
{
c->SetRelayValue(Relay::kOff);
}
Wait(0.5);
}
}
This starts right after creating the compressor object.
You only need to call start once in the program.