Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5067

Beginners • Re: Make file throwing warning in terminal and other stuff

$
0
0

Code:

uint16_t configReg = read16(MAX17043_CONFIG);configReg &= 0xFFE0;  // Mask out threshold bitsconfigReg |= percent; // Add new threshold
Can it be written in a more concise, better way than the horrible translation I have done for the pico version above ??
You could write the masking and setting on one line as

Code:

uint16_t configReg = read16(MAX17043_CONFIG);configReg = (0xFFE0 & configReg) | percent;
Or even make the whole thing one line

Code:

uint16_t configReg = (read16(MAX17043_CONFIG) & 0xFFE0) | percent;
Andy,
Thanks a lot for the help.
Very appreciated!

Statistics: Posted by Gitduino — Tue Jan 23, 2024 4:26 am



Viewing all articles
Browse latest Browse all 5067

Trending Articles