70 lines
1.3 KiB
C
70 lines
1.3 KiB
C
#ifndef _OLR_CONTROLLER_LIB_h
|
|
#define _OLR_CONTROLLER_LIB_h
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"{
|
|
#endif
|
|
|
|
#include "Arduino.h"
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
extern int DIGITAL_CTRL[]; // Global Array containig PINs used for the Digital Controllers (ex: Push Buttons)
|
|
|
|
|
|
#define DIG_CTRL_1_PIN A2 // switch player 1 to PIN and GND
|
|
#define DIG_CTRL_2_PIN A0 // switch player 2 to PIN and GND
|
|
#define DIG_CTRL_3_PIN A3 // switch player 3 to PIN and GND
|
|
#define DIG_CTRL_4_PIN A1 // switch player 4 to PIN and GND
|
|
|
|
|
|
|
|
enum ctr_idx { // Used to access controller by "name" (and not via zero-offset index)
|
|
CTRL_1 = 0, // Ex: DIGITAL_CTRL[CTRL_2]
|
|
CTRL_2 ,
|
|
CTRL_3 ,
|
|
CTRL_4
|
|
};
|
|
|
|
|
|
|
|
|
|
#define PIN_VCC_ADC1 6
|
|
#define PIN_VCC_ADC2 7
|
|
|
|
enum ctr_type {
|
|
NOT_DEFINED = 0,
|
|
DIGITAL_MODE,
|
|
ANALOG_MODE,
|
|
DEMO_MODE,
|
|
};
|
|
|
|
typedef struct{
|
|
enum ctr_type mode;
|
|
int pin;
|
|
int adc;
|
|
int badc;
|
|
int delta_analog;
|
|
byte flag_sw;
|
|
}controller_t;
|
|
|
|
void controller_setup( void );
|
|
|
|
void controller_init( controller_t* ct, enum ctr_type mode, int pin );
|
|
|
|
byte controller_getStatus( controller_t* ct );
|
|
|
|
float controller_getSpeed( controller_t* ct );
|
|
|
|
float controller_getAccel ( void );
|
|
|
|
bool controller_isActive( int pin );
|
|
|
|
|
|
#ifdef __cplusplus
|
|
} // extern "C"
|
|
#endif
|
|
|
|
#endif
|
|
|