mirror of
https://github.com/clockworkpi/WiringPi.git
synced 2026-03-19 02:12:43 +01:00
Removed redundant files
This commit is contained in:
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* gertboard.c:
|
||||
* Simple test for the SPI bus on the Gertboard
|
||||
*
|
||||
* Hardware setup:
|
||||
* D/A port 0 jumpered to A/D port 0.
|
||||
*
|
||||
* We output a sine wave on D/A port 0 and sample A/D port 0. We then
|
||||
* copy this value to D/A port 1 and use a 'scope on both D/A ports
|
||||
* to check all's well.
|
||||
*
|
||||
* Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
|
||||
***********************************************************************
|
||||
* This file is part of wiringPi:
|
||||
* https://projects.drogon.net/raspberry-pi/wiringpi/
|
||||
*
|
||||
* wiringPi is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wiringPi 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
#define B_SIZE 200
|
||||
#undef DO_TIMING
|
||||
|
||||
#include <wiringPi.h>
|
||||
#include <gertboard.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
double angle ;
|
||||
int i ;
|
||||
uint32_t x1 ;
|
||||
int buffer [B_SIZE] ;
|
||||
|
||||
#ifdef DO_TIMING
|
||||
unsigned int now, then ;
|
||||
#endif
|
||||
|
||||
printf ("Raspberry Pi Gertboard SPI test program\n") ;
|
||||
|
||||
if (wiringPiSetupSys () < 0)
|
||||
return -1 ;
|
||||
|
||||
if (gertboardSPISetup () < 0)
|
||||
return 1 ;
|
||||
|
||||
// Generate a Sine Wave
|
||||
|
||||
for (i = 0 ; i < B_SIZE ; ++i)
|
||||
{
|
||||
angle = ((double)i / (double)B_SIZE) * M_PI * 2.0 ;
|
||||
buffer [i] = (int)rint ((sin (angle)) * 127.0 + 128.0) ;
|
||||
}
|
||||
|
||||
|
||||
for (;;)
|
||||
{
|
||||
#ifdef DO_TIMING
|
||||
then = millis () ;
|
||||
#endif
|
||||
|
||||
for (i = 0 ; i < B_SIZE ; ++i)
|
||||
{
|
||||
gertboardAnalogWrite (0, buffer [i]) ;
|
||||
|
||||
#ifndef DO_TIMING
|
||||
x1 = gertboardAnalogRead (0) ;
|
||||
gertboardAnalogWrite (1, x1 >> 2) ; // 10-bit A/D, 8-bit D/A
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DO_TIMING
|
||||
now = millis () ;
|
||||
printf ("%4d mS, %9.7f S/sample", now - then, ((double)(now - then) / 1000.0) / (double)B_SIZE) ;
|
||||
printf (" -> %9.4f samples/sec \n", 1 / (((double)(now - then) / 1000.0) / (double)B_SIZE)) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.7 KiB |
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* piFace.c:
|
||||
* Simple test for the PiFace interface board.
|
||||
*
|
||||
* Read the buttons and output the same to the LEDs
|
||||
*
|
||||
* Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
|
||||
***********************************************************************
|
||||
* This file is part of wiringPi:
|
||||
* https://projects.drogon.net/raspberry-pi/wiringpi/
|
||||
*
|
||||
* wiringPi is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wiringPi 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
#include <wiringPi.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int outputs [4] = { 0,0,0,0 } ;
|
||||
|
||||
void scanButton (int button)
|
||||
{
|
||||
if (digitalRead (button) == LOW)
|
||||
{
|
||||
outputs [button] ^= 1 ;
|
||||
digitalWrite (button, outputs [button]) ;
|
||||
}
|
||||
|
||||
while (digitalRead (button) == LOW)
|
||||
delay (1) ;
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
int pin, button ;
|
||||
|
||||
printf ("Raspberry Pi wiringPiFace test program\n") ;
|
||||
|
||||
if (wiringPiSetupPiFace () == -1)
|
||||
exit (1) ;
|
||||
|
||||
// Enable internal pull-ups
|
||||
|
||||
for (pin = 0 ; pin < 8 ; ++pin)
|
||||
pullUpDnControl (pin, PUD_UP) ;
|
||||
|
||||
|
||||
for (;;)
|
||||
{
|
||||
for (button = 0 ; button < 4 ; ++button)
|
||||
scanButton (button) ;
|
||||
delay (1) ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
111
examples/test1.c
111
examples/test1.c
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* test1.c:
|
||||
* Simple test program to test the wiringPi functions
|
||||
* This is a sequencer to make a patter appear on 8 LEDs
|
||||
* connected to the GPIO pins.
|
||||
*
|
||||
* Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
|
||||
***********************************************************************
|
||||
* This file is part of wiringPi:
|
||||
* https://projects.drogon.net/raspberry-pi/wiringpi/
|
||||
*
|
||||
* wiringPi is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wiringPi 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
#include <wiringPi.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
// Simple sequencer data
|
||||
// Triplets of LED, On/Off and delay
|
||||
|
||||
uint8_t data [] =
|
||||
{
|
||||
0, 1, 1,
|
||||
1, 1, 1,
|
||||
0, 0, 0, 2, 1, 1,
|
||||
1, 0, 0, 3, 1, 1,
|
||||
2, 0, 0, 4, 1, 1,
|
||||
3, 0, 0, 5, 1, 1,
|
||||
4, 0, 0, 6, 1, 1,
|
||||
5, 0, 0, 7, 1, 1,
|
||||
6, 0, 1,
|
||||
7, 0, 1,
|
||||
|
||||
0, 0, 1, // Extra delay
|
||||
|
||||
// Back again
|
||||
|
||||
7, 1, 1,
|
||||
6, 1, 1,
|
||||
7, 0, 0, 5, 1, 1,
|
||||
6, 0, 0, 4, 1, 1,
|
||||
5, 0, 0, 3, 1, 1,
|
||||
4, 0, 0, 2, 1, 1,
|
||||
3, 0, 0, 1, 1, 1,
|
||||
2, 0, 0, 0, 1, 1,
|
||||
1, 0, 1,
|
||||
0, 0, 1,
|
||||
|
||||
0, 0, 1, // Extra delay
|
||||
|
||||
9, 9, 9, // End marker
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
int pin ;
|
||||
int dataPtr ;
|
||||
int l, s, d ;
|
||||
|
||||
printf ("Raspberry Pi wiringPi test program\n") ;
|
||||
|
||||
if (wiringPiSetup () == -1)
|
||||
exit (1) ;
|
||||
|
||||
for (pin = 0 ; pin < 8 ; ++pin)
|
||||
pinMode (pin, OUTPUT) ;
|
||||
|
||||
pinMode (8, INPUT) ; // Pin 8 SDA0 - Has on-board 2k2 pull-up resistor
|
||||
|
||||
dataPtr = 0 ;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
l = data [dataPtr++] ; // LED
|
||||
s = data [dataPtr++] ; // State
|
||||
d = data [dataPtr++] ; // Duration (10ths)
|
||||
|
||||
if ((l + s + d) == 27)
|
||||
{
|
||||
dataPtr = 0 ;
|
||||
continue ;
|
||||
}
|
||||
|
||||
digitalWrite (l, s) ;
|
||||
|
||||
if (digitalRead (8) == 0) // Pressed as our switch shorts to ground
|
||||
delay (d * 10) ; // Faster!
|
||||
else
|
||||
delay (d * 100) ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* test2.c:
|
||||
* This tests the hardware PWM channel.
|
||||
*
|
||||
* Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
|
||||
***********************************************************************
|
||||
* This file is part of wiringPi:
|
||||
* https://projects.drogon.net/raspberry-pi/wiringpi/
|
||||
*
|
||||
* wiringPi is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wiringPi 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
#include <wiringPi.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
int bright ;
|
||||
|
||||
printf ("Raspberry Pi wiringPi PWM test program\n") ;
|
||||
|
||||
if (wiringPiSetup () == -1)
|
||||
exit (1) ;
|
||||
|
||||
pinMode (1, PWM_OUTPUT) ;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
for (bright = 0 ; bright < 1024 ; ++bright)
|
||||
{
|
||||
pwmWrite (1, bright) ;
|
||||
delay (1) ;
|
||||
}
|
||||
|
||||
for (bright = 1023 ; bright >= 0 ; --bright)
|
||||
{
|
||||
pwmWrite (1, bright) ;
|
||||
delay (1) ;
|
||||
}
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* tone.c:
|
||||
* Test of the softTone module in wiringPi
|
||||
* Plays a scale out on pin 3 - connect pizeo disc to pin 3 & 0v
|
||||
*
|
||||
* Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
|
||||
***********************************************************************
|
||||
* This file is part of wiringPi:
|
||||
* https://projects.drogon.net/raspberry-pi/wiringpi/
|
||||
*
|
||||
* wiringPi is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wiringPi 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <wiringPi.h>
|
||||
#include <softTone.h>
|
||||
|
||||
#define PIN 3
|
||||
|
||||
int scale [8] = { 262, 294, 330, 349, 392, 440, 494, 525 } ;
|
||||
|
||||
int main ()
|
||||
{
|
||||
int i ;
|
||||
|
||||
if (wiringPiSetup () == -1)
|
||||
{
|
||||
fprintf (stdout, "oops: %s\n", strerror (errno)) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
softToneCreate (PIN) ;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
for (i = 0 ; i < 8 ; ++i)
|
||||
{
|
||||
printf ("%3d\n", i) ;
|
||||
softToneWrite (PIN, scale [i]) ;
|
||||
delay (500) ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user