From 22ac8c37aafc1fcdf14e0b7f4cd2963d151e9217 Mon Sep 17 00:00:00 2001 From: Fisch Date: Wed, 2 May 2018 11:27:10 +0200 Subject: [PATCH] fix ev scale min max line int overflow --- lightmeter.ino | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lightmeter.ino b/lightmeter.ino index 84d2ab6..066feca 100644 --- a/lightmeter.ino +++ b/lightmeter.ino @@ -1353,8 +1353,8 @@ void updateDisplay_Lightmeter() //Lightmeter display } //ev min & max - int8_t xpos_ev_min=(ev_min-_startev*1.0) *FULLEVLINEDISTANCE; //calculate display position for ev - int8_t xpos_ev_max=(ev_max-_startev*1.0) *FULLEVLINEDISTANCE; //calculate display position for ev + int16_t xpos_ev_min=(ev_min-_startev*1.0) *FULLEVLINEDISTANCE; //calculate display position for ev + int16_t xpos_ev_max=(ev_max-_startev*1.0) *FULLEVLINEDISTANCE; //calculate display position for ev bool arrow_is_between_minmax=true; if (xpos_arrow<=xpos_ev_min || xpos_arrow>=xpos_ev_max){ @@ -1375,7 +1375,19 @@ void updateDisplay_Lightmeter() //Lightmeter display } } if (ev_min>-254 && ev_max>-254){ //evmin and max are set - display.drawLine(xpos_ev_min,4,xpos_ev_max ,4,WHITE); //draw single line between them + uint8_t _xpos_ev_min_line=xpos_ev_min; + uint8_t _xpos_ev_max_line=xpos_ev_max; + if (xpos_ev_min<0){ + _xpos_ev_min_line=0; + }else if (xpos_ev_min>=WIDTH-1){ + _xpos_ev_min_line=WIDTH-1; + } + if (xpos_ev_max<0){ + _xpos_ev_max_line=0; + }else if (xpos_ev_max>=WIDTH-1){ + _xpos_ev_max_line=WIDTH-1; + } + display.drawLine(_xpos_ev_min_line,4,_xpos_ev_max_line ,4,WHITE); //draw single line between them } for (int8_t i=-(xpos_arrow-xpos_ev_min)/FULLEVLINEDISTANCE;i<(xpos_ev_max-xpos_arrow)/FULLEVLINEDISTANCE;i++){ //draw black lines for every zone border