ошибки где их быть не должно

cheshire
cheshire аватар
Offline
Зарегистрирован: 11.07.2014

Написал программу, вроде ошибок не должно быть, но когда компелирую то я получаю 2 ошибки, которых вроде как быть не должно.

вот код

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const int buttonPinLeft = 13;      //  Up button
const int buttonPinRight = 8;     //  Down button
const int buttonPinEsc = 7;       // Esc button
const int buttonPinEnter = 6;     //  Enter button
int uwPinPWM = 10;
int uaPinPWM = 9; 
int lastButtonPushed = 0;
int lastButtonEnterState = LOW; 
int lastButtonEscState = LOW; 
int lastButtonLeftState = LOW; 
int lastButtonRightState = LOW; 
long lastEnterDebounceTime = 0;
long lastEscDebounceTime = 0; 
long lastLeftDebounceTime = 0; 
long lastRightDebounceTime = 0;
long debounceDelay = 150; 
int A ;
int reading;
int toleranz;
int schaltzeit;
int gang;

#define MAXSIZE 21

typedef struct gang_s
{
    unsigned int gUw;
    unsigned int gUa;
    int pwmua;
} gang_s;

gang_s jetzt;
gang_s solljetzt;
gang_s erster[MAXSIZE]  = {{2125,2500,128},{2125,2575,132},{2125,2650,136},{2125,2725,140},{2125,2800,144},{2125,2875,148},{2125,2950,152},{2125,3025,156},{2125,3100,160},{2125,3175,164},{2125,3250,168},{2125,3325,172},{2125,3400,176},{2125,3475,180},{2125,3550,184},{2125,3625,188},{2125,3700,192},{2125,3775,196},{2125,3850,200},{2125,3925,202},{2125,4000,204}};
gang_s zweiter[MAXSIZE] = {{2125,2500,128},{2125,2425,124},{2125,2350,120},{2125,2275,116},{2125,2200,112},{2125,2125,108},{2125,2050,104},{2125,1975,100},{2125,1900,96},{2125,1825,92},{2125,1750,88},{2125,1675,84},{2125,1600,80},{2125,1525,76},{2125,1450,72},{2125,1375,68},{2125,1300,64},{2125,1225,60},{2125,1150,56},{2125,1075,52},{2125,1000,51}};
gang_s neutral = {2125,2500};


  
void setup() {
  pinMode(buttonPinLeft, INPUT);
  pinMode(buttonPinRight, INPUT);
  pinMode(buttonPinEnter, INPUT);
  pinMode(buttonPinEsc, INPUT);
  pinMode(uwPinPWM, OUTPUT);
  pinMode(uaPinPWM, OUTPUT);
  lcd.begin(16, 4);
  lcd.clear();
  A = 0;  
  gang = 0;
  gang_s jetzt = { 2125,2500,128 };
  analogWrite(uwPinPWM, 108); 
  analogWrite(uaPinPWM, jetzt.pwmua);
  toleranz=1;
  schaltzeit = 100;
}

