void hardware_flashlight_toggle() { if(hardware_flashlightIsOn()) { hardware_flashlight(0); } else { hardware_flashlight(1); } }
void shutter::off(void) { if(conf.devMode) hardware_flashlight(0); if(cable_connected == 0) { if(bulb && shutter_state) { ir.shutterNow(); } shutter_state = 0; } else if(conf.bulbMode == 0) { SHUTTER_CLOSE; MIRROR_DOWN; _delay_ms(50); CHECK_CABLE; } else if(conf.bulbMode == 1 && shutter_state == 1) { SHUTTER_CLOSE; MIRROR_DOWN; _delay_ms(50); CHECK_CABLE; shutter_state = 0; full(); shutter_state = 0; } }
void Clock::sleep() { if(!sleepOk) sleep_time = 0; else if(!sleepWasOk) awake(); sleepWasOk = sleepOk; if(sleepOk && sleep_time >= (uint16_t) conf.sysOffTime * 10) { // lcd.off(); /* attachInterrupt(1,wakeupFunction,LOW); sleep_mode(); detachInterrupt(1);*/ hardware_off(); awake(); wasSleeping = 1; } else if(backlightVal == 0 && light_time >= (uint16_t) conf.lcdBacklightTime * 10) { backlightVal = lcd.getBacklight(); lcd.backlight(0); } if(hardware_flashlightIsOn()) { if(flashlight_time >= (uint16_t) conf.flashlightOffTime * 10) { hardware_flashlight(0); } } else { flashlight_time = 0; } }
void shutter::full(void) { if(conf.devMode) hardware_flashlight(1); MIRROR_UP; SHUTTER_OPEN; }
void shutter::half(void) { if(conf.devMode) hardware_flashlight(0); SHUTTER_CLOSE; MIRROR_UP; }
void shutter::off(void) { if(conf.devMode) hardware_flashlight(0); SHUTTER_CLOSE; MIRROR_DOWN; _delay_ms(50); CHECK_CABLE; ir_shutter_state = 0; shutter_state = 0; }
void hardware_light_enable(uint8_t level) { hardware_flashlight(0); if(level > 2) level = 2; DDRA &= ~0b00000111; // clear all // PORTA &= ~0b00000111; // clear all // setBit(level, DDRA); // Powers Sensor // clrBit(level, PORTA); }
void shutter::half(void) { if(conf.devMode) hardware_flashlight(0); if(cable_connected == 0) { if(bulb && shutter_state) { shutter_state = 0; ir.shutterNow(); } shutter_state = 0; } else { SHUTTER_CLOSE; MIRROR_UP; } }
unsigned int hardware_readLight(uint8_t r) { // Need to power off lights // hardware_flashlight(0); char backlightVal = lcd.getBacklight(); lcd.backlight(0); if(backlightVal > 0) _delay_ms(50); if(r > 2) r = 2; DDRA &= ~0b00000111; // clear all // PORTA &= ~0b00000111; // clear all // setBit(r, DDRA); // Powers Sensor // clrBit(r, PORTA); _delay_ms(50); uint16_t light = hardware_analogRead(0); clrBit(r, DDRA); // Shuts down Sensor // if(backlightVal > lcd.getBacklight()) lcd.backlight(backlightVal); return light; }
void shutter::full(void) { if(conf.devMode) hardware_flashlight(1); if(cable_connected == 0) { if(bulb) shutter_state = 1; else shutter_state = 0; ir.shutterNow(); } else if(conf.bulbMode == 0) { MIRROR_UP; SHUTTER_OPEN; } else if(conf.bulbMode == 1 && shutter_state == 0) { MIRROR_UP; SHUTTER_OPEN; shutter_state = 1; _delay_ms(50); half(); } }
void hardware_off(void) { hardware_flashlight(0); if(battery_status() == 0) { //if(timer.cableIsConnected()) //{ // menu.message(STR("Error: Cable")); //} //else //{ shutter_off(); // Save the current time-lapse settings to nv-mem timer.saveCurrent(); // If USB is used, detach from the bus USB_Detach(); // Shutdown bluetooth bt.disconnect(); bt.sleep(); // Disable all interrupts cli(); // Shutdown setHigh(POWER_HOLD_PIN); FOREVER; //} } else // Plugged in { // Charging screen // clock.sleeping = 1; menu.spawn((void *) batteryStatus); } }
volatile char lightMeter(char key, char first) { static char held = 0; if(first) { lcd.backlight(0); hardware_flashlight(0); } if(!held) { lcd.cls(); menu.setTitle(TEXT("Light Meter")); if(key == FR_KEY) { held = 1; menu.setBar(TEXT("RETURN"), TEXT("RUN")); } else { menu.setBar(TEXT("RETURN"), TEXT("PAUSE")); } char buf[6] , l; uint16_t val; char* text; val = (uint16_t)hardware_readLight(0); int_to_str(val, buf); text = buf; l = lcd.measureStringTiny(text); lcd.writeStringTiny(80 - l, 12 + SY, text); lcd.writeStringTiny(3, 12 + SY, TEXT("Level 1:")); val = (uint16_t)hardware_readLight(1); int_to_str(val, buf); text = buf; l = lcd.measureStringTiny(text); lcd.writeStringTiny(80 - l, 18 + SY, text); lcd.writeStringTiny(3, 18 + SY, TEXT("Level 2:")); val = (uint16_t)hardware_readLight(2); int_to_str(val, buf); text = buf; l = lcd.measureStringTiny(text); lcd.writeStringTiny(80 - l, 24 + SY, text); lcd.writeStringTiny(3, 24 + SY, TEXT("Level 3:")); lcd.update(); _delay_ms(10); } else { if(key == FR_KEY) held = 0; } if(key == FL_KEY) { lcd.backlight(255); return FN_CANCEL; } return FN_CONTINUE; }
volatile char motionTrigger(char key, char first) { uint8_t i; uint16_t val; static uint16_t lv[3]; static uint8_t threshold = 2; if(key == LEFT_KEY) { if(threshold > 0) threshold--; first = 1; } if(key == RIGHT_KEY) { if(threshold < 4) threshold++; first = 1; } if(first) { sleepOk = 0; clock.tare(); lcd.cls(); menu.setTitle(TEXT("Motion Sensor")); menu.setBar(TEXT("RETURN"), BLANK_STR); lcd.drawLine(10, 22, 84-10, 22); lcd.drawLine(11, 21, 11, 23); lcd.drawLine(84-11, 21, 84-11, 23); lcd.drawLine(12, 20, 12, 24); lcd.drawLine(84-12, 20, 84-12, 24); lcd.drawLine(13, 20, 13, 24); lcd.drawLine(84-13, 20, 84-13, 24); lcd.setPixel(42, 21); lcd.setPixel(42+10, 21); lcd.setPixel(42-10, 21); lcd.setPixel(42+20, 21); lcd.setPixel(42-20, 21); i = threshold * 10; lcd.drawLine(42-3-20+i, 16, 42+3-20+i, 16); lcd.drawLine(42-2-20+i, 17, 42+2-20+i, 17); lcd.drawLine(42-1-20+i, 18, 42+1-20+i, 18); lcd.setPixel(42-20+i, 19); lcd.writeStringTiny(19, 25, TEXT("SENSITIVITY")); lcd.update(); lcd.backlight(0); hardware_flashlight(0); _delay_ms(50); for(i = 0; i < 3; i++) { lv[i] = (uint16_t)hardware_readLight(i); } } uint8_t thres = 4 - threshold + 2; if((4 - threshold) > 2) thres += ((4 - threshold) - 1) * 2; for(i = 0; i < 3; i++) { val = (uint16_t)hardware_readLight(i); if(clock.eventMs() > 1000 && val > thres && (val < (lv[i] - thres) || val > (lv[i] + thres))) { clock.tare(); shutter_capture(); } lv[i] = val; } if(key == FL_KEY) { sleepOk = 1; lcd.backlight(255); return FN_CANCEL; } return FN_CONTINUE; }