uint8_t Remote::send(uint8_t id, uint8_t type) { switch(id) { case REMOTE_BATTERY: return bt.sendDATA(id, type, (void *) &battery_percent, sizeof(uint8_t)); 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(program)); case REMOTE_START: return bt.sendDATA(id, type, 0, 0); case REMOTE_STOP: return bt.sendDATA(id, type, 0, 0); } return 0; }
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; }
uint8_t Remote::debugMessage(char *str) { uint8_t len = 0; while(*(str + len) != '\0' && len < 255) len++; return bt.sendDATA(REMOTE_DEBUG, REMOTE_TYPE_SEND, (void *) str, len); }
uint8_t Remote::set(uint8_t id, uint8_t value) { return bt.sendDATA(id, REMOTE_TYPE_SET, (void *) &value, sizeof(value)); }
uint8_t Remote::unWatch(uint8_t id) { return bt.sendDATA(id, REMOTE_TYPE_NOTIFY_UNWATCH, 0, 0); }
uint8_t Remote::request(uint8_t id) { requestActive = 1; return bt.sendDATA(id, REMOTE_TYPE_REQUEST, 0, 0); }