1 year ago

#373853

test-img

Penescu Vlad

How this enum syntax works

I am trying to build a game for Arduino, so I searched for a starting point and got to this syntax:

enum DisplayItem upperItem = (DisplayItem)((graphicRam[x/(8/2)][y*2]>>((x%(8/2))*2))&0x3);

where I have the enum variable with it's states:

enum DisplayItem {GRAPHIC_ITEM_NONE, GRAPHIC_ITEM_A, GRAPHIC_ITEM_B, GRAPHIC_ITEM_NUM};

The ((graphicRam[x/(8/2)][y*2]>>((x%(8/2))*2))&0x3) part is from the rest of the code and I think it can be treated as a simple integer. My question is how (DisplayItem)(something) works? I've tried to run a simpler code but this syntax (enum variable)(x) just give me an error.

syntax

arduino

enumeration

arduino-c++

0 Answers

Your Answer

Accepted video resources