fix ev scale min max line int overflow

This commit is contained in:
interfisch 2018-05-02 11:27:10 +02:00
parent fed0957650
commit 22ac8c37aa
1 changed files with 15 additions and 3 deletions

View File

@ -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