{"id":290133,"date":"2018-09-30T23:50:03","date_gmt":"2018-09-30T19:50:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=290133"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=290133","title":{"rendered":"\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0436\u0435\u0441\u0442\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e APDS-9960"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ox\/bk\/bh\/oxbkbhl6uwlr0-1dynm5tppscw0.jpeg\" alt=\"image\"><\/p>\n<p>  \u0427\u0438\u0442\u0430\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043a \u043c\u043e\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 <a href=\"https:\/\/habr.com\/post\/423847\/\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043f\u0440\u043e APDS-9960, \u0433\u0434\u0435 \u0440\u0435\u0447\u044c \u0448\u043b\u0430 \u043f\u0440\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u0430 \u0438 \u0443\u0440\u043e\u0432\u043d\u044f \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u0441\u0442\u0430\u043b\u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c\u0438 \u0434\u0432\u0435 \u0432\u0435\u0449\u0438: 1) \u0442\u0435\u043c\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0436\u0435\u0441\u0442\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0438 2) \u0442\u0435\u043c\u0430 \u044d\u0442\u0430 \u043d\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0430.<\/p>\n<p>  \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438 \u0443\u0436 \u0432\u0437\u044f\u043b\u0441\u044f \u0437\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 APDS-9960, \u0442\u043e \u0431\u0435\u0437 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044f \u0436\u0435\u0441\u0442\u043e\u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0430\u0448\u0435\u043b \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0438 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0442\u043e\u0436\u0435.<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0412\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043e\u0431\u0437\u043e\u0440 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0436\u0435\u0441\u0442\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0435\u043d\u0441\u043e\u0440 APDS-9960.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441\u0435\u043d\u0441\u043e\u0440\u0430, \u0441\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435. \u0412\u044b \u0441\u0430\u043c\u0438 \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043c \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0436\u0435\u0441\u0442\u0430\u043c\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e APDS-9960.<br \/>  \u041a\u0430\u043a \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437, \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u0434\u043e\u043c, \u0432\u0441\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e. \u041f\u043e\u043b\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043a\u043e\u0434\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0440\u0435\u043c\u0430\u0440\u043a\u0430: \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0436\u0435\u0441\u0442\u043e\u0432 \u0443 APDS-9960 \u043d\u0435 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u044f\u043c \u0432\u043e\u0442, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b, \u0437\u043d\u0430\u0447\u0438\u0442, \u0440\u0435\u0433\u0438\u0441\u0442\u0440, \u0430 \u0442\u0430\u043c \u0443\u0436\u0435 \u0438 \u0436\u0435\u0441\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u043b\u0435\u0436\u0438\u0442 \u2014 \u0442\u0430\u043a\u043e\u0433\u043e \u0432 APDS-9960 \u043d\u0435\u0442; \u0430 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u0436\u0435\u0441\u0442\u043e\u0432, \u0447\u0435\u043c \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0438 \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f.<\/p>\n<p>  \u0412\u043e\u043e\u0431\u0449\u0435, \u044d\u0442\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438 \u0445\u043e\u0440\u043e\u0448\u043e \u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c. \u041d\u0435 \u043e\u0447\u0435\u043d\u044c \u2014 \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442\u044c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u043d\u0441\u043e\u0440\u0430 \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u0433\u043e, \u0430 \u0445\u043e\u0440\u043e\u0448\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e, \u0432\u043a\u0443\u043f\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0438, \u043c\u043e\u0436\u043d\u043e, \u0438\u0437\u043e\u0449\u0440\u044f\u044f\u0441\u044c, \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0430\u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0436\u0435\u0441\u0442\u043e\u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u0430\u043a\u0438\u0445 \u0443\u0433\u043e\u0434\u043d\u043e \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0445 \u0438 \u0432\u0441\u044f\u043a\u0438\u0445.<\/p>\n<p>  \u041d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435\u0441\u0435\u0442 \u043b\u0438\u0448\u044c \u043e\u0431\u0437\u043e\u0440\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u043c\u0438 UP-DOWN-LEFT-RIGHT \u0436\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<p>  \u041d\u0443 \u0447\u0442\u043e \u0436\u0435, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c.<\/p>\n<p>  <b>\u0422\u0435\u043e\u0440\u0438\u044f<\/b><\/p>\n<p>  \u041f\u043e\u0437\u0432\u043e\u043b\u044e \u0441\u0435\u0431\u0435 \u0447\u0443\u0442\u043e\u0447\u043a\u0443 \u043c\u0430\u0442\u0447\u0430\u0441\u0442\u0438.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0438 \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0432 APDS-9960 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0418\u041a \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434 \u0438 \u0447\u0435\u0442\u044b\u0440\u0435 \u0444\u043e\u0442\u043e\u0434\u0438\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043a\u0430\u043a \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043f\u0440\u043e\u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043d\u0438\u0436\u0435, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442 \u0441\u0438\u0433\u043d\u0430\u043b\u044b \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u0431\u043b\u0438\u0436\u043d\u0435\u0433\u043e \u0418\u041a (NIR).<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/__\/k4\/vq\/__k4vqf3yty6sjcshtq77znw_v0.jpeg\" alt=\"image\"><\/p>\n<p>  \u0418\u041a \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434 (LED) \u043d\u0435\u0441\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0438, \u0430 \u0444\u043e\u0442\u043e\u0434\u0438\u043e\u0434\u044b (UDLR) \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442 \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u043d\u044b\u0439 \u043e\u0442 \u00ab\u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u044f\u00bb \u0441\u0432\u0435\u0442.<\/p>\n<p>  \u0424\u043e\u0442\u043e\u0434\u0438\u043e\u0434\u044b \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u043d\u0430 \u0441\u0435\u043d\u0441\u043e\u0440\u0435 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u00ab\u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u044f\u00bb, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u043e\u0442\u043e\u0434\u0438\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0418\u041a-\u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0438 \u043c\u0435\u043d\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 APDS-9960 \u043d\u0435\u0434\u0432\u0443\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u043c, \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u0440\u044f\u044f \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044f \u0430\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u0443 \u0438 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c \u0444\u0430\u0437 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432 \u0441 \u0444\u043e\u0442\u043e\u0434\u0438\u043e\u0434\u043e\u0432 UDLR. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/aj\/ts\/ok\/ajtsok_p-tpsaa1cyx5uoy2uonm.jpeg\" alt=\"image\"><\/p>\n<p>  <b>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430<\/b><\/p>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 APDS-9960, \u043a\u0430\u043a \u0438 \u0432 <a href=\"https:\/\/habr.com\/post\/423847\/\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0440\u0430\u0437<\/a>, \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c STM32VLDISCOVERY. \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u043e\u0441\u044c.<\/p>\n<p>  <u>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 APDS-9960<\/u><\/p>\n<p>  \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0441\u0435\u043d\u0441\u043e\u0440\u0430.<\/p>\n<p>  \u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u043e\u0442:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">APDS9960_init<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">void APDS9960_init(void) {  \ti2c1_write(APDS9960_CONTROL, DEFAULT_PGAIN); \ti2c1_write(APDS9960_GPENTH, DEFAULT_GPENTH); \ti2c1_write(APDS9960_GEXTH, DEFAULT_GEXTH); \ti2c1_write(APDS9960_GCONF2, DEFAULT_GGAIN); \ti2c1_write(APDS9960_GPULSE, DEFAULT_PULSE_LENGTH); \ti2c1_write(APDS9960_PPULSE, DEFAULT_PULSE_LENGTH);  } <\/code><\/pre>\n<\/p><\/div>\n<\/div>\n<p>  \u0427\u0442\u043e \u0436\u0435 \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f.<\/p>\n<pre><code class=\"cpp\">i2c1_write(APDS9960_CONTROL, DEFAULT_PGAIN);<\/code><\/pre>\n<p>  PGAIN (Proximity Gain Control) \u2014 \u044d\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u043c \u0443\u0441\u0438\u043b\u0435\u043d\u0438\u044f \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u044f. \u041f\u0440\u0438\u0441\u0432\u043e\u0438\u043c \u0435\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 2, \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0443\u0441\u0438\u043b\u0435\u043d\u0438\u044e \u0432 \u0447\u0435\u0442\u044b\u0440\u0435 \u0440\u0430\u0437\u0430.<\/p>\n<pre><code class=\"cpp\">i2c1_write(APDS9960_GPENTH, DEFAULT_GPENTH); i2c1_write(APDS9960_GEXTH, DEFAULT_GEXTH); <\/code><\/pre>\n<p>  GPENTH (Gesture Proximity Enter Threshold Register) \u2014 \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0436\u0435\u0441\u0442\u0430.<br \/>  GEXTH (Gesture Exit Threshold Register), \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0436\u0435\u0441\u0442\u0430.<\/p>\n<pre><code class=\"cpp\">i2c1_write(APDS9960_GCONF2, DEFAULT_GGAIN); <\/code><\/pre>\n<p>  \u0412 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 GCONF2 (Gesture configuration two) \u043c\u044b \u044f\u0432\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 GGAIN (Gesture Gain Control) \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0443\u0441\u0438\u043b\u0435\u043d\u0438\u044f \u0432 \u0447\u0435\u0442\u044b\u0440\u0435 \u0440\u0430\u0437\u0430.<\/p>\n<pre><code class=\"cpp\">i2c1_write(APDS9960_GPULSE, DEFAULT_PULSE_LENGTH); i2c1_write(APDS9960_PPULSE, DEFAULT_PULSE_LENGTH); <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0430. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0442\u043e\u043a\u0430 \u0418\u041a \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 0, \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u043a\u0443 \u0432 100 \u043c\u0410, \u043d\u0430\u0441 \u044d\u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0443\u0441\u0442\u0440\u043e\u0438\u0442 \u2014 \u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c.<br \/>  \u0418\u041a \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0430 \u0432 APDS-9960 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 \u0438 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0434\u043b\u044f \u0436\u0435\u0441\u0442\u043e\u0432 GPULSE (Gesture pulse count and length): GPLEN (Gesture Pulse Length) \u0438 GPULSE (Number of Gesture Pulses), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u044f PPULSE (Proximity Pulse Count Register): PPLEN (Proximity Pulse Length) \u0438 PPULSE (Proximity Pulse Count) \u0437\u0430\u0434\u0430\u044e\u0449\u0438\u043c\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 \u0438 \u043f\u0435\u0440\u0438\u043e\u0434 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430.<br \/>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c, \u0447\u0442\u043e GPLEN \u0438 PPLEN \u043f\u0440\u0438\u043c\u0443\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 2 \u0440\u0430\u0432\u043d\u043e\u0435 16 \u043c\u043a\u0441, \u0430 GPULSE \u0438 PPULSE \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 9, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 10 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430\u043c.<\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043d\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432 \u0438 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043e\u0431\u0437\u043e\u0440\u0430 APDS-9960.<\/p>\n<p>  <u>\u0427\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/u><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043c\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0446\u0438\u043a\u043b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0447\u043d\u0435\u043c \u0442\u043e \u0438 \u0434\u0435\u043b\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0444\u043e\u0442\u043e\u0434\u0438\u043e\u0434\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0436\u0435\u0441\u0442\u0430 \u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0433\u043e.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u043e-\u043d\u0430\u043f\u0435\u0440\u0432\u043e, \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u043c APDS-9960 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0436\u0435\u0441\u0442\u0430\u043c\u0438 \u0438 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0435\u043c.<\/p>\n<pre><code class=\"cpp\">GesturesSet(GESTURES_START); <\/code><\/pre>\n<p>  \u0418 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 GVALID. GVALID (Gesture FIFO Data) \u2014 \u044d\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 GSTATUS (Gesture Status Register), \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043d\u0430\u0445\u043e\u0434\u044f\u0441\u044c \u0432 \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u043c \u043e\u0442 \u043d\u0443\u043b\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438, \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043d\u0430\u043c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0443 \u0441\u0435\u043d\u0441\u043e\u0440\u0430 \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0433\u043e\u0434\u043d\u044b\u0435 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0436\u0435\u0441\u0442\u0430\u0445.<\/p>\n<p>  \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0443\u0447\u0438\u0442 \u043d\u0430\u0441, \u0447\u0442\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0436\u0435\u0441\u0442\u0430\u0445 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0431\u0443\u0444\u0435\u0440\u0435, \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 32 x 4 \u0431\u0430\u0439\u0442.<br \/>  \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0444\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 GFLVL (Gesture FIFO level), \u0442.\u0435. \u043f\u043e \u043c\u043e\u0438\u043c \u0441\u0443\u0433\u0443\u0431\u043e \u044d\u043c\u043f\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f\u043c, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f GFLVL*4. \u041a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/oy\/57\/ry\/oy57ryfaagi3qqrur9htiefckx0.jpeg\" alt=\"image\"><\/p>\n<p>  \u041d\u0443 \u0438 \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0444\u0435\u0440\u0430, \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 First In \u2014 First Out. \u0422\u043e \u0435\u0441\u0442\u044c, \u0433\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0447\u0435\u043c \u00ab\u0440\u0430\u043d\u044c\u0448\u0435\u00bb \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043b \u0441\u0438\u0433\u043d\u0430\u043b \u0441 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0444\u043e\u0442\u043e\u0434\u0438\u043e\u0434\u043e\u0432 \u0442\u0435\u043c \u00ab\u0432\u044b\u0448\u0435\u00bb \u0432 GFLVL \u043e\u043d \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0435 \u0441 \u0444\u043e\u0442\u043e\u0434\u0438\u043e\u0434\u043e\u0432 (UDLR) \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 Gesture FIFO Register:<\/p>\n<p>   \u2014 GFIFO_U (Gesture FIFO Data, UP)<br \/>   \u2014 GFIFO_D (Gesture FIFO Data, DOWN)<br \/>   \u2014 GFIFO_L (Gesture FIFO Data, LEFT)<br \/>   \u2014 GFIFO_R (Gesture FIFO Data, RIGHT)<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432, GFLVL \u0434\u0435\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f; \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0447\u0442\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u0441\u0435\u0433\u043e \u0431\u0443\u0444\u0435\u0440\u0430 \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u043a\u0430 GFLVL \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u0442 \u043d\u0443\u043b\u044f.<\/p>\n<p>  \u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0436\u0435\u0441\u0442\u043e\u0432 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u0430\u0439\u0442\u0430 \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0444\u0435\u0440\u0430, \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0435\u043c \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0445.<\/p>\n<pre><code class=\"cpp\">GestureUp = i2c1_read(APDS9960_GFIFO_U); GestureDown = i2c1_read(APDS9960_GFIFO_D); GestureLeft = i2c1_read(APDS9960_GFIFO_L); GestureRight = i2c1_read(APDS9960_GFIFO_R); <\/code><\/pre>\n<p>  <u>\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0436\u0435\u0441\u0442\u043e\u0432<\/u><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u0436\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u0436\u0435\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u043b, \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043c \u043d\u0435\u0445\u0438\u0442\u0440\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">GestUpDown = GestureUp-GestureDown; GestLeftRight = GestureLeft-GestureRight; <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0436\u0435\u0441\u0442\u043e\u0432 \u043d\u0430\u043c \u0432\u0430\u0436\u043d\u044b \u043d\u0435 \u0441\u0430\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f GestUpDown \u0438 GestLeftRight, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u0437\u043d\u0430\u043a, \u0442\u0430\u043a \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430.<br \/>  \u0422\u043e \u0435\u0441\u0442\u044c, \u0438\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044f \u043d\u0430 \u0432\u0445\u043e\u0434 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 GestUpDown \u0438 GestLeftRight \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043a\u0430\u043a\u043e\u0439 \u0438\u043c\u0435\u043d\u043d\u043e \u0436\u0435\u0441\u0442 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d. <\/p>\n<p>  \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 GestUpDown \u0438 GestLeftRight \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043d\u0438\u0436\u0435<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xx\/ts\/g-\/xxtsg-0zw2h7ralowsgsd_8tmoc.jpeg\" alt=\"image\"><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u043d\u0443\u043b\u0438\u043c GFLVL:<\/p>\n<pre><code class=\"cpp\">GesturesSet(GESTURES_STOP); <\/code><\/pre>\n<p>  \u2026 \u0438 \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u0446\u0435\u043b\u0438\u043a\u043e\u043c:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">main.c<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\"> #include \"stm32f10x.h\"  #define APDS9960_I2C_ADDR       0x39 #define APDS9960_ENABLE         0x80 #define APDS9960_GSTATUS        0xAF #define APDS9960_GFLVL          0xAE  \/\/Gesture FIFO Register (0xFC \u2013 0xFF): #define APDS9960_GFIFO_U        0xFC #define APDS9960_GFIFO_D        0xFD #define APDS9960_GFIFO_L        0xFE #define APDS9960_GFIFO_R        0xFF   #define APDS9960_CONTROL        0x8F #define APDS9960_GPENTH         0xA0 #define APDS9960_GEXTH          0xA1 #define APDS9960_GCONF2         0xA3 #define APDS9960_GPULSE         0xA6 #define APDS9960_PPULSE         0x8E  #define GESTURES_START          0x01 #define GESTURES_STOP           0x02  #define DEFAULT_GPENTH          40      \/\/ Threshold for entering gesture mode #define DEFAULT_GEXTH           30      \/\/ Threshold for exiting gesture mode     #define DEFAULT_PGAIN           8 \t\t\t\/\/ Proximity Gain Control: 4X  #define DEFAULT_GGAIN           0x40\t\t\/\/ Gesture Gain Control: 4X  #define DEFAULT_PULSE_LENGTH    0x89    \/\/ 16us, 10 pulses  \/* Bit fields *\/ #define APDS9960_PON            0x01 #define APDS9960_AEN            0x02 #define APDS9960_PEN            0x04 #define APDS9960_WEN            0x08 #define APSD9960_AIEN           0x10 #define APDS9960_PIEN           0x20 #define APDS9960_GEN            0x40 #define APDS9960_GVALID         0x01  int GestUpDown = 0; int GestLeftRight = 0;  \/\/-----------------------------------------------------------------------  uint8_t i2c1_read(uint8_t addr); void i2c1_write(uint8_t addr, uint8_t data);  void I2C1_init(void) { \t \tI2C_InitTypeDef I2C_InitStructure;   GPIO_InitTypeDef  GPIO_InitStructure;    RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB| RCC_APB2Periph_AFIO , ENABLE);  \tGPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; \tGPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD; \tGPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; \tGPIO_Init(GPIOB, &amp;GPIO_InitStructure); \t \tI2C_StructInit(&amp;I2C_InitStructure); \tI2C_InitStructure.I2C_ClockSpeed = 100000; \tI2C_InitStructure.I2C_OwnAddress1 = 0x01; \tI2C_InitStructure.I2C_Ack = I2C_Ack_Enable; \tI2C_Init(I2C1, &amp;I2C_InitStructure); \tI2C_Cmd(I2C1, ENABLE);  }  \/\/-----------------------------------------------------------------------  void APDS9960_init(void) {  \ti2c1_write(APDS9960_CONTROL, DEFAULT_PGAIN);\t\t \ti2c1_write(APDS9960_GPENTH, DEFAULT_GPENTH); \ti2c1_write(APDS9960_GEXTH, DEFAULT_GEXTH); \ti2c1_write(APDS9960_GCONF2, DEFAULT_GGAIN); \ti2c1_write(APDS9960_GPULSE, DEFAULT_PULSE_LENGTH); \ti2c1_write(APDS9960_PPULSE, DEFAULT_PULSE_LENGTH); \t }  \/\/-----------------------------------------------------------------------  uint8_t i2c1_read(uint8_t addr) { \tuint8_t data; \twhile(I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY)); \tI2C_GenerateSTART(I2C1, ENABLE); \twhile(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT)); \tI2C_Send7bitAddress(I2C1, APDS9960_I2C_ADDR&lt;&lt;1, I2C_Direction_Transmitter); \twhile(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); \tI2C_SendData(I2C1, addr); \twhile(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED)); \tI2C_GenerateSTART(I2C1, ENABLE); \twhile(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT)); \tI2C_Send7bitAddress(I2C1, APDS9960_I2C_ADDR&lt;&lt;1, I2C_Direction_Receiver); \twhile(!I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_BYTE_RECEIVED)); \tdata = I2C_ReceiveData(I2C1); \twhile(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_RECEIVED)); \tI2C_AcknowledgeConfig(I2C1, DISABLE); \tI2C_GenerateSTOP(I2C1, ENABLE); \twhile(I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY)); \treturn data; }  \/\/-----------------------------------------------------------------------  void i2c1_write(uint8_t addr, uint8_t data) { \tI2C_GenerateSTART(I2C1, ENABLE); \twhile(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT)); \tI2C_Send7bitAddress(I2C1, APDS9960_I2C_ADDR&lt;&lt;1, I2C_Direction_Transmitter); \twhile(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); \tI2C_SendData(I2C1, addr); \twhile(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED)); \tI2C_SendData(I2C1, data); \twhile(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED)); \tI2C_GenerateSTOP(I2C1, ENABLE); \twhile(I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY)) {};  }  \/\/-----------------------------------------------------------------------  void GesturesSet(uint8_t GestSel) { \t \tswitch (GestSel)   \t{   \t\tcase GESTURES_START: \t\t\ti2c1_write(APDS9960_ENABLE, APDS9960_GEN | APDS9960_PEN | APDS9960_PON); \t\t\tbreak; \t\tcase GESTURES_STOP: \t\t\ti2c1_write(APDS9960_ENABLE, APDS9960_PEN | APDS9960_PON); \t\t\tbreak;   \t\tdefault: \t\t\ti2c1_write(APDS9960_ENABLE, APDS9960_GEN | APDS9960_PEN | APDS9960_PON);\t\t\t \t} \t }  \/\/-----------------------------------------------------------------------  int main() { \t \tuint8_t GFLVL_buf = 0; \t \tuint8_t GSTATUS_buf = 0;  \tuint8_t GestureUp = 0; \tuint8_t GestureDown = 0; \tuint8_t GestureLeft = 0; \tuint8_t GestureRight = 0; \t \tI2C1_init(); \t \tAPDS9960_init();    while (1)   {  \t\tGFLVL_buf = 0; \t\t \t\tGSTATUS_buf = 0;  \t\tGestureUp = 0; \t\tGestureDown = 0; \t\tGestureLeft = 0; \t\tGestureRight = 0; \t\t \t\tGestUpDown = 0; \t\tGestLeftRight = 0; \t\t \t\tGesturesSet(GESTURES_START);  \t\tGSTATUS_buf = i2c1_read(APDS9960_GSTATUS);  \t\tif(GSTATUS_buf &amp; APDS9960_GVALID) { \t\t \t\t\tGFLVL_buf = i2c1_read(APDS9960_GFLVL);  \t\t\tif(GFLVL_buf) { \t\t\t\t \t\t\t\tGestureUp = i2c1_read(APDS9960_GFIFO_U); \t\t\t\tGestureDown = i2c1_read(APDS9960_GFIFO_D); \t\t\t\tGestureLeft = i2c1_read(APDS9960_GFIFO_L); \t\t\t\tGestureRight = i2c1_read(APDS9960_GFIFO_R);\t\t\t\t  \t\t\t\t\/\/Truth table: \t\t\t\t\/\/UP: \t GestUpDown(+) | GestLeftRight(+) \t\t\t\t\/\/DOWN:  GestUpDown(-) | GestLeftRight(-) \t\t\t\t\/\/LEFT:  GestUpDown(+) | GestLeftRight(-) \t\t\t\t\/\/RIGHT: GestUpDown(-) | GestLeftRight(+) \t\t\t\t \t\t\t\tGestUpDown = GestureUp-GestureDown; \t\t\t\tGestLeftRight = GestureLeft-GestureRight; \t\t\t\t\t\t \t\t\t\tGesturesSet(GESTURES_STOP);  \t\t\t} \t\t\t \t\t} \t\t\t \t}  }    <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0425\u043e\u0447\u0443 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0436\u0435\u0441\u0442\u043e\u0432 \u0443 APDS-9960 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0434\u0430\u0436\u0435 \u043d\u0435\u043f\u043b\u043e\u0445\u043e. \u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0435, \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0432 APDS-9960 UV and IR \u0444\u0438\u043b\u044c\u0442\u0440\u044b.<\/p>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u0435\u043d. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p><\/div>\n<p>        <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/post\/424947\/\"> https:\/\/habr.com\/post\/424947\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ox\/bk\/bh\/oxbkbhl6uwlr0-1dynm5tppscw0.jpeg\" alt=\"image\"><\/p>\n<p>  \u0427\u0438\u0442\u0430\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043a \u043c\u043e\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 <a href=\"https:\/\/habr.com\/post\/423847\/\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043f\u0440\u043e APDS-9960, \u0433\u0434\u0435 \u0440\u0435\u0447\u044c \u0448\u043b\u0430 \u043f\u0440\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u0430 \u0438 \u0443\u0440\u043e\u0432\u043d\u044f \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u0441\u0442\u0430\u043b\u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c\u0438 \u0434\u0432\u0435 \u0432\u0435\u0449\u0438: 1) \u0442\u0435\u043c\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0436\u0435\u0441\u0442\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0438 2) \u0442\u0435\u043c\u0430 \u044d\u0442\u0430 \u043d\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0430.<\/p>\n<p>  \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438 \u0443\u0436 \u0432\u0437\u044f\u043b\u0441\u044f \u0437\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 APDS-9960, \u0442\u043e \u0431\u0435\u0437 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044f \u0436\u0435\u0441\u0442\u043e\u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0430\u0448\u0435\u043b \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0438 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0442\u043e\u0436\u0435.<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0412\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043e\u0431\u0437\u043e\u0440 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0436\u0435\u0441\u0442\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0435\u043d\u0441\u043e\u0440 APDS-9960.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-290133","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/290133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=290133"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/290133\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=290133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=290133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=290133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}