V1 switch.c: Move duplicate code into function
This commit is contained in:
15
V1/switch.c
15
V1/switch.c
@@ -33,20 +33,23 @@ void freePin(char *pin)
|
||||
writeFile(BASEPATH "unexport", pin, strlen(pin));
|
||||
}
|
||||
|
||||
void setDirection(char *pin, char *direction, int dirlen)
|
||||
{
|
||||
char path[50];
|
||||
sprintf(path, BASEPATH GPIO_FOLDER "direction", pin);
|
||||
writeFile(path, direction, dirlen);
|
||||
}
|
||||
|
||||
void registerInput(char *pin)
|
||||
{
|
||||
registerPin(pin);
|
||||
char path[50];
|
||||
sprintf(path, BASEPATH GPIO_FOLDER "direction", pin);
|
||||
writeFile(path, "in", 2);
|
||||
setDirection(pin, "in", 2);
|
||||
}
|
||||
|
||||
void registerOutput(char *pin)
|
||||
{
|
||||
registerPin(pin);
|
||||
char path[50];
|
||||
sprintf(path, BASEPATH GPIO_FOLDER "direction", pin);
|
||||
writeFile(path, "out", 3);
|
||||
setDirection(pin, "out", 3);
|
||||
}
|
||||
|
||||
int readInput(char *pin)
|
||||
|
||||
Reference in New Issue
Block a user