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 factoryReset(char key, char first) { if(first) { lcd.cls(); lcd.writeString(14, 12, TEXT("Reset all")); lcd.writeString(14, 22, TEXT("settings?")); menu.setTitle(TEXT("Reset")); menu.setBar(TEXT("CANCEL"), TEXT("RESET")); lcd.update(); } switch(key) { case FL_KEY: return FN_CANCEL; case FR_KEY: settings_default(); menu.message(TEXT("Factory Reset")); return FN_CANCEL; } return FN_CONTINUE; }
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; }
volatile char lighteningTrigger(char key, char first) { if(first) { sleepOk = 0; hardware_lightening_enable(); lcd.cls(); menu.setTitle(TEXT("Lightening")); lcd.writeString(25, 20, TEXT("READY")); menu.setBar(TEXT("RETURN"), TEXT("CALIBRATE")); lcd.update(); } if(key == FL_KEY || key == LEFT_KEY) { sleepOk = 1; hardware_lightening_disable(); return FN_CANCEL; } if(key == FR_KEY) { menu.message(TEXT("Calibrating")); hardware_lightening_disable(); } return FN_CONTINUE; }
volatile char timerRemoteStart(char key, char first) { menu.message(TEXT("Started Remote")); remote.set(REMOTE_PROGRAM); remote.set(REMOTE_START); menu.spawn((void*)timerStatusRemote); return FN_JUMP; }
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; }
volatile char timerStop(char key, char first) { if(first) timer.running = 0; menu.message(TEXT("Stopped")); menu.back(); return FN_CANCEL; }
uint8_t Remote::send(uint8_t id, uint8_t type) { switch(id) { case REMOTE_BATTERY: return bt.sendDATA(id, type, (void *) &battery_percent, sizeof(battery_percent)); case REMOTE_STATUS: return bt.sendDATA(id, type, (void *) &timer.status, sizeof(timer.status)); case REMOTE_PROGRAM: return bt.sendDATA(id, type, (void *) &timer.current, sizeof(timer.current)); case REMOTE_MODEL: { uint8_t tmp = REMOTE_MODEL_TLP; return bt.sendDATA(id, type, (void *) &tmp, sizeof(uint8_t)); } case REMOTE_FIRMWARE: { unsigned long version = VERSION; void *ptr = &version; return bt.sendDATA(id, type, ptr, sizeof(version)); } case REMOTE_BT_FW_VERSION: { uint8_t btVersion = bt.version(); return bt.sendDATA(id, type, (void *) &btVersion, sizeof(btVersion)); } case REMOTE_PROTOCOL_VERSION: { unsigned long remoteVersion = REMOTE_VERSION; void *ptr = &remoteVersion; return bt.sendDATA(id, type, ptr, sizeof(remoteVersion)); } case REMOTE_CAMERA_FPS: return bt.sendDATA(id, type, (void *) &conf.cameraFPS, sizeof(conf.cameraFPS)); case REMOTE_CAMERA_MAKE: return bt.sendDATA(id, type, (void *) &conf.cameraMake, sizeof(conf.cameraMake)); case REMOTE_ISO: { uint8_t tmp = camera.iso(); return bt.sendDATA(id, type, (void *) &tmp, sizeof(tmp)); } case REMOTE_APERTURE: { uint8_t tmp = camera.aperture(); return bt.sendDATA(id, type, (void *) &tmp, sizeof(tmp)); } case REMOTE_SHUTTER: { uint8_t tmp = camera.shutter(); return bt.sendDATA(id, type, (void *) &tmp, sizeof(tmp)); } case REMOTE_VIDEO: { uint8_t tmp = camera.recording; return bt.sendDATA(id, type, (void *) &tmp, sizeof(tmp)); } case REMOTE_LIVEVIEW: { uint8_t tmp = camera.modeLiveView; return bt.sendDATA(id, type, (void *) &tmp, sizeof(tmp)); } case REMOTE_THUMBNAIL: { menu.message(STR("Busy")); /* uint8_t ret = camera.getCurrentThumbStart(); if(ret != PTP_RETURN_ERROR) { bt.sendDATA(REMOTE_THUMBNAIL_SIZE, type, (void *) &PTP_Bytes_Total, sizeof(PTP_Bytes_Total)); bt.sendDATA(id, type, (void *) PTP_Buffer, PTP_Bytes_Received); while(ret == PTP_RETURN_DATA_REMAINING) { ret = camera.getCurrentThumbContinued(); bt.sendDATA(id, type, (void *) PTP_Buffer, PTP_Bytes_Received); } } */ ///////////////////////// DEMO Code //////////////////////////// PTP_Bytes_Total = sizeof(thm); bt.sendDATA(REMOTE_THUMBNAIL_SIZE, type, (void *) &PTP_Bytes_Total, sizeof(PTP_Bytes_Total)); uint16_t total_sent = 0, i; while(total_sent < PTP_Bytes_Total) { for(i = 0; i < PTP_BUFFER_SIZE; i++) { PTP_Buffer[i] = pgm_read_byte(&thm[i + total_sent]); if(total_sent + i >= PTP_Bytes_Total) break; } PTP_Bytes_Received = i; total_sent += PTP_Bytes_Received; if(PTP_Bytes_Received == 0) break; bt.sendDATA(id, type, (void *) PTP_Buffer, PTP_Bytes_Received); if(total_sent >= PTP_Bytes_Total) break; } ///////////////////////////////////////////////////////////////// return 0; } default: return bt.sendDATA(id, type, 0, 0); } return 0; }
volatile void Button::poll() { uint8_t i; char p; for(i = 0; i < NUM_KEYS; i++) { p = pgm_read_byte(&button_pins[i]); if(i < 2) p = (getBit(p, FB_PIN) == LOW); else p = (getBit(p, B_PIN) == LOW); if(p) // key is pressed { if(button_count[i] < DEBOUNCE_REPEAT_DELAY) { button_count[i]++; if(button_count[i] > DEBOUNCE_ON) { if(button_status[i] == 0) { button_flag[i] = 1; button_status[i] = 1; //button debounced to 'pressed' status clock.awake(); // keep from sleeping since a button was pressed } } } else { if(i + 1 == UP_KEY || i + 1 == DOWN_KEY || (verticalRepeat && (i + 1 == LEFT_KEY || i + 1 == RIGHT_KEY))) { button_flag[i] = 1; button_status[i] = 1; //button debounced to 'pressed' status button_count[i] = DEBOUNCE_REPEAT_DELAY - DEBOUNCE_REPEAT_SPEED; } else if(i + 1 == FL_KEY) { off_count++; if(off_count > POWER_OFF_TIME) { menu.message(TEXT("Power Off")); menu.task(); cli(); while(getBit(p, FB_PIN) == LOW) wdt_reset(); hardware_off(); } } } } else // not pressed { if(i + 1 == FL_KEY) off_count = 0; if(button_count[i] > 0) { //button_flag[i] = 0; if(button_count[i] > DEBOUNCE_MAX) button_count[i] = DEBOUNCE_MAX; button_count[i]--; if(button_count[i] < DEBOUNCE_OFF) { button_status[i] = 0; //button debounced to 'released' status } } } } }
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; }