From b61a824901d33abb128bf8f701a0e93c0810aa62 Mon Sep 17 00:00:00 2001 From: Fisch Date: Mon, 9 Apr 2018 11:45:18 +0200 Subject: [PATCH] lower debounce time, add trigger hold to measure, calibrate battery voltage --- lightmeter.ino | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lightmeter.ino b/lightmeter.ino index fa61272..e3df436 100644 --- a/lightmeter.ino +++ b/lightmeter.ino @@ -32,7 +32,7 @@ BH1750 lightMeter; #define TIME_METERINGMODESELECTION_CLOSE 4000 #define LDRDELAY 50 //minimum delay between ldr readings. Transistor for lower value pulldown resistor switches in between #define INCIDENTDELAY 100 //minimum delay between incident sensor (BH1750) readings -#define DEBOUNCETIME 50 //time to not check for inputs after key press +#define DEBOUNCETIME 20 //time to not check for inputs after key press #define BUTTONTIMEHOLD 750 //time for button hold #define voltage_warn 3.4 //voltage per cell //TODO implement warning @@ -287,7 +287,7 @@ void handleInputs() */ //Voltage - vbat=map(analogRead(PIN_VBAT), 0,3910,0,8400)/1000.0; //180k and 300k voltage divider. 8,4V -> 3,15V=3910 + vbat=map(analogRead(PIN_VBAT), 0,3560,0,8200)/1000.0; //180k and 300k voltage divider. 8,4V -> 3,15V=3910 //LDR if ( loopmillis-last_ldrReading>LDRDELAY ) @@ -438,7 +438,7 @@ void handleInputs_Lightmeter() } } - if (button_trigger) { //Trigger + if (button_trigger || button_hold_trigger) { //Trigger ev=getEV(); //set ev to current measurement by selected mode } @@ -928,6 +928,9 @@ void updateDisplay_Lightmeter() //Lightmeter display //EV Scale uint8_t _startev=2; //first ev to display, 13 ev values can fit on screen + if (ev>13){ + _startev=5+ev-13; + } #define FULLEVLINEDISTANCE 9 #define THIRDEVLINEDISTANCE 3 @@ -963,12 +966,17 @@ void updateDisplay_Lightmeter() //Lightmeter display if (_ev_decimals <= 0.1666 || _ev_decimals > 0.8333) { //without fraction displayed _xpos_current_evtext_move=2; } - display.setCursor(xpos_arrow-_xpos_current_evtext_move,ypos_icon_arrow+icon_arrow_height+2); //current ev text position + + int _displayev=(int)ev; if (_ev_decimals > 0.8333 ){ - display.print((int)ev+1); //EV Value under arrow. Ceil - }else{ - display.print((int)ev); //EV Value under arrow + _displayev=(int)(ev+1);//EV Value under arrow. Ceil } + if (_displayev>=10){ + _xpos_current_evtext_move+=5; //move digits to left + } + display.setCursor(xpos_arrow-_xpos_current_evtext_move,ypos_icon_arrow+icon_arrow_height+2); //current ev text position + display.print(_displayev); //EV Value under arrow + if ( _ev_decimals > 0.1666 && _ev_decimals <= 0.4166) { display.drawXBitmap(xpos_arrow , ypos_icon_arrow+icon_arrow_height-(icon_one_third_height-8)/2 +2, icon_one_third_bits, icon_one_third_width, icon_one_third_height, WHITE); //one third