{"id":16146156,"url":"https://github.com/libdriver/pmw3901mb","last_synced_at":"2025-03-16T09:33:27.971Z","repository":{"id":40354879,"uuid":"446027953","full_name":"libdriver/pmw3901mb","owner":"libdriver","description":"PMW3901MB full function driver library for general MCU and Linux.","archived":false,"fork":false,"pushed_at":"2025-03-09T04:38:04.000Z","size":3002,"stargazers_count":23,"open_issues_count":0,"forks_count":14,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-03-09T05:22:09.308Z","etag":null,"topics":["c","full-function-driver","linux","mcu","optical-flow","pmw3901mb","spi"],"latest_commit_sha":null,"homepage":"https://www.libdriver.com","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libdriver.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-09T07:59:23.000Z","updated_at":"2025-03-09T04:37:39.000Z","dependencies_parsed_at":"2023-12-22T13:03:46.362Z","dependency_job_id":"d5d580d9-53f0-47e3-9653-d9efb6429861","html_url":"https://github.com/libdriver/pmw3901mb","commit_stats":{"total_commits":20,"total_committers":2,"mean_commits":10.0,"dds":"0.050000000000000044","last_synced_commit":"1fdf4a625df99b6dcc78e3b365bd7bd1c644fded"},"previous_names":["libdriver/pmw3901mb"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libdriver%2Fpmw3901mb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libdriver%2Fpmw3901mb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libdriver%2Fpmw3901mb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libdriver%2Fpmw3901mb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libdriver","download_url":"https://codeload.github.com/libdriver/pmw3901mb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243809844,"owners_count":20351406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","full-function-driver","linux","mcu","optical-flow","pmw3901mb","spi"],"created_at":"2024-10-10T00:19:17.687Z","updated_at":"2025-03-16T09:33:26.823Z","avatar_url":"https://github.com/libdriver.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[English](/README.md) | [ 简体中文](/README_zh-Hans.md) | [繁體中文](/README_zh-Hant.md) | [日本語](/README_ja.md) | [Deutsch](/README_de.md) | [한국어](/README_ko.md)\n\n\u003cdiv align=center\u003e\n\u003cimg src=\"/doc/image/logo.svg\" width=\"400\" height=\"150\"/\u003e\n\u003c/div\u003e\n\n## LibDriver PMW3901MB\n\n[![MISRA](https://img.shields.io/badge/misra-compliant-brightgreen.svg)](/misra/README.md) [![API](https://img.shields.io/badge/api-reference-blue.svg)](https://www.libdriver.com/docs/pmw3901mb/index.html) [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](/LICENSE)\n\nThe PMW3901MB is PixArt Imaging's latest optical  navigation chip designed with far field optics technology  that enables navigation in the air. It is housed in a 28-pin chip-on-board  (COB)  package  that  provides  X-Y  motion information  with  a  wide  working  range  of  80  mm  to infinity.  It  is  most  suitable  for  far  field application  for motion detection. \n\nLibDriver PMW3901MB is the full function driver of pmw3901mb launched by LibDriver. It provides frame reading, navigation reading, interrupt reading and other functions LibDriver is MISRA compliant.\n\n### Table of Contents\n\n  - [Instruction](#Instruction)\n  - [Install](#Install)\n  - [Usage](#Usage)\n    - [example basic](#example-basic)\n    - [example frame](#example-frame)\n    - [example interrupt](#example-interrupt)\n  - [Document](#Document)\n  - [Contributing](#Contributing)\n  - [License](#License)\n  - [Contact Us](#Contact-Us)\n\n### Instruction\n\n/src includes LibDriver PMW3901MB source files.\n\n/interface includes LibDriver PMW3901MB SPI platform independent template.\n\n/test includes LibDriver PMW3901MB driver test code and this code can test the chip necessary function simply.\n\n/example includes LibDriver PMW3901MB sample code.\n\n/doc includes LibDriver PMW3901MB offline document.\n\n/datasheet includes PMW3901MB datasheet.\n\n/project includes the common Linux and MCU development board sample code. All projects use the shell script to debug the driver and the detail instruction can be found in each project's README.md.\n\n/misra includes the LibDriver MISRA code scanning results.\n\n### Install\n\nReference /interface SPI platform independent template and finish your platform SPI driver.\n\nAdd the /src directory, the interface driver for your platform, and your own drivers to your project, if you want to use the default example drivers, add the /example directory to your project.\n\n### Usage\n\nYou can refer to the examples in the /example directory to complete your own driver. If you want to use the default programming examples, here's how to use them.\n\n#### example basic\n\n```C\n#include \"driver_pmw3901mb_basic.h\"\n\nuint8_t res;\nfloat height;\nfloat delta_x;\nfloat delta_y;\nuint32_t i, times;\npmw3901mb_motion_t motion;\n\nheight = 1.0f;\ntimes = 3;\nres = pmw3901mb_basic_init();\nif (res ！= 0)\n{\n    return 1;\n}\n\n...\n\nfor (i = 0; i \u003c times; i++)\n{\n    read:\n\n    res = pmw3901mb_basic_read(height, \u0026motion, (float *)\u0026delta_x, (float *)\u0026delta_y);\n    if (res ！= 0)\n    {\n        (void)pmw3901mb_basic_deinit();\n\n        return 1;\n    }\n\n    /* check the result */\n    if (motion.is_valid == 1)\n    {\n        /* print the result */\n\n        pmw3901mb_interface_debug_print(\"pmw3901mb: %d/%d.\\n\", i + 1, times);\n        pmw3901mb_interface_debug_print(\"pmw3901mb: delta_x: %0.3fcm delta_y: %0.3fcm.\\n\", delta_x, delta_y);\n        pmw3901mb_interface_debug_print(\"pmw3901mb: raw_average is 0x%02X.\\n\", motion.raw_average);\n        pmw3901mb_interface_debug_print(\"pmw3901mb: raw_max is 0x%02X.\\n\", motion.raw_max);\n        pmw3901mb_interface_debug_print(\"pmw3901mb: raw_min is 0x%02X.\\n\", motion.raw_min);\n        pmw3901mb_interface_debug_print(\"pmw3901mb: observation is 0x%02X.\\n\", motion.observation);\n        pmw3901mb_interface_debug_print(\"pmw3901mb: shutter is 0x%04X.\\n\", motion.shutter);\n        pmw3901mb_interface_debug_print(\"pmw3901mb: surface quality is 0x%04X.\\n\\n\", motion.surface_quality);\n    }\n    else\n    {\n        pmw3901mb_interface_delay_ms(500);\n\n        goto read;\n    }\n\n    /* delay 1000 ms */\n    pmw3901mb_interface_delay_ms(1000);\n    \n    ...\n}\n\n...\n    \n(void)pmw3901mb_basic_deinit();\n\nreturn 0;\n```\n\n#### example frame\n\n```C\n#include \"driver_pmw3901mb_frame.h\"\n\nuint8_t res;\nuint32_t k, times;\nuint32_t i, j;\nstatic uint8_t gs_frame[35][35];\n\ntimes = 3;\nres = pmw3901mb_frame_init();\nif (res != 0)\n{\n    return 1;\n}\n\n...\n\nfor (k = 0; k \u003c times; k++)\n{\n    res = pmw3901mb_frame_read(gs_frame);\n    if (res != 0)\n    {\n        (void)pmw3901mb_frame_deinit();\n\n        return 1;\n    }\n\n    pmw3901mb_interface_debug_print(\"pmw3901mb: %d/%d.\\n\", k + 1, times);\n    \n    /* print frame */\n    for (i = 0; i \u003c 35; i++)\n    {\n        for (j = 0; j \u003c 35; j++)\n        {\n            pmw3901mb_interface_debug_print(\"0x%02X \", gs_frame[i][j]);\n        }\n        pmw3901mb_interface_debug_print(\"\\n\");\n    }\n    pmw3901mb_interface_debug_print(\"\\n\");\n\n    /* delay 1000 ms */\n    pmw3901mb_interface_delay_ms(1000);\n    \n    ...\n}\n\n...\n    \n(void)pmw3901mb_frame_deinit();\n\nreturn 0;\n```\n\n#### example interrupt\n\n```C\n#include \"driver_pmw3901mb_interrupt.h\"\n\nuint8_t (*g_gpio_irq)(float height_m) = NULL;\nstatic uint8_t gs_flag;\nuint8_t res;\nuint32_t i, times;\n\nstatic void a_callback(pmw3901mb_motion_t *motion, float delta_x, float delta_y)\n{\n    /* check the result */\n    if (motion-\u003eis_valid == 1)\n    {\n        /* print the result */\n        pmw3901mb_interface_debug_print(\"pmw3901mb: find interrupt.\\n\");\n        pmw3901mb_interface_debug_print(\"pmw3901mb: delta_x: %0.3fcm delta_y: %0.3fcm.\\n\", delta_x, delta_y);\n        pmw3901mb_interface_debug_print(\"pmw3901mb: raw_average is 0x%02X.\\n\", motion-\u003eraw_average);\n        pmw3901mb_interface_debug_print(\"pmw3901mb: raw_max is 0x%02X.\\n\", motion-\u003eraw_max);\n        pmw3901mb_interface_debug_print(\"pmw3901mb: raw_min is 0x%02X.\\n\", motion-\u003eraw_min);\n        pmw3901mb_interface_debug_print(\"pmw3901mb: observation is 0x%02X.\\n\", motion-\u003eobservation);\n        pmw3901mb_interface_debug_print(\"pmw3901mb: shutter is 0x%04X.\\n\", motion-\u003eshutter);\n        pmw3901mb_interface_debug_print(\"pmw3901mb: surface quality is 0x%04X.\\n\\n\", motion-\u003esurface_quality);\n        \n        /* set flag */\n        gs_flag = 1;\n    }\n}\n\n...\n    \ntimes = 3;\nres = gpio_interrupt_init();\nif (res != 0)\n{\n    return 1;\n}\ng_gpio_irq = pmw3901mb_interrupt_irq_handler;\n\n...\n\nres = pmw3901mb_interrupt_init(_callback);\nif (res != 0)\n{\n    (void)pmw3901mb_interrupt_deinit();\n\n    return 1;\n}\n\n...\n\nfor (i = 0; i \u003c times; i++)\n{\n    pmw3901mb_interface_debug_print(\"pmw3901mb: %d/%d.\\n\", i + 1, times);\n\n    gs_flag = 0;\n    while (gs_flag == 0)\n    {\n        pmw3901mb_interface_delay_ms(10);\n    }\n    \n    ...\n}\n\n...\n    \n(void)pmw3901mb_interrupt_deinit();\n(void)gpio_interrupt_deinit();\ng_gpio_irq = NULL;\n\nreturn 0;\n```\n\n### Document\n\nOnline documents: [https://www.libdriver.com/docs/pmw3901mb/index.html](https://www.libdriver.com/docs/pmw3901mb/index.html).\n\nOffline documents: /doc/html/index.html.\n\n### Contributing\n\nPlease refer to CONTRIBUTING.md.\n\n### License\n\nCopyright (c) 2015 - present LibDriver All rights reserved\n\n\n\nThe MIT License (MIT) \n\n\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\n\nof this software and associated documentation files (the \"Software\"), to deal\n\nin the Software without restriction, including without limitation the rights\n\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\ncopies of the Software, and to permit persons to whom the Software is\n\nfurnished to do so, subject to the following conditions: \n\n\n\nThe above copyright notice and this permission notice shall be included in all\n\ncopies or substantial portions of the Software. \n\n\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n\nSOFTWARE. \n\n### Contact Us\n\nPlease send an e-mail to lishifenging@outlook.com.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibdriver%2Fpmw3901mb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibdriver%2Fpmw3901mb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibdriver%2Fpmw3901mb/lists"}