From fdb066cfb9375b8ef54c9997d6aec0e1bb3ff490 Mon Sep 17 00:00:00 2001 From: Fisch Date: Thu, 3 May 2018 15:53:37 +0200 Subject: [PATCH] add pinhole shuttertimes and ev error scale, add some more high aperature values --- lightmeter.ino | 123 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 110 insertions(+), 13 deletions(-) diff --git a/lightmeter.ino b/lightmeter.ino index f7e6b80..af1f93d 100644 --- a/lightmeter.ino +++ b/lightmeter.ino @@ -58,20 +58,25 @@ float shuttertimes1[]={64,32,16,8,4,2,1,1.0/2, 1.0/4, 1.0/8, 1.0/15, 1.0/30, 1.0 #define SHUTTERTIMES1_MAXINDEX 19 float shuttertimes2[]={30,25,20,15,13,10,8,6,5,4,3.2,2.5,2,1.6,1.3,1,0.8,0.6,0.5,0.4,0.3,1.0/4,1.0/5,1.0/6,1.0/8,1.0/10,1.0/13,1.0/15,1.0/20,1.0/25,1.0/30,1.0/40,1.0/50,1.0/60,1.0/80,1.0/100,1.0/125,1.0/160,1.0/200,1.0/250,1.0/320,1.0/400,1.0/500,1.0/640,1.0/800,1.0/1000,1.0/1250,1.0/1600,1.0/2000,1.0/2500,1.0/3200,1.0/4000}; #define SHUTTERTIMES2_MAXINDEX 51 -String settingsnameShutterSelectionMode[]={"Analog","Digital"}; //names for tables -#define MAXIMUM_SHUTTERSELECTIONMODES 2 +float shuttertimes3[]={3600,2400,1800,1200,900,600,420,300,210,150,100,60,45,30,20,16,10,8,6,4,3,2,1.5,1,0.5,0.25,0.125,1.0/16}; +#define SHUTTERTIMES3_MAXINDEX 27 +String settingsnameShutterSelectionMode[]={"Analog","Digital","Pinhole"}; //names for tables +#define MAXIMUM_SHUTTERSELECTIONMODES 3 -float aperaturesFull[]={1,1.4, 2, 2.8, 4, 5.6, 8, 11, 16, 22, 32}; -#define APERATURESFULL_MAXINDEX 10 -float aperaturesHalf[]={1, 1.2, 1.4, 1.7, 2, 2.4, 2.8, 3.4, 4, 4.8, 5.6, 6.7, 8, 9.5, 11, 13, 16, 19, 22}; -#define APERATURESHALF_MAXINDEX 18 +//Aperature numbers https://en.wikipedia.org/wiki/F-number +float aperaturesFull[]={1,1.4, 2, 2.8, 4, 5.6, 8, 11, 16, 22, 32,45}; +#define APERATURESFULL_MAXINDEX 11 +float aperaturesHalf[]={1, 1.2, 1.4, 1.7, 2, 2.4, 2.8, 3.4, 4, 4.8, 5.6, 6.7, 8, 9.5, 11, 13, 16, 19, 22, 27 ,32, 38, 45}; +#define APERATURESHALF_MAXINDEX 22 float aperaturesThird[]={1, 1.1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.5, 2.8, 3.2, 3.5, 4, 4.5, 5.0, 5.6, 6.3, 7.1, 8, 9, 10, 11, 13, 14, 16, 18, 20, 22, 25, 29, 32, 36, 40, 45}; #define APERATURESTHIRD_MAXINDEX 33 String settingsnameAperatureSelectionMode[]={"Full","Half","Third"}; //names for tables #define MAXIMUM_APERATURESELECTIONMODES 3 -float isoFull[]={12,25,50,100,200,400,800,1600,3200,6400,12500,25600}; -float isoThird[]={12,16,20,25,32,40,50,64,80,100,125,160,200,250,320,400,500,640,800,1000,1250,1600,2000,2500,3200,4000,5000,6400,8000,10000,12500,16000,20000,25600}; +float isoFull[]={0.78,1.56,3.13,6.25,12.5,25,50,100,200,400,800,1600,3200,6400,12500,25600}; +uint8_t isoFullDIN[]={0,3, 6, 9, 12, 15,18,21 ,24 ,27 ,30 ,33 ,36 ,39 ,42 ,45}; +float isoThird[]={0.78,0.98,1.24,1.56,1.97,2.48,3.13,3.93,4.96,6.25,7.87,9.92,12.5,16,20,25,32,40,50,64,80,100,125,160,200,250,320,400,500,640,800,1000,1250,1600,2000,2500,3200,4000,5000,6400,8000,10000,12500,16000,20000,25600}; +uint8_t isoThirdDIN[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20, 21, 22 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,30 ,31 ,32 ,33 ,34 ,35 ,36 ,37 ,38 ,39 ,40 ,41 ,42 ,43 ,44 ,56}; @@ -151,7 +156,7 @@ bool manualev_mode=false; //manual ev change by left/right //Usersettings float setAperature=8; //set to use aperature. 0 for auto float setShutter=0; //set to use shutter time, 0 for auto -uint16_t setISO=100; //set to ISO +float setISO=100; //set to ISO float eeprom_setAperature=0; //set to use aperature. 0 for auto float eeprom_setShutter=0; //set to use shutter time, 0 for auto @@ -926,6 +931,9 @@ float roundShutter(float pShutter, uint8_t pMethod) //round shutter to typical v case 2: // return shuttertimes2[_index]; break; + case 3: // + return shuttertimes3[_index]; + break; } } @@ -1042,6 +1050,9 @@ void changeShutter(int8_t pchange){ //pchange>0 means more light exposure (brigh case 2: _maximumShutterIndex=sizeof(shuttertimes2)/sizeof(float); break; + case 3: + _maximumShutterIndex=sizeof(shuttertimes3)/sizeof(float); + break; } if (!( -pchange<0 && _newShutterIndex==0)){ //changed value would not yield negative index @@ -1057,11 +1068,25 @@ void changeShutter(int8_t pchange){ //pchange>0 means more light exposure (brigh case 2: // setShutter=shuttertimes2[_newShutterIndex]; break; + case 3: // + setShutter=shuttertimes3[_newShutterIndex]; + break; } } uint8_t findShutterIndex(float pShutter,uint8_t pMethod) //find index of closest aperature from given aperature tables (pMethod { - float _minDistance=abs(pShutter-shuttertimes1[0]); + float _minDistance=0; + switch(userSettings.shutterSelectionMode){ + case 1: // + _minDistance=abs(pShutter-shuttertimes1[0]); + break; + case 2: // + _minDistance=abs(pShutter-shuttertimes2[0]); + break; + case 3: // + _minDistance=abs(pShutter-shuttertimes3[0]); + break; + } float _lastminDistance=_minDistance; uint8_t _index=0; uint8_t _maxindexpossible=0; @@ -1073,6 +1098,9 @@ uint8_t findShutterIndex(float pShutter,uint8_t pMethod) //find index of closest case 2: _maxindexpossible=SHUTTERTIMES2_MAXINDEX; break; + case 3: + _maxindexpossible=SHUTTERTIMES3_MAXINDEX; + break; } @@ -1091,6 +1119,9 @@ uint8_t findShutterIndex(float pShutter,uint8_t pMethod) //find index of closest case 2: _minDistance=abs(pShutter - shuttertimes2[_index]); break; + case 3: + _minDistance=abs(pShutter - shuttertimes3[_index]); + break; } _index++; //next } @@ -1152,6 +1183,41 @@ uint8_t findISOIndex(float pISO,uint8_t pMethod) //find index of closest iso fro return _index-2; } +int isoToDIN(float pISO,uint8_t pMethod){ + uint8_t _isoIndex=findISOIndex(pISO,pMethod); + switch(pMethod){ + case 1: + return isoFullDIN[_isoIndex]; + break; + case 2: + return isoThirdDIN[_isoIndex]; + break; + } +} + +void displayPrintISO(float pISO,bool pDisplayBoth){ //for lower iso values use din notation + + if (pISO>=25 || pDisplayBoth){ + if (pDisplayBoth){ + display.print(pISO,2); + }else{ + display.print(pISO,0); + } + } + if (pDisplayBoth){ + display.print("/"); + } + if (pISO<25 || pDisplayBoth){ + display.print(isoToDIN(pISO,userSettings.ISOSelectionMode)); + display.write(0xF7); //degree char + } +} + +float calculateEV(float pISO, float pShutter, float pAperature) +{ //EV = log2 ( 100* Aperature^2 / (ISO * Time )) + return log (100*pow(pAperature,2) / (pISO*pShutter)) / log (2); +} + void updateDisplay() { if (loopmillis-last_displayupdate>=DISPLAY_UPDATEDELAY){ @@ -1249,9 +1315,34 @@ void updateDisplay_Lightmeter() //Lightmeter display }else{ //manual ev selection drawRectCorners(xpos_shutter-2, ypos_shutter-2, 60, 18, 5, WHITE); //alternative border } - } + //Draw line for ev error + float _actualEV = calculateEV(setISO,_showShutter,_showAperature); + float _evError=_actualEV-ev; //Line on the right means suggested values will overexpose the image + uint8_t evErrorX=0; + uint8_t evErrorY=ypos_aperature+16; + if (setAperature>0){ //Aperature Priority Mode + evErrorX=xpos_shutter+20; + evErrorY=ypos_shutter+16; + }else if(setShutter>0) { //Shutter Priority Mode + evErrorX=xpos_aperature+20; + evErrorY=ypos_aperature+16; + } + uint8_t everrorpixels_per_ev=20; + if (_evError>1 || _evError<1){ //scale smaller if error greater 1 EV + everrorpixels_per_ev=10; + } + display.drawLine(evErrorX,evErrorY,evErrorX,evErrorY+1,WHITE); //center line + display.drawLine(evErrorX-everrorpixels_per_ev,evErrorY,evErrorX-everrorpixels_per_ev,evErrorY+1,WHITE); //-1 ev + display.drawLine(evErrorX+everrorpixels_per_ev,evErrorY,evErrorX+everrorpixels_per_ev,evErrorY+1,WHITE); //+1ev + if (_evError>1 || _evError<1){ //scale smaller if error greater 1 EV + display.drawLine(evErrorX-2*everrorpixels_per_ev,evErrorY,evErrorX-2*everrorpixels_per_ev,evErrorY+1,WHITE); //-1 ev + display.drawLine(evErrorX+2*everrorpixels_per_ev,evErrorY,evErrorX+2*everrorpixels_per_ev,evErrorY+1,WHITE); //+1ev + } + display.drawLine(evErrorX,evErrorY,evErrorX+(everrorpixels_per_ev*_evError+0.5),evErrorY,WHITE); //Draw ev error line + + //Meteringmode Icon if (meteringmode == METERINGMODE_REFLECTIVE){ display.drawXBitmap(xpos_icon, ypos_icon, icon_spot_bits, icon_spot_width, icon_spot_height, WHITE); }else if (meteringmode == METERINGMODE_INCIDENT) { @@ -1259,7 +1350,13 @@ void updateDisplay_Lightmeter() //Lightmeter display } //ISO - display.setCursor(xpos_iso,ypos_iso); display.setTextSize(1); display.print("ISO "); display.print(setISO); + display.setCursor(xpos_iso,ypos_iso); display.setTextSize(1); + if (setISO<25){ + display.print("DIN "); //below iso 25 only din value is shown here + }else{ + display.print("ISO "); + } + displayPrintISO(setISO,false);//display.print(formatISO(setISO,false)); //EV Scale @@ -1480,7 +1577,7 @@ void updateDisplay_Settings() } display.print(settingStrings[_currentItemIndex]); switch(_currentItemIndex){ //if values need to be shown - case 0: display.print(setISO); + case 0: displayPrintISO(setISO,true);//display.print(formatISO(setISO,true)); break; case 1: display.print(settingsnameAperatureSelectionMode[userSettings.aperatureSelectionMode-1]); break;