Title: 警惕C++里的构造函数 · Issue #31 · RTduino/RTduino · GitHub
Open Graph Title: 警惕C++里的构造函数 · Issue #31 · RTduino/RTduino
X Title: 警惕C++里的构造函数 · Issue #31 · RTduino/RTduino
Description: 构造函数里初始化设备这种行为可能会引发一些行为不可控。因为构造函数什么时候初始化并不确定,例如,一旦传感器通过构造函数初始化的时机比IIc设备框架要早,那么,传感器肯定是不工作的。例如: SmartDrive smd = SmartDrive(SmartDrive_DefaultAddress); //<= 这个函数内部调用了Wire.begin函数, 调用Wire.begin初始化的时候很有可能iic都没有初始化. 因此最好的方法是将其放在setup函数中。 void...
Open Graph Description: 构造函数里初始化设备这种行为可能会引发一些行为不可控。因为构造函数什么时候初始化并不确定,例如,一旦传感器通过构造函数初始化的时机比IIc设备框架要早,那么,传感器肯定是不工作的。例如: SmartDrive smd = SmartDrive(SmartDrive_DefaultAddress); //<= 这个函数内部调用了Wire.begin函数, 调用Wire.begin初始化的时候很...
X Description: 构造函数里初始化设备这种行为可能会引发一些行为不可控。因为构造函数什么时候初始化并不确定,例如,一旦传感器通过构造函数初始化的时机比IIc设备框架要早,那么,传感器肯定是不工作的。例如: SmartDrive smd = SmartDrive(SmartDrive_DefaultAddress); //<= 这个函数内部调用了Wire.begin函数, 调用Wire.begin初始化的...
Opengraph URL: https://github.com/RTduino/RTduino/issues/31
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"警惕C++里的构造函数","articleBody":"构造函数里初始化设备这种行为可能会引发一些行为不可控。因为构造函数什么时候初始化并不确定,例如,一旦传感器通过构造函数初始化的时机比IIc设备框架要早,那么,传感器肯定是不工作的。例如:\r\n```\r\nSmartDrive smd = SmartDrive(SmartDrive_DefaultAddress); //\u003c= 这个函数内部调用了Wire.begin函数, 调用Wire.begin初始化的时候很有可能iic都没有初始化. 因此最好的方法是将其放在setup函数中。\r\n\r\nvoid setup()\r\n{\r\n Serial.begin(9600);\r\n}\r\n\r\nvoid loop()\r\n{\r\n //Print on serial monitor\r\n Serial.print(\"Motor powered: \" + smd.IsMotorPowered(SmartDrive_Motor_ID_1));\r\n\r\n delay(1000);\r\n}\r\n```","author":{"url":"https://github.com/mysterywolf","@type":"Person","name":"mysterywolf"},"datePublished":"2022-08-07T20:25:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/31/RTduino/issues/31"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:258f44bb-fdd4-7e68-cce5-dce52e0a9312 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BD94:14E054:27275A:32CBD2:6990AF8F |
| html-safe-nonce | 17ac1ae4ff54f9e2ceba8ac27309ecfcbbac19f7fc507071ec932c901c8c86e6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDk0OjE0RTA1NDoyNzI3NUE6MzJDQkQyOjY5OTBBRjhGIiwidmlzaXRvcl9pZCI6Ijc1NTI5ODU1NzcwNDc1MDI3MzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 07820810516a6fe63f48f60006a07aba0b30faa44099705d3dd7c54f894cc2c8 |
| hovercard-subject-tag | issue:1331114667 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/RTduino/RTduino/31/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bc55005634a1160edfec74a919efc72165943178f3ba27fb03245c330cc52016/RTduino/RTduino/issues/31 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bc55005634a1160edfec74a919efc72165943178f3ba27fb03245c330cc52016/RTduino/RTduino/issues/31 |
| og:image:alt | 构造函数里初始化设备这种行为可能会引发一些行为不可控。因为构造函数什么时候初始化并不确定,例如,一旦传感器通过构造函数初始化的时机比IIc设备框架要早,那么,传感器肯定是不工作的。例如: SmartDrive smd = SmartDrive(SmartDrive_DefaultAddress); //<= 这个函数内部调用了Wire.begin函数, 调用Wire.begin初始化的时候很... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mysterywolf |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/RTduino/RTduino git https://github.com/RTduino/RTduino.git |
| octolytics-dimension-user_id | 104340484 |
| octolytics-dimension-user_login | RTduino |
| octolytics-dimension-repository_id | 437460543 |
| octolytics-dimension-repository_nwo | RTduino/RTduino |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 437460543 |
| octolytics-dimension-repository_network_root_nwo | RTduino/RTduino |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 848bc6032dcc93a9a7301dcc3f379a72ba13b96e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width