-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Refactor configuration structure #90
Conversation
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 like the addition of orientation
and ranging
as well as the move of the config to the zone. However, reading this structure i feel like it might make sense to add a sensor
object which holds all sensor specific settings? I know i previously denied that, but at the current state it makes sense to build a Sensor
in Roode
instead of zone
, orientation
and ranging
. What do you think? Of course we can skip that to another PR anytime soon.
Two sidenotes:
- Cause you are very energetic to ditch getter/setter -> lets do so
- Your C++ auto-formatter is configured different as mine, which sucks because there is a lot of formatting in this PR. Ill add a auto-formatter config to the project to prevent that.
Yeah I totally agree. Was it was coming together I thought that as well. I can do it here if you want or we can wait. Up to you.
I don't want to bully you into it lol. I do feel strongly about it and I tried to post some reasoning. I definitely want to look into immutability or blocking writes where not expected. But also given the nature of how the codebase is consumed it might not be too important...
I see you've added a clang formatter config. I was missing that as well. The formatting was inconsistent but I didn't want to do a blanket reformat of code I wasn't touching. Also I wasn't sure which preferences you had. I'll rebase and reformat 👍 |
components/roode/roode.cpp
Outdated
while (1) | ||
{ | ||
} | ||
this->mark_failed(); | ||
return; |
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.
Did you know about this and avoided it for a reason? API states it logs the error and then update/loop/etc. functions are no longer called. This felt better than blocking the entire runtime.
Rebased & got new formatting in. More tomorrow. |
Although we don't completely use this I2C abstraction yet, it gets us closer.
components/vl53l1x/__init__.py
Outdated
} | ||
), | ||
} | ||
).extend(i2c.i2c_device_schema(0x52)) |
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.
).extend(i2c.i2c_device_schema(0x52)) | |
).extend(i2c.i2c_device_schema(0x29)) |
When i added 0x52 i was using a knock off sensor. Genuine VL53L1X have 0x29 as default address
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.
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.
Nope the pololu as well as the GY-53 uses 0x29 and those are the two preferred sensors. Black PCB sometimes uses 0x52. ST itself says 0x29 7 Bit or 0x52 16 bit.
I have both variants here, however I will only support the polol, guy-53, adafruit and sparkfun
…ult to first found. This lets the entire VL53L1X component be omitted from config if using defaults
…ROI. This allows ROI to be recalibrated later without losing what the config overrides are.
Don't set ranging mode again if it hasn't changed.
There's still lots of clean up that can happen. But since this is blocking you, I'll stop here 😄 |
This is a great PR! I'll need to test it in detail before merging it, but it looks good to me. Feel always free to open another PR 🙂 |
This new structure breaks things up by subject instead of the manual/automatic parameter values. I believe this is much easier to understand and allows parameters to be more granularly defined with automatic or manual values.
New minimal config with defaults
roode:
vl53l1x
section can be omitted if using defaultsi2c
section can be omitted if on default pins SDA/SCLAll options spelled out
I tried to not touch too much, but it was hard. One of my main goals was to get stuff out of
Roode
class. So having separateZone
,Threshold
,ROI
objects helps with that. But still configuring everything throughRoode
defeats that purpose.There's a lot of data points here. I avoided a lot of getters & some setters because it's just so much boilerplate that doesn't add any value. Usually it's said to be "cleaner" because "encapsulation", but it's really not. Data set via property or setter is the same thing, the setter doesn't restrict anything. I have them in a few places where it's easier to code gen in python.
As we continue to refactor we can reduce the tightness of the coupling between these objects. Just trying not to do too much at once here.