improve ev scale dynamics
This commit is contained in:
parent
5e6cc2eeac
commit
8742a0e5c6
|
@ -863,20 +863,13 @@ float getEV(){
|
||||||
|
|
||||||
void calculateFromEV()
|
void calculateFromEV()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (setAperature>0){ //Aperature Priority
|
if (setAperature>0){ //Aperature Priority
|
||||||
showAperature=setAperature; //use user set Aperature
|
showAperature=setAperature; //use user set Aperature
|
||||||
showShutter=calculateShutter(ev,setISO, setAperature);
|
showShutter=calculateShutter(ev,setISO, setAperature);
|
||||||
}else if(setShutter>0){ //Shutter Priority
|
}else if(setShutter>0){ //Shutter Priority
|
||||||
showShutter=setShutter; //use user set Shutter
|
showShutter=setShutter; //use user set Shutter
|
||||||
showAperature=calculateAperature(ev, setISO, setShutter);
|
showAperature=calculateAperature(ev, setISO, setShutter);
|
||||||
}else{ //Auto
|
|
||||||
//TODO
|
|
||||||
showAperature=42;
|
|
||||||
showShutter=42;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double evToLux(double ev) {
|
double evToLux(double ev) {
|
||||||
|
@ -1250,31 +1243,63 @@ void updateDisplay_Lightmeter() //Lightmeter display
|
||||||
|
|
||||||
|
|
||||||
//EV Scale
|
//EV Scale
|
||||||
int8_t _startev=-5; //first ev to display, 13 ev values can fit on screen
|
uint8_t _evrangedisplay=10;//which range to display. Default value
|
||||||
if (ev>2 && (ev_min<-254 || ev_min>2)){ //TODO make ev scale start better
|
if (ev_min>-254 && ev_max>-254){ //values set
|
||||||
_startev=0;
|
_evrangedisplay=ev_max-ev_min;
|
||||||
}
|
}
|
||||||
if (ev>11 || ev_max>11){
|
if (_evrangedisplay<6){ //minimum range
|
||||||
_startev=5+ev-11;
|
_evrangedisplay=6;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FULLEVLINEDISTANCE 9
|
//#define FULLEVLINEDISTANCE 9
|
||||||
#define THIRDEVLINEDISTANCE 3
|
//#define THIRDEVLINEDISTANCE 3
|
||||||
|
|
||||||
|
uint8_t FULLEVLINEDISTANCE=((int)(WIDTH/(_evrangedisplay+2))/3)*3; //scale distance to fit evrange_display with safety margin, floor to multiples of 3
|
||||||
|
uint8_t THIRDEVLINEDISTANCE=FULLEVLINEDISTANCE/3;
|
||||||
|
uint8_t _max_evvalues_displayed=(WIDTH/(FULLEVLINEDISTANCE));
|
||||||
#define ypos_evtext 7
|
#define ypos_evtext 7
|
||||||
#define ypos_icon_arrow 6
|
#define ypos_icon_arrow 6
|
||||||
|
|
||||||
uint8_t xpos_arrow=(ev-_startev*1.0) *FULLEVLINEDISTANCE; //calculate display position for ev
|
int8_t _startev=-5; //first ev to display, 13 ev values can fit on screen
|
||||||
|
/*if (ev>2 && (ev_min<-254 || ev_min>2)){ //TODO make ev scale start better
|
||||||
|
_startev=0;
|
||||||
|
}
|
||||||
|
if (ev>_max_ev_displayed-2 || ev_max>_max_ev_displayed-2){
|
||||||
|
_startev=5+ev-(_max_ev_displayed-2);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
float _evrangemargin=(_max_evvalues_displayed-_evrangedisplay)/2.0; //space left on both sides between evnrange (min to max) and display width
|
||||||
|
if (_evrangemargin<0){ //bound
|
||||||
|
_evrangemargin=0;
|
||||||
|
}
|
||||||
|
if (ev_min>-254 && ev_max>-254 ){ //minmax values set
|
||||||
|
if (ev>=ev_min && ev<=ev_max){ //arrow between min and max
|
||||||
|
_startev=(ev_max-ev_min)/2+ev_min - _max_evvalues_displayed/2; //center of evmin and max at display center
|
||||||
|
}else{ //arrow outside of ev min max range
|
||||||
|
if (ev<ev_min) { //on the left
|
||||||
|
_startev=ev-_evrangemargin-2;
|
||||||
|
}else if (ev>ev_max) { //on the right
|
||||||
|
_startev=ev+_evrangemargin-_evrangedisplay;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{ //ev min max values not set yet
|
||||||
|
_startev=ev-_max_evvalues_displayed/2; //center
|
||||||
|
_startev=(int(_startev/(_max_evvalues_displayed/2)))*(_max_evvalues_displayed/2); //floor to multiples of (_evrangedisplay/2)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t xpos_arrow=(ev-_startev*1.0) *FULLEVLINEDISTANCE+1; //calculate display position for ev
|
||||||
|
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.drawLine(THIRDEVLINEDISTANCE,0,THIRDEVLINEDISTANCE,0,WHITE); //first third line
|
display.drawLine(THIRDEVLINEDISTANCE,0,THIRDEVLINEDISTANCE,0,WHITE); //first third line
|
||||||
display.drawLine(THIRDEVLINEDISTANCE+THIRDEVLINEDISTANCE,0,THIRDEVLINEDISTANCE+THIRDEVLINEDISTANCE,0,WHITE); //second third line
|
display.drawLine(THIRDEVLINEDISTANCE+THIRDEVLINEDISTANCE,0,THIRDEVLINEDISTANCE+THIRDEVLINEDISTANCE,0,WHITE); //second third line
|
||||||
for (uint8_t _fullevline=1;_fullevline<=13;_fullevline++){
|
for (uint8_t _fullevline=1;_fullevline<=_max_evvalues_displayed;_fullevline++){ //with fullevlindistance=9 and WIDTH=128 -> <=13
|
||||||
int8_t _current_evvalue = _fullevline+_startev;
|
int8_t _current_evvalue = _fullevline+_startev;
|
||||||
uint8_t _xpos_center_evtext = _fullevline*FULLEVLINEDISTANCE; //center of current ev line x pos
|
uint8_t _xpos_center_evtext = _fullevline*FULLEVLINEDISTANCE; //center of current ev line x pos
|
||||||
display.drawLine(_xpos_center_evtext,0,_xpos_center_evtext,2,WHITE);
|
display.drawLine(_xpos_center_evtext,0,_xpos_center_evtext,2,WHITE);
|
||||||
display.drawLine(_xpos_center_evtext+THIRDEVLINEDISTANCE,0,_xpos_center_evtext+THIRDEVLINEDISTANCE,0,WHITE);
|
display.drawLine(_xpos_center_evtext+THIRDEVLINEDISTANCE,0,_xpos_center_evtext+THIRDEVLINEDISTANCE,0,WHITE);
|
||||||
display.drawLine(_xpos_center_evtext+THIRDEVLINEDISTANCE+THIRDEVLINEDISTANCE,0,_xpos_center_evtext+THIRDEVLINEDISTANCE+THIRDEVLINEDISTANCE,0,WHITE);
|
display.drawLine(_xpos_center_evtext+THIRDEVLINEDISTANCE+THIRDEVLINEDISTANCE,0,_xpos_center_evtext+THIRDEVLINEDISTANCE+THIRDEVLINEDISTANCE,0,WHITE);
|
||||||
if (_fullevline%2==1){ //only every second
|
if ((FULLEVLINEDISTANCE>9 && _current_evvalue<10 && _current_evvalue>=0) || (FULLEVLINEDISTANCE>12) || _fullevline%2==1){ //display every single digit ev if distance greater 9 OR if dist. gr. 12 OTHERWISE only every second digit
|
||||||
|
|
||||||
uint8_t _evtextmove=2; //movement of left point of text to the left. Compensation for center position
|
uint8_t _evtextmove=2; //movement of left point of text to the left. Compensation for center position
|
||||||
if (_current_evvalue>9 || _current_evvalue<0){ //text has two digits
|
if (_current_evvalue>9 || _current_evvalue<0){ //text has two digits
|
||||||
|
@ -1328,27 +1353,30 @@ void updateDisplay_Lightmeter() //Lightmeter display
|
||||||
}
|
}
|
||||||
|
|
||||||
//ev min & max
|
//ev min & max
|
||||||
uint8_t xpos_ev_min=(ev_min-_startev*1.0) *FULLEVLINEDISTANCE; //calculate display position for ev
|
int8_t xpos_ev_min=(ev_min-_startev*1.0) *FULLEVLINEDISTANCE; //calculate display position for ev
|
||||||
uint8_t xpos_ev_max=(ev_max-_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
|
||||||
|
|
||||||
bool arrow_is_between_minmax=true;
|
bool arrow_is_between_minmax=true;
|
||||||
if (xpos_arrow<xpos_ev_min || xpos_arrow>xpos_ev_max){
|
if (xpos_arrow<=xpos_ev_min || xpos_arrow>=xpos_ev_max){
|
||||||
arrow_is_between_minmax=false; //selected ev is not between min and max ev
|
arrow_is_between_minmax=false; //selected ev is not between min and max ev
|
||||||
}
|
}
|
||||||
if (ev_min>-254){ //ev_min is set (-255 is placeholder for "not set")
|
if (ev_min>-254 && xpos_ev_min>=0 && xpos_ev_min<WIDTH){ //ev_min is set (-255 is placeholder for "not set")
|
||||||
display.drawLine(xpos_ev_min,2,xpos_ev_min,5,WHITE);
|
display.drawLine(xpos_ev_min,2,xpos_ev_min,5,WHITE);
|
||||||
if ((xpos_arrow-xpos_ev_min)>3 && arrow_is_between_minmax){ //arrow is not overlaying line and is in between min and max
|
if ((xpos_arrow-xpos_ev_min)>3 && arrow_is_between_minmax){ //arrow is not overlaying line and is in between min and max
|
||||||
display.drawLine(xpos_ev_min,4,xpos_arrow ,4,WHITE); //line from left horizontally to arrow
|
//display.drawLine(xpos_ev_min,4,xpos_arrow ,4,WHITE); //line from left horizontally to arrow
|
||||||
display.drawLine(xpos_ev_min,5,xpos_arrow - 4,5,WHITE); //line from left horizontally to arrow
|
display.drawLine(xpos_ev_min,5,xpos_arrow - 4,5,WHITE); //line from left horizontally to arrow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ev_max>-254){ //ev_min is set (-255 is placeholder for "not set")
|
if (ev_max>-254 && xpos_ev_max>=0 && xpos_ev_max<WIDTH){ //ev_min is set (-255 is placeholder for "not set")
|
||||||
display.drawLine(xpos_ev_max,2,xpos_ev_max,5,WHITE);
|
display.drawLine(xpos_ev_max,2,xpos_ev_max,5,WHITE);
|
||||||
if ((xpos_ev_max-xpos_arrow)>3 && arrow_is_between_minmax){ //arrow is not overlaying line and is in between min and max
|
if ((xpos_ev_max-xpos_arrow)>3 && arrow_is_between_minmax){ //arrow is not overlaying line and is in between min and max
|
||||||
display.drawLine(xpos_ev_max,4,xpos_arrow ,4,WHITE); //line from right horizontally to arrow
|
//display.drawLine(xpos_ev_max,4,xpos_arrow ,4,WHITE); //line from right horizontally to arrow
|
||||||
display.drawLine(xpos_ev_max,5,xpos_arrow + 2,5,WHITE); //line from right horizontally to arrow
|
display.drawLine(xpos_ev_max,5,xpos_arrow + 2,5,WHITE); //line from right horizontally to arrow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
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
|
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
|
||||||
display.drawLine(xpos_arrow+i*FULLEVLINEDISTANCE+FULLEVLINEDISTANCE/2,4,xpos_arrow+i*FULLEVLINEDISTANCE+FULLEVLINEDISTANCE/2 ,5,BLACK); //erase part of horizontal line
|
display.drawLine(xpos_arrow+i*FULLEVLINEDISTANCE+FULLEVLINEDISTANCE/2,4,xpos_arrow+i*FULLEVLINEDISTANCE+FULLEVLINEDISTANCE/2 ,5,BLACK); //erase part of horizontal line
|
||||||
|
|
Loading…
Reference in New Issue