-- 先設定這顆 IC 的 slave 位址，之後才能用 i2c.* 存取（見「I2C 讀寫」頁）。
i2c.addr(0x58)

-- bit.* 位元運算，搭配 i2c.set()／i2c.clr() 修改暫存器位元。
check(bit.band(0xFF, 0x0F) == 0x0F, "band masks low nibble")
check(bit.bor(0x10, 0x01) == 0x11, "bor combines bits")
check(bit.bxor(0xFF, 0x0F) == 0xF0, "bxor flips low nibble")
check(bit.bnot(0) == -1, "bnot(0) is -1 (signed 32-bit result)")
check(bit.lshift(1, 4) == 0x10, "lshift(1,4) == 0x10")
check(bit.tohex(0xAB, -2) == "AB", "tohex(-2) gives 2 uppercase digits")

i2c.write(0x30, 0x00)
i2c.set(0x30, 0x0F)
check(i2c.read(0x30) == 0x0F, "i2c.set ORs in the mask")
i2c.clr(0x30, 0x03)
check(i2c.read(0x30) == 0x0C, "i2c.clr ANDs the mask out")

log("info", "bits done")
