Fix spacing issues. Who wrote this code? Why is there no copyright?

This commit is contained in:
Steve Checkoway
2008-12-26 12:03:06 +00:00
parent 70be48e225
commit 97024035e8
@@ -15,28 +15,33 @@ REGISTER_SOUND_DRIVER_CLASS(LinuxWeedTech);
static int fd = -1; static int fd = -1;
static LightsState CurLights; static LightsState CurLights;
inline void SerialClose() static inline void SerialClose()
{ {
if(fd!=1) {close(fd);} if( fd != 1 )
close( fd );
} }
inline void SerialOut(const char *str, int len) static inline void SerialOut(const char *str, int len)
{ {
if(fd!=-1) { if( fd ==-1 )
return;
write( fd, str, len ); write( fd, str, len );
usleep( 2000 ); usleep( 2000 );
} }
}
inline void SerialOpen() static inline void SerialOpen()
{ {
// Make sure we've not already opened the port // Make sure we've not already opened the port
SerialClose(); SerialClose();
// Open a fresh instance.. // Open a fresh instance..
fd = open( "/dev/ttyS0", O_WRONLY | O_NOCTTY | O_NDELAY ); fd = open( "/dev/ttyS0", O_WRONLY | O_NOCTTY | O_NDELAY );
if(fd < 0) {LOG->Warn("Error opening serial port for lights. Error:: %d %s", errno, strerror(errno));} if( fd < 0 )
else { {
LOG->Warn( "Error opening serial port for lights. Error:: %d %s", errno, strerror(errno) );
}
else
{
struct termios my_termios; struct termios my_termios;
tcgetattr( fd, &my_termios ); tcgetattr( fd, &my_termios );
tcflush( fd, TCIFLUSH ); tcflush( fd, TCIFLUSH );
@@ -45,7 +50,6 @@ inline void SerialOpen()
cfsetospeed( &my_termios, B9600 ); cfsetospeed( &my_termios, B9600 );
tcsetattr( fd, TCSANOW, &my_termios ); tcsetattr( fd, TCSANOW, &my_termios );
} }
return;
} }
// End serial driver // // End serial driver //
@@ -96,7 +100,6 @@ LightsDriver_LinuxWeedTech::LightsDriver_LinuxWeedTech()
SerialOut( strinit, 5 ); SerialOut( strinit, 5 );
strinit[0] = 'B'; strinit[0] = 'B';
SerialOut( strinit, 5 ); SerialOut( strinit, 5 );
return;
} }
LightsDriver_LinuxWeedTech::~LightsDriver_LinuxWeedTech() LightsDriver_LinuxWeedTech::~LightsDriver_LinuxWeedTech()
@@ -109,7 +112,6 @@ LightsDriver_LinuxWeedTech::~LightsDriver_LinuxWeedTech()
// Close port // Close port
SerialClose(); SerialClose();
return;
} }
void LightsDriver_LinuxWeedTech::Set( const LightsState *ls ) void LightsDriver_LinuxWeedTech::Set( const LightsState *ls )
@@ -120,11 +122,13 @@ void LightsDriver_LinuxWeedTech::Set(const LightsState *ls)
{ {
LightsMode lm = LIGHTSMAN->GetLightsMode(); LightsMode lm = LIGHTSMAN->GetLightsMode();
if(lm == LIGHTSMODE_GAMEPLAY) { if( lm == LIGHTSMODE_GAMEPLAY )
{
// Since all cabinet lights flash together during gameplay.. If 1 light is on, all are on. // Since all cabinet lights flash together during gameplay.. If 1 light is on, all are on.
// However, the player's menu buttons do NOT flash. This section allows us to turn // However, the player's menu buttons do NOT flash. This section allows us to turn
// on multiple lights without bogging down the system with delays. ((2ms between commands req.)) // on multiple lights without bogging down the system with delays. ((2ms between commands req.))
FOREACH_CabinetLight( cl ) { FOREACH_CabinetLight( cl )
{
bOn |= ls->m_bCabinetLights[cl]; bOn |= ls->m_bCabinetLights[cl];
CurLights.m_bCabinetLights[cl] = ls->m_bCabinetLights[cl]; CurLights.m_bCabinetLights[cl] = ls->m_bCabinetLights[cl];
} }
@@ -132,11 +136,19 @@ void LightsDriver_LinuxWeedTech::Set(const LightsState *ls)
str[0]='A'; str[0]='A';
str[1]='W'; str[1]='W';
if(bOn) {str[2]='C'; str[3]='F';} if( bOn )
else {str[2]='0'; str[3]='0';} {
str[2]='C';
str[3]='F';
}
else
{
str[2]='0';
str[3]='0';
}
// Send command // Send command
printf("%s\n",str); puts( str );
SerialOut( str, 6 ); SerialOut( str, 6 );
return; return;
} }
@@ -145,7 +157,8 @@ void LightsDriver_LinuxWeedTech::Set(const LightsState *ls)
{ {
// Only send the command if the light has changed states (on/off) // Only send the command if the light has changed states (on/off)
bOn = ls->m_bCabinetLights[cl]; bOn = ls->m_bCabinetLights[cl];
if(bOn != CurLights.m_bCabinetLights[cl]) { if( bOn != CurLights.m_bCabinetLights[cl] )
{
if(cl == LIGHT_MARQUEE_UP_LEFT) {str[0] = 'A'; str[2] = 'A';} if(cl == LIGHT_MARQUEE_UP_LEFT) {str[0] = 'A'; str[2] = 'A';}
else if(cl == LIGHT_MARQUEE_UP_RIGHT) {str[0] = 'A'; str[2] = 'B';} else if(cl == LIGHT_MARQUEE_UP_RIGHT) {str[0] = 'A'; str[2] = 'B';}
else if(cl == LIGHT_MARQUEE_LR_LEFT) {str[0] = 'A'; str[2] = 'C';} else if(cl == LIGHT_MARQUEE_LR_LEFT) {str[0] = 'A'; str[2] = 'C';}
@@ -154,10 +167,13 @@ void LightsDriver_LinuxWeedTech::Set(const LightsState *ls)
else if(cl == LIGHT_BASS_RIGHT) {str[0] = 'A'; str[2] = 'H';} else if(cl == LIGHT_BASS_RIGHT) {str[0] = 'A'; str[2] = 'H';}
if(bOn) {str[1]='L';} if( bOn )
else {str[1]='H';} str[1]='L';
else
str[1]='H';
if(str[0]!=0x00) { if( str[0] != 0x00 )
{
SerialOut( str, 6 ); SerialOut( str, 6 );
str[0]=0x00; str[0]=0x00;
} }
@@ -188,10 +204,13 @@ void LightsDriver_LinuxWeedTech::Set(const LightsState *ls)
if(gb == GAME_BUTTON_START) {str[0] = 'A'; str[2] = 'F';} if(gb == GAME_BUTTON_START) {str[0] = 'A'; str[2] = 'F';}
} }
if(bOn) {str[1]='L';} if( bOn )
else {str[1]='H';} str[1]='L';
else
str[1]='H';
if(str[0]!=0x00) { if( str[0] != 0x00 )
{
//SerialOut(str, 6); //SerialOut(str, 6);
str[0]=0x00; str[0]=0x00;
} }
@@ -200,5 +219,4 @@ void LightsDriver_LinuxWeedTech::Set(const LightsState *ls)
} }
} }
return;
} }