def take_picture2(self, save): """Take a picture, returning the JPEG bytes, with the option to save it to the SD card.""" cmd = Command(CommandType.takepic2) cmd.set_arg(Command.HDR_ARG_ARG1, int(save)) rcmd = self._send_cmd(cmd) return Picture.from_bytes(rcmd.body)
def set_wifi_channel(self, chan): """Set the wifi channel""" if not 1 <= chan <= 13: raise ValueError('invalid wifi channel') cmd = Command(CommandType.setwifichan) cmd.set_arg(Command.HDR_ARG_ARG1, chan) rcmd = self._send_cmd(cmd) return rcmd.get_arg(Command.HDR_ARG_ARG1) == 0
def start_video_stream(self, highdef=True): """Start a live video stream""" cmd = Command(CommandType.startstream) cmd.set_arg(Command.HDR_ARG_ARG1, int(highdef)) if self._compare_and_set_streaming(False, True): for frame in self._stream_loop(cmd, VideoFrame): yield frame return
def set_recording_rotate_duration(self, t): """Sets default recording length to t seconds (min 60, max 600). Change only seems to take affect after a server restart.""" if not 60 <= t <= 600: raise ValueError('seconds is out of range') cmd = Command(CommandType.setrectime) cmd.set_arg(Command.HDR_ARG_ARG1, t // 60) rcmd = self._send_cmd(cmd) return rcmd.get_arg(Command.HDR_ARG_ARG1) == 0
def list_pictures2(self, n): """Returns a list of up to `n` pictures from /mnt/Photo (max 512). Similar to `list_pictures()`, but the server implements this as a separate command.""" if not 0 <= n <= 512: raise ValueError('invalid number for max pictures to list') cmd = Command(CommandType.getpiclist2) cmd.set_arg(Command.HDR_ARG_ARG1, n) rcmd = self._send_cmd(cmd) if rcmd.get_arg(Command.HDR_ARG_ARG1) != 0: return None return list(PictureListItem.iter_from_bytes(rcmd.body))
def set_resolution(self, res1080p): """True to set resolution to 1080p, false for 720p""" cmd = Command(CommandType.set1080p) cmd.set_arg(Command.HDR_ARG_ARG1, int(res1080p)) rcmd = self._send_cmd(cmd) return rcmd.get_arg(Command.HDR_ARG_ARG1) == 0
def set_camera_flip(self, flip): """Sets the camera orientation from the given CameraFlip element""" cmd = Command(CommandType.setcamflip) cmd.set_arg(Command.HDR_ARG_ARG1, flip.value) rcmd = self._send_cmd(cmd) return rcmd.get_arg(Command.HDR_ARG_ARG1) == 0
def set_baudrate(self, rate): """Set baudrate for drone's flight control""" cmd = Command(CommandType.setbaudrate) cmd.set_arg(Command.HDR_ARG_ARG1, rate) rcmd = self._send_cmd(cmd) return rcmd.get_arg(Command.HDR_ARG_ARG1) == 0