jok3r
02.04.2014, 18:52
Ich versuche vergebens eine zwei dimensionales Array an eine Funktion zu übergeben.
void Pos_save(int *Position[][])
{
...........
.........
if (digitalRead(Taster1) == HIGH) //Speichern
{
for (int i = 0; i < 4 ; i++ )
{
Wire.beginTransmission(GeberAddr[i]);
Wire.write(255);
Wire.endTransmission();
Wire.requestFrom(GeberAddr[i], 2);
if (2 <= Wire.available())
{
byte MSB =Wire.read();
delay(1);
byte LSB =Wire.read();
Position[Pos_Display][i] = (MSB << 6) + LSB;
}
}
lcd.setCursor(4,1);
lcd.print(Position[Pos_Display][0]);
lcd.setCursor(14,1);
lcd.print(Position[Pos_Display][1]);
lcd.setCursor(4,2);
lcd.print(Position[Pos_Display][2]);
lcd.setCursor(14,2);
lcd.print(Position[Pos_Display][3]);
Position[Pos_Display][4] = Pos_Display; // Speichern von Pos
Position[Pos_Display][5] = Tool_Display; // Speichern von Tool
Position[Pos_Display][6] = Delay_Display; // Speichern von Delay
Position[Pos_Display][7] = Speed_Display; // Speichern von Speed
delay(2000);
lcd.clear();
Teachen_menue();
Pos_Display++;
lcd.setCursor(19, 3);
lcd.print(Pos_Display);
}
}
Deklariert ist dieses Array Global
und hier müsste ich darauf zugreifen können ->
void Automatik()
{
if (digitalRead(Taster1) == HIGH) // Taster 1(Start) Automatik Starten.
{
for (int Pos_Display = 0; Pos_Display <=6 ; Pos_Display++) // Fahre 6 Programme ab
{
do {
for (int i = 0; i < 4 ; i++ )
{
Wire.beginTransmission(GeberAddr[i]);
Wire.write(255);
Wire.endTransmission();
Wire.requestFrom(GeberAddr[i], 2);
byte MSB =Wire.read();
delay(1);
byte LSB =Wire.read();
IstPosition[i] = (MSB << 6) + LSB;
}
Stepperdelta0 = -( Position[Pos_Display][2]- IstPosition[2]);
Stepperdelta1 = -( Position[Pos_Display][3]- IstPosition[3]);
Stepperdelta2 = -( Position[Pos_Display][1]- IstPosition[1]);
Stepperdelta3 = -( Position[Pos_Display][0]- IstPosition[0]);
if( Stepperdelta0 > 50 | Stepperdelta0 < -50 ){
stepper0.setSpeed(-Stepperdelta0);
stepper0.runSpeed();
}
if( Stepperdelta1 > 50 | Stepperdelta1 < -50 ){
stepper1.setSpeed(Stepperdelta1);
stepper1.runSpeed();
}
if( Stepperdelta2 > 50 | Stepperdelta2 < -50 ){
stepper2.setSpeed(-Stepperdelta2);
stepper2.runSpeed();
}
if( Stepperdelta2 > 50 | Stepperdelta2 < -50 ){
stepper3.setSpeed(Stepperdelta3);
stepper3.runSpeed();
}
........................
............
......
}
Was muss ich da besonderes beachten ? Kann man das nicht ohne Pointer bewerkstellen ?
void Pos_save(int *Position[][])
{
...........
.........
if (digitalRead(Taster1) == HIGH) //Speichern
{
for (int i = 0; i < 4 ; i++ )
{
Wire.beginTransmission(GeberAddr[i]);
Wire.write(255);
Wire.endTransmission();
Wire.requestFrom(GeberAddr[i], 2);
if (2 <= Wire.available())
{
byte MSB =Wire.read();
delay(1);
byte LSB =Wire.read();
Position[Pos_Display][i] = (MSB << 6) + LSB;
}
}
lcd.setCursor(4,1);
lcd.print(Position[Pos_Display][0]);
lcd.setCursor(14,1);
lcd.print(Position[Pos_Display][1]);
lcd.setCursor(4,2);
lcd.print(Position[Pos_Display][2]);
lcd.setCursor(14,2);
lcd.print(Position[Pos_Display][3]);
Position[Pos_Display][4] = Pos_Display; // Speichern von Pos
Position[Pos_Display][5] = Tool_Display; // Speichern von Tool
Position[Pos_Display][6] = Delay_Display; // Speichern von Delay
Position[Pos_Display][7] = Speed_Display; // Speichern von Speed
delay(2000);
lcd.clear();
Teachen_menue();
Pos_Display++;
lcd.setCursor(19, 3);
lcd.print(Pos_Display);
}
}
Deklariert ist dieses Array Global
und hier müsste ich darauf zugreifen können ->
void Automatik()
{
if (digitalRead(Taster1) == HIGH) // Taster 1(Start) Automatik Starten.
{
for (int Pos_Display = 0; Pos_Display <=6 ; Pos_Display++) // Fahre 6 Programme ab
{
do {
for (int i = 0; i < 4 ; i++ )
{
Wire.beginTransmission(GeberAddr[i]);
Wire.write(255);
Wire.endTransmission();
Wire.requestFrom(GeberAddr[i], 2);
byte MSB =Wire.read();
delay(1);
byte LSB =Wire.read();
IstPosition[i] = (MSB << 6) + LSB;
}
Stepperdelta0 = -( Position[Pos_Display][2]- IstPosition[2]);
Stepperdelta1 = -( Position[Pos_Display][3]- IstPosition[3]);
Stepperdelta2 = -( Position[Pos_Display][1]- IstPosition[1]);
Stepperdelta3 = -( Position[Pos_Display][0]- IstPosition[0]);
if( Stepperdelta0 > 50 | Stepperdelta0 < -50 ){
stepper0.setSpeed(-Stepperdelta0);
stepper0.runSpeed();
}
if( Stepperdelta1 > 50 | Stepperdelta1 < -50 ){
stepper1.setSpeed(Stepperdelta1);
stepper1.runSpeed();
}
if( Stepperdelta2 > 50 | Stepperdelta2 < -50 ){
stepper2.setSpeed(-Stepperdelta2);
stepper2.runSpeed();
}
if( Stepperdelta2 > 50 | Stepperdelta2 < -50 ){
stepper3.setSpeed(Stepperdelta3);
stepper3.runSpeed();
}
........................
............
......
}
Was muss ich da besonderes beachten ? Kann man das nicht ohne Pointer bewerkstellen ?