void loop() {
  switch(A){
  case 0:
    lcd.setCursor(0, 0);
    lcd.print(jetzt.gUw);
    lcd.setCursor(0,1);
    lcd.print(jetzt.gUa);
    lcd.setCursor(0,2);
  if ((jetzt.gUw=2125) && (jetzt.gUa>=3000)) {
    lcd.print("Gang: 1");
  }
  else if((jetzt.gUw=2125) && (jetzt.gUa<=2000)) {
    lcd.print("Gang: 2");
  }
  else{
    lcd.print("Gang: N");
  }
  break; 
  case 10:  
    lcd.setCursor(0, 0);
    lcd.print("> T: Ideal");
    lcd.setCursor(0,1);
    lcd.print("  T: +5%");
    lcd.setCursor(0,2);
    lcd.print("  T: -5%");
    lcd.setCursor(0,3);
    lcd.print("  T: +10%");
    break;
  case 20:
    lcd.setCursor(0,0);
    lcd.print("  T: Ideal");
    lcd.setCursor(0,1);
    lcd.print("> T: +5%");
    lcd.setCursor(0,2);
    lcd.print("  T: -5%");
    lcd.setCursor(0,3);
    lcd.print("  T: +10%");
    break;
  case 30:
    lcd.setCursor(0,0);
    lcd.print("  T: Ideal");
    lcd.setCursor(0,1);
    lcd.print("  T: +5%");
    lcd.setCursor(0,2);
    lcd.print("> T: -5%");
    lcd.setCursor(0,3);
    lcd.print("  T: +10%");
    break;
  case 40:
    lcd.setCursor(0,0);
    lcd.print("  T: +5%");
    lcd.setCursor(0,1);
    lcd.print("  T: -5%");
    lcd.setCursor(0,2);
    lcd.print("> T: +10%");
    lcd.setCursor(0,3);
    lcd.print("  T: -10%");
    break;
  case 50:	  
    lcd.setCursor(0,0);
    lcd.print("  T: +5%");
    lcd.setCursor(0,1);
    lcd.print("  T: -5%");
    lcd.setCursor(0,2);
    lcd.print("  T: +10%");
    lcd.setCursor(0,3);
    lcd.print("> T: -10%");
    break;
  case 11:  
    lcd.setCursor(0, 0);
    lcd.print("> auf 1.Gang");
    lcd.setCursor(0,1);
    lcd.print("  auf 2.Gang");
    lcd.setCursor(0,2);
  case 12:
    lcd.setCursor(0,0);
    lcd.print("  auf 1.Gang");
    lcd.setCursor(0,1);
    lcd.print("> auf 2.Gang");
    lcd.setCursor(0,2);
    break;
  case 110:
    lcd.setCursor(0,0);
    lcd.print("  Schaltzeit:");
    lcd.setCursor(0,1);
    lcd.print(schaltzeit);
    lcd.setCursor(0,2);
    break;
  default:
    lcd.setCursor(0,0);
    lcd.print("Glückwunsch!");
    lcd.setCursor(0,1);
    lcd.print("Du hast das Pro-");
    lcd.setCursor(0,2);
    lcd.print("gramm kaputt");
    lcd.setCursor(0,3);
    lcd.print("gemacht! :-D");
    break;
  }


  int buttonEnterState=LOW;            
  int buttonEscState=LOW;            
  int buttonLeftState=LOW;            
  int buttonRightState=LOW;  
  reading = digitalRead(buttonPinEnter);
  if (reading != lastButtonEnterState) {
    lastEnterDebounceTime = millis();
  }
  if ((millis() - lastEnterDebounceTime) > debounceDelay) {
    buttonEnterState=reading;
    lastEnterDebounceTime=millis();
  }
  lastButtonEnterState = reading;
  reading = digitalRead(buttonPinEsc);
  if (reading != lastButtonEscState) {
    lastEscDebounceTime = millis();
  }
  if ((millis() - lastEscDebounceTime) > debounceDelay) {
    buttonEscState = reading;
    lastEscDebounceTime=millis();
  }
  lastButtonEscState = reading;
  reading = digitalRead(buttonPinRight);
  if (reading != lastButtonRightState) {
    lastRightDebounceTime = millis();
  }
  if ((millis() - lastRightDebounceTime) > debounceDelay) {
    buttonRightState = reading;
    lastRightDebounceTime =millis();
  }
  lastButtonRightState = reading;   
  reading = digitalRead(buttonPinLeft);
  if (reading != lastButtonLeftState) {
    lastLeftDebounceTime = millis();
  }
  if ((millis() - lastLeftDebounceTime) > debounceDelay) {
    buttonLeftState = reading;
    lastLeftDebounceTime=millis();
  }
  lastButtonLeftState = reading; 
  if (buttonEnterState==HIGH){
    lastButtonPushed=buttonPinEnter;
  }
  else if(buttonEscState==HIGH){
    lastButtonPushed=buttonPinEsc;
  }
  else if(buttonRightState==HIGH){
    lastButtonPushed=buttonPinRight;
  }
  else if(buttonLeftState==HIGH){
    lastButtonPushed=buttonPinLeft;
  }
  else{
    lastButtonPushed=0;
  }

  //////////////////////////////  Taster  ///////////////////////////////////
  //menu key down 

  if (buttonRightState==HIGH ) {
    if((A == 10) || (A == 20) || (A == 30)|| (A == 40)) {
      A = A + 10;
    }
    else if(A == 11) {
      A = A + 1;
    }
     else if(A == 110){
      schaltzeit = schaltzeit + 100;  
     }
  }
  //menu key up
  if (buttonLeftState==HIGH) {
    if((A == 20) || (A == 30) || (A == 40)|| (A == 50)) {
      A = A - 10;
    }
    else if((A == 12)) {
      A = A - 1;
    }
     else if( A == 110 ){
     schaltzeit = schaltzeit - 100;
     }
  }

  //menu key ok
  if (buttonEnterState==HIGH) {
    switch(A){
    case 10:
      toleranz=1;
      A=11;
      break;

    case 20:
      toleranz= 5;
      A=11;
      break;

    case 30:
      toleranz= -5;
      A=11;
      break;

    case 40:
      toleranz=10;
      A=11;
      break;

    case 50:
      toleranz=-10;
      A=11;
      break;
      
    case 11:
      gang = 1;
      A=110;
      break;

    case 12:
      gang = 2;
      A=110;
      break;
     
     case 110:
         switch(gang){
          
         case 1:

         jetzt = umschaltfkt(zweiter, neutral, erster, schaltzeit, toleranz);

         break;
         
         case 2:
         
         jetzt = umschaltfkt(erster, neutral, zweiter, schaltzeit, toleranz);
         
         break;
         
         default:
         break;
         }
         A==0;
     break;

    default:
      A=10;
      break;    
    }
  }
  //menu key ESC
  if ( buttonEscState==HIGH) { 
    if((A == 11) || (A == 12)) {
      A = 10;
    } 
    else if(A > 100) {
      A = 11;
    }
    else if((A == 20) || (A == 30) || (A == 40) || (A == 50)) {
      A = 10;
    }
    else if(A == 110) {
      A = 11;
    }
  

}
  if ((buttonLeftState==HIGH) && (buttonRightState==HIGH)) {
  A=10;
  }
}
 
  gang_s umschaltfkt( gang_s j[], gang_s n[], gang_s w[], int t, int tol )
  {
    int a;
    int b;
    for( a = 20; a > 0; a--)
    {
      lcd.setCursor(0, 0);
      lcd.print((j[a].gUw + ((j[a].gUw*tol)/100)));
      lcd.setCursor(0,1);
      lcd.print((j[a].gUa + ((j[a].gUa*tol)/100)));
      analogWrite(uaPinPWM, ((j[a].pwmua + ((j[a].pwmua*tol)/100))));
      delay(t/42);
    }
    
    for( b = 0; b < 20; b++){
      lcd.setCursor(0, 0);
      lcd.print(w[b].gUw);
      lcd.setCursor(0,1);
      lcd.print(w[b].gUa);
      analogWrite(uaPinPWM, j[b].pwmua);
      delay(t/42);
    }
  return w[20];
 }


в конце ошибка test:6: error: 'gang_s does not name a type
и test:289: error: 'umschaltfkt' was not declared in this scope

не понимаю из-за чего эти ошибки появились ведь вроде структура декларирована правилно и функ. тоже есть. я уже отчаился тут с этой программой =( помогите

зарание спасибо!

 

cheshire
cheshire аватар
Offline
Зарегистрирован: 11.07.2014

ооок ошибка нашлась, извинияюсь за глупость