You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
813 B
C++
39 lines
813 B
C++
void GPIO_setup(){
|
|
for (int i = 0; i < Size_DI; i++) {
|
|
pinMode(DiPin[i], INPUT);
|
|
}
|
|
for (int i = 0; i < Size_DO; i++) {
|
|
pinMode(DoPin[i], OUTPUT);
|
|
}
|
|
|
|
analogReference(EXTERNAL);
|
|
}
|
|
|
|
void read_analog(){
|
|
int i = 0;
|
|
|
|
for(i = 0 ; i < Size_AI ; i++){
|
|
Values_AI[i] = analogRead(AiPin[i]);
|
|
|
|
/*
|
|
for(int j = 0; j < AI_AVG_SIZE - 1; j++) {
|
|
Recent_AI[i][j] = Recent_AI[i][j + 1];
|
|
}
|
|
Recent_AI[i][AI_AVG_SIZE - 1] = Values_AI[i];
|
|
*/
|
|
// 현재 인덱스 위치에 값을 저장
|
|
Recent_AI[i][index_AI] = Values_AI[i];
|
|
}
|
|
// 인덱스를 증가시키고, 필요한 경우 순환
|
|
index_AI = (index_AI + 1) % AI_AVG_SIZE;
|
|
}
|
|
|
|
void read_digital(){
|
|
int i = 0;
|
|
|
|
Values_DI = 0;
|
|
for(i = 0 ; i < Size_DI ; i++){
|
|
bitWrite(Values_DI, i, digitalRead(DiPin[i]));
|
|
}
|
|
}
|