{
    "ok": true,
    "data": {
        "title": "EP-0109",
        "rev_id": 10670,
        "updated_at": "2021-08-27T10:25:37+00:00",
        "chunk_count": 29,
        "chunks": [
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "",
                "chunk_index": 0,
                "content": "# EP-0109",
                "char_count": 9,
                "token_estimate": 3
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "Description",
                "chunk_index": 1,
                "content": "DockerPi DIY Programmable intelligent toycar is based on DockerPi Motor Board(A) and DockerPi Power Board.You could DIY it's appearance and power.\n\nOf course,if you want to get started directly,we also provide the power board and Arcylic board for you.We offer several packages to you.The DockerPi\n\nPower Board could provide powerful power for the car.You could choose to design its appearance by yourself.Besides,you could connect the camera module\n\nto achieve the function of identifying objects.The following we will show you how to use the wireless keyboard and wireless handle to control the car by pygame.\n\n**Remember:Don't assemble and disassemble the board when the power supply is working.They don't support hot plug**",
                "char_count": 727,
                "token_estimate": 182
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "Features",
                "chunk_index": 2,
                "content": "-   DockerPi Series\n-   Programmable\n-   Intelligent toycar\n-   Easy to control\n-   DIY\n-   Selective control\n-   Wireless control\n-   Handle\n-   Keyboard\n-   Motor",
                "char_count": 164,
                "token_estimate": 41
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "Package Includes",
                "chunk_index": 3,
                "content": "-   Essentials\n    -   1 x Battery case\n        -   3 x 18650(**Not included**)\n        -   2 x DC Motor\n        -   2 x Acrylic gasket\n        -   2 x M\\*12 Half-round head screw\n        -   2 x PH Connector\n    -   2 x 65mm Black rubber wheel\n        -   4 x M4\\*4 Hexagon socket tightening screw\n        -   8 x M3\\*9 Half-round head screw\n        -   8 x M3 Nut\n        -   4 x M3\\*5 Half-round head screw\n        -   2 x M4\\*5 Half-round head screw\n    -   1 x All around wheel\n        -   4 x M3\\*22 + 6 Copper stick\n        -   4 x M2.5 Nut\n        -   4 x M5\\*4 Half-round head screw\n    -   1 x Motor Board\n    -   2 x Coupling\n    -   2 x Coupling fixing bracket\n    -   1 x Power Board\n    -   1 x Instruction\n    -   1 x Acrylic sheet design drawings\n    -   4 x M2.5 Nut\n    -   4 x M2.5\\*6+6Copper stick\n    -   8 x M2.5\\*12+6Copper\n    -   4 x M2.5\\*6 Half-round head screw\n\n<!-- -->\n\n-   Optional\n    -   TF card\n    -   Arcylic board\n    -   RaspberryPi\n    -   Wireless handle\n    -   Wireless keyboard",
                "char_count": 1020,
                "token_estimate": 255
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "Announcements",
                "chunk_index": 4,
                "content": "-   '''Please turn off the power when you connect it!\n\n'''\n\n-   DockerPi Series Board does not support hot plug\n-   Please do not install reverse battery",
                "char_count": 153,
                "token_estimate": 39
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "Configuring I2C(Raspberry Pi)",
                "chunk_index": 5,
                "content": "-   Run **sudo raspi-config** and follow the prompts to install i2c support for the ARM core and linux kernel\n-   Go to **Interfacing Options**\n\n<img src=\"Raspi-config-1.png\" title=\"Raspi-config-1.png\" width=\"400\" alt=\"Raspi-config-1.png\" \/> then **I2C** <img src=\"Raspi-config-2.png\" title=\"Raspi-config-2.png\" width=\"400\" alt=\"Raspi-config-2.png\" \/> Enable! <img src=\"Raspi-config-3.png\" title=\"Raspi-config-3.png\" width=\"400\" alt=\"Raspi-config-3.png\" \/> Done! <img src=\"Raspi-config-4.png\" title=\"Raspi-config-4.png\" width=\"400\" alt=\"Raspi-config-4.png\" \/>",
                "char_count": 559,
                "token_estimate": 140
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Handle to control the toycar**",
                "chunk_index": 6,
                "content": "-   **Handle model:A-038 2.4G wireless gamepad**\n-   **Note:Different models of handles may not match the program**\n\nFirst you need prepare a TF card to burn the raspbian.You can download the system from the official website.\n\nWhen you finished this,please connect it by ssh.\n\n-   First,please open the function of wireless function.Execute the following command:\n\n` sudo raspi-config`\n\n-   Then choose the option on the picture\n\n|                                                                                                                 |\n|-----------------------------------------------------------------------------------------------------------------|\n| <figure>\n <img src=\"DockerPi_DIY_Car(2).png\" title=\"DockerPi_DIY_Car(2).png\" width=\"500\" alt=\"DockerPi_DIY_Car(2).png\" \/>\n <figcaption aria-hidden=\"true\">DockerPi_DIY_Car(2).png<\/figcaption>\n <\/figure>                                                                                                        |\n\n-   Then choose the option on the picture",
                "char_count": 1013,
                "token_estimate": 254
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Handle to control the toycar**",
                "chunk_index": 7,
                "content": "|                                                                                                                 |\n|-----------------------------------------------------------------------------------------------------------------|\n| <figure>\n <img src=\"DockerPi_DIY_Car(7).png\" title=\"DockerPi_DIY_Car(7).png\" width=\"500\" alt=\"DockerPi_DIY_Car(7).png\" \/>\n <figcaption aria-hidden=\"true\">DockerPi_DIY_Car(7).png<\/figcaption>\n <\/figure>                                                                                                        |\n\n-   You can configure your wifi\n-   Then you need install the python3's module pygame\n\n` sudo apt-get -y install python3-pygame`\n\n-   You also need to install python3's smbus\n\n` sudo apt-get -y install python3-smbus`\n\n-   Please install the python3's joystick\n\n` sudo pip3 install joystick`\n\n-   Please install the python3's matplotlib\n\n` sudo pip3 install matplotlib`\n\n-   Please open the RaspberryPi's I2C\n-   You could install the following script to achieve the safeshut down function.\n\n` wget -qO- `[`https:\/\/git.io\/fj3b9`](https:\/\/git.io\/fj3b9)` | sudo bash`\n\n**\nCodes<\/br>**",
                "char_count": 1123,
                "token_estimate": 281
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Handle to control the toycar**",
                "chunk_index": 8,
                "content": "-   Create a new file and named:toycar.py and paste following codes:\n-   Press the arrowkey of up:Go ahead\n-   Press the arrowkey of down:Go back\n-   Press the arrowkey of left:Turn left\n-   Press the arrowkey of right:Turn right\n\n<!-- -->\n\nimport joystick\n    import sys\n    import time\n    import pygame\n    import smbus\n\nbus = smbus.SMBus(1)\n    MOTOR_DRIVER_ADDRESS = 0x18\n    MOTOR_DRIVER_SPEED_1_L = 0x01\n    MOTOR_DRIVER_SPEED_1_H = 0x02\n    MOTOR_DRIVER_SPEED_2_L = 0x03\n    MOTOR_DRIVER_SPEED_2_H = 0x04\n    MOTOR_DRIVER_DIRECTION = 0x09\n    MOTOR_DRIVER_SPEED_NOW_1_L = 0x0a\n    MOTOR_DRIVER_SPEED_NOW_1_H = 0x0b\n    MOTOR_DRIVER_SPEED_NOW_2_L = 0x0c\n    MOTOR_DRIVER_SPEED_NOW_2_H = 0x0d\n    MOTOR_DRIVER_DIRECTION_NOW = 0x12\n    MOTOR_DRIVER_ENABLE = 0x13\n    MOTOR_DRIVER_MODE = 0X14\n    MOTOR_DRIVER_PWM_NOW_2_L = 0x1f\n    MOTOR_DRIVER_PWM_NOW_2_H = 0x20",
                "char_count": 868,
                "token_estimate": 217
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Handle to control the toycar**",
                "chunk_index": 9,
                "content": "def setspeed():\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_1_L,speed & 0xff)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_1_H,speed >> 8)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_2_L,speed & 0xff)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_2_H,speed >> 8)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_ENABLE,1)\n    def turnright():\n        temp0 = 300\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_1_L,temp0 & 0xff)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_1_H,temp0 >> 8)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_2_L,(temp0 -100) & 0xff)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_2_H,(temp0 -100) >> 8)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_ENABLE,1)\n    def turnleft():\n        temp0 = 300\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_1_L,(temp0 - 100) & 0xff)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_1_H,(temp0 - 100) >> 8)\n        bus.",
                "char_count": 1133,
                "token_estimate": 284
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Handle to control the toycar**",
                "chunk_index": 10,
                "content": "write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_2_L,temp0 & 0xff)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_2_H,temp0 >> 8)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_ENABLE,1)\n    def setdirection(sysnax):\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_DIRECTION,sysnax)\n    # Define some colors",
                "char_count": 364,
                "token_estimate": 91
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Handle to control the toycar**",
                "chunk_index": 11,
                "content": "BLACK    = (   0,   0,   0)\n    WHITE    = ( 255, 255, 255)\n    # This is a simple class that will help us print to the screen\n\nclass TextPrint:\n        def (self):\n            self.reset()\n            self.font = pygame.font.Font(None, 20)\n        def print(self, screen, textString):\n            textBitmap = self.font.render(textString, True, BLACK)\n            screen.blit(textBitmap, [self.x, self.y])\n            self.y += self.line_height\n        def reset(self):\n            self.x = 10\n            self.y = 10\n            self.line_height = 15\n        def indent(self):\n            self.x += 10\n        def unindent(self):\n            self.x -= 10\n    pygame.init()\n    # Set the width and height of the screen [width,height]\n\nsize = [500, 700]\n    screen = pygame.display.set_mode(size)\n    pygame.display.set_caption(\"My Game\")\n    #Loop until the user clicks the close button.\n    done = False\n    # Used to manage how fast the screen updates\n\nclock = pygame.time.Clock()\n    # Initialize the joysticks\n\npygame.joystick.init()\n    # Get ready to print\n\ntextPrint = TextPrint()\n    # -------- Main Program Loop -----------\n\nwhile done==False:\n        # EVENT PROCESSING STEP",
                "char_count": 1185,
                "token_estimate": 297
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Handle to control the toycar**",
                "chunk_index": 12,
                "content": "for event in pygame.event.get(): # User did something\n\nif event.type == pygame.QUIT: # If user clicked close\n\ndone=True # Flag that we are done so we exit this loop\n\n# DRAWING STEP\n\n# First, clear the screen to white. Don't put other drawing commands\n\n# above this, or they will be erased with this command.\n\nscreen.fill(WHITE)\n        textPrint.reset()\n        # Get count of joysticks\n\njoystick_count = pygame.joystick.get_count()\n        #textPrint.print(screen, \"Number of joysticks: {}\".format(joystick_count) )\n        textPrint.indent()\n        # For each joystick:\n\nfor i in range(joystick_count):\n            joystick = pygame.joystick.Joystick(i)\n            joystick.init()\n            # Usually axis run in pairs, up\/down for one, and left\/right for\n\n# the other.",
                "char_count": 775,
                "token_estimate": 194
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Handle to control the toycar**",
                "chunk_index": 13,
                "content": "axes = joystick.get_numaxes()\n            #textPrint.print(screen, \"Number of axes: {}\".format(axes) )\n            #textPrint.indent()\n            for i in range( axes ):\n                axis = joystick.get_axis( i )\n                textPrint.print(screen, \"Axis {} value: {:>6.3f}\".format(i, axis) )\n                if i==1 and axis== -1.0:\n                    print(\"Left up\",axis)\n                if i==1 and axis > 0.3:\n                    print(\"Left down\",axis)\n                if i==0 and axis== -1:\n                    print(\"Left left\",axis)\n                if i==0 and axis > 0.3:\n                    print(\"Left right\",axis)\n                if i==4 and axis== -1.0:\n                    print(\"Right up\",axis)\n                if i==4 and axis > 0.3:\n                    print(\"Right down\",axis)\n                if i==3 and axis== -1:\n                    print(\"Right left\",axis)\n                if i==3 and axis > 0.3:\n                    print(\"Right right\",axis)\n                if i==2 and axis > 0.3:\n                    print(\"LT\",axis)\n                if i==5 and axis > 0.3:\n                    print(\"RT\",axis)",
                "char_count": 1128,
                "token_estimate": 282
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Handle to control the toycar**",
                "chunk_index": 14,
                "content": "textPrint.unindent()\n            buttons = joystick.get_numbuttons()\n            textPrint.print(screen, \"Number of buttons: {}\".format(buttons) )\n            textPrint.indent()\n\nfor i in range( buttons ):\n                button = joystick.get_button( i )\n                textPrint.print(screen, \"Button {:>2} value: {}\".format(i,button) )\n                if i==0 and button ==1:\n                    print(\"A\")\n                if i==1 and button ==1:\n                    print(\"B\")\n                if i==2 and button ==1:\n                    print(\"X\")\n                if i==3 and button ==1:\n                    print(\"Y\")\n                if i==4 and button ==1:\n                    print(\"LB\")\n                if i==5 and button ==1:\n                    print(\"RB\")\n                if i==6 and button ==1:\n                    print(\"BACK\")\n                if i==7 and button ==1:\n                    print(\"START\")\n                if i==8 and button ==1:\n                    print(\"Logitech\")\n                if i==9 and button ==1:\n                    print(\"Left GA\")\n                if i==10 and button ==1:\n                    print(\"Right GA\")",
                "char_count": 1150,
                "token_estimate": 288
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Handle to control the toycar**",
                "chunk_index": 15,
                "content": "textPrint.unindent()\n            # Hat switch. All or nothing for direction, not like joysticks.\n\n# Value comes back in an array.\n\nhats = joystick.get_numhats()\n            textPrint.print(screen, \"Number of hats: {}\".format(hats) )\n            textPrint.indent()\n\nfor i in range( hats ):\n                speed = 300\n                hat = joystick.get_hat( i )\n                textPrint.print(screen, \"Hat {} value: {}\".format(i, str(hat)) )\n                if hat==(1,0) :\n                    print(\"Turn right\")\n                    turnright()\n                if hat==(-1,0) :\n                    print(\"Turn left\")\n                    turnleft()\n                if hat==(0,1):\n                    print(\"Go ahead\")\n                    setspeed()\n                    setdirection(2)\n                    if hat==(1,0) :\n                        print(\"Turn right\")\n                        turnright()\n                    if hat==(-1,0) :\n                        print(\"Turn left\")\n                        turnleft()",
                "char_count": 1015,
                "token_estimate": 254
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Handle to control the toycar**",
                "chunk_index": 16,
                "content": "if hat==(0,0):\n                    print(\"Slowing down\")\n                    temp1 = (bus.read_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_PWM_NOW_2_H) << 8) | (bus.read_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_PWM_NOW_2_L))\n                    print(temp1)\n                    speed = temp1\n                    while speed > 0 :\n                        speed = speed - 8\n                        time.sleep(0.01)\n                        setspeed()\n                if hat==(0,-1):\n                    print(\"Go back\")\n                    setspeed()\n                    setdirection(1)\n                    if hat==(1,0) :\n                            print(\"Turn right\")\n                            turnright()\n                    if hat==(-1,0) :\n                        print(\"Turn left\")\n                        turnleft()\n            textPrint.unindent()\n            #textPrint.unindent()\n\n# ALL CODE TO DRAW SHOULD GO ABOVE THIS COMMENT\n\n# Go ahead and update the screen with what we've drawn.\n\npygame.display.flip()\n        # Limit to 20 frames per second\n\nclock.tick(20)\n    # Close the window and quit.\n\n# If you forget this line, the program will 'hang'\n\npygame.quit ()\n\n-   Execute it!",
                "char_count": 1195,
                "token_estimate": 299
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Handle to control the toycar**",
                "chunk_index": 17,
                "content": "` python3 toycar.py`\n\n-   Plug the wireless handle receiver into the Raspberry Pi,then enjoy it!",
                "char_count": 96,
                "token_estimate": 24
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Keyboard to control the toycar**",
                "chunk_index": 18,
                "content": "**\nSoftware environment<\/br>**\n\nFirst you need prepare a TF card to burn the raspbian.You can download the system from the official website.\n\nWhen you finished this,please connect it by ssh.\n\n-   First,please open the function of wireless function.Execute the following command:\n\n` sudo raspi-config`\n\n-   Then choose the option on the picture\n\n|                                                                                                                 |\n|-----------------------------------------------------------------------------------------------------------------|\n| <figure>\n <img src=\"DockerPi_DIY_Car(2).png\" title=\"DockerPi_DIY_Car(2).png\" width=\"500\" alt=\"DockerPi_DIY_Car(2).png\" \/>\n <figcaption aria-hidden=\"true\">DockerPi_DIY_Car(2).png<\/figcaption>\n <\/figure>                                                                                                        |\n\n-   Then choose the option on the picture",
                "char_count": 928,
                "token_estimate": 232
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Keyboard to control the toycar**",
                "chunk_index": 19,
                "content": "|                                                                                                                 |\n|-----------------------------------------------------------------------------------------------------------------|\n| <figure>\n <img src=\"DockerPi_DIY_Car(7).png\" title=\"DockerPi_DIY_Car(7).png\" width=\"500\" alt=\"DockerPi_DIY_Car(7).png\" \/>\n <figcaption aria-hidden=\"true\">DockerPi_DIY_Car(7).png<\/figcaption>\n <\/figure>                                                                                                        |\n\n-   You can configure your wifi\n-   Then you need install the python3's module pygame\n\n` sudo apt-get -y install python3-pygame`\n\n-   You also need to install python3's smbus\n\n` sudo apt-get -y install python3-smbus`\n\n-   Please open the RaspberryPi's I2C\n-   You could install the following script to achieve the safeshut down function.\n\n` wget -qO- `[`https:\/\/git.io\/fj3b9`](https:\/\/git.io\/fj3b9)` | sudo bash`\n\n**\nCodes<\/br>**\n\n-   Create a new file and named:toycar.py and paste following codes:\n-   Press the key of W:Go ahead\n-   Press the key of S:Go back\n-   Press the key of A:Turn left\n-   Press the key of D:Turn right\n\n<!-- -->",
                "char_count": 1181,
                "token_estimate": 296
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Keyboard to control the toycar**",
                "chunk_index": 20,
                "content": "import pygame\n    import sys\n    import smbus\n    import time\n\n#MOTOR_DRIVER Address\n    MOTOR_DRIVER_ADDRESS = 0x18\n    MOTOR_DRIVER_BUS = 1\n    bus = smbus.SMBus(MOTOR_DRIVER_BUS)\n\n#MOTOR_DRIVER Functions\n    MOTOR_DRIVER_SPEED_1_L = 0x01\n    MOTOR_DRIVER_SPEED_1_H = 0x02\n    MOTOR_DRIVER_SPEED_2_L = 0x03\n    MOTOR_DRIVER_SPEED_2_H = 0x04\n    MOTOR_DRIVER_DIRECTION = 0x09\n    MOTOR_DRIVER_ENABLE = 0x13\n    MOTOR_DRIVER_PWM_NOW_2_L = 0x1f\n    MOTOR_DRIVER_PWM_NOW_2_H = 0x20",
                "char_count": 479,
                "token_estimate": 120
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Keyboard to control the toycar**",
                "chunk_index": 21,
                "content": "pygame.init()\n    screen = pygame.display.set_mode((600, 400))\n    pygame.display.set_caption('pygame event')\n    def setspeed():\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_1_L,speed & 0xff)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_1_H,speed >> 8)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_2_L,speed & 0xff)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_2_H,speed >> 8)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_ENABLE,1)\n    def decspeed():\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_1_L,temp1 & 0xff)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_1_H,temp1 >> 8)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_2_L,temp1 & 0xff)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_2_H,temp1 >> 8)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_ENABLE,1)\n    def turnleft():\n        temp0 = 200\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_1_L,(temp0 - 100) & 0xff)\n        bus.",
                "char_count": 1120,
                "token_estimate": 280
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Keyboard to control the toycar**",
                "chunk_index": 22,
                "content": "write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_1_H,((temp0 - 100) >> 8) | 0x80)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_2_L,temp0 & 0xff)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_2_H,(temp0 >> 8) | 0x80)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_ENABLE,1)\n    def turnright():\n        temp0 = 200\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_1_L,temp0 & 0xff)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_1_H,((temp0 >> 8) | 0x80))\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_2_L,(temp0 - 100) & 0xff)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_SPEED_2_H,((temp0 - 100) >> 8) | 0x80)\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_ENABLE,1)\n    def setdirection(sysnax):\n        bus.write_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_DIRECTION,sysnax)",
                "char_count": 938,
                "token_estimate": 235
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Keyboard to control the toycar**",
                "chunk_index": 23,
                "content": "while True:\n        for event in pygame.event.get():\n            if event.type == pygame.QUIT:\n                sys.exit()\n            #\n            keyboard_list = [pygame.K_w,pygame.K_s,pygame.K_a,pygame.K_d]\n            keys_pressed = pygame.key.get_pressed()\n            if keys_pressed[keyboard_list[0]]:\n                print(\"Go ahead\")\n                speed = 200\n                while (speed < 300):\n                    speed += 10\n                    setdirection(2)\n                    setspeed()\n                    if keys_pressed[keyboard_list[2]]:\n                        print(\"Turn left\")\n                        turnleft()\n                    elif keys_pressed[keyboard_list[3]]:\n                        print(\"Turn right\")\n                        turnright()",
                "char_count": 776,
                "token_estimate": 194
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Keyboard to control the toycar**",
                "chunk_index": 24,
                "content": "elif keys_pressed[keyboard_list[1]]:\n                print(\"Go back\")\n                speed = 200\n                while (speed < 350):\n                    speed += 10\n                    setdirection(1)\n                    setspeed()\n                    if keys_pressed[keyboard_list[2]]:\n                        print(\"Turn left\")\n                        turnleft()\n                    elif keys_pressed[keyboard_list[3]]:\n                        print(\"Turn right\")\n                        turnright()\n            elif keys_pressed[keyboard_list[2]]:\n                print(\"Turn left\")\n                turnleft()\n\nelif keys_pressed[keyboard_list[3]]:\n                print(\"Turn right\")\n                turnright()\n            else:\n                temp1 = (bus.read_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_PWM_NOW_2_H) << 8) | (bus.read_byte_data(MOTOR_DRIVER_ADDRESS,MOTOR_DRIVER_PWM_NOW_2_L))\n                print(temp1)\n                while (temp1 > 0):\n                    time.sleep(0.01)\n                    temp1 -= 4\n                    decspeed()\n        pygame.display.update()\n\n-   Execute it!\n\n` sudo DISPLAY=:0.0 python3 toycar.py`",
                "char_count": 1153,
                "token_estimate": 289
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "How to use > **Use the Keyboard to control the toycar**",
                "chunk_index": 25,
                "content": "-   Plug the wireless keyboard receiver into the Raspberry Pi,then enjoy it!",
                "char_count": 76,
                "token_estimate": 19
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "FAQ",
                "chunk_index": 26,
                "content": "-   Q: Can the Bluetooth controller be used?\n\n` A: Yes,we do not recommend it, the delay is very high`\n\n-   Q: Why can I control it when I use the handle, sometimes I can’t control it?\n\n` A: Please observe if the four lights on your handle are flashing together.If the flashing together means re-pairing, `\n`    the signal cannot be transmitted.`\n\n-   Q: What is the maximum speed the car can reaching?\n\n` A: It will be faster than your imagination,the max is 1300r\/min.However, i suggest you don't do like this,it may damage the car.`\n\n-   Q: Sometimes,the toycar is out of my control,what's wrong with it?\n\n` A: Maybe the raspberry pie's wireless signal is too weak.Also,this is related to your program.`\n\n-   Q: Why i have executed the command:sudo halt,but the Raspberypi and Power Board's Led is still working?\n\n` A: Because you havn't installed the script about power.Please install it then have a try.`\n\n-   Q: If i have ran the program and the raspberrypi is fine,i have reed the value of register of speed,but the car has't any response?",
                "char_count": 1046,
                "token_estimate": 262
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "FAQ",
                "chunk_index": 27,
                "content": "` A: Please check the Power Board's power supply pin.It may be broken.`\n`    Meantime,you may not plug the wireless keyboard receiver into the Raspberry Pi`",
                "char_count": 156,
                "token_estimate": 39
            },
            {
                "title": "EP-0109",
                "rev_id": 10670,
                "heading_path": "Keywords",
                "chunk_index": 28,
                "content": "DockerPi,DIY,toycar,intelligent,Programmable",
                "char_count": 44,
                "token_estimate": 11
            }
        ]
    }
}