// HELPFULL PIN MAPPING AND FUNCTION DIAGRAM
//
// SW PIN HW PIN SW PIN
// +-----+-----+----------+------+---+-NanoPi-NEO--+------+----------+-----+-----+
// | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
// +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
// | | | 3.3V | | | 1 || 2 | | | 5V | | |
// | 12 | 8 | GPIOA12 | OUT | 1 | 3 || 4 | | | 5V | | |
// | 11 | 9 | GPIOA11 | ALT5 | 0 | 5 || 6 | | | 0v | | |
// | 203 | 7 | GPIOG11 | OUT | 0 | 7 || 8 | 0 | ALT5 | GPIOG6 | 15 | 198 |
// | | | 0v | | | 9 || 10 | 0 | ALT5 | GPIOG7 | 16 | 199 |
// | 0 | 0 | GPIOA0 | ALT5 | 0 | 11 || 12 | 1 | OUT | GPIOA6 | 1 | 6 |
// | 2 | 2 | GPIOA2 | OFF | 0 | 13 || 14 | | | 0v | | |
// | 3 | 3 | GPIOA3 | OFF | 0 | 15 || 16 | 0 | OFF | GPIOG8 | 4 | 200 |
// | | | 3.3v | | | 17 || 18 | 0 | OFF | GPIOG9 | 5 | 201 |
// | 64 | 12 | GPIOC0 | OUT | 1 | 19 || 20 | | | 0v | | |
// | 65 | 13 | GPIOC1 | OUT | 0 | 21 || 22 | 0 | ALT5 | GPIOA1 | 6 | 1 |
// | 66 | 14 | GPIOC2 | ALT4 | 0 | 23 || 24 | 1 | OUT | GPIOC3 | 10 | 67 |
// +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
#include <stdlib.h>
#include <wiringPi.h>
#define RESET "\033[0m"
#define GREEN "\033[32m"
int main(void)
{
int input ;
int z = 0 ;
char a[100] = "Nothing" ;
wiringPiSetup() ;
pinMode (7, OUTPUT) ;
for(;;)
{
system("clear");
printf("<1> Antenna ON (powered), <2> Antenna Attenuate -20db (powered), <3> Rest -80db (unpowered) \n");
printf("<4> Exit ON (powered), <5> Exit Attenuate -20db (powered), <6> Exit -80db (unpowered) \n");
printf("You last entered: " GREEN "%i %s " RESET, z, a) ;
scanf("%d", &input);
if (input == 1)
{
z = 1 ;
strcpy( a, "Antenna ON (powered)") ;
digitalWrite(7, HIGH) ;
digitalWrite(1, LOW) ;
}
else if (input == 2)
{
z = 2 ;
strcpy( a, "Antenna Attenuate -20db (powered)") ;
digitalWrite(7, LOW) ;
digitalWrite(1, HIGH) ;
}
else if (input == 3)
{
z = 3 ;
strcpy( a, "Rest -80db (unpowered)") ;
digitalWrite(7, LOW) ;
digitalWrite(1, LOW) ;
}
else if (input == 4)
{
printf( GREEN "EXIT Antenna ON (powered)\n" RESET);
digitalWrite(7, HIGH) ;
digitalWrite(1, LOW) ;
return 0;
}
else if (input == 5)
{
printf( GREEN "EXIT Antenna Attenuate -20db (powered)\n" RESET);
digitalWrite(7, LOW) ;
digitalWrite(1, HIGH) ;
return 0;
}
else if (input == 6)
{
printf( GREEN "EXIT Rest -80db (unpowered)\n" RESET);
digitalWrite(7, LOW) ;
digitalWrite(1, LOW) ;
return 0;
}
}
}