Enumerations and switch statements - General Discussion and Assistance - CHDK Forum

Enumerations and switch statements

  • 4 Replies
  • 2159 Views
Enumerations and switch statements
« on: 17 / November / 2009, 08:08:45 »
Advertisements
I am adding some new features to motion detection.

The code switches based on an enumerated value.

For example :

switch(motion_detector.pixel_measure_mode){
         case MD_MEASURE_MODE_Y:

That works.

The original MX3 code has :

switch(motion_detector.pixel_measure_mode){
         MD_MEASURE_MODE_Y:

That also works.

However, if I omit 'case' from my code I get a compiler error about labels (I think) being previously declared.


Why is this  ?

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Enumerations and switch statements
« Reply #1 on: 17 / November / 2009, 08:34:18 »
IMHO, in switch statement without case:
 switch(x){
 label1: f(); break;
 label2: g(); break;
 default: h();
}

only default section is executed in any case.

Re: Enumerations and switch statements
« Reply #2 on: 17 / November / 2009, 08:43:13 »
IMHO ..
only default section is executed in any case.

That is what I thought.

So, the MX3 code is incorrect ?

Also, I have a spotmeter function that shows the average luminance of a 24x16 pixel area in the middle of the screen.
That works for A620 and ixus860, it always shows 255 with the SX200IS.

That is based on MX3's code for calculating byte position in the live viewport.

I have assumed that the byte-order for all viewports is the same.

Is that correct ?


« Last Edit: 17 / November / 2009, 09:19:23 by Microfunguy »

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Enumerations and switch statements
« Reply #3 on: 17 / November / 2009, 12:08:10 »
So, the MX3 code is incorrect ?
Probably yes.
Quote
Also, I have a spotmeter function that shows the average luminance of a 24x16 pixel area in the middle of the screen.
That works for A620 and ixus860, it always shows 255 with the SX200IS.
That is based on MX3's code for calculating byte position in the live viewport.
I have assumed that the byte-order for all viewports is the same.
Is that correct ?
If live histogram and zebra are working in record mode for sx200, this is correct. (or my program for remote shooting with live viewfinder)
« Last Edit: 17 / November / 2009, 12:10:10 by ewavr »


Re: Enumerations and switch statements
« Reply #4 on: 17 / November / 2009, 12:11:41 »
If live histogram and zebra are working in record mode for sx200, this is correct.

Yes, they are both working.
I used less complicated code than the CHDK version and zebra covers the entire viewport area.

I will investigate  .....

Any idea why Canon use a 720 wide viewport ?

It must be of some use to their firmware.
« Last Edit: 17 / November / 2009, 12:15:47 by Microfunguy »

 

Related Topics