コード例 #1
0
ファイル: main.c プロジェクト: BBCNET/Raspberry-PI
int main(int argc, char **argv)
{
	wiringPiSetup();
	system("sudo gpio load i2c");
	//pinMode (0, OUTPUT);
	//printf("%c\n",test('A'));

	piGlowSetup(TRUE);
	while(1)
	{
		int i=5;
		for(i; i>=0; i--)
		{
			piGlowRing(i, 60);
			delay(2000);
			system("piglow off");
		}
		//~ i=0;
		system("piglow off");
	}
}
コード例 #2
0
ファイル: piGlow1.c プロジェクト: cschirin/computergraphics
int main (void)
{
  int i ;
  int step, ring, leg ;

// Always initialise wiringPi:
//	Use the Sys method if you don't need to run as root

  wiringPiSetupSys () ;

// Initialise the piGlow devLib with our chosen pin base

  piGlowSetup (1) ;

// LEDs, one at a time

  printf ("LEDs, one at a time\n") ;
  for (; !keypressed () ;)
    for (leg = 0 ; leg < 3 ; ++leg)
    {
      for (ring = 0 ; ring < 6 ; ++ring)
      {
	pulseLed (leg, ring) ;
	if (keypressed ())
	  break ;
      }
      if (keypressed ())
	break ;
    }
  clearKeypressed () ;

// Rings, one at a time

  printf ("Rings, one at a time\n") ;
  for (; !keypressed () ;)
    for (ring = 0 ; ring < 6 ; ++ring)
    {
      pulseRing (ring) ;
      if (keypressed ())
	break ;
    }
  clearKeypressed () ;

// Legs, one at a time

  printf ("Legs, one at a time\n") ;
  for (; !keypressed () ;)
    for (leg = 0 ; leg < 3 ; ++leg)
    {
      pulseLeg (leg) ;
      if (keypressed ())
	break ;
    }
  clearKeypressed () ;

  delay (1000) ;

// Sequence - alternating rings, legs and random

  printf ("Sequence now\n") ;
  for (; !keypressed () ;)
  {
    for (i = 0 ; i < 20 ; ++i)
      for (step = 0 ; step < LEG_STEPS ; ++step)
      {
	for (leg = 0 ; leg < 3 ; ++leg)
	  piGlowLeg (leg, legSequence [step * 3 + leg]) ;
	delay (80) ;
      }

    for (i = 0 ; i < 10 ; ++i)
      for (step = 0 ; step < RING_STEPS ; ++step)
      {
	for (ring = 0 ; ring < 6 ; ++ring)
	  piGlowRing (ring, ringSequence [step * 6 + ring]) ;
	delay (80) ;
      }

    for (i = 0 ; i < 1000 ; ++i)
    {
      leg  = random () % 3 ;
      ring = random () % 6 ;
      piGlow1 (leg, ring, random () % 256) ;
      delay (5) ; 
      piGlow1 (leg, ring, 0) ;
    }
  }

  return 0 ;
}
コード例 #3
0
ファイル: piglow.c プロジェクト: cschirin/computergraphics
int main (int argc, char *argv [])
{
  int percent ;
  int ring, leg ;

// Always initialise wiringPi:
//	Use the Sys method if you don't need to run as root

  wiringPiSetupSys () ;

// Initialise the piGlow devLib

  piGlowSetup (FALSE) ;

  if (argc == 1)
    failUsage () ;

  if ((argc == 2) && (strcasecmp (argv [1], "off") == 0))
  {
    for (leg = 0 ; leg < 3 ; ++leg)
      piGlowLeg (leg, 0) ;
    return 0 ;
  }

  if (argc == 3)
  {
    percent = getPercent (argv [2]) ;

    /**/ if (strcasecmp (argv [1], "red") == 0)
      piGlowRing (PIGLOW_RED, percent) ;
    else if (strcasecmp (argv [1], "yellow") == 0)
      piGlowRing (PIGLOW_YELLOW, percent) ;
    else if (strcasecmp (argv [1], "orange") == 0)
      piGlowRing (PIGLOW_ORANGE, percent) ;
    else if (strcasecmp (argv [1], "green") == 0)
      piGlowRing (PIGLOW_GREEN, percent) ;
    else if (strcasecmp (argv [1], "blue") == 0)
      piGlowRing (PIGLOW_BLUE, percent) ;
    else if (strcasecmp (argv [1], "white") == 0)
      piGlowRing (PIGLOW_WHITE, percent) ;
    else if (strcasecmp (argv [1], "all") == 0)
      for (ring = 0 ; ring < 6 ; ++ring)
	piGlowRing (ring, percent) ;
    else
    {
      fprintf (stderr, "piglow: invalid colour\n") ;
      exit (EXIT_FAILURE) ;
    }
    return 0 ;
  }

  if (argc == 4)
  {
    /**/ if (strcasecmp (argv [1], "leg") == 0)
    {
      leg = atoi (argv [2]) ;
      if ((leg < 0) || (leg > 2))
      {
	fprintf (stderr, "piglow: leg value out of range\n") ;
	exit (EXIT_FAILURE) ;
      }
      percent = getPercent (argv [3]) ;
      piGlowLeg (leg, percent) ;
    }
    else if (strcasecmp (argv [1], "ring") == 0)
    {
      ring = atoi (argv [2]) ;
      if ((ring < 0) || (ring > 5))
      {
	fprintf (stderr, "piglow: ring value out of range\n") ;
	exit (EXIT_FAILURE) ;
      }
      percent = getPercent (argv [3]) ;
      piGlowRing (ring, percent) ;
    }
    return 0 ;
  }

  if (argc == 5)
  {
    if (strcasecmp (argv [1], "led") != 0)
      failUsage () ;

    leg = atoi (argv [2]) ;
    if ((leg < 0) || (leg > 2))
    {
      fprintf (stderr, "piglow: leg value out of range\n") ;
      exit (EXIT_FAILURE) ;
    }
    ring = atoi (argv [3]) ;
    if ((ring < 0) || (ring > 5))
    {
      fprintf (stderr, "piglow: ring value out of range\n") ;
      exit (EXIT_FAILURE) ;
    }
    percent = getPercent (argv [4]) ;
    piGlow1 (leg, ring, percent) ;
    return 0 ;
  }

  failUsage () ;
  return 0 ; 
}