From d3a26172c0d5438ca02335cb4f592d8537dd6b3e Mon Sep 17 00:00:00 2001 From: Dmitry Blinov Date: Wed, 6 Dec 2023 14:22:40 +0200 Subject: [PATCH] garland: fix issue with division by zero in first scene setup --- code/espurna/garland/scene.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/espurna/garland/scene.h b/code/espurna/garland/scene.h index 2f5f3559..068ce4d2 100644 --- a/code/espurna/garland/scene.h +++ b/code/espurna/garland/scene.h @@ -32,9 +32,9 @@ public: void setAnim(Anim* anim) { _anim = anim; } bool finishedAnimCycle() { return _anim ? _anim->finishedycle() : true; } - unsigned long getAvgCalcTime() { return sum_calc_time / calc_num; } - unsigned long getAvgPixlTime() { return sum_pixl_time / pixl_num; } - unsigned long getAvgShowTime() { return sum_show_time / show_num; } + unsigned long getAvgCalcTime() { return calc_num > 0 ? sum_calc_time / calc_num : 0; } + unsigned long getAvgPixlTime() { return pixl_num > 0 ? sum_pixl_time / pixl_num : 0; } + unsigned long getAvgShowTime() { return show_num > 0 ? sum_show_time / show_num : 0; } int getNumShows() { return numShows; } byte getBrightness() { return brightness; } void setBrightness(byte value) { brightness = value; }