{
    "ok": true,
    "data": {
        "title": "K-0592",
        "rev_id": 12359,
        "updated_at": "2022-08-04T06:04:23+00:00",
        "chunk_count": 26,
        "chunks": [
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "",
                "chunk_index": 0,
                "content": "# K-0592",
                "char_count": 8,
                "token_estimate": 2
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "Mini Tower UPS Kit",
                "chunk_index": 1,
                "content": "<figure>\n<img src=\"K-0592-主.png\" title=\"K-0592-主.png\" width=\"320\" alt=\"K-0592-主.png\" \/>\n<figcaption aria-hidden=\"true\">K-0592-主.png<\/figcaption>\n<\/figure>",
                "char_count": 154,
                "token_estimate": 44
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "Description",
                "chunk_index": 2,
                "content": "This is a 3D printed Case for Raspberry Pi 4B and UPS PLUS. The material of case is made of PLA, and the side is made of transparent acrylic material. Ice tower cooler can be placed into the case with Raspberry Pi 4B and UPS Plus. The 0.96 inch OLED screen provided in kit can display the running status of Raspberry Pi or UPS Plus through programming.\n\n     Note: Since the case is printed by FDM 3D printer and is made of PLA material, the surface of the case will have a little roughness, which is normal and does not affect the use. If necessary, you can polish it by yourself.\n\n     Raspberry Pi 4B does not include in the package!!",
                "char_count": 637,
                "token_estimate": 160
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "Features",
                "chunk_index": 3,
                "content": "-   Support Raspberry Pi 4B only\n-   Easy to assemble\n-   Support OLED display\n-   Support UPS Plus integration\n-   Support ICE Tower Cooler integration\n-   Good appearance\n-   Compact mini",
                "char_count": 189,
                "token_estimate": 48
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "Gallery",
                "chunk_index": 4,
                "content": "-   Product Outlook\n\n<img src=\"K-0592-主.png\" title=\"K-0592-主.png\" width=\"800\" alt=\"K-0592-主.png\" \/>\n\\* New Features <img src=\"K-0592-0.96.jpg\" title=\"K-0592-0.96.jpg\" width=\"800\" alt=\"K-0592-0.96.jpg\" \/>\n\\* Definition of Ports <img src=\"K-0592-2.jpg\" title=\"K-0592-2.jpg\" width=\"800\" alt=\"K-0592-2.jpg\" \/>\n\\* UPS Plus <img src=\"K-0592-ups.jpg\" title=\"K-0592-ups.jpg\" width=\"800\" alt=\"K-0592-ups.jpg\" \/>",
                "char_count": 402,
                "token_estimate": 105
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "Package Includes",
                "chunk_index": 5,
                "content": "-   1 x 3D printing Case\n-   2 x Acrylic side panel\n-   2 x 0.96 inch OLED Display and jumper wires\n-   1 x UPS Plus Module with screws and copper pillars\n-   1 x Low profile Ice tower cooler kit",
                "char_count": 195,
                "token_estimate": 49
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to assemble",
                "chunk_index": 6,
                "content": "-   1\\. Fix the copper pillar to 3D printing case.\n-   2\\. Fix UPS Plus with short copper pillar.\n-   3\\. Fix Raspberry Pi 4B with short copper pillar and make sure the pogopin is against to the GPIO Pin.\n-   4\\. Fix the metal bracket of low profile ice tower cooler with M2.5 screws.\n-   5\\. Fix low profile ice tower cooler to Raspberry Pi with M2.5 screws.\n-   6\\. Fix 0.96 inch OLED display to the case with glue gun or tape, and connect the pins to GPIO according to the wiki's circuit diagram.\n-   7\\. Fix two side with acrylic panel with screws.\n-   8\\. You can also fix the fan to the arcrylic panel on the side.\n\n<img src=\"K-0592安装.jpg\" title=\"K-0592安装.jpg\" width=\"800\" alt=\"K-0592安装.jpg\" \/>\n<img src=\"K-0592安装2new.jpg\" title=\"K-0592安装2new.jpg\" width=\"800\" alt=\"K-0592安装2new.jpg\" \/>",
                "char_count": 791,
                "token_estimate": 213
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to assemble > Wiring Details",
                "chunk_index": 7,
                "content": "<img src=\"K-0592-接线标注.jpg\" title=\"K-0592-接线标注.jpg\" width=\"800\" alt=\"K-0592-接线标注.jpg\" \/>\n==How to enable OLED screen==",
                "char_count": 117,
                "token_estimate": 45
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to assemble > Method 1",
                "chunk_index": 8,
                "content": "0.96 inch OLED usage please refer to: \\[ <https:\/\/wiki.52pi.com\/index.php\/S-0005> \\] After installing ssd1306 driver, you can refer to the example code to create your own python script to show system informations.",
                "char_count": 213,
                "token_estimate": 54
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to assemble > Method 2",
                "chunk_index": 9,
                "content": "-   This method will refer to Adafruit python SSD1306 example for this display.\n\nOpen a terminal and Download demo code from: \\[ <https:\/\/github.com\/adafruit\/Adafruit_Python_SSD1306> \\]\n\nsudo python3 -m pip install --upgrade pip setuptools wheel\n    git clone https:\/\/github.com\/adafruit\/Adafruit_Python_SSD1306.git\n    cd Adafruit_Python_SSD1306\n    sudo python setup.py install\n    pip3 install Adafruit-BBIO\n\n-   Run example Demo:\n\n<!-- -->\n\ncd examples\/\n\n-   You may need to modify the stats.py as following code:\n\n<!-- -->\n\nimport time\n\nimport Adafruit_GPIO.SPI as SPI\n    import Adafruit_SSD1306\n\nfrom PIL import Image\n    from PIL import ImageDraw\n    from PIL import ImageFont\n\nimport subprocess\n    import smbus2\n    # from ina219 import INA219, DeviceRangeError\n\n# Raspberry Pi pin configuration:\n\nRST = None     # on the PiOLED this pin isnt used\n\n# Note the following are only used with SPI:\n\nDC = 23\n    SPI_PORT = 0\n    SPI_DEVICE = 0\n    DEVICE_BUS = 1\n\nDEVICE_ADDR  = 0x17\n    PROTECT_VOLT = 3700\n    SAMPLE_TIME = 2",
                "char_count": 1032,
                "token_estimate": 258
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to assemble > Method 2",
                "chunk_index": 10,
                "content": "ina_supply = INA219(0.00725, address=0x40)\n    ina_supply.configure()\n    supply_voltage = ina_supply.voltage()\n    supply_current = ina_supply.current()\n    supply_power = ina_supply.power()\n\nina_batt = INA219(0.005, address=0x45)\n    ina_batt.configure()\n    batt_voltage = ina_batt.voltage()\n    batt_current = ina_batt.current()\n    batt_power = ina_batt.power()\n\n# Beaglebone Black pin configuration:\n\n# RST = 'P9_12'\n\n# Note the following are only used with SPI:\n\n# DC = 'P9_15'\n\n# SPI_PORT = 1\n\n# SPI_DEVICE = 0\n\n# 128x32 display with hardware I2C:\n\n# disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST)　　　####### please comment this line by adding hash tag in front of line #######\n\n# 128x64 display with hardware I2C:  ##########################Please Open following line by removing hash tag ######\n\ndisp = Adafruit_SSD1306.SSD1306_128_64(rst=RST)\n\n# Note you can change the I2C address by passing an i2c_address parameter like:\n\n# disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, i2c_address=0x3C)\n\n# Alternatively you can specify an explicit I2C bus number, for example\n\n# with the 128x32 display you would use:\n\n# disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST, i2c_bus=2)",
                "char_count": 1180,
                "token_estimate": 295
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to assemble > Method 2",
                "chunk_index": 11,
                "content": "# 128x32 display with hardware SPI:\n\n# disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST, dc=DC, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=8000000))\n\n# 128x64 display with hardware SPI:\n\n# disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, dc=DC, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=8000000))\n\n# Alternatively you can specify a software SPI implementation by providing\n\n# digital GPIO pin numbers for all the required display pins.  For example\n\n# on a Raspberry Pi with the 128x32 display you might use:\n\n# disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST, dc=DC, sclk=18, din=25, cs=22)\n\n# Initialize library.\n\ndisp.begin()\n\n# Clear display.\n\ndisp.clear()\n    disp.display()\n\n# Create blank image for drawing.\n\n# Make sure to create image with mode '1' for 1-bit color.\n\nwidth = disp.width\n    height = disp.height\n    image = Image.new('1', (width, height))\n\n# Get drawing object to draw on image.\n\ndraw = ImageDraw.Draw(image)\n\n# Draw a black filled box to clear the image.\n\ndraw.rectangle((0,0,width,height), outline=0, fill=0)\n\n# Draw some shapes.\n\n# First define some constants to allow easy resizing of shapes.",
                "char_count": 1132,
                "token_estimate": 283
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to assemble > Method 2",
                "chunk_index": 12,
                "content": "padding = -2\n    top = padding\n    bottom = height-padding\n    # Move left to right keeping track of the current x position for drawing shapes.\n\nx = 0\n\n# Load default font.\n\nfont = ImageFont.load_default()\n\n# Alternatively load a TTF font.  Make sure the .ttf font file is in the same directory as the python script!\n\n# Some other nice fonts to try: http:\/\/www.dafont.com\/bitmap.php\n\n# font = ImageFont.truetype('Minecraftia.ttf', 8)\n\n# i2c bus configure\n\nbus = smbus2.SMBus(DEVICE_BUS)\n    aReceivedBuf = []\n    aReceivedBuf.append(0x00)\n\nfor i in range(1, 255):\n        aReceivedBuf.append(bus.read_byte_data(DEVICE_ADDR, i))\n\nwhile True:\n\n# Draw a black filled box to clear the image.\n\ndraw.rectangle((0,0,width,height), outline=0, fill=0)\n\n# Shell scripts for system monitoring from here : https:\/\/unix.stackexchange.com\/questions\/119126\/command-to-display-memory-usage-disk-usage-and-cpu-load",
                "char_count": 897,
                "token_estimate": 225
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to assemble > Method 2",
                "chunk_index": 13,
                "content": "cmd = \"hostname -I | cut -d\\' \\' -f1\"\n        IP = subprocess.check_output(cmd, shell = True )\n        cmd = \"top -bn1 | grep load | awk '{printf \\\"CPU Load: %.2f\\\", $(NF-2)}'\"\n        CPU = subprocess.check_output(cmd, shell = True )\n        cmd = \"free -m | awk 'NR==2{printf \\\"Mem: %s\/%sMB %.2f%%\\\", $3,$2,$3*100\/$2 }'\"\n        MemUsage = subprocess.check_output(cmd, shell = True )\n        cmd = \"df -h | awk '$NF==\\\"\/\\\"{printf \\\"Disk: %d\/%dGB %s\\\", $3,$2,$5}'\"\n        Disk = subprocess.check_output(cmd, shell = True )\n\naReceivedBuf = []\n        aReceivedBuf.append(0x00)\n\nfor i in range(1, 255):\n            aReceivedBuf.append(bus.read_byte_data(DEVICE_ADDR, i))\n\nbatt_voltage = ina_batt.voltage()\n        batt_current = ina_batt.current()\n        batt_power = ina_batt.power()\n        if (aReceivedBuf[8] << 8 | aReceivedBuf[7]) > 4000:\n            charge_port = 'Charging via Type-C'\n        elif (aReceivedBuf[10] << 8 | aReceivedBuf[9]) > 4000:\n            charge_port = 'Charging via MicroUSB'\n        else:\n            charge_port = 'Not Charging'\n\n# Write two lines of text.",
                "char_count": 1089,
                "token_estimate": 273
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to assemble > Method 2",
                "chunk_index": 14,
                "content": "draw.text((x, top),       \"IP: \" + str(IP.decode('utf-8')),  font=font, fill=255)\n        draw.text((x, top+8),     str(CPU.decode('utf-8')), font=font, fill=255)\n        draw.text((x, top+16),    str(MemUsage.decode('utf-8')),  font=font, fill=255)\n        draw.text((x, top+25),    str(Disk.decode('utf-8')),  font=font, fill=255)\n\n# Display image.\n\ndisp.image(image)\n        disp.display()\n        time.sleep(3)\n\ndraw.rectangle((0,0,width,height), outline=0, fill=0)\n        draw.text((x, top),\"Voltage: \" + str(batt_voltage),  font=font, fill=255)\n        draw.text((x, top+8), \"Current:\" + str(batt_current), font=font, fill=255)\n        draw.text((x, top+16),\"Power:\" + str(batt_power),  font=font, fill=255)\n        draw.text((x, top+25),\"ChargePort:\" + str(charge_port),  font=font, fill=255)\n        # display UPS information\n\ndisp.image(image)\n        disp.display()\n        time.sleep(3)\n\n-   Then execute following command:\n\n<!-- -->\n\npython3 stats.py",
                "char_count": 963,
                "token_estimate": 241
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to assemble > Method 3",
                "chunk_index": 15,
                "content": "-   Easy way\n\n1\\. Turn on \\`i2c function\\` by using \\`sudo raspi-config\\` -\\> \\`interface options\\` -\\> \\`i2c\\` -\\> \\`enable\\` -\\> \\`yes\\`.\n2. Check if the screen has been recognized by Raspberry Pi.\n\n    i2cdetect -y 1\n\nif encount \\`command not found\\` error, please install \\`i2c-tools\\` by using \\`sudo apt update && sudo apt -y install i2c-tools\\`.\n3. Install dependencies libraries:\n\n    sudo apt -y install python3 python3-pip python3-pil libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7 libtiff5\n\n4\\. Grant privilleges to user \\`pi\\`\n\n    sudo usermod -a -G gpio,i2c pi\n\n5\\. Download sample code from this repo:\n\n    git clone https:\/\/github.com\/rm-hull\/luma.examples.git\n    cd luma.examples\/\n\n6\\. Install the dependencies\n\n    sudo -H pip3 install -e .\n\n7\\. Entering into example folder and test it.\n\n    cd luma.examples\/examples\/\n    python3 sys_info.py",
                "char_count": 881,
                "token_estimate": 221
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "OLED Configuration Tutorial Video",
                "chunk_index": 16,
                "content": "-   YouTube channel: \\[ <https:\/\/youtu.be\/AxBXI-b07lc> \\]",
                "char_count": 57,
                "token_estimate": 15
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "Documentations",
                "chunk_index": 17,
                "content": "-   SSD1306 Datasheet:![](SSD1306-Revision_1.0.pdf \"SSD1306-Revision_1.0.pdf\")\n-   Mechanical Drawing:![](0.96inch_Mechanical_Drawing.pdf \"0.96inch_Mechanical_Drawing.pdf\")\n-   UPS Plus: \\[ <https:\/\/wiki.52pi.com\/index.php\/UPS_Plus_SKU:_EP-0136> \\]\n-   Github: \\[ <https:\/\/github.com\/geeekpi\/minitowercase\/edit\/main\/README.md> \\]",
                "char_count": 329,
                "token_estimate": 83
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to display UPS information on OLED",
                "chunk_index": 18,
                "content": "-   1.Make sure OLED display has been connected to Raspberry Pi on GPIO properly.\n\n<!-- -->\n\ncheck if the OLED screen is detected by Raspberry Pi via using following command in terminal: `i2cdetect -y 1`\n\n-   2.Enable \\`I2C function\\` by using \\`sudo raspi-config\\` command, and navigate to \\`interface options\\` -\\> \\`I2C\\` -\\> \\`Enable\\` -\\> \\`YES\\`.\n-   3.Make sure Raspberry Pi has been connected to internet.\n-   4.Install dependents package via following commands:\n\n<!-- -->\n\nsudo usermod -a -G i2c,spi,gpio pi\n    sudo apt install python-dev python-pip libfreetype6-dev libjpeg-dev build-essential\n    sudo apt install libsdl-dev libportmidi-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev libsdl-image1.2-dev\n    sudo -H pip3 install psutil\n    sudo -H pip3 install pi-ina219\n    sudo -H pip3 install Pillow\n\n-   Log out and in again and clone this repository:\n\n<!-- -->\n\ngit clone https:\/\/github.com\/rm-hull\/luma.examples.git\n    cd luma.examples\n\n-   Finally, install the luma libraries using:\n\n<!-- -->\n\nsudo -H pip3 install -e .\n\n-   Change directory to \\`luma.examples\/examples\\`\n\n<!-- -->\n\ncd luma.examples\/examples\/\n\n-   Backup \\`sys_info.py\\` file.\n\n<!-- -->\n\ncp sys_info.py sys_info.py.bak",
                "char_count": 1200,
                "token_estimate": 300
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to display UPS information on OLED > If UPS Plus is Connected",
                "chunk_index": 19,
                "content": "-   Modify \\`sys_info.py\\` file as following code, this is just a demo code, you can modify it as you want:\n\n<!-- -->\n\nimport os\n    import sys\n    import time\n    from pathlib import Path\n    from datetime import datetime\n    import smbus2\n    from ina219 import INA219, DeviceRangeError\n\nif os.name != 'posix':\n        sys.exit('{} platform not supported'.format(os.name))\n\nfrom demo_opts import get_device\n    from luma.core.render import canvas\n    from PIL import ImageFont\n\ntry:\n        import psutil\n    except ImportError:\n        print(\"The psutil library was not found. Run 'sudo -H pip install psutil' to install it.\")\n        sys.exit()\n\n# setting up configuration of UPS device.\n\nDEVICE_BUS = 1\n    DEVICE_ADDR = 0x17\n    PROTECT_VOLT = 3700\n    SAMPLE_TIME = 2\n\n# initializing an instance of ina_supply.\n\nina_supply = INA219(0.00725, address=0x40)\n    ina_supply.configure()\n    supply_voltage = ina_supply.voltage()\n    supply_current = ina_supply.current()\n    supply_power = ina_supply.power()\n\n# initializing instance of batteries status.",
                "char_count": 1056,
                "token_estimate": 264
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to display UPS information on OLED > If UPS Plus is Connected",
                "chunk_index": 20,
                "content": "ina_batt = INA219(0.005, address=0x45)\n    ina_batt.configure()\n    batt_voltage = ina_batt.voltage()\n    batt_current = ina_batt.current()\n    batt_power = ina_batt.power()\n\n# initializing an I2C bus.\n\nbus = smbus2.SMBus(DEVICE_BUS)\n\n# functions\n\ndef bytes2human(n):\n        \"\"\"\n        >>> bytes2human(10000)\n        '9K'\n        >>> bytes2human(100001221)\n        '95M'\n        \"\"\"\n        symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')\n        prefix = {}\n        for i, s in enumerate(symbols):\n            prefix[s] = 1 << (i + 1) * 10\n        for s in reversed(symbols):\n            if n >= prefix[s]:\n                value = int(float(n) \/ prefix[s])\n                return '%s%s' % (value, s)\n        return \"%sB\" % n\n\n# display cpu usage.\n\ndef cpu_usage():\n        # load average, uptime\n\nuptime = datetime.now() - datetime.fromtimestamp(psutil.boot_time())\n        av1, av2, av3 = os.getloadavg()\n        return \"Ld:%.1f %.1f %.1f Up: %s\" \\\n            % (av1, av2, av3, str(uptime).split('.')[0])\n\n# display memory usage.\n\ndef mem_usage():\n        usage = psutil.virtual_memory()\n        return \"Mem: %s %.0f%%\" \\\n            % (bytes2human(usage.used), 100 - usage.percent)",
                "char_count": 1190,
                "token_estimate": 298
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to display UPS information on OLED > If UPS Plus is Connected",
                "chunk_index": 21,
                "content": "# display disk usage.\n\ndef disk_usage(dir):\n        usage = psutil.disk_usage(dir)\n        return \"SD:  %s %.0f%%\" \\\n            % (bytes2human(usage.used), usage.percent)\n\n# display network status.\n\ndef network(iface):\n        stat = psutil.net_io_counters(pernic=True)[iface]\n        return \"%s: Tx%s, Rx%s\" % \\\n               (iface, bytes2human(stat.bytes_sent), bytes2human(stat.bytes_recv))\n\n# draw status on OLED screen.\n\ndef stats(device):\n        # use custom font\n\nfont_path = str(Path().resolve().parent.joinpath('fonts', 'C&C Red Alert [INET].ttf'))\n        font2 = ImageFont.truetype(font_path, 12)\n\nwith canvas(device) as draw:\n            draw.text((0, 0), cpu_usage(), font=font2, fill=\"white\")\n            if device.height >= 32:\n                draw.text((0, 14), mem_usage(), font=font2, fill=\"white\")\n\nif device.height >= 64:\n                draw.text((0, 26), disk_usage('\/'), font=font2, fill=\"white\")\n                try:\n                    draw.text((0, 38), network('wlan0'), font=font2, fill=\"white\")\n                except KeyError:\n                    # no wifi enabled\/available\n\npass\n\n# display charging port status.",
                "char_count": 1147,
                "token_estimate": 287
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to display UPS information on OLED > If UPS Plus is Connected",
                "chunk_index": 22,
                "content": "def chrg_port():\n        aReceivedBuf = []\n        aReceivedBuf.append(0x00)\n        for i in range(1, 255):\n            aReceivedBuf.append(bus.read_byte_data(DEVICE_ADDR, i))\n\nif (aReceivedBuf[8] << 8 | aReceivedBuf[7]) > 4000:\n            charge_port = 'Charging via TYPE-C'\n        elif (aReceivedBuf[10] << 8 | aReceivedBuf[9]) > 4000:\n            charge_port = 'Charging via MicroUSB'\n        else:\n            charge_port = 'Not Charging'\n        return \"CP: %s\" % charge_port\n\n# display batteries current status.\n\ndef batt_cur():\n        aReceivedBuf = []\n        aReceivedBuf.append(0x00)\n        for i in range(1, 255):\n            aReceivedBuf.append(bus.read_byte_data(DEVICE_ADDR, i))\n        chrg_rate = ina_batt.current()\n        return \"Bat Current: %.3f mA\" % chrg_rate\n\n# display batteries capacity status.\n\ndef batt_cap():\n        aReceivedBuf = []\n        aReceivedBuf.append(0x00)\n        for i in range(1, 255):\n            aReceivedBuf.append(bus.read_byte_data(DEVICE_ADDR, i))\n        capacity = (aReceivedBuf[20] << 8 | aReceivedBuf[19])\n        return \"Bat Capacity: %d%%\"% capacity\n\n# display full batteries voltage status.",
                "char_count": 1151,
                "token_estimate": 288
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to display UPS information on OLED > If UPS Plus is Connected",
                "chunk_index": 23,
                "content": "def full_bat():\n        aReceivedBuf = []\n        aReceivedBuf.append(0x00)\n        for i in range(1, 255):\n            aReceivedBuf.append(bus.read_byte_data(DEVICE_ADDR, i))\n        full_batt = (aReceivedBuf[14] << 8 | aReceivedBuf[13])\n        return \"Full Bat Voltage: %d mV\" % full_batt\n\n# display UPS status infor on OLED screen.\n\ndef ups_status(device):\n        # use custom font\n\nfont_path = str(Path().resolve().parent.joinpath('fonts', 'C&C Red Alert [INET].ttf'))\n        font2 = ImageFont.truetype(font_path, 12)\n\nwith canvas(device) as draw:\n            draw.text((0, 0), full_bat(), font=font2, fill=\"white\")\n            if device.height >= 32:\n                draw.text((0, 14), batt_cap(), font=font2, fill=\"white\")\n\nif device.height >= 64:\n                draw.text((0, 26), chrg_port(), font=font2, fill=\"white\")\n                try:\n                    draw.text((0, 38), batt_cur(), font=font2, fill=\"white\")\n                except KeyError:\n                    # no wifi enabled\/available\n\npass\n\n# define mainloop.\n\ndef main():\n        while True:\n            stats(device)\n            time.sleep(5)\n            ups_status(device)\n            time.sleep(5)",
                "char_count": 1177,
                "token_estimate": 295
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "How to display UPS information on OLED > If UPS Plus is Connected",
                "chunk_index": 24,
                "content": "if  == \"\":\n        try:\n            device = get_device()\n            main()\n        except KeyboardInterrupt:\n            pass\n\n-   Execute it.\n\n<!-- -->\n\npython3 sys_info.py",
                "char_count": 175,
                "token_estimate": 44
            },
            {
                "title": "K-0592",
                "rev_id": 12359,
                "heading_path": "Keywords",
                "chunk_index": 25,
                "content": "-   Mini Tower UPS Kit, UPS case, ice tower case, case for raspberry pi 4B.",
                "char_count": 75,
                "token_estimate": 19
            }
        ]
    }
}