{
    "ok": true,
    "data": {
        "title": "EP-0098",
        "rev_id": 10658,
        "updated_at": "2021-08-27T10:24:10+00:00",
        "chunk_count": 19,
        "chunks": [
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "",
                "chunk_index": 0,
                "content": "# EP-0098",
                "char_count": 9,
                "token_estimate": 3
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "DockerPi NightLight",
                "chunk_index": 1,
                "content": "<figure>\n<img src=\"Nlddl01.jpg\" title=\"Nlddl01.jpg\" width=\"300\" alt=\"Nlddl01.jpg\" \/>\n<figcaption aria-hidden=\"true\">Nlddl01.jpg<\/figcaption>\n<\/figure>",
                "char_count": 150,
                "token_estimate": 38
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Description",
                "chunk_index": 2,
                "content": "DockerPi NightLight is a DockerPi series expansion board with 8 WS2812 RGB LEDs. The expansion board communicates with I2C protocol. It can be used in Raspberry Pi, Jetson Nano and other single board computers (require I2C peripherals).\n\nYou can programmatically control the color of each LED, such as Python or C, or you can control the color of each LED directly through system commands without programming. Most Linux distributions include the i2c-tools, which allows you to control this.\n\nDockerPi NightLight can only be used one, but can be stacked with other DockerPi expansion board. If you need to run for a long time, we also recommend that you use our DockerPi Power expansion board to provide more power.\n\nThe module is stacked on the top layer and can be placed with acrylic decoration for better show.",
                "char_count": 814,
                "token_estimate": 204
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Features",
                "chunk_index": 3,
                "content": "<figure>\n<img src=\"Nlddl06.jpg\" title=\"Nlddl06.jpg\" width=\"300\" alt=\"Nlddl06.jpg\" \/>\n<figcaption aria-hidden=\"true\">Nlddl06.jpg<\/figcaption>\n<\/figure>\n\n-   DockerPi Series\n-   Programmable\n-   Control directly(without programming)\n-   Extend the GPIO Pins\n-   WS2812 RGB LEDs\n-   Independent control of each LED\n-   2 \\* Demo acrylic supports your quick start\n-   2 \\* Blank acrylic supports your custom ideas\n-   Recommended to be stacked at the top\n-   Can Stack with other Stack board\n-   Independent of the mainboard hardware (require I2C support)",
                "char_count": 551,
                "token_estimate": 138
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Official Compatibility Test",
                "chunk_index": 4,
                "content": "Not only support the following development boards, other development boards can be compatible if they have I2C peripherals. (Note: some software changes may be required)\n\n| Platform                  | DockerPi Nightlight | Notes                                |\n|---------------------------|---------------------|--------------------------------------|\n| Raspberry Pi All Platform | √                   | Not Include CM Series & EOL Platform |\n| Banana Pi M3              | √                   | Python 3 & Modify DEVICE_BUS to 2    |\n| Orange Pi Zero            | √                   | Python 3 & Modify DEVICE_BUS to 0    |\n|                           |                     |                                      |",
                "char_count": 716,
                "token_estimate": 179
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Gallery",
                "chunk_index": 5,
                "content": "|                                              |                                              |\n|----------------------------------------------|----------------------------------------------|\n| ![ 320px\\| left](Nlddl04.jpg \" 320px| left\") | ![ 320px\\| none](Nlddl01.jpg \" 320px| none\") |",
                "char_count": 287,
                "token_estimate": 72
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Package Includes",
                "chunk_index": 6,
                "content": "-   1 x DockerPi NightLight\n-   4 x M2.5\\*12 + 6 Copper stick\n-   4 x M2.5\\*6 Nut\n-   4 x M2.5\\*6 Half-round head screw\n-   1 x Instructions\n-   1 x Acrylic Pattern Design (Stander)\n-   4 x Acrylic Pattern Design (2x Demo and 2x Blank)",
                "char_count": 235,
                "token_estimate": 59
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Register Map",
                "chunk_index": 7,
                "content": "| Register Address | Function   | Value                                                       |\n|------------------|------------|-------------------------------------------------------------|\n| 0x01             | LED1 Red   | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x02             | LED1 Green | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x03             | LED1 Blue  | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x04             | LED2 Red   | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x05             | LED2 Green | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x06             | LED2 Blue  | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x07             | LED3 Red   | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x08             | LED3 Green | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x09             | LED3 Blue  | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x0a             | LED4 Red   | 0(FULL OFF) - 255(FULL ON)                                  |",
                "char_count": 1151,
                "token_estimate": 288
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Register Map",
                "chunk_index": 8,
                "content": "| 0x0b             | LED4 Green | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x0c             | LED4 Blue  | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x0d             | LED5 Red   | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x0e             | LED5 Green | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x0f             | LED5 Blue  | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x10             | LED6 Red   | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x11             | LED6 Green | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x12             | LED6 Blue  | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x13             | LED7 Red   | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x14             | LED7 Green | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x15             | LED7 Blue  | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x16             | LED8 Red   | 0(FULL OFF) - 255(FULL ON)                                  |",
                "char_count": 1151,
                "token_estimate": 288
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Register Map",
                "chunk_index": 9,
                "content": "| 0x17             | LED8 Green | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x18             | LED8 Blue  | 0(FULL OFF) - 255(FULL ON)                                  |\n| 0x19             | Button     | 0x01 - Button Pressed 0x00 - Button Released\/Manually Reset |",
                "char_count": 287,
                "token_estimate": 72
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Configuring I2C(Raspberry Pi)",
                "chunk_index": 10,
                "content": "Run **sudo raspi-config** and follow the prompts to install i2c support for the ARM core and linux kernel\nGo to **Interfacing Options** <img src=\"Raspi-config-1.png\" title=\"Raspi-config-1.png\" width=\"320\" alt=\"Raspi-config-1.png\" \/> then **I2C** <img src=\"Raspi-config-2.png\" title=\"Raspi-config-2.png\" width=\"320\" alt=\"Raspi-config-2.png\" \/> Enable! <img src=\"Raspi-config-3.png\" title=\"Raspi-config-3.png\" width=\"320\" alt=\"Raspi-config-3.png\" \/> Done! <img src=\"Raspi-config-4.png\" title=\"Raspi-config-4.png\" width=\"320\" alt=\"Raspi-config-4.png\" \/>",
                "char_count": 550,
                "token_estimate": 138
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Direct control without programming(Raspberry Pi)",
                "chunk_index": 11,
                "content": "The following script demonstrates turn on and turn off each LED.\n\n    #!\/bin\/bash\n\n    for i in $(seq 1 24)\n    do\n            i2cset -y 1 0x15 $i 0xFF   # turn on the led\n\n            sleep 0.5\n            i2cset -y 1 0x15 $i 0x00   # turn of the led\n\n            sleep 0.5\n    done",
                "char_count": 283,
                "token_estimate": 71
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Program in Language C(Raspberry Pi)",
                "chunk_index": 12,
                "content": "Create source code and name it \"led.c\"\n\n#include <stdio.h>\n    #include <wiringPi.h>\n    #include <wiringPiI2C.h>\n\n#define BUTTON_REG_ADDR 0x19\n\nint main(){\n            int fd;\n            int is_press = 1;\n            int is_draw = 0;\n            int i = 0;\n\nfd = wiringPiI2CSetup(0x15);\n\nfor(i = 1;i<25;i++) wiringPiI2CWriteReg8(fd,i,0x00);",
                "char_count": 342,
                "token_estimate": 86
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Program in Language C(Raspberry Pi)",
                "chunk_index": 13,
                "content": "for(;;)\n            {\n                    if (wiringPiI2CReadReg8(fd, BUTTON_REG_ADDR) == 0x01 )\n                    {\n                            is_press++;\n                            is_draw = 1;\n                            wiringPiI2CWriteReg8(fd,BUTTON_REG_ADDR, 0x0);\n                    }\n                    if(is_press && is_draw){\n                            is_draw = 0;\n                            for(i = 1;i<25;i++){\n                                    if(is_press > 3) is_press = 1;\n                                    if(((i + is_press) % 3) == 0)\n                                    {\n                                            wiringPiI2CWriteReg8(fd,i,0xff);\n                                    }else{\n                                            wiringPiI2CWriteReg8(fd,i,0x00);\n                                    }\n                                    delay(100);\n                            }\n\nwiringPiI2CWriteReg8(fd,BUTTON_REG_ADDR, 0x0);\n                    }\n            }\n    }\n\nCompile!\n\n`gcc led.c -lwiringPi -o led`\nExec It!\n\n`.\/led`\n----",
                "char_count": 1069,
                "token_estimate": 268
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Program in Language Python(Raspberry Pi)",
                "chunk_index": 14,
                "content": "The following code is recommended to be executed using Python 3 and install the **smbus** library:\n\n    import time as t\n    import smbus\n    import sys\n\n    DEVICE_BUS = 1\n    DEVICE_ADDR = 0x15\n    bus = smbus.SMBus(DEVICE_BUS)\n\n    while True:\n        try:\n            for i in range(1,25):\n                bus.write_byte_data(DEVICE_ADDR, i, 0xFF)\n                t.sleep(0.2)\n                bus.write_byte_data(DEVICE_ADDR, i, 0x00)\n                t.sleep(0.2)\n        except KeyboardInterrupt as e:\n            sys.exit()\n            print(\"Quit the Loop\")\n\n------------------------------------------------------------------------",
                "char_count": 638,
                "token_estimate": 160
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Program in Java(Raspberry Pi)",
                "chunk_index": 15,
                "content": "Create a new file named:NightLight.java and paste following code:\n\nimport java.io.IOException;\n    import java.util.Arrays;\n\nimport com.pi4j.io.i2c.I2CBus;\n    import com.pi4j.io.i2c.I2CDevice;\n    import com.pi4j.io.i2c.I2CFactory;\n    import com.pi4j.io.i2c.I2CFactory.UnsupportedBusNumberException;\n    import com.pi4j.platform.PlatformAlreadyAssignedException;\n    import com.pi4j.util.Console;\n\npublic class NightLight {\n\npublic static final int DOCKERPI_NIGHTLIGHT_BOARD = 0x19;\n        public static final byte RESET_BIT = (byte) 0x00;\n\n\/\/ NightLight Address\n        public static final int NIGHTLIGHT_REG_ADDR = 0x15;\n\n\/\/ LED of NightLight\n        public static final byte LED1_RED = (byte) 0x01;\n\n\/\/ NightLight LED status\n        public static final byte NIGHTLIGHT_ON = (byte) 0xFF;\n        public static final byte NIGHTLIGHT_OFF = (byte) 0x00;\n\npublic static void main(String[] args)\n                throws InterruptedException, PlatformAlreadyAssignedException, IOException, UnsupportedBusNumberException {\n\nint i = 1;\n            final Console console = new Console();",
                "char_count": 1082,
                "token_estimate": 271
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Program in Java(Raspberry Pi)",
                "chunk_index": 16,
                "content": "I2CBus i2c = I2CFactory.getInstance(I2CBus.BUS_1);\n            I2CDevice device = i2c.getDevice(DOCKERPI_NIGHTLIGHT_BOARD);\n\nwhile (true) {\n                if (device.read(BUTTON_ADDR) == 0x01) {\n                    console.println(\"the button has been pressed\");\n                    device.write(BUTTON_ADDR, RESET_BIT);\n                    i++;\n                    if (i > 2) {\n                        i = 1;\n                    }\n                }\n                if (i == 1) {\n                    console.println(\"Turn off LED!\");\n                    device.write(LED1_RED, NIGHTLIGHT_OFF);\n                    Thread.sleep(5000);\n                }\n                if (i == 2) {\n                    console.println(\"Turn on LED!\");\n                    device.write(LED1_RED, NIGHTLIGHT_ON);\n                    Thread.sleep(5000);\n                }\n            }\n        }\n    }\n\n-   Compile it and running:\n\n<!-- -->\n\njavac NightLight.java -classpath .:\/opt\/pi4j\/lib\/'*'\n\nsudo java -classpath .:classes:\/opt\/pi4j\/lib\/'*' NightLight",
                "char_count": 1036,
                "token_estimate": 259
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Keywords",
                "chunk_index": 17,
                "content": "-   DockerPi,RGB,RGB LED,WS2812,Colorful",
                "char_count": 40,
                "token_estimate": 10
            },
            {
                "title": "EP-0098",
                "rev_id": 10658,
                "heading_path": "Video Tutorial",
                "chunk_index": 18,
                "content": "<img src=\"Youtube.jpeg\" title=\"Youtube.jpeg\" width=\"200\" alt=\"Youtube.jpeg\" \/>\n\\* Please follow the link:\n\n-   \\[ DockerPi NightLight Board Tutorial\\| <https:\/\/youtu.be\/KI7cQQLffG0> \\]",
                "char_count": 184,
                "token_estimate": 46
            }
        ]
    }
}