Menu

📰
0

Reddit - Please wait for verification

learn programming·/u/JustCallMeBigD·3 days ago
#LDmz5Juw
Reading 0:00
15s threshold

I'm working on a project where I have a battery level indication on the display. When the battery level just teeters on the threshold from one "level" to another, the battery charge level indicated rapidly fluctuates which just looks unappealing on the display. This is the code that determines the battery level and how to draw the battery level indicator: void battLevel(int battChk) { if (battChk == 0) battLvl = 0; if (battChk != 0) { if (battChk > 1010) battLvl = 5; if (battChk < 1010) battLvl = 4; if (battChk < 960) battLvl = 3; if (battChk < 860) battLvl = 2; if (battChk < 820) battLvl = 1; } } "battChk" 0 is only possible if the project is on DC power, thus I have it broken out separately to activate the DC power indicator in place of the battery symbol. Probably not necessary to do it that way, but that was my thinking.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More