eBoard ๐Ÿ‰  โ‘ โ‘งโ‘จ
Written for SIA 2017/2018
eagle_I2CInOut.h
Go to the documentation of this file.
1 #ifndef EAGLE_EBOARD_HELPLIB_I2CINOUT
2 #define EAGLE_EBOARD_HELPLIB_I2CINOUT
3  //To avoid not_found issues
5  #define DIGITAL_IN 0x0
6  #define DIGITAL_IN_INV 0x1
8  #define DIGITAL_IN_PULLUP 0x2
10  #define DIGITAL_IN_PULLUP_INV 0x3
12  #define DIGITAL_OUT 0x4
14  #define DIGITAL_OUT_INV 0x5
16  #define DIGITAL_OUT_LOW 0x6
18  #define DIGITAL_OUT_HIGH 0x7
20  #define ANALOG_IN_8_BIT 0x8
22  #define ANALOG_IN_10_BIT 0x9
24  #define ANALOG_IN_MEAN_8_BIT 0xA
26  #define ANALOG_IN_MEAN_10_BIT 0xB
28  #define COUNTER_8_BIT 0xC
30  #define COUNTER_16_BIT 0xD
32  #define COUNTER_RISE_8_BIT 0xE
34  #define COUNTER_RISE_16_BIT 0xF
36  #define PWM_SLOW 0x8
38  #define PWM_FAST 0x9
40  #define FREQ_LOW 0xA
42  #define FREQ_HIGH 0xB
44  #define COUNTER_B_DIR 0xC
46  #define COUNTER_B_DIR_PULLUP 0xD
48  #define COUNTER_MEAN_8_BIT 0xE
50  #define COUNTER_MEAN_16_BIT 0xF
52 
76  struct I2CInOut{
83  #if EBOARD_USE_UTILITY > 0x0
84  inline void read(void);
87  inline void changeAddress(optVAL_t);
89  inline void changeModes(optVAL_t,optVAL_t,optVAL_t);
90  #endif
91 
95  inline void write(void);
96 
98  optVAL_t A; //if you've used uint16_t values you'll have to replace it here
99  //we only have B - DiOut and C - AO [OUT]
104  };
107  this->A=0x0;this->B=0x0;this->C=0x0;
108  }
109  #if EBOARD_USE_UTILITY > 0x0
110  void I2CInOut::read(void) {}
111  void I2CInOut::changeAddress(optVAL_t){}
112  void I2CInOut::changeModes(optVAL_t,optVAL_t,optVAL_t) {}
113  #endif
114  void I2CInOut::write(void){
115  setPin(PIN_MOTOR_DIR,((this->B)!=0x0));
116  writePWM(this->C);
117  }
119 #endif
void writePWM(optVAL_t val)
write a clamped pwm value to an output pin
optVAL_t C
storing value for C-pin [MOTOR SPE]
[COPY&PASTE] This is the SoccerBoard ghost struct :D
void write(void)
this will write values stored in B and C
optVAL_t B
storing value for B-pin [MOTOR DIR]
I2CInOut(SoccerBoard &, optVAL_t, optVAL_t, optVAL_t, optVAL_t)
The constructor.
#define PIN_MOTOR_DIR
Definition: eBoard.h:420
[COPY&PASTE] This is the I2CInOut ghost struct :D
int optVAL_t
Definition: eBoard.h:196
optVAL_t A
storing value for A-pin (๐Ÿ”ง I prevent errors!)