Hello Matrix Team,
in my good old FC4 days the following function/calculation I got from JonnyW was working perfect!!
byte = (byte >> 7) & 1 | (byte >> 5) & 2 | (byte >> 3) & 4 | (byte >> 1) & 8 | (byte << 1) & 0x10 | (byte << 3) & 0x20 | (byte << 5) & 0x40| (byte << 7) & 0x80
The purpose was to change the bit order inside a byte from LSB to MSB or vice versa.
Unfortunately the ESP32 compiler is not accepting this and the build failed.
Any ideas for a solution??
BR
Dirk
ESP32 and BIT order LSB to MSB or vice versa
-
- Posts: 89
- http://meble-kuchenne.info.pl
- Joined: Fri Dec 04, 2020 11:03 am
- Has thanked: 6 times
- Been thanked: 12 times
Re: ESP32 and BIT order LSB to MSB or vice versa
....mh i belive not because that string was put in a FC calculation box!!
I`ll check with a C-Box too and semikolon!!
BR
Dirk
I`ll check with a C-Box too and semikolon!!
BR
Dirk
Happy FC9, FC-8 and FC-6 professional user
Re: ESP32 and BIT order LSB to MSB or vice versa
OK I put the follwing sentence in a C-Box, unfortunatley the ESP32 compiler still faild to build.
FCV_BYTE = (FCV_BYTE >> 7) & 1 | (FCV_BYTE >> 5) & 2 | (FCV_BYTE >> 3) & 4 | (FCV_BYTE >> 1) & 8 | (FCV_BYTE << 1) & 0x10 | (FCV_BYTE << 3) & 0x20 | (FCV_BYTE << 5) & 0x40| (FCV_BYTE << 7) & 0x80;
FCV_BYTE = (FCV_BYTE >> 7) & 1 | (FCV_BYTE >> 5) & 2 | (FCV_BYTE >> 3) & 4 | (FCV_BYTE >> 1) & 8 | (FCV_BYTE << 1) & 0x10 | (FCV_BYTE << 3) & 0x20 | (FCV_BYTE << 5) & 0x40| (FCV_BYTE << 7) & 0x80;
Happy FC9, FC-8 and FC-6 professional user
-
- Valued Contributor
- Posts: 402
- Joined: Mon Dec 07, 2020 1:00 pm
- Has thanked: 75 times
- Been thanked: 220 times
Re: ESP32 and BIT order LSB to MSB or vice versa
Try this instead...
Code: Select all
byte = ((byte >> 7) & 1) | ((byte >> 5) & 2) | ((byte >> 3) & 4) | ((byte >> 1) & 8) | ((byte << 1) & 0x10) | ((byte << 3) & 0x20) | ((byte << 5) & 0x40) | ((byte << 7) & 0x80)