I have uploaded a new revision of APM to the trunk repository (r3665) with automatic flap functionality. I am really pressed for time so am hoping some community members can do some flight testing on it and report back.
Flap functionality can be assigned to channel 5 or 6, using the rc_5_funct and rc_6_funct parameters (similar to setting up differential ailerons). The value to assign for automatic flaps is RC_6_FUNCT_FLAP_AUTO (in your config file) or 2 in the GCS parameter.
Flaps will function manually in flight modes of MANUAL through FLY_BY_WIRE_B, and will be set automatically for flight modes of FLY_BY_WIRE_C and higher. If you want to know what FLY_BY_WIRE_C is, you'll have to wait a couple more days ;)
Automatic flap deployment is based on desired speed. Desired speed is the current value of airspeed_cruise, which can be set with mission commands, or on the fly by changing the parameter value. If you do not have an airspeed sensor flap deployment is based on the current value of throttle_cruise. Four parameters have been added that can be set through your configuration file or through the ground station with MAVLink. These are two speed values and two flap positions. If the speed setpoint is above flap_1_speed then the flap position will be 0%. If the speed setpoint is between flap_1_speed and flap_2_speed then the flap position shall be flap_1_percent. If the speed setpoint is below flap_2_speed then the flap position shall be flap_2_percent.
The flap range is set up with the normal radio calibration procedure. A flap value of 0% corresponds to the minimum value on the flap channel and a flap value of 100% corresponds to the maximum value on the flap channel.
Modest flap deployment should be useful for AP applications where you need to fly at a slow speed. Higher flap deployment will be useful for even slower airspeeds with increased descent rates for landing approaches.
Have fun with it and please let me know how it goes.