Possible division per 0

This commit is contained in:
bsongis
2012-06-26 20:14:12 +00:00
parent 5eb81c5853
commit 7b000b376d
+6 -5
View File
@@ -791,11 +791,12 @@ void FrskyValueWithMinMax::set(uint8_t value, uint8_t unit)
void frskyEvalCurrentConsumptionBoundary()
{
if (g_model.frsky.currentSource == CURRENT_SOURCE_HUB) {
currentConsumptionBoundary = 3600;
}
else {
currentConsumptionBoundary = 360000L / (g_model.frsky.channels[g_model.frsky.currentSource-1].ratio << g_model.frsky.channels[g_model.frsky.currentSource-1].multiplier);
currentConsumptionBoundary = 3600;
if (g_model.frsky.currentSource > CURRENT_SOURCE_HUB) {
uint16_t divider = (g_model.frsky.channels[g_model.frsky.currentSource-1].ratio << g_model.frsky.channels[g_model.frsky.currentSource-1].multiplier);
if (divider > 5) {
currentConsumptionBoundary = 360000L / divider;
}
}
}