Currently the closest means we have to tell whether the battery is connected or not is if we read a battery charge percentage of 50.0. We need to leverage that to infer whether the battery appears to be disconnected, and prevent the laser from firing if that is the case (with explanatory message for the user).
In my mind, we can "average over" the case in which the battery charge "legitimately" passes through 50.0 by tracking whether the charge was in the range [48, 50) or (50, 52] in the last minute. If the laser initially comes up at 50.0 I would treat that as disconnected, noting that as soon as we get a Reading with a battery_perc != 50.0 we can re-enable the battery at that point anyway.
Currently the closest means we have to tell whether the battery is connected or not is if we read a battery charge percentage of 50.0. We need to leverage that to infer whether the battery appears to be disconnected, and prevent the laser from firing if that is the case (with explanatory message for the user).
In my mind, we can "average over" the case in which the battery charge "legitimately" passes through 50.0 by tracking whether the charge was in the range [48, 50) or (50, 52] in the last minute. If the laser initially comes up at 50.0 I would treat that as disconnected, noting that as soon as we get a Reading with a battery_perc != 50.0 we can re-enable the battery at that point anyway.