2008-06-02 17:41:35 -04:00
|
|
|
/*
|
2015-10-04 14:51:05 -04:00
|
|
|
* Copyright (C) 2006 Paul Davis
|
2008-06-02 17:41:35 -04:00
|
|
|
* Copyright (C) 2007 Michael Taht
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2015-10-04 14:51:05 -04:00
|
|
|
*
|
2008-06-02 17:41:35 -04:00
|
|
|
* */
|
|
|
|
|
|
|
|
#include <tranzport_control_protocol.h>
|
|
|
|
|
|
|
|
// Lights are buffered, and arguably these functions should be eliminated or inlined
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::lights_on ()
|
|
|
|
{
|
|
|
|
lights_pending.set();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::lights_off ()
|
|
|
|
{
|
|
|
|
lights_pending.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
TranzportControlProtocol::light_on (LightID light)
|
|
|
|
{
|
|
|
|
lights_pending.set(light);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
TranzportControlProtocol::light_off (LightID light)
|
|
|
|
{
|
|
|
|
lights_pending.reset(light);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TranzportControlProtocol::lights_init()
|
|
|
|
{
|
|
|
|
lights_invalid.set();
|
2015-10-04 14:51:05 -04:00
|
|
|
lights_flash = lights_pending = lights_current.reset();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
// Now that all this is bitsets, I don't see much
|
2008-06-02 17:41:35 -04:00
|
|
|
// need for these 4 to remain in the API
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
void TranzportControlProtocol::light_validate (LightID light)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
lights_invalid.reset(light);
|
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
void TranzportControlProtocol::light_invalidate (LightID light)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
lights_invalid.set(light);
|
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
void TranzportControlProtocol::lights_validate ()
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
lights_invalid.reset();
|
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
void TranzportControlProtocol::lights_invalidate ()
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
lights_invalid.set();
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
TranzportControlProtocol::light_set (LightID light, bool offon)
|
|
|
|
{
|
|
|
|
uint8_t cmd[8];
|
|
|
|
cmd[0] = 0x00; cmd[1] = 0x00; cmd[2] = light; cmd[3] = offon;
|
|
|
|
cmd[4] = 0x00; cmd[5] = 0x00; cmd[6] = 0x00; cmd[7] = 0x00;
|
|
|
|
|
|
|
|
if (write (cmd) == 0) {
|
|
|
|
lights_current[light] = offon;
|
|
|
|
lights_invalid.reset(light);
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|