-
Couldn't load subscription status.
- Fork 28
Initial MOxy sensor code #15
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
Initial MOxy sensor code #15
Conversation
Repo uses 4 space indentation, even in 2019 indentation conversion is still hard :P thank you sublime text for saving us.
This will unpack the data and build it into the API so profiles can handle the patterns easier.
This should fix up everything.
Add to build so its compile tested all the time
Convert all tabs to spaces
Decoding not yet completly tested (TODOS added)
Gotta have a driver to reset the hardware.
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.
Apparently I can't request changes to myself since I authored this PR @Sepp62, but here are my comments. I am going to revamp my testing infra this next week (right now I have to book my main desktop into windows just to run Simulant+ when i prefer coding in linux) so I am going to try setting up a raspberry pi with windows so I can test easier.
| #include "ANTPLUS.h" | ||
| | ||
| #define BAUD_RATE 9600 | ||
| #define CHANNEL_1 0 |
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.
CHANNEL_1 but defined as 0?
| #define ANTPLUS_MUSCLEOXYGENPROFILEPRIVATEDEFINES_h | ||
| | ||
| /* Channel Config */ | ||
| #define ANTPLUS_MUSCLEOXYGEN_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_RECEIVE |
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.
ANTPLUS_MUSCLEOXYGEN_DISPLAY_CHANNELTYPE
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.
Changed
| #define ANTPLUS_MUSCLEOXYGEN_DEVICETYPE 31 | ||
| #define ANTPLUS_MUSCLEOXYGEN_CHANNELPERIOD 8192 | ||
| // Master channel | ||
| #define ANTPLUS_MUSCLEOXYGEN_MASTER_CHANNELTYPE 0x10 |
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.
#define ANTPLUS_MUSCLEOXYGEN_MONITOR_CHANNELTYPE CHANNEL_TYPE_BIDIRECTIONAL_TRANSMIT
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.
Changed
| // Master channel | ||
| #define ANTPLUS_MUSCLEOXYGEN_MASTER_CHANNELTYPE 0x10 | ||
| #define ANTPLUS_MUSCLEOXYGEN_MASTER_TRANSMISSIONTYPE 5 | ||
| #define ANTPLUS_MUSCLEOXYGEN_MASTER_DEVICENUMBER 5 |
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.
What is this for?
| #define ANTPLUS_MUSCLEOXYGEN_SEARCHTIMEOUT 12 | ||
| | ||
| /* Pages */ | ||
| #define ANTPLUS_MUSCLEOXYGEN_DATAPAGE_MUSCLEOXYGENDATA 1 |
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.
add _NUMBER
| MuscleOxygenBaseMainDataPageMsg::MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber) : MuscleOxygenBaseGenericMsg() | ||
| { | ||
| _buffer[ANTPLUS_DEFAULT_DATAPAGE_BYTE] = dataPageNumber; | ||
| setCapabilities(); |
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.
See comment on other review about automating API :)
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.
dataPageNumber parameter removed.
| void setTotalHemoglobinConcentration( uint16_t tc ); | ||
| void setCurrentSaturatedHemoglobinPercentage(uint16_t cp); | ||
| | ||
| // internal |
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.
Why are these internal? Don't we want users to set these values?
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.
"internal" removed
| } | ||
| | ||
| void ProfileMuscleOxygenMonitor::transmitNextDataPage() { | ||
| // some static aux messages |
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.
I'm out of town (and off grid) in the mountains, but next week I'll do my best to fill in these missing common datapages on core/base-master and merge it into the shifter and moxy branches for you.
| _patternStep = 0; | ||
| | ||
| // debug | ||
| /* |
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.
Debug needs to be removed :)
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.
Removed
| | ||
| void ProfileMuscleOxygenMonitor::transmitMuscleOxygenMainPageMsg() { | ||
| MuscleOxygenBaseMainDataPageMsg msg; | ||
| msg.setEventCount( _eventCount ); |
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.
I don't think we can control this, if I'm reading the datasheet right, it should only increment when the sensor gets a new value, which is outside the libraries' control and depends on the moxy hardware.
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.
Changed
| Oh also i forgot, both PRs I didn't check the bit math yet for the messages, not quite awake enough for that, will check that next version. |
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.
Definitely very close to being ready to merge 👍 bit math looks good
| void setNotifications(uint8_t n = 0x00); | ||
| void setCapabilities(uint8_t c = 0x06); | ||
| void setEventCount(uint8_t n); | ||
| uint8_t * getBuffer() { return _buffer; } |
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.
Implemented by AntTxDataRequest :)
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.
Removed
| _buffer[5] |= (tc >> 8) & 0x0F; | ||
| } | ||
| | ||
| /* TODO |
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.
Looks good, what is missing here that needs the TODO?
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.
The behaviour of "setPreviousSaturatedHemoglobinPercentage" cannot be verified with my moxy display device. So it is not clear for me, how to handle it from the application side. Of course, I read the antplus docs, but I do not have a clue about the use of it. Since I cannot test it, I commented it out to give somebody else a chance to use 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.
I think the device just bumps the reading down. So on every event it moves the current value into previous and puts a new current. Docs site this reasoning for in the event of a data loss. It would be awesome if the class could handle this itself but since the class is never preserver I don't think there is a way around it other than showing the user through the example to do it themselves.
src/Profiles/MuscleOxygen/DataPages/Base/ANTPLUS_MuscleOxygenBaseMainDataPageMsg.h Show resolved Hide resolved
Add datapage 81 to the mix
Add datapage 80 for TX
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.
Few minor comments I can deal with, although there is the issue of the merge, but same comment applies as in the other PR, I can rebase and force push if you want :) just let me know.
| msg.setTotalHemoglobinConcentration(_c); | ||
| msg.setCurrentSaturatedHemoglobinPercentage(_c++/4); | ||
| msg.setEventCount(_eventCount++); | ||
| |
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.
TODO to add "previous sat hemoglobin"
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.
This function is a mystery to me and my moxy display. Somebody else should integrate 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.
Will do
| .DS_Store | ||
| .tags* | ||
| tags | ||
| examples/BikeSensorConverter/arduino_secrets.h |
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.
looks like the same merge happened here as well.
| | ||
| MuscleOxygenBaseMainDataPageMsg::MuscleOxygenBaseMainDataPageMsg(uint8_t dataPageNumber) : BaseDataPageMsg<BroadcastDataMsg>() | ||
| { | ||
| memset(_buffer, 0, MESSAGE_SIZE); |
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.
Just curious what the benefit of memsetting the values are :) All values in the datapage should be defined so we shouldnt be left with an 0s.
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.
During development, you cannot be sure to have all the bytes in a defined state. Initializing with "0" makes it easier to see bugs in bit math. Generally spoken: Initializing member data has very low cost and pays off during develplement and maintenance life cycle. In our special case "moxy" setPreviousSaturatedHemoglobinPercentage is unused and therefore a default initialization is helpful.
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.
Fair point, I think though I would just set it to 0 it out in the variable declaration.
*edit fair
| Going to merge, rebase then force push. The merge will disappear as in shifting but commits will be preserved. |
No description provided.