Esempio n. 1
0
static void doWriteByte (int argc, char *argv [])
{
  int val ;

  if (argc != 3)
  {
    fprintf (stderr, "Usage: %s wb value\n", argv [0]) ;
    exit (1) ;
  }

  val = (int)strtol (argv [2], NULL, 0) ;

  digitalWriteByte (val) ;
}
Esempio n. 2
0
static void ledPercent (int percent)
{
  unsigned int output = 0 ;

  if (percent > 11) output |= 0x01 ;
  if (percent > 22) output |= 0x02 ;
  if (percent > 33) output |= 0x04 ;
  if (percent > 44) output |= 0x08 ;
  if (percent > 55) output |= 0x10 ;
  if (percent > 66) output |= 0x20 ;
  if (percent > 77) output |= 0x40 ;
  if (percent > 88) output |= 0x80 ;

  digitalWriteByte (output) ;
}
int main(void)
{
	int i;

	if(wiringPiSetup() < 0){ // setup wiringPi
		printf("wiringPi setup failed !\n");
		return -1;
	}

	for(i = 0; i < 8; i++){  // set pin mode as output(GPIO0~GPIO7)
		pinMode(i, OUTPUT);
	}

	while(1){
		for(i = 0; i < sizeof(SegCode)/sizeof(uchar); i++){ // display 0~9,A~F
			digitalWriteByte(SegCode[i]);
			delay(500);
		}
		digitalWriteByte(0x00);   //segment off
		delay(1000);
	}

	return 0;
}
Esempio n. 4
0
static void write_gpio (uint8_t val)
{
    //Set GPIO buffer to output
    set_gpio_output ();
    
    //Disable IC3 for a moment
    digitalWrite (IC3_CE, IC3_DISABLE);
    //Write to output buffer
    digitalWriteByte (val);
    output_waiting = true;
    //Clock the data into IC4, ready for the WPC to pick it up
    out_clk ();

    //Set GPIO buffer back to input
    digitalWrite (IC3_CE, IC3_ENABLE);
    set_gpio_input ();
}