Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

# Importantly, this function sets the bits in the integer pointed to by display which may or MAY NOT BE the global display variable. To properly set the display bits, set_display_from_batt() will need t

Importantly, this function sets the bits in the integer pointed to by display which may or MAY NOT BE the global display variable.

To properly set the display bits, set_display_from_batt() will need to do bit shifting along with bitwise operations to construct the correct bit pattern for the display.

A good trick to use is to create a series of bit patterns that correspond to the various digits. For example, according to the diagrams above, the bit pattern for 9 is 0b1101111. If a 9 should appear on the display somewhere, this bit pattern should be shifted and combined with the existing bits in display so that a 9 will show. Creating similar constant mask patterns for each digit, the decimal place, the positions of the Voltage/Percent indicator, and the bars for the visual level indicator is a good way to make this problem manageable.

A detailed explanation of one approach to the problem follows.

• Create an array of bit masks for each of the digits 0-9. The 0th element of the array contains a bit mask like 0b0111111 which represents the bits that should be set for a 0 digit, the 1th element of this array has a mask like 0b0000011 which are the bits to be set for a 1. There should be ten entries in this array in indices 0-9.
• Use modulo to determine the integer value for right, middle, and left digits for the display from volts or percent. Each digit should have a value from 0-9 and be Stored in its own variable.