ESP32 and BIT order LSB to MSB or vice versa

For general Flowcode discussion that does not belong in the other sections.
Post Reply
dvcam99
Posts: 89
http://meble-kuchenne.info.pl
Joined: Fri Dec 04, 2020 11:03 am
Has thanked: 6 times
Been thanked: 12 times

ESP32 and BIT order LSB to MSB or vice versa

Post by dvcam99 »

Hello Matrix Team,

in my good old FC4 days the following function/calculation I got from JonnyW was working perfect!! :D

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
Happy FC9, FC-8 and FC-6 professional user ;)

LeighM
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

Post by LeighM »

Did you forget the semicolon at the end of the statement? - if C
Or are you using this in Flowcode calculation?

dvcam99
Posts: 89
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

Post by dvcam99 »

....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
Happy FC9, FC-8 and FC-6 professional user ;)

dvcam99
Posts: 89
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

Post by dvcam99 »

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;
Happy FC9, FC-8 and FC-6 professional user ;)

LeighM
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

Post by LeighM »

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)

dvcam99
Posts: 89
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

Post by dvcam99 »

TOP our are great!! Works!! :D :D :D

Many thanks
Happy FC9, FC-8 and FC-6 professional user ;)

Post Reply