struct mit Arduino

OP #4798066
Lesenswert?

Hi!

Also, ich habe das ganze System von Structs noch nicht so ganz 
verstanden …
Soweit bin ich bis jetzt:

library.h
1
typedef struct
2
{
3
  uint8_t key;
4
  uint8_t status;
5
}
6
gk_t;
7

8
gk_t getKeys( void );

library.ccp
1
gk_t getKeys( void )
2
{
3
  gk_t gk;
4

5
  gk.key = 2;
6
  gk.status = 4;
7
  return( gk );
8
}

TestSketch.ino
1
Serial.println( getKeys().key );
2
// printet 2

Mein Problem ist, wie weise ich den gk.key und gk.status neue Werte 
innerhalb der ccp zu? Also in der Theorie so:

library.ccp
1
gk_t getKeys( void )
2
{
3
  gk_t gk;
4

5
  gk.key = 2;
6
  gk.status = 4;
7
  return( gk );
8
}
9

10
void library::key_status() 
11
{
12
if(a == b) {
13
getKeys().key = 12;
14
}
15
}

Das klappt nicht, und ich denke ich habe da etwas grundsätzlich nicht 
verstanden. Kann mir jemand helfen, bzw es mir erklären?

Grüße und Danke!

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren