Skip to content

Analog pin is behind multiplexer. #22

Answered by rlogiacco
bhattvishal asked this question in Q&A
Discussion options

You must be logged in to vote

If all you want is to map a sensed voltage to a battery percentage then you don't need to instantiate the Battery class: just use any of the static functions provided:

  • sigmoidal(uint16_t voltage, uint16_t minVoltage, uint16_t maxVoltage)
  • asigmoidal(uint16_t voltage, uint16_t minVoltage, uint16_t maxVoltage)
  • linear(uint16_t voltage, uint16_t minVoltage, uint16_t maxVoltage)

You only have to convert the value you sensed to a voltage and those functions have been declared static also to support this use case. What suggested by @Mingyu-Kim only wastes additional memory to store data that you are not going to use, so the memory is wasted without any benefit whatsoever.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by rlogiacco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #22 on December 17, 2020 13:29.