當前位置: 首頁>>代碼示例>>Python>>正文


Python uctypes.addressof方法代碼示例

本文整理匯總了Python中uctypes.addressof方法的典型用法代碼示例。如果您正苦於以下問題:Python uctypes.addressof方法的具體用法?Python uctypes.addressof怎麽用?Python uctypes.addressof使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在uctypes的用法示例。


在下文中一共展示了uctypes.addressof方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: show

# 需要導入模塊: import uctypes [as 別名]
# 或者: from uctypes import addressof [as 別名]
def show(self):
        lb = self.linebuf
        buf = self.buffer
        self._write(b'\x5c', 0)  # Enable data write
        if self.height == 128:
            for l in range(128):
                l0 = (95 - l) % 128  # 95 94 .. 1 0 127 126 .. 96
                start = l0 * self.width
                _lcopy(lb, addressof(buf) + start, self.width)
                self._write(lb, 1)  # Send a line
        else:
            for l in range(128):
                if l < 64:
                    start = (63 -l) * self.width  # 63 62 .. 1 0
                    _lcopy(lb, addressof(buf) + start, self.width)
                    self._write(lb, 1)  # Send a line
                elif l < 96:  # This is daft but I can't get setrow to work
                    self._write(lb, 1)  # Let RAM counter increase
                else:
                    start = (191 - l) * self.width  # 127 126 .. 95
                    _lcopy(lb, addressof(buf) + start, self.width)
                    self._write(lb, 1)  # Send a line 
開發者ID:peterhinch,項目名稱:micropython-nano-gui,代碼行數:24,代碼來源:ssd1351.py

示例2: from_buffer

# 需要導入模塊: import uctypes [as 別名]
# 或者: from uctypes import addressof [as 別名]
def from_buffer(data):
        """
        Parse HCI SCO data

        References can be found here:
        * https://www.bluetooth.org/en-us/specification/adopted-specifications
        ** Core specification 4.1
        ** [vol 2] Part E (Section 5) - HCI Data Formats
        ** [vol 2] Part E (Section 5.4) - Exchange of HCI-specific information
        """
        hci_sco = uctypes.struct(
            uctypes.addressof(data[:HCI_SCO.struct_size]),
            HCI_SCO_STRUCT,
            uctypes.LITTLE_ENDIAN
        )
        data = data[HCI_SCO.struct_size:]
        return HCI_SCO(hci_sco.handle, hci_sco.ps, hci_sco.xx, data) 
開發者ID:dmazzella,項目名稱:uble,代碼行數:19,代碼來源:sco.py

示例3: __init__

# 需要導入模塊: import uctypes [as 別名]
# 或者: from uctypes import addressof [as 別名]
def __init__(self, evtcode, data=b'', module="IDB05A1"):
        evtname, evtstruct = HCI_EVENTS[evtcode]
        subevtcode, subevtname = (0, "")
        if evtcode in (EVT_LE_META_EVENT, EVT_VENDOR):
            subevt = uctypes.struct(
                uctypes.addressof(data),
                evtstruct,
                uctypes.LITTLE_ENDIAN
            )
            subevtcode = subevt.subevent
            if evtcode == EVT_LE_META_EVENT:
                subevtname, evtstruct = HCI_LE_META_EVENTS[subevtcode]
            elif evtcode == EVT_VENDOR:
                subevtname, evtstruct = HCI_VENDOR_EVENTS[subevtcode]
            data = bytes(subevt.data)

        self._evtcode = evtcode
        self._evtname = evtname
        self._subevtcode = subevtcode
        self._subevtname = subevtname
        self._struct = evtstruct
        self._data = data
        self._module = module 
開發者ID:dmazzella,項目名稱:uble,代碼行數:25,代碼來源:event.py

示例4: __getattr__

# 需要導入模塊: import uctypes [as 別名]
# 或者: from uctypes import addressof [as 別名]
def __getattr__(self, name):
        if name == "evtcode":
            return self._evtcode
        elif name == "evtname":
            return self._evtname
        elif name == "subevtcode":
            return self._subevtcode
        elif name == "subevtname":
            return self._subevtname
        elif name == "struct_size":
            return uctypes.sizeof(self.struct)
        elif name == "struct":
            if self._struct is None:
                return None
            return uctypes.struct(
                uctypes.addressof(self.data),
                self._struct.get(self._module, self._struct),
                uctypes.LITTLE_ENDIAN
            )
        elif name == "length":
            return len(self._data)
        elif name == "data":
            return self._data 
開發者ID:dmazzella,項目名稱:uble,代碼行數:25,代碼來源:event.py

示例5: write_trailer

# 需要導入模塊: import uctypes [as 別名]
# 或者: from uctypes import addressof [as 別名]
def write_trailer(outfile):
    outfile.write('}\n\n')
    outfile.write("colortable = (\n    b'")
    size = len(icon_colortable)
    for i in range(size):
        outfile.write("\\x{:02x}".format(icon_colortable[i]))
        if (i % 16) == 15 and i != (size - 1):
            outfile.write("'\n    b'")
    outfile.write("')\n\n")
    outfile.write("width = {}\n".format(icon_width))
    outfile.write("height = {}\n".format(icon_height))
    outfile.write("colors = {}\n".format(icon_colors))
    outfile.write("""
def get_icon(no):
    return width, height, addressof(_icons[no]), colors, addressof(colortable)
""") 
開發者ID:peterhinch,項目名稱:micropython-tft-gui,代碼行數:18,代碼來源:bmp_to_icon.py

示例6: one_line_data

# 需要導入模塊: import uctypes [as 別名]
# 或者: from uctypes import addressof [as 別名]
def one_line_data(self, line, stage):
        mv_linebuf = memoryview(self.line_buffer)
        self.asm_data[2] = addressof(mv_linebuf)
        self.asm_data[3] = stage
        spi_send_byte = self.spi.send           # send data
        self._SPI_send(b'\x70\x0a')
        self.Pin_EPD_CS.low()                   # CS low until end of line
        spi_send_byte(b'\x72\x00')              # data bytes
        odd_pixels(self.asm_data, 0, line * BYTES_PER_LINE)
        offset = BYTES_PER_LINE
        offset = scan(self.line_buffer, line, offset)
        even_pixels(self.asm_data, offset, line * BYTES_PER_LINE)
        offset += BYTES_PER_LINE

        spi_send_byte(mv_linebuf[:offset])      # send the accumulated line buffer
        self.Pin_EPD_CS.high()
        self._SPI_send(b'\x70\x02\x72\x07')     # output data to panel 
開發者ID:peterhinch,項目名稱:micropython-epaper,代碼行數:19,代碼來源:epdpart.py

示例7: __enter__

# 需要導入模塊: import uctypes [as 別名]
# 或者: from uctypes import addressof [as 別名]
def __enter__(self):
        self._acquire(uctypes.addressof(self.lock))
        return self 
開發者ID:peterhinch,項目名稱:micropython-samples,代碼行數:5,代碼來源:mutex.py

示例8: test

# 需要導入模塊: import uctypes [as 別名]
# 或者: from uctypes import addressof [as 別名]
def test(self):          # Nonblocking: try to acquire, return True if success.
        return self._attempt(uctypes.addressof(self.lock)) == 0 
開發者ID:peterhinch,項目名稱:micropython-samples,代碼行數:4,代碼來源:mutex.py

示例9: __getattr__

# 需要導入模塊: import uctypes [as 別名]
# 或者: from uctypes import addressof [as 別名]
def __getattr__(self, name):
        if name == "ogf":
            return self._ogf
        elif name == "ogf_name":
            return self._ogf_name
        elif name == "ocf":
            return self._ocf
        elif name == "ocf_name":
            return self._ocf_name
        elif name == "opcode":
            return self._opcode
        elif name == "evtcode":
            return self._evtcode
        elif name == "request_struct":
            if self._request_struct is None:
                return None
            return uctypes.struct(
                uctypes.addressof(self.request_data),
                self._request_struct.get(self._module, self._request_struct),
                uctypes.LITTLE_ENDIAN
            )
        elif name == "response_struct":
            if self._response_struct is None:
                return None
            return uctypes.struct(
                uctypes.addressof(self.response_data),
                self._response_struct.get(self._module, self._response_struct),
                uctypes.LITTLE_ENDIAN
            )
        elif name == "request_length":
            return len(self._request_data)
        elif name == "request_data":
            return self._request_data
        elif name == "response_length":
            return len(self._response_data)
        elif name == "response_data":
            return self._response_data
        else:
            raise AttributeError(name) 
開發者ID:dmazzella,項目名稱:uble,代碼行數:41,代碼來源:cmd.py

示例10: from_buffer

# 需要導入模塊: import uctypes [as 別名]
# 或者: from uctypes import addressof [as 別名]
def from_buffer(data):
        """
        Attribute opcode is the first octet of the PDU

         0 1 2 3 4 5 6 7
        -----------------
        |   att opcode  |
        -----------------
        |     a     |b|c|
        -----------------
        a - method
        b - command flag
        c - authentication signature flag

        References can be found here:
            * https://www.bluetooth.org/en-us/specification/adopted-specifications
            ** Core specification 4.1
            ** [vol 3] Part F (Section 3.3) - Attribute PDU
        """
        opcode = ustruct.unpack(ATT.struct_format, data[:ATT.struct_size])[0]

        # att = uctypes.struct(
        #     uctypes.addressof(data[:ATT.struct_size]),
        #     ATT_STRUCT,
        #     uctypes.LITTLE_ENDIAN
        # )

        data = data[ATT.struct_size:]
        return ATT(opcode, data) 
開發者ID:dmazzella,項目名稱:uble,代碼行數:31,代碼來源:att.py

示例11: write_header

# 需要導入模塊: import uctypes [as 別名]
# 或者: from uctypes import addressof [as 別名]
def write_header(outfile):
    outfile.write("""
# Code generated by bmp_to_icon.py
from uctypes import addressof

"""
)
    outfile.write("_icons = { \n") 
開發者ID:peterhinch,項目名稱:micropython-tft-gui,代碼行數:10,代碼來源:bmp_to_icon.py

示例12: printChar

# 需要導入模塊: import uctypes [as 別名]
# 或者: from uctypes import addressof [as 別名]
def printChar(self, c, bg_buf=None):
# get the charactes pixel bitmap and dimensions
        if self.text_font:
            fmv, rows, cols = self.text_font.get_ch(c)
        else:
            raise AttributeError('No font selected')
        cbytes, cbits = divmod(cols, 8)  # Not in packed format
        dcols = (cbytes + 1) * 8 if cbits else cbytes * 8 # cols for display
        pix_count = dcols * rows   # number of bits in the char
# test char fit
        if self.text_x + cols > self.text_width:  # does the char fit on the screen?
            if self.text_scroll:
                self.printCR()      # No, then CR
                self.printNewline(True) # NL: advance to the next line
            else:
                return 0
# Retrieve Background data if transparency is required
        if self.transparency: # in case of transpareny, the frame buffer content is needed
            if bg_buf is None:    # buffer allocation needed?
                if len(self.bg_buf) < pix_count * 3:
                    del(self.bg_buf)
                    gc.collect()
                    self.bg_buf = bytearray(pix_count * 3) # Make it bigger
                bg_buf = self.bg_buf
            self.setXY(self.text_x, self.text_y, self.text_x + dcols - 1, self.text_y + rows - 1) # set area
            TFT_io.tft_read_cmd_data_AS(0x2e, bg_buf, pix_count * 3) # read background data
        else:
            bg_buf = 0 # dummy assignment, since None is not accepted
# Set XY range & print char
        self.setXY(self.text_x, self.text_y, self.text_x + dcols - 1, self.text_y + rows - 1) # set area
        TFT_io.displaySCR_charbitmap(addressof(fmv), pix_count, self.text_color, bg_buf) # display char!
#advance pointer
        self.text_x += (cols + self.text_gap)
        return cols + self.text_gap 
開發者ID:peterhinch,項目名稱:micropython-tft-gui,代碼行數:36,代碼來源:tft.py

示例13: get_icon

# 需要導入模塊: import uctypes [as 別名]
# 或者: from uctypes import addressof [as 別名]
def get_icon(icon_index = 0, color_index = 0):
    return width, height, addressof(_icons[icon_index]), colors, addressof(colortable[color_index]) 
開發者ID:peterhinch,項目名稱:micropython-tft-gui,代碼行數:4,代碼來源:traffic.py

示例14: draw

# 需要導入模塊: import uctypes [as 別名]
# 或者: from uctypes import addressof [as 別名]
def draw(x, y, icon_index, draw_fct, color_index = 0):
    draw_fct(x - width//2, y - height // 2, width, height, addressof(_icons[icon_index]), colors, addressof(colortable[color_index])) 
開發者ID:peterhinch,項目名稱:micropython-tft-gui,代碼行數:4,代碼來源:traffic.py

示例15: frame_data_repeat

# 需要導入模塊: import uctypes [as 別名]
# 或者: from uctypes import addressof [as 別名]
def frame_data_repeat(self, stage, use_old):
        self.asm_data[0] = addressof(self.image)
        self.asm_data[1] = addressof(self.image_old) if use_old else 0
        start = pyb.millis()
        count = 0
        while True:
            self.frame_data(stage)
            count +=1
            if pyb.elapsed_millis(start) > self.factored_stage_time:
                break
        if self.verbose:
            print('frame_data_repeat count = {}'.format(count)) 
開發者ID:peterhinch,項目名稱:micropython-epaper,代碼行數:14,代碼來源:epdpart.py


注:本文中的uctypes.addressof方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。