-
-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix/wt901 via SerialPIO #96
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
47c92de
Neopixel magenta flash on serial overflow
Apehaenger 2c88deb
Fix timing and add comms error display via NeoPixel
Apehaenger 74ccc49
Fix build of WT901_INSTEAD_OF_SOUND
Apehaenger d7d0b20
Fix Wstringop-overflow warning (nv_config related)
Apehaenger 0aac871
Re-enabled unknown unlock sequence
Apehaenger 8cc09ed
Merge branch 'main' into bugfix/WT901
ClemensElflein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,26 +10,23 @@ CJY901 ::CJY901(SerialPIO *serial) | |
this->serial = serial; | ||
} | ||
|
||
void CJY901::begin(int baudrate) { | ||
void CJY901::begin(unsigned long baudrate) { | ||
serial->begin(baudrate); | ||
delay(1000); | ||
uint8_t unlock[] = {0xFF,0xF0,0xF0,0xF0,0xF0}; | ||
/*uint8_t unlock[] = {0xFF,0xF0,0xF0,0xF0,0xF0}; // undocumented / unknown? | ||
serial->write(unlock, 5); | ||
serial->flush(); | ||
delay(10);*/ | ||
writeRegister(RSW, 0b0000000000010110); // Return data content | ||
delay(10); | ||
writeRegister(RSW, 0b0000000000010110); | ||
writeRegister(RRATE, 0x08); // Return rate 0x06 = 10Hz (default), 0x08 = 50Hz, 0x09 = 100Hz | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMU_CYCLETIME is 20ms, so I reduced WT's return rate to 50Hz |
||
delay(10); | ||
writeRegister(RRATE, 0x09); | ||
writeRegister(0x0b, 0x00); // X axis Magnetic bias | ||
delay(10); | ||
writeRegister(0x0b,0x00); | ||
writeRegister(0x0c, 0x00); // Y axis Magnetic bias | ||
delay(10); | ||
writeRegister(0x0c,0x00); | ||
writeRegister(0x0d, 0x00); // Z axis Magnetic bias | ||
delay(10); | ||
writeRegister(0x0d,0x00); | ||
delay(10); | ||
|
||
|
||
|
||
|
||
ucRxCnt = 0; | ||
} | ||
|
@@ -43,6 +40,7 @@ void CJY901 ::update() | |
if (ucRxBuffer[0] != 0x55) | ||
{ | ||
ucRxCnt = 0; | ||
commsError_ = true; | ||
continue; | ||
} | ||
if (ucRxCnt < 11) | ||
|
@@ -112,3 +110,12 @@ void CJY901::writeRegister(uint8_t address, uint16_t data) { | |
delay(100); | ||
|
||
} | ||
|
||
bool CJY901::commsError() { | ||
bool hold = commsError_; | ||
#ifdef WT901 | ||
hold |= serial->overflow(); | ||
#endif | ||
commsError_ = false; | ||
return hold; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't find this unlock code in any documentation. Only in a doubtful Amazon comment. So I disabled it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://forum.arduino.cc/t/help-calibrating-witmotion-inclinometer-through-ttl-with-mega2560/941394/1
This is what my Google-fu gave me, not sure if it is related thou
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is needed I remember sniffing the configuration of the GUI app to see how they do it because just sending config didn't work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your comments!
After reading @FadeFx comment and link I immediately thought: "Could be an Auto-Baud detection sequence", but in-between tested it. It's not :-)
Will uncomment it again.