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

rewrite ir_Argo by using bit field #1264

Merged
merged 2 commits into from
Sep 6, 2020
Merged

Conversation

siriuslzx
Copy link
Collaborator

@siriuslzx siriuslzx commented Sep 5, 2020

I think it must meet 3 conditions when using bit field:

  1. Don't straddle bytes unless necessary;
  2. Don't exceed the width of the underlying type;
  3. Follow the Object's alignment requirement
    see https://en.cppreference.com/w/cpp/language/bit_field#Notes
    https://en.cppreference.com/w/cpp/language/object#Alignment

for example:

    // Byte 2~4
    uint64_t          :3;
    uint64_t Mode     :3;
    uint64_t Temp     :5;  // straddle byte 2 and 3
    uint64_t Fan      :2;
    uint64_t RoomTemp :5;  // straddle byte 3 and 4
    uint64_t Flap     :3;  // SwingV
    uint64_t          :3;  // OnTimer, maybe hours

The field "Temp" straddle byte 2 and 3 and "RoomTemp" straddle byte 3 and 4, it means the bytes 2~4 should be taken as a whole, so you can't use uint8_t or uint16_t to hold them. If you use uint32_t, it's size is 4 and it's alignment must >=4, so you can't place it at byte 2. Finally, I use uint64_t start at byte 0.

Copy link
Owner

@crankyoldgit crankyoldgit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, as usual. Review Comment is non-blocking, but I'd appreciate your opinion/thoughts.

src/ir_Argo.h Outdated Show resolved Hide resolved
@siriuslzx siriuslzx merged commit 93f8292 into crankyoldgit:master Sep 6, 2020
@crankyoldgit
Copy link
Owner

@siriuslzx In future, please use the "Squash and Merge" option when merging PRs.

See: https://github.com/crankyoldgit/IRremoteESP8266/wiki/Library-Maintainers-Guide#merging-your-pull-request
(I only just added that after I saw you didn't use that.)

@siriuslzx
Copy link
Collaborator Author

@siriuslzx In future, please use the "Squash and Merge" option when merging PRs.

See: https://github.com/crankyoldgit/IRremoteESP8266/wiki/Library-Maintainers-Guide#merging-your-pull-request
(I only just added that after I saw you didn't use that.)

got it

crankyoldgit added a commit that referenced this pull request Oct 2, 2020
_v2.7.11 (20200902)_

**[Features]**
- Transcold: Add detailed support. (#1256 #1278)
- Airwell/Whirlpool: Add handling of previous state to `.toCommon()` (#1275 #1276)
- IRMQTTServer: Change how MQTT packet/buffer size is set. (#1271)
- Fujitsu: Add support for timers. (#1255 #1261 #1262)
- Neoclima: Add Economy & Fahrenheit support (#1260 #1265)
- Technibel: Cleanup and code fixes/improvements. (#1259 #1266)
- Technibel: Add detailed A/C support (#1259)
- Transcold: Add basic support. (#1256 #1258)

**[Misc]**
- refactor ir_Delonghi (#1285)
- Whirlpool: Change default mode in `convertMode()` (#1283 #1284)
- SamsungAC: Unit tests to help debug poor signal (#1277 #1280)
- Add question & note about VS1838b use to issue template. (#1281)
- rewrite ir_Corona (#1274)
- tools/mkkeywords: Fix minor parsing issue. (#1272)
- Add Zhongxian Li to Contributers.md (#1270)
- rewrite Carrier (#1269)
- rewrite ir_Argo by using bit field (#1264)
- rewrite ir_Amcor by using bit field (#1263)
- Update Fujitsu supported model info.
- Clarify the scope of the LittleFS breaking change.
crankyoldgit added a commit that referenced this pull request Oct 2, 2020
_v2.7.11 (20201002)_

**[Features]**
- Transcold: Add detailed support. (#1256 #1278)
- Airwell/Whirlpool: Add handling of previous state to `.toCommon()` (#1275 #1276)
- IRMQTTServer: Change how MQTT packet/buffer size is set. (#1271)
- Fujitsu: Add support for timers. (#1255 #1261 #1262)
- Neoclima: Add Economy & Fahrenheit support (#1260 #1265)
- Technibel: Cleanup and code fixes/improvements. (#1259 #1266)
- Technibel: Add detailed A/C support (#1259)
- Transcold: Add basic support. (#1256 #1258)

**[Misc]**
- refactor ir_Delonghi (#1285)
- Whirlpool: Change default mode in `convertMode()` (#1283 #1284)
- SamsungAC: Unit tests to help debug poor signal (#1277 #1280)
- Add question & note about VS1838b use to issue template. (#1281)
- rewrite ir_Corona (#1274)
- tools/mkkeywords: Fix minor parsing issue. (#1272)
- Add Zhongxian Li to Contributers.md (#1270)
- rewrite Carrier (#1269)
- rewrite ir_Argo by using bit field (#1264)
- rewrite ir_Amcor by using bit field (#1263)
- Update Fujitsu supported model info.
- Clarify the scope of the LittleFS breaking change.
@crankyoldgit crankyoldgit mentioned this pull request Oct 2, 2020
siriuslzx pushed a commit that referenced this pull request Oct 4, 2020
* Regenerate Doxygen documentation

* v2.7.11 release
_v2.7.11 (20201002)_

**[Features]**
- Transcold: Add detailed support. (#1256 #1278)
- Airwell/Whirlpool: Add handling of previous state to `.toCommon()` (#1275 #1276)
- IRMQTTServer: Change how MQTT packet/buffer size is set. (#1271)
- Fujitsu: Add support for timers. (#1255 #1261 #1262)
- Neoclima: Add Economy & Fahrenheit support (#1260 #1265)
- Technibel: Cleanup and code fixes/improvements. (#1259 #1266)
- Technibel: Add detailed A/C support (#1259)
- Transcold: Add basic support. (#1256 #1258)

**[Misc]**
- refactor ir_Delonghi (#1285)
- Whirlpool: Change default mode in `convertMode()` (#1283 #1284)
- SamsungAC: Unit tests to help debug poor signal (#1277 #1280)
- Add question & note about VS1838b use to issue template. (#1281)
- rewrite ir_Corona (#1274)
- tools/mkkeywords: Fix minor parsing issue. (#1272)
- Add Zhongxian Li to Contributers.md (#1270)
- rewrite Carrier (#1269)
- rewrite ir_Argo by using bit field (#1264)
- rewrite ir_Amcor by using bit field (#1263)
- Update Fujitsu supported model info.
- Clarify the scope of the LittleFS breaking change.
@crankyoldgit
Copy link
Owner

FYI, the changes mentioned above have now been included in the new v2.7.11 release of the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants