def change_event_cb(e): obj = e.get_target() row = lv.C_Pointer() col = lv.C_Pointer() table.get_selected_cell(row, col) # print("row: ",row.uint_val) chk = table.has_cell_ctrl(row.uint_val, 0, lv.table.CELL_CTRL.CUSTOM_1) if chk: table.clear_cell_ctrl(row.uint_val, 0, lv.table.CELL_CTRL.CUSTOM_1) else: table.add_cell_ctrl(row.uint_val, 0, lv.table.CELL_CTRL.CUSTOM_1)
def aligned_buf(buf, alignment): """Return an aligned buffer Given a buffer, return a memory view within that buffer, which starts at an aligned address in RAM. The returned memory view is possibly smaller. !! You must keep a reference to the original buffer to prevent the garbage collector from collecting the aligned view! Arguments: buf -- An object that implements buffer protocol alignment -- Integer value """ p = lv.C_Pointer() p.ptr_val = buf if not buf_fmt: return None addr = ustruct.unpack(buf_fmt, p.ptr_val)[0] mod = addr % alignment offset = alignment - mod if mod != 0 else 0 if len(buf) <= offset: return None addr += offset p = lv.C_Pointer.cast(ustruct.pack(buf_fmt, addr)) return p.ptr_val.__dereference__(len(buf) - offset)