cava with pipe, and template

This commit is contained in:
Nathan GOUARDERES
2021-07-30 10:59:34 +02:00
parent 7117cbbe4c
commit 6add75c64e
12 changed files with 378 additions and 85 deletions

View File

@@ -1,11 +1,37 @@
/** \file rpi_selector.c
* \brief This module is used to manage selector on gpio
*/
/***************************************************************************************************
* Includes
**************************************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <wiringPi.h>
/***************************************************************************************************
* Preprocessor Constants and Macros
**************************************************************************************************/
/***************************************************************************************************
* Type and Contant Definitions
**************************************************************************************************/
unsigned const selectorPinNumber = 4;
/* TODO use GPIO function from ../gpio/gipo.h (same pin number) */
int selectorPins[4] = {5, 6, 26, 27};
void setup_selector() {
/***************************************************************************************************
* Persistent Variables
**************************************************************************************************/
/***************************************************************************************************
* Internal Function Prototypes
**************************************************************************************************/
/***************************************************************************************************
* External Function Definitions
**************************************************************************************************/
void selector_setup() {
wiringPiSetupGpio();
for (size_t i = 0; i < selectorPinNumber; ++i) {
@@ -14,7 +40,7 @@ void setup_selector() {
}
}
int get_selector_position() {
int selector_get_position() {
for (size_t i = 0; i < selectorPinNumber; ++i) {
if (digitalRead(selectorPins[i])) {
return i;
@@ -23,10 +49,14 @@ int get_selector_position() {
return -1;
}
void print_selector() {
void selector_print() {
char modeStr[] = "0 | 0 | 0 | 0 \n";
for (size_t i = 0; i < selectorPinNumber; ++i) {
modeStr[i * 4] = digitalRead(selectorPins[i]) ? '1' : '0';
}
printf(modeStr);
}
fprintf(stderr, modeStr);
}
/***************************************************************************************************
* Internal Function Definitions
**************************************************************************************************/

View File

@@ -1,10 +1,40 @@
/** \file rpi_selector.h
* \brief This module is used to manage selector on gpio
*/
/***************************************************************************************************
* Includes
**************************************************************************************************/
#if !defined(__RPI_SELECTOR_H__)
#define __RPI_SELECTOR_H__
void setup_selector();
/***************************************************************************************************
* Preprocessor Constants and Macros
**************************************************************************************************/
int get_selector_position();
/***************************************************************************************************
* Type and Contant Definitions
**************************************************************************************************/
void print_selector();
/***************************************************************************************************
* Global Variables
**************************************************************************************************/
/***************************************************************************************************
* External Function Prototypes
**************************************************************************************************/
/**
* \brief setup the selector module
**/
void selector_setup();
/**
* \brief get the selector position
**/
int selector_get_position();
/**
* \brief debug: print the selector position
**/
void selector_print();
#endif /* __RPI_SELECTOR_H__ */