Click here to Skip to main content
15,886,873 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionSDI Project Question Pin
Arrin23-Jun-15 9:00
Arrin23-Jun-15 9:00 
SuggestionRe: SDI Project Question Pin
David Crow23-Jun-15 9:50
David Crow23-Jun-15 9:50 
GeneralRe: SDI Project Question Pin
Arrin23-Jun-15 12:21
Arrin23-Jun-15 12:21 
QuestionUse #define or enum in switch() case(s) ? Pin
Vaclav_22-Jun-15 5:40
Vaclav_22-Jun-15 5:40 
AnswerRe: Use #define or enum in switch() case(s) ? Pin
PIEBALDconsult22-Jun-15 5:51
mvePIEBALDconsult22-Jun-15 5:51 
AnswerRe: Use #define or enum in switch() case(s) ? Pin
Jochen Arndt22-Jun-15 6:51
professionalJochen Arndt22-Jun-15 6:51 
AnswerRe: Use #define or enum in switch() case(s) ? Pin
Albert Holguin22-Jun-15 9:49
professionalAlbert Holguin22-Jun-15 9:49 
AnswerRe: Use #define or enum in switch() case(s) ? Pin
Vaclav_22-Jun-15 15:42
Vaclav_22-Jun-15 15:42 
<pre lang="Thanks for all replies, I have implemented basic code in SAM3x8E processor - Arduino Due and it works as expected
Thanks

// test input assigment array
#define MAX_INPUT 32
int Input[MAX_INPUT] = {42, 2, 3, 4, 6, 7, 8}; // TODO assign real
volatile byte bInputStateArray[MAX_INPUT]; // state machine array

// test using enum
enum State
{
LED_on,
LED_off,
TEST
};

volatile enum State State_Array[MAX_INPUT];


do
{
switch (State_Array[iInputPin])
{
case LED_on:
{
#ifdef DEBUG
#ifdef LCD_OUTPUT
Utility_LCD_Process("case LED_on ");
#endif
#endif
State_Array[iInputPin] = LED_off;
break;
}
case LED_off:
{
#ifdef DEBUG
#ifdef LCD_OUTPUT
Utility_LCD_Process("case LED_off ");
#endif
#endif
State_Array[iInputPin] = TEST; // illegal case test
break;
}

case NOT_IMPLEMENTED:
{
#ifdef DEBUG
#ifdef LCD_OUTPUT
Utility_LCD_Process("case LED_off ");
#endif
#endif
State_Array[iInputPin] = TEST; // illegal case test
break;
}



default:
#ifdef DEBUG
#ifdef LCD_OUTPUT
Utility_LCD_Process("Invalid case ");
#endif
#endif
}
} while (true);

"></pre>

One more question - since the state is changed using interrupt it needs to be declared as volatile.It compiles with "volatile enum..." so it should be correct syntax, but I cannot test it as yet - the hardware is not ready, but I will try to emulate the interrupt.
AM I on the right track?

-- modified 22-Jun-15 21:55pm.
GeneralRe: Use #define or enum in switch() case(s) ? Pin
Frankie-C22-Jun-15 22:44
Frankie-C22-Jun-15 22:44 
GeneralRe: Use #define or enum in switch() case(s) ? Pin
Vaclav_23-Jun-15 4:44
Vaclav_23-Jun-15 4:44 
AnswerRe: Use #define or enum in switch() case(s) ? Pin
Albert Holguin24-Jun-15 12:12
professionalAlbert Holguin24-Jun-15 12:12 
GeneralRe: Use #define or enum in switch() case(s) ? Pin
Vaclav_26-Jun-15 5:25
Vaclav_26-Jun-15 5:25 
GeneralRe: Use #define or enum in switch() case(s) ? Pin
Albert Holguin26-Jun-15 10:16
professionalAlbert Holguin26-Jun-15 10:16 
GeneralJust released the latest version of my open source project... Pin
Corvusoft21-Jun-15 4:30
Corvusoft21-Jun-15 4:30 
GeneralRe: Just released the latest version of my open source project... Pin
CPallini21-Jun-15 21:37
mveCPallini21-Jun-15 21:37 
GeneralRe: Just released the latest version of my open source project... Pin
Corvusoft21-Jun-15 21:50
Corvusoft21-Jun-15 21:50 
GeneralRe: Just released the latest version of my open source project... Pin
CPallini22-Jun-15 2:04
mveCPallini22-Jun-15 2:04 
GeneralRe: Just released the latest version of my open source project... Pin
Corvusoft21-Jun-15 21:52
Corvusoft21-Jun-15 21:52 
QuestionUpdatePanningFeedback() moves entire application window Pin
bob1697220-Jun-15 3:05
bob1697220-Jun-15 3:05 
QuestionDoubt Pin
Member 1177902719-Jun-15 16:38
Member 1177902719-Jun-15 16:38 
AnswerRe: Doubt Pin
Richard MacCutchan19-Jun-15 21:13
mveRichard MacCutchan19-Jun-15 21:13 
GeneralRe: Doubt Pin
Member 1177902720-Jun-15 21:07
Member 1177902720-Jun-15 21:07 
QuestionRe: Doubt Pin
Richard MacCutchan20-Jun-15 21:14
mveRichard MacCutchan20-Jun-15 21:14 
AnswerRe: Doubt Pin
Member 1177902720-Jun-15 21:21
Member 1177902720-Jun-15 21:21 
GeneralRe: Doubt Pin
Richard MacCutchan20-Jun-15 21:33
mveRichard MacCutchan20-Jun-15 21:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.