milesburton / Arduino-Temperature-Control-Library

Arduino Temperature Library

Home Page:https://www.milesburton.com/w/index.php/Dallas_Temperature_Control_Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

if A0-3 are not 1, will break resolution switch statement()

karlg100 opened this issue · comments

switch (scratchPad[CONFIGURATION]) {

It appears this switch statement will fail if any of the A0-3 bits are pulled down.

This is because bits 0-3 match these hardware set address bits. Default they are pulled up. But a user can configure these with hardware or dynamically pulling up or down.

The CONFIGURATION bit probably needs to be masked out with a | of 11110000 or 0xF0, then the macros redefined to be 0xN0.

Not sure what other repercussions this change would have however.

There is the same problem in setResolution(). It won't actually fail but it may write when it does not need to.
Needs a systematic look through all of the code.

The correct fix is to write a Scratchpad class which hides the details of how to access things such as the resolution. I have one in preparation.