|
In lugnet.general, Philippe Hurbain wrote:
>
> The LEGO company just released a document detailing the complete protocol
> used by Power Functions RC receiver.
In collaboration with Jason Railton I have modified/extended the NBC and NXC API
functions for the HiTechnic iRLink device in support of the newly documented
Power Function modes as well as the R/C Train IR protocol. I uploaded a new
test_release zip to the BricxCC page with NBC and BricxCC executable updates
with these new API functions included in the compiler and BricxCC syntax
highlighter/code completion support for NBC and NXC programs. These updates
will be in the next beta release of NBC/NXC and the next official BricxCC
release.
http://bricxcc.sourceforge.net/test_release.zip
The old HTPowerFunctionCommand API function is gone. It is replaced by the new
HTPFComboDirect function.
All the new NXC functions are listed below. For NBC the status is returned via
an additional parameter but otherwise the function signatures are identical.
HTPFComboDirect(port, channel, outa, outb)
HTPFSinglePin(port, channel, out, pin, func, bContinuous)
HTPFSingleOutputCST(port, channel, out, func)
HTPFSingleOutputPWM(port, channel, out, func)
HTPFComboPWM(port, channel, outa, outb)
HTPFTrain(port, channel, func)
HTIRTrain(port, channel, func)
HTPFRawOutput(port, nibble0, nibble1, nibble2)
HTPFRepeat(port, count, delay)
The HTPFRepeat function allows you to send the previous command again in a loop
count number of times with a wait of delay milliseconds between each
transmission.
The following constants are HTPFComboDirect output commands.
#define HTPF_CMD_STOP 0
#define HTPF_CMD_FWD 1
#define HTPF_CMD_REV 2
#define HTPF_CMD_BRAKE 3
For all Power Function API calls you can use the channel constants shown here:
#define HTPF_CHANNEL_1 0
#define HTPF_CHANNEL_2 1
#define HTPF_CHANNEL_3 2
#define HTPF_CHANNEL_4 3
These power function mode constants are used internally by the API functions
listed above.
#define PF_MODE_TRAIN 0
#define PF_MODE_COMBO_DIRECT 1
#define PF_MODE_SINGLE_PIN_CONT 2
#define PF_MODE_SINGLE_PIN_TIME 3
#define PF_MODE_COMBO_PWM 4
#define PF_MODE_SINGLE_OUTPUT_PWM 4
#define PF_MODE_SINGLE_OUTPUT_CST 6
When calling either HTIRTrain (for use with R/C Train receivers) or HTPFTrain
(for use with the Power Function receiver) you should use one of these four
train functions. The "unused" mode 0 in the Power Function receiver operates
identically to the standard R/C Train IR receiver with respect to controlling
the attached motor/light.
#define TRAIN_FUNC_STOP 0
#define TRAIN_FUNC_INCR_SPEED 1
#define TRAIN_FUNC_DECR_SPEED 2
#define TRAIN_FUNC_TOGGLE_LIGHT 4
The HTIRTrain function uses a different IR protocol than the HTPFTrain function
and the receiver interprets channel #3 as ALL so you should use these channel
constants instead of the Power Function-specific channel constants when calling
HTIRTrain.
#define TRAIN_CHANNEL_1 0
#define TRAIN_CHANNEL_2 1
#define TRAIN_CHANNEL_3 2
#define TRAIN_CHANNEL_ALL 3
For SingleOutput and SinglePin power function modes you should use these output
constants.
#define PF_OUT_A 0
#define PF_OUT_B 1
Use the pin constants with the SinglePin function listed above.
#define PF_PIN_C1 0
#define PF_PIN_C2 1
These constants are SinglePin operation which can be used with the HTPFSinglePin
function listed above.
#define PF_FUNC_NOCHANGE 0
#define PF_FUNC_CLEAR 1
#define PF_FUNC_SET 2
#define PF_FUNC_TOGGLE 3
The SingleOutputCST API function uses these func constants:
#define PF_CST_CLEAR1_CLEAR2 0
#define PF_CST_SET1_CLEAR2 1
#define PF_CST_CLEAR1_SET2 2
#define PF_CST_SET1_SET2 3
#define PF_CST_INCREMENT_PWM 4
#define PF_CST_DECREMENT_PWM 5
#define PF_CST_FULL_FWD 6
#define PF_CST_FULL_REV 7
#define PF_CST_TOGGLE_DIR 8
The SingleOutputPWM and ComboPWM API functions both use these constants for
specifying the speed and direction of the motor(s).
#define PF_PWM_FLOAT 0
#define PF_PWM_FWD1 1
#define PF_PWM_FWD2 2
#define PF_PWM_FWD3 3
#define PF_PWM_FWD4 4
#define PF_PWM_FWD5 5
#define PF_PWM_FWD6 6
#define PF_PWM_FWD7 7
#define PF_PWM_BRAKE 8
#define PF_PWM_REV7 9
#define PF_PWM_REV6 10
#define PF_PWM_REV5 11
#define PF_PWM_REV4 12
#define PF_PWM_REV3 13
#define PF_PWM_REV2 14
#define PF_PWM_REV1 15
|
|
Message has 3 Replies:
Message is in Reply To:
19 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|