#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@文件    :hexBit.py
@时间    :2021/12/09 13:48:58
@作者    :None
@版本    :1.0
@说明    :获取位的值
'''


def a_bit(data, i):
    if i == 1:
        return data & 0x01
    if i == 2:
        return (data & 0x02) >> 1
    if i == 3:
        return (data & 0x04) >> 2
    if i == 4:
        return (data & 0x08) >> 3
    if i == 5:
        return (data & 0x10) >> 4
    if i == 6:
        return (data & 0x20) >> 5
    if i == 7:
        return (data & 0x40) >> 6
    if i == 8:
        return (data & 0x80) >> 7


def hex_bcd(data):
    s = data // 16
    g = data % 16
    c = s * 10 + g
    return str(c)


def bcd_hex(data):
    int_data = int(data)
    s = int_data // 10
    g = int_data % 10
    c = s * 16 + g
    return c
