akupila / Arduino-MMA8452

MIT License
7 stars 7 forks source link

Suggestion #3

Open kshepitzki opened 6 years ago

kshepitzki commented 6 years ago

I would like to suggest to complement your library with a getPitchRoll() function which should be quite handy, void MMA8452::getPitchRoll(float pitch, float roll) { float Xg, Yg, Zg; getAcceleration(&Xg, &Yg, &Zg);

//Low Pass Filter
_fXg = Xg * _alpha + (_fXg * (1.0 - _alpha));
_fYg = Yg * _alpha + (_fYg * (1.0 - _alpha));
_fZg = Zg * _alpha + (_fZg * (1.0 - _alpha));

*roll = (atan2(-_fYg, _fZg)*180.0) / M_PI;
*pitch = (atan2(_fXg, sqrt(_fYg*_fYg + _fZg*_fZg))*180.0) / M_PI;

} And class members: float _fXg=0, _fYg=0, _fZg=0, _alpha=0.5;

akupila commented 6 years ago

I like the idea. Happy to merge a PR!

kshepitzki commented 6 years ago
body p { margin-bottom: 0cm; margin-top: 0pt; } 

I did. 
Check out if you like and approve.
The code is tested and works perfect.

On 5/25/2018 4:26 PM, Antti Kupila
  wrote:

  I like the idea. Happy to merge a PR!
  —
    You are receiving this because you authored the thread.
    Reply to this email directly, view it on GitHub, or mute the thread.
  {"@context":"http://schema.org","@type":"EmailMessage","potentialAction":{"@type":"ViewAction","target":"https://github.com/akupila/Arduino-MMA8452/issues/3#issuecomment-392057146","url":"https://github.com/akupila/Arduino-MMA8452/issues/3#issuecomment-392057146","name":"View Issue"},"description":"View this Issue on GitHub","publisher":{"@type":"Organization","name":"GitHub","url":"https://github.com"}}
  {"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/akupila/Arduino-MMA8452","title":"akupila/Arduino-MMA8452","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/akupila/Arduino-MMA8452"}},"updates":{"snippets":[{"icon":"PERSON","message":"@akupila in #3: I like the idea. Happy to merge a PR!"}],"action":{"name":"View Issue","url":"https://github.com/akupila/Arduino-MMA8452/issues/3#issuecomment-392057146"}}}
  {

"@type": "MessageCard", "@context": "http://schema.org/extensions", "hideOriginalBody": "false", "originator": "37567f93-e2a7-4e2a-ad37-a9160fc62647", "title": "Re: [akupila/Arduino-MMA8452] Suggestion (#3)", "sections": [ { "text": "", "activityTitle": "Antti Kupila", "activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png", "activitySubtitle": "@akupila", "facts": [

] } ], "potentialAction": [ { "name": "Add a comment", "@type": "ActionCard", "inputs": [ { "isMultiLine": true, "@type": "TextInput", "id": "IssueComment", "isRequired": false } ], "actions": [ { "name": "Comment", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"akupila/Arduino-MMA8452\",\n\"issueId\": 3,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}" } ] }, { "name": "Close issue", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"akupila/Arduino-MMA8452\",\n\"issueId\": 3\n}" }, { "targets": [ { "os": "default", "uri": "https://github.com/akupila/Arduino-MMA8452/issues/3#issuecomment-392057146" } ], "@type": "OpenUri", "name": "View on GitHub" }, { "name": "Unsubscribe", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 337779942\n}" } ], "themeColor": "26292E" }

    Virus-free. www.avast.com