-
Notifications
You must be signed in to change notification settings - Fork 2
/
input.cpp
32 lines (28 loc) · 888 Bytes
/
input.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//#include<stm32f10x.h>
//#include<stm32f10x_adc.h>
//#include<stm32f10x_gpio.h>
#include "input.h"
#include "hardware.h"
#include "config.h"
const uint16_t butEqPin[] = { GPIO_Pin_8, GPIO_Pin_12, GPIO_Pin_14, GPIO_Pin_15, GPIO_Pin_13, GPIO_Pin_0 };
const GPIO_Def * butEqPort[] = { H_GPIOA, H_GPIOA, H_GPIOC, H_GPIOC, H_GPIOC, H_GPIOA };
bool Input::getState(uint8_t button){
if (button <= 5){
return (butEqPort[button]->IDR & butEqPin[button]) == 0;
}
return false;
}
short int Input::getXAxis(){
int counter = 0;
for (int i = 0; i < 8; i++){
counter += getAdcValueForXAxis();
}
return (sysConfig.invertAxisX) ? (counter >> 3) * -1 : counter >> 3;
}
short int Input::getYAxis(){
int counter = 0;
for (int i = 0; i < 8; i++){
counter += getAdcValueForYAxis();
}
return (sysConfig.invertAxisY) ? (counter >> 3) * -1 : counter >> 3;
}