volatile char shutter_saveAs(char key, char first) { static char name[MENU_NAME_LEN - 1]; static char newId; if(first) { newId = timer.nextId(); if(newId < 0) { menu.message(TEXT("No Space")); return FN_CANCEL; } } char ret = menu.editText(key, name, TEXT("Save As"), first); if(ret == FN_SAVE) { name[MENU_NAME_LEN - 2] = 0; strcpy((char*)timer.current.Name, name); timer.save(newId); menu.message(TEXT("Saved")); menu.back(); } return ret; }
volatile char runHandler(char key, char first) { static char pressed; if(first) { pressed = key; key = 0; } if(pressed == FR_KEY) { menu.message(TEXT("Timer Started")); timer.begin(); menu.spawn((void*)timerStatus); return FN_JUMP; } menu.push(); menu.select(0); menu.init((menu_item*)menu_options); lcd.update(); return FN_CANCEL; }
void settings_default() { timer.setDefault(); strcpy((char*)conf.sysName, " "); conf.warnTime = 2; conf.mirrorTime = 2; conf.cameraFPS = 33; conf.bulbMode = 0; conf.lcdColor = 0; conf.cameraMake = CANON; conf.settingsVersion = SETTINGS_VERSION; conf.shutterVersion = SHUTTER_VERSION; conf.lcdBacklightTime = 3; conf.sysOffTime = 12; conf.flashlightOffTime = 3; conf.devMode = 0; conf.auxPort = AUX_MODE_DISABLED; conf.btMode = BT_MODE_SLEEP; conf.halfPress = HALF_PRESS_ENABLED; conf.bulbOffset = 75; conf.interface = INTERFACE_AUTO; conf.brampMode = BRAMP_MODE_BULB_ISO; conf.autoRun = AUTO_RUN_OFF; conf.modeSwitch = USB_CHANGE_MODE_DISABLED; conf.dollyPulse = 100; conf.lcdContrast = 0xf; conf.lcdCoefficent = 0x7; conf.lcdBias = 0x4; conf.bulbMin = 56; conf.isoMax = 10; conf.apertureMax = 31; conf.apertureMin = 2; settings_save(); settings_load(); }
void settings_default() { timer.setDefault(); strcpy((char*)conf.sysName, " "); conf.warnTime = 2; conf.mirrorTime = 2; conf.lcdColor = 0; conf.settingsVersion = SETTINGS_VERSION; conf.shutterVersion = SHUTTER_VERSION; conf.lcdBacklightTime = 3; conf.sysOffTime = 12; conf.flashlightOffTime = 3; conf.devMode = 0; conf.auxPort = AUX_MODE_DISABLED; conf.btMode = BT_MODE_SLEEP; conf.brampMode = BRAMP_MODE_BULB_ISO; conf.autoRun = AUTO_RUN_OFF; conf.dollyPulse = 100; conf.dollyPulse2 = 100; conf.lcdContrast = 3; conf.lcdCoefficent = 0x7; conf.lcdBias = 0x3; conf.isoMax = 10; conf.apertureMax = 31; conf.apertureMin = 2; conf.debugEnabled = 0; conf.arbitraryBulb = 0; conf.menuWrap = 1; conf.extendedRamp = 0; strcpy((char*)conf.test, "Test "); conf.lightIntegrationMinutes = 5; conf.pFactor = 10; conf.iFactor = 12; conf.dFactor = 12; conf.errorAlert = 0; conf.lightThreshold = 20; conf.linearInterpolation = 0; conf.camera.cameraFPS = 33; conf.camera.nikonUSB = 0; conf.camera.bulbEndOffset = 8; conf.camera.bulbMin = 56; conf.camera.bulbOffset = 75; conf.camera.negBulbOffset = 0; conf.camera.interface = INTERFACE_AUTO; conf.camera.cameraMake = CANON; conf.camera.bulbMode = 0; conf.camera.halfPress = HALF_PRESS_ENABLED; conf.camera.modeSwitch = USB_CHANGE_MODE_DISABLED; conf.camera.brampGap = 6; for(uint8_t i = 0; i < MAX_CAMERAS_SETTINGS; i++) { camera_settings_t cs; memset((void*)&cs, 0, sizeof(camera_settings_t)); eeprom_write_block((const void*)&cs, &camera_settings_eep[i], sizeof(camera_settings_t)); } settings_save(); settings_load(); }
volatile char timerRevert(char key, char first) { if(first) timer.load(timer.currentId); menu.message(TEXT("Reverted")); menu.back(); return FN_CANCEL; }
volatile char timerSaveCurrent(char key, char first) { if(first) timer.save(timer.currentId); menu.message(TEXT("Saved")); menu.back(); return FN_CANCEL; }
volatile char timerSaveDefault(char key, char first) { if(first) timer.save(0); menu.message(TEXT("Saved")); menu.back(); return FN_CANCEL; }
void updateConditions() { if(timerNotRunning != !timer.running) menu.refresh(); timerNotRunning = !timer.running; modeTimelapse = (timer.current.Mode & TIMELAPSE); modeHDR = (timer.current.Mode & HDR); modeStandard = (!modeHDR && !modeRamp); modeRamp = (timer.current.Mode & RAMP); modeRampKeyAdd = (modeRamp && (timer.current.Keyframes < MAX_KEYFRAMES)); modeRampKeyDel = (modeRamp && (timer.current.Keyframes > 1)); bulb1 = timer.current.Keyframes > 1 && modeRamp; bulb2 = timer.current.Keyframes > 2 && modeRamp; bulb3 = timer.current.Keyframes > 3 && modeRamp; bulb4 = timer.current.Keyframes > 4 && modeRamp; showGap = timer.current.Photos != 1 && modeTimelapse; showRemoteStart = (remote.connected && !remote.running); clock.sleepOk = timerNotRunning && !timer.cableIsConnected() && bt.state != BT_ST_CONNECTED && sleepOk; }
void settings_init() { settings_load(); uint8_t need_save = 0; if(conf.shutterVersion != SHUTTER_VERSION) { timer.setDefault(); conf.shutterVersion = SHUTTER_VERSION; need_save = 1; } if(conf.settingsVersion != SETTINGS_VERSION) { settings_default(); need_save = 0; settings_reset = 1; // This is where we'd put a setup wizard } if(need_save) settings_save(); }
void settings_init() { settings_load(); if(eeprom_read_byte((const uint8_t *) &conf_eep) == 255 || conf.version != VERSION) { timer.setDefault(); strcpy((char *)conf.sysName, "sys01"); conf.warnTime = 2; conf.mirrorTime = 2; conf.cameraFPS = 34; conf.bulbMode = 0; conf.lcdColor = 0; conf.cameraMake = CANON; conf.version = VERSION; conf.lcdBacklightTime = 3; conf.sysOffTime = 12; conf.flashlightOffTime = 3; settings_save(); } settings_load(); }
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); } }
void Remote::event() { switch(bt.event) { case BT_EVENT_DISCONNECT: notify.unWatch(&remote_notify); // stop all active notifications //debug(STR("REMOTE::EVENT: Disconnected\r\n")); connected = 0; break; case BT_EVENT_CONNECT: connected = 1; //debug(STR("REMOTE::EVENT: Connected\r\n")); request(REMOTE_MODEL); break; case BT_EVENT_DATA: switch(bt.dataId) { case REMOTE_STATUS: if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND); if(bt.dataType == REMOTE_TYPE_SEND && bt.dataSize == sizeof(timer_status)) memcpy(&status, bt.data, bt.dataSize); if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_STATUS, (void *)&timer.status, sizeof(timer.status), &remote_notify); if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_STATUS, &remote_notify); break; case REMOTE_PROGRAM: if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND); if(bt.dataType == REMOTE_TYPE_SEND && bt.dataSize == sizeof(program)) memcpy(¤t, bt.data, bt.dataSize); if(bt.dataType == REMOTE_TYPE_SET && bt.dataSize == sizeof(program)) { memcpy((void*)&timer.current, bt.data, bt.dataSize); menu.refresh(); } if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_PROGRAM, (void *)&timer.current, sizeof(timer.current), &remote_notify); if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_PROGRAM, &remote_notify); break; case REMOTE_BATTERY: if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND); if(bt.dataType == REMOTE_TYPE_SEND) memcpy(&battery, bt.data, bt.dataSize); if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_BATTERY, (void *)&battery_percent, sizeof(battery_percent), &remote_notify); if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_BATTERY, &remote_notify); break; case REMOTE_START: if(bt.dataType == REMOTE_TYPE_REQUEST) send(timer.running ? REMOTE_START : REMOTE_STOP, REMOTE_TYPE_SEND); if(bt.dataType == REMOTE_TYPE_SEND) running = 1; if(bt.dataType == REMOTE_TYPE_SET) runHandler(FR_KEY, 1); if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_START, (void *)&timer.running, sizeof(timer.running), &remote_notify); if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_START, &remote_notify); break; case REMOTE_STOP: if(bt.dataType == REMOTE_TYPE_REQUEST) send(timer.running ? REMOTE_START : REMOTE_STOP, REMOTE_TYPE_SEND); if(bt.dataType == REMOTE_TYPE_SEND) running = 0; if(bt.dataType == REMOTE_TYPE_SET) timerStop(FR_KEY, 1); if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_START, (void *)&timer.running, sizeof(timer.running), &remote_notify); if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_START, &remote_notify); break; case REMOTE_BULB_START: if(bt.dataType == REMOTE_TYPE_SET) timer.bulbStart(); break; case REMOTE_BULB_END: if(bt.dataType == REMOTE_TYPE_SET) timer.bulbEnd(); break; case REMOTE_CAPTURE: if(bt.dataType == REMOTE_TYPE_SET) timer.capture(); break; case REMOTE_MODEL: if(bt.dataType == REMOTE_TYPE_REQUEST) send(REMOTE_MODEL, REMOTE_TYPE_SEND); if(bt.dataType == REMOTE_TYPE_SEND) memcpy(&model, bt.data, bt.dataSize); break; case REMOTE_FIRMWARE: case REMOTE_BT_FW_VERSION: case REMOTE_PROTOCOL_VERSION: if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND); break; case REMOTE_CAMERA_FPS: if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND); if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_CAMERA_FPS, (void *)&conf.cameraFPS, sizeof(conf.cameraFPS), &remote_notify); if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_CAMERA_FPS, &remote_notify); break; case REMOTE_CAMERA_MAKE: if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND); if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_CAMERA_MAKE, (void *)&conf.cameraMake, sizeof(conf.cameraMake), &remote_notify); if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_CAMERA_MAKE, &remote_notify); break; case REMOTE_DEBUG: if(bt.dataType == REMOTE_TYPE_SEND) { bt.data[bt.dataSize] = 0; debug_remote(bt.data); } break; case REMOTE_ISO: if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND); if(bt.dataType == REMOTE_TYPE_SET && bt.dataSize == sizeof(uint8_t)) { uint8_t tmp; memcpy((void*)&tmp, bt.data, bt.dataSize); camera.setISO(tmp); } break; case REMOTE_APERTURE: if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND); if(bt.dataType == REMOTE_TYPE_SET && bt.dataSize == sizeof(uint8_t)) { uint8_t tmp; memcpy((void*)&tmp, bt.data, bt.dataSize); camera.setAperture(tmp); } break; case REMOTE_SHUTTER: if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND); if(bt.dataType == REMOTE_TYPE_SET && bt.dataSize == sizeof(uint8_t)) { uint8_t tmp; memcpy((void*)&tmp, bt.data, bt.dataSize); camera.setShutter(tmp); } break; case REMOTE_THUMBNAIL: if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND); break; case REMOTE_VIDEO: if(bt.dataType == REMOTE_TYPE_SET && bt.dataSize == sizeof(uint8_t)) { uint8_t tmp; memcpy((void*)&tmp, bt.data, bt.dataSize); if(tmp) camera.videoStart(); else camera.videoStop(); } if(bt.dataType == REMOTE_TYPE_SEND && bt.dataSize == sizeof(uint8_t)) { uint8_t tmp; memcpy((void*)&tmp, bt.data, bt.dataSize); if(tmp) recording = true; else recording = false; } if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND); if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_VIDEO, (void *)&camera.recording, sizeof(camera.recording), &remote_notify); if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_VIDEO, &remote_notify); break; case REMOTE_LIVEVIEW: if(bt.dataType == REMOTE_TYPE_SET && bt.dataSize == sizeof(uint8_t)) { uint8_t tmp; memcpy((void*)&tmp, bt.data, bt.dataSize); if(tmp) camera.liveView(tmp); } if(bt.dataType == REMOTE_TYPE_SEND && bt.dataSize == sizeof(uint8_t)) { uint8_t tmp; memcpy((void*)&tmp, bt.data, bt.dataSize); if(tmp) modeLiveView = true; else modeLiveView = false; } if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND); if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_LIVEVIEW, (void *)&camera.modeLiveView, sizeof(camera.modeLiveView), &remote_notify); if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_LIVEVIEW, &remote_notify); break; default: return; } bt.event = BT_EVENT_NULL; break; } requestActive = 0; }
volatile char cableRelease(char key, char first) { static char status; //, cable; if(first) { status = 0; //cable = 0; lcd.cls(); menu.setTitle(TEXT("Cable Remote")); menu.setBar(TEXT("Bulb"), TEXT("Photo")); lcd.update(); timer.half(); } if(key == FL_KEY) { if(status != 1) { status = 1; lcd.eraseBox(8, 18, 8 + 6 * 11, 26); lcd.writeString(8, 18, TEXT("(BULB OPEN)")); timer.bulbStart(); lcd.update(); } else { status = 0; lcd.eraseBox(8, 18, 8 + 6 * 11, 26); timer.bulbEnd(); lcd.update(); } } else if(key == FR_KEY && status != 1) { status = 0; lcd.eraseBox(8, 18, 8 + 6 * 11, 26); timer.capture(); lcd.update(); } else if(key != 0) { status = 0; lcd.eraseBox(8, 18, 8 + 6 * 11, 26); timer.half(); lcd.update(); } /* if(timer.cableIsConnected()) { if(cable == 0) { cable = 1; lcd.writeStringTiny(6, 28, TEXT("Cable Connected")); lcd.update(); } } else { if(cable == 1) { cable = 0; lcd.eraseBox(6, 28, 6 + 15 * 5, 36); lcd.update(); } } */ if(key == LEFT_KEY) { timer.off(); return FN_CANCEL; } return FN_CONTINUE; }
volatile char shutterTest(char key, char first) { static char status, cable; if(first) { status = 0; cable = 0; lcd.cls(); menu.setTitle(TEXT("Shutter Test")); menu.setBar(TEXT("Half"), TEXT("Full")); lcd.update(); } if(key == FL_KEY && status != 1) { status = 1; lcd.eraseBox(20, 18, 20 + 6 * 6, 26); lcd.writeString(20, 18, TEXT("(HALF)")); timer.half(); lcd.update(); } else if(key == FR_KEY && status != 2) { status = 2; lcd.eraseBox(20, 18, 20 + 6 * 6, 26); lcd.writeString(20, 18, TEXT("(FULL)")); timer.full(); lcd.update(); } else if(key != 0) { status = 0; lcd.eraseBox(20, 18, 20 + 6 * 6, 26); timer.off(); lcd.update(); } if(timer.cableIsConnected()) { if(cable == 0) { cable = 1; lcd.writeStringTiny(6, 28, TEXT("Cable Connected")); lcd.update(); } } else { if(cable == 1) { cable = 0; lcd.eraseBox(6, 28, 6 + 15 * 5, 36); lcd.update(); } } if(key == LEFT_KEY) return FN_CANCEL; return FN_CONTINUE; }
volatile char shutter_load(char key, char first) { static char menuSize; static char menuSelected; static char itemSelected; uint8_t c; char ch, update, menuScroll; update = 0; if(first) { menuScroll = 0; update = 1; } if(key == UP_KEY && menuSelected > 0) { menuSelected--; update = 1; } else if(key == DOWN_KEY && menuSelected < menuSize - 1) { menuSelected++; update = 1; } if(update) { lcd.cls(); if(menuSelected > 2) menuScroll = menuSelected - 2; menuSize = 0; char i = 0; for(char x = 1; x < MAX_STORED; x++) { i++; ch = eeprom_read_byte((uint8_t*)&stored[i - 1].Name[0]); if(ch == 0 || ch == 255) continue; for(c = 0; c < MENU_NAME_LEN - 1; c++) // Write settings item text // { if(i >= menuScroll && i <= menuScroll + 5) { ch = eeprom_read_byte((uint8_t*)&stored[i - 1].Name[c]); if(ch == 0) break; if(ch < 'A' || ch > 'Z') ch = ' '; lcd.writeChar(3 + c * 6, 8 + 9 * (menuSize - menuScroll), ch); if(menuSize == menuSelected) itemSelected = i - 1; } } menuSize++; } lcd.drawHighlight(2, 7 + 9 * (menuSelected - menuScroll), 81, 7 + 9 * (menuSelected - menuScroll) + 8); menu.setTitle(TEXT("Load Saved")); menu.setBar(TEXT("CANCEL"), TEXT("LOAD")); lcd.drawLine(0, 3, 0, 40); lcd.drawLine(83, 3, 83, 40); lcd.update(); } switch(key) { case FL_KEY: case LEFT_KEY: return FN_CANCEL; case FR_KEY: case RIGHT_KEY: timer.load(itemSelected); menu.message(TEXT("Loaded")); menu.back(); menu.select(0); return FN_SAVE; } return FN_CONTINUE; }