Skip to content

[adc] Add support for HX71708#821

Open
EllaFoxo wants to merge 7 commits intoKalicoCrew:mainfrom
EllaFoxo:feature/adc-hx71708
Open

[adc] Add support for HX71708#821
EllaFoxo wants to merge 7 commits intoKalicoCrew:mainfrom
EllaFoxo:feature/adc-hx71708

Conversation

@EllaFoxo
Copy link
Copy Markdown
Contributor

The smaller version of the HX717 is the HX71708, which has configurable sample rates instead of the gain/channel, since there is only a single channel on this board. There is a fixed gain value of 128. This adapts the existing HX71x implementation to configure this chip accordingly.

Checklist

  • pr title makes sense
  • added a test case if possible
  • if new feature, added to the readme
  • ci is happy and green

@EllaFoxo EllaFoxo marked this pull request as ready for review February 3, 2026 06:43
@EllaFoxo EllaFoxo changed the title [WIP] [adc] Add support for HX71708 [adc] Add support for HX71708 Feb 3, 2026
@EllaFoxo
Copy link
Copy Markdown
Contributor Author

EllaFoxo commented Feb 3, 2026

Hiya, I'll be coming back to update the docs on this soon, but just want a pair of eyes on the source to make sure it's up to snuff. Cc @garethky

Comment thread klippy/extras/hx71x.py
# HX717 gain/channel options
{"A-128": 1},
"A-128",
{320: 4, 3: 80, 20: 2, 10: 1},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the 80 SPS option is transposed

{320: 4, 3: 80, 20: 2, 10: 1},
{320: 4, 80: 3, 20: 2, 10: 1},

Comment thread src/sensor_hx71x.c
uint_fast8_t gain_or_sps = hx71x->gain_or_sps;

uint_fast8_t extra_bits;
if (gain_or_sps == 1) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just have a single argument called "extra_bits" or maybe "setting_bits" and used that throughtout. That gets rid of the gain_or_sps flag and sps_bits

Even the error check is checking the same range so it would still function correctly.

Comment thread klippy/extras/hx71x.py
# We forward the sps bits to hx71x_read_adc so that it can read the extra bits required
if sensor_type == "hx71708":
self.gain_or_sps = 1
self.sps_bits = config.getchoice(
Copy link
Copy Markdown
Contributor

@garethky garethky Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like this is being tacked on the side. If there are going to be different configurable properties for different sensor types then we should accept that 100%. It looks like the sub types should not have that responsibility.

Some unique config logic is needed for each sensor type and then the resulting extra_bits get passed in to this class.

For the hx71708 specifically, the gain doesn't need to be read, since its not configurable.

I could argue something similar about the HX711, its SPS cant be set in software. I've already had people complain that they set the SPS but it didn't work. Maybe I need to have HX711_10 and HX711_80 as sensor types so people don't get the wrong idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants