Loading...
Pages: [1]   Go Down
Author Topic: Enumerator values to char*  (Read 202 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 142
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi I have an enumerator, and I want to print the names of the elements within the enumerator to my lcd.
i.e if you have
Code:
enum Enumerator{Word1, Word2, Word3};
My lcd uses this function to draw to the screen:
Code:
void draw(char* string) {
  // graphic commands to redraw the complete screen should be placed here 
  u8g.setFont(u8g_font_unifont);
  //u8g.setPrintPos(0, 20);

  u8g.drawStr( 0, 22, (char *) string);
}
It works if I pass it a string that is cast to char*.
I am trying to pass it the name of a value within the enumerator however likethis:
Code:
char* chord = "";
int navigator = 0;
word= (char*) Enumerator(navigator);
draw((char*)word);
The code compiles but nothing appears on my lcd. I want (in this case) Word1 to appear on the lcd so I was wondering is there another way to grab the name of the values in an enumerator?
Logged

Finland
Offline Offline
Sr. Member
****
Karma: 0
Posts: 270
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Enums don't work as you seem to think. Enums are more like named integer values. You should use an array of strings instead.
Logged

Pages: [1]   Go Up
Print
 
Jump to: