import random import duml_cmdset import duml_crc import operator import rm_log import tools logger = rm_log.dji_scratch_logger_get() DUSS_MB_PACKAGE_V1_HEAD_SIZE = 11 DUSS_MB_PACKAGE_V1_CRC_SIZE = 2 DUSS_MB_PACKAGE_V1_CRCH_INIT = 0x77 DUSS_MB_PACKAGE_V1_CRC_INIT = 0x3692 def hostid2packid(host_id): host_id = int(host_id) host_id = ((int(host_id / 100) & 0x1f) | ((host_id % 100) << 5) & 0xe0) return [host_id] def _seqid2packid(seqid): seqid = tools.to_uint16(seqid) seqid_l = seqid & 0xff seqid_h = (seqid >> 8) & 0xff return [seqid_l, seqid_h] data_convert_func = { 'int8': tools.int8_to_byte,
from rm_log import dji_scratch_logger_get from tools import byte_to_float from tools import byte_to_int32 from tools import byte_to_string from widget_define import * from widget_module import Widget logger = dji_scratch_logger_get() def byte_to_value(type, byte): if type == 'bool': return byte[0] elif type == 'int32': return byte_to_int32(byte) elif type == 'float': return byte_to_float(byte) elif type == 'string': return byte_to_string(byte) class Position(object): def __init__(self): self.x = 0 self.y = 0 def update(self, x, y): self.x = x self.y = y def get(self):