Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add addresses header #177

Merged
merged 12 commits into from
Aug 15, 2023
Merged

Add addresses header #177

merged 12 commits into from
Aug 15, 2023

Conversation

maciekish
Copy link
Contributor

@maciekish maciekish commented Aug 12, 2023

This patch updates Protocol.lua to save address constants to doc\Addresses.h. This file can be included in the Arduino library to simplfy addressing.

Usage example:

void onIntCautionLBrightChange(unsigned int newValue) {
  analogWrite(13, newValue / (256 * 6));
}
DcsBios::IntegerBuffer intCautionLBrightBuffer(A_10C_INT_CAUTION_L_BRIGHT, onIntCautionLBrightChange);

Instead of:

void onIntCautionLBrightChange(unsigned int newValue) {
  analogWrite(13, newValue / (256 * 6));
}
DcsBios::IntegerBuffer intCautionLBrightBuffer(0x137a, 0xffff, 0, onIntCautionLBrightChange);

This is a snippet of the generated file:

#define A_10C_INT_CONSOLE_L_BRIGHT 0x1370, 0xFFFF, 0
#define A_10C_LCP_ACCEL_COMP 0x1144, 0x400, 10
#define A_10C_LCP_ENG_INST 0x1148, 0xFFFF, 0
#define A_10C_LCP_ANTICOLLISION 0x1144, 0x80, 7
#define A_10C_LCP_FLOOD 0x114E, 0xFFFF, 0
#define A_10C_LCP_FLIGHT_INST 0x114A, 0xFFFF, 0

This patch updates Protocol.lua to save address constants to doc\Addresses.h. This file can be included in the Arduino library to simplfy addressing.

For example:

void onIntCautionLBrightChange(unsigned int newValue) {
  analogWrite(13, newValue / (256 * 6));
}
DcsBios::IntegerBuffer intCautionLBrightBuffer(A_10C_INT_CAUTION_L_BRIGHT, onIntCautionLBrightChange);
@charliefoxtwo
Copy link
Member

@WarLord211 this looks good to me and I think is a good addition - it should help make it easier for arduino users to update their code in the event the underlying addresses change.

@maciekish
Copy link
Contributor Author

Also updated documentation to use the macros instead of addresses. Bort will need a separate PR if this is merged.

image

@maciekish
Copy link
Contributor Author

Just noticed i missed some manual document{} statements in the actual aircraft definitions, thought it was all in Utils.lua. I'll try to update these later today.

@maciekish
Copy link
Contributor Author

All done now.

@WarLord211 WarLord211 merged commit d845921 into DCS-Skunkworks:master Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants