Ejemplo n.º 1
0
void die(int error)
{
    os::lowsyslog("Fatal error %i\n", error);
    while (1)
    {
        setStatusLed(false);
        ::usleep(25000);
        setStatusLed(true);
        ::usleep(25000);
    }
}
Ejemplo n.º 2
0
int main(int argc, char * argv[])
{
	int k;
	char * file_name = 0;
	int verbose = 0;
	
	
	for (k = 1; k < argc; ++k) {
		if (0 == strcmp(argv[k], "-v"))
			++verbose;
		else if (0 == strcmp(argv[k], "-vv"))
			verbose += 2;
		else if (0 == strcmp(argv[k], "-vvv"))
			verbose += 3;
		else if (*argv[k] == '-') {
			printf("Unrecognized switch: %s\n", argv[k]);
			file_name = 0;
			break;
		}
	}
	if(!verbose)
		daemon(0, 0); /*  run in the background */
	/* start button thread */
	pthread_t button_thread;
	void *ButtonControl();
	pthread_create(&button_thread,NULL, ButtonControl, NULL);
	
        for (;;) {
        	if (file_exists(STATUS_FILE))
        		setStatusLed(2, verbose);
        	else {
        		int st_sda = getPowerMode(DEVNAME_SDA, verbose);
        		int st_sdb = getPowerMode(DEVNAME_SDB, verbose);
        		if(st_sda == PM_STATUS_STANDBY && st_sdb == PM_STATUS_STANDBY) {
        			setStatusLed(0, verbose);
        		}
        		else {
        			setStatusLed(1, verbose);
        		}
        	}
        	sleep(1);
        }
        return 0;
}
//------------------------------------------------------------------------------
tOplkError target_setLed(tLedType ledType_p, BOOL fLedOn_p)
{
    tOplkError  ret = kErrorOk;

    switch (ledType_p)
     {
         case kLedTypeStatus:
            setStatusLed(fLedOn_p);
            break;

         case kLedTypeError:
            setErrorLed(fLedOn_p);
            break;

         default:
            ret = kErrorIllegalInstance;
            break;
     }

    return ret;
}
Ejemplo n.º 4
0
/* Called by callbacks for songbank failure and song success.
  Sends a packet to William. */
void setOutgoingPacket(uint8_t tripletIndex)
{
  char * p_triplet = colourTriplets[tripletIndex];
  outgoingPacket[0] = PACKET_HEADER_TO_WILLIAM;
  outgoingPacket[1] = p_triplet[0];
  outgoingPacket[2] = p_triplet[1];
  outgoingPacket[3] = p_triplet[2];
  outgoingPacket[4] = 0;
  for (int i = 0; i < 4; i++)
    outgoingPacket[4] += outgoingPacket[i];
  /* diagnostic */
#ifdef _DEBUG
  for (int i = 0; i < 5; i++)
    Serial.write(outgoingPacket[i]);
  Serial.write(7);
  for (int i = 0; i < 3; i++)
    Serial.write(p_triplet[i]);
  Serial.write(88);
#endif
  // set led
  PORTB &= ~(0b00111101);
  PORTD &= ~(0b01100000);
  setStatusLed(tripletIndex);
}