18-02-2019, 17:48
Witam, ściagnąłem z innternetu kod który słuzy mi do odczytywania i pokazywanie wartosći pracy silnika. Przełączanie poszczególnych wartosci odbywa sie za pomocą przycisku. Jestem słaby w programowaniu, ale starałem sie zmienic to na komende (INPUT_PULLUP), jednak sie nie udało. Chciałbym, zeby poszczegolna komenda sie przełączała za pomocą dwoch przycisków, prosze o pomoc. KOD:
Cały program: https://github.com/ibanezgomez/FISBlocks
Kod:
// Will return:
// 0 - Nothing
// 1 - Key Up pressed
// 2 - Key Down pressed
int getKeyStatusRandom(){
int key1=random(0,2);
int key2=random(0,2);
if(key1 == 1 && key2 == 0) return 1;
if(key1 == 0 && key2 == 1) return 2;
if(key1 == 0 && key2 == 0) return 0;
if(key1 == 1 && key2 == 1){
if(random(0,2)==1) return 1;
else return 2;
}
}
// 0 - Nothing
// 1 - Up
// 2 - Down
void refreshParams(int type){
if(type==1){
if(currentSensor < nSensors -1) currentSensor++;
else{
currentSensor=0;
if(currentGroup < (currentModule->ngroups) - 1) currentGroup++;
else{
if(currentModule->addr == ADR_Dashboard) currentModule=modules[1];
else currentModule=modules[0];
currentGroup=0;
kwp.disconnect();
}
}
}
else if(type==2){
if(currentSensor > 0) currentSensor--;
else{
currentSensor=nSensors-1;
if(currentGroup > 0) currentGroup--;
else{
if(currentModule->addr == ADR_Dashboard) currentModule=modules[1];
else currentModule=modules[0];
currentGroup=currentModule->ngroups-1;
kwp.disconnect();
}
}
}
}
Cały program: https://github.com/ibanezgomez/FISBlocks