display funcs
This commit is contained in:
1 parent
44350539b2
commit
692f0b11c4
1 file changed
+34
-22
@@ -16,15 +16,20 @@ void get_all(int *a) {
|
||||
}
|
||||
|
||||
void print_all_quiet(int *a) {
|
||||
for (int i = 1; i <= 31; i++) {
|
||||
if (i % 10) {
|
||||
printf("%d ", a[i]);
|
||||
} else if (i == 30) {
|
||||
printf("%d ", a[i]);
|
||||
} else {
|
||||
putchar('\n');
|
||||
}
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
printf("%d ", a[i]);
|
||||
}
|
||||
putchar('\n');
|
||||
|
||||
for (int i = 11; i <= 20; i++) {
|
||||
printf("%d ", a[i]);
|
||||
}
|
||||
putchar('\n');
|
||||
|
||||
for (int i = 21; i <= 31; i++) {
|
||||
printf("%d ", a[i]);
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
void print_all_oneline(int *a) {
|
||||
@@ -34,13 +39,32 @@ void print_all_oneline(int *a) {
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
void print_all_pretty(int *a) {
|
||||
printf("Pins 01-10\t");
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
printf("%d ", a[i]);
|
||||
}
|
||||
|
||||
printf("\nPins 11-20\t");
|
||||
for (int i = 11; i <= 20; i++) {
|
||||
printf("%d ", a[i]);
|
||||
}
|
||||
|
||||
printf("\nPins 21-30\t");
|
||||
for (int i = 21; i <= 30; i++) {
|
||||
printf("%d ", a[i]);
|
||||
}
|
||||
|
||||
printf("\nPin 31:\t\t%d\n", a[31]);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/*
|
||||
* pins[] array: GPIO pins only, input only; using WiringPi num scheme
|
||||
* 0: placeholder
|
||||
* 1-31: WiringPi 1-31
|
||||
*/
|
||||
int pins[31];
|
||||
int pins[32];
|
||||
int pin;
|
||||
|
||||
wiringPiSetupPinType(WPI_PIN_WPI);
|
||||
@@ -49,19 +73,7 @@ int main(int argc, char *argv[]) {
|
||||
switch (argc) {
|
||||
case 1: // print everything
|
||||
get_all(pins);
|
||||
printf("Pins 1-10:\n\t");
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
printf("%d ", pins[i]);
|
||||
}
|
||||
printf("\nPins 11-20:\n\t");
|
||||
for (int i = 11; i <= 20; i++) {
|
||||
printf("%d ", pins[i]);
|
||||
}
|
||||
printf("\nPins 21-30:\n\t");
|
||||
for (int i = 21; i <= 30; i++) {
|
||||
printf("%d ", pins[i]);
|
||||
}
|
||||
putchar('\n');
|
||||
print_all_pretty(pins);
|
||||
break;
|
||||
case 2: // print 1 pin
|
||||
pin = atoi(argv[1]);
|
||||
|
||||
Reference in new issue
Block a user