-
Notifications
You must be signed in to change notification settings - Fork 53
Slide Potentiometer #63
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
Slide Potentiometer #63
Conversation
feat: Slide potentiometer
Graphics is modelled after this spec sheet PTA Series - Low Profile Slide Potentiometer |
Great start! Where would the 3 pins be located? For the tip, you could use a single rect with a gradient (I think that'd also look a bit better). Also, I think the body could use a gradient to give it more metallic look |
Pins: On a real slide potentiometer they are underneath. I am not sure how to deal with that. They are close to the ends, so maybe take some artistic license and add pins that stick out from the ends. For the tip, I am not entirely sure what you mean. I was struggling a lot with the gradients. I think it is hard to make it look right. |
Sticking them out from the ends sounds like a good solution.
How do you create the gradients?
…On Tue, Apr 20, 2021 at 6:45 PM Søren Ranneries ***@***.***> wrote:
Pins: On a real slide potentiometer they are underneath. I am not sure how
to deal with that. They are close to the ends, so maybe take some artistic
license and add pins that stick out from the ends.
For the tip, I am not entirely sure what you mean. I was struggling a lot
with the gradients. I think it is hard to make it look right.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#63 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGZ3HRVYGGBSH3IFATO47DTJWORPANCNFSM43GNNMIA>
.
|
I'm using inkscape, but I just don't think it is that easy to use. Also I am not that experienced with drawing/graphical design so I am also not sure how to apply a gradient to make it look better. Never the less I will push a new version soon. |
Yes, inkscape is not very straight forward when it comes to gradient editing. What I usually do, I place the original photo behind (or on top / below) the shape, and then I tinker with the gradient until I get a look that resembles the original. If you need, I can make a short video that shows how I do this |
Good to see this slowly coming to life and taking form :) Please let me know when you feel ready for me to go over the code and share my feedback |
Works as 100 % zoom, but is messed up at other scales...
Note: for adding the keyboard interaction, you can probably use a |
I think this is close enough to done to be reviewed. Issues:
Steps to reproduce the switching issue:
When doing step 4, the slide jumps to the last position it had after doing step 2. It is like the input element and the SVG looses synchronization when using the keyboard. |
Thank you!
Seems like it could be solved using some CSS, something like:
Probably some kind of bluish outline will fit. As far as the switching issue, I don't think it's a show stopper. Sounds like an edge case we can live with. I'm going to try and integrate your WiP into wokwi.com to see if there are any issues I can spot. |
Alright, you can see it in action here: https://wokwi.com/arduino/projects/297604176384360973 Feedback I gathered so far:
|
Thanks for the feedback!
For the pins, how does the signal property work? In a real slide potentiometer the top left pin and the right pin is connected to each end of the resistor. The lower left pin is connected to the gang (tip). For handling rotation I can imagine several approaches.
|
Thanks!
You can set the lower left pin (the one that is connected to the tip) to This is a bit arbitrary, but the simulator uses the That's what I did with the standard potentiometer. Also called the pins VCC, SIG and GND: readonly pinInfo: ElementPin[] = [
{ name: 'GND', x: 29, y: 68.5, number: 1, signals: [{ type: 'power', signal: 'GND' }] },
{ name: 'SIG', x: 37, y: 68.5, number: 2, signals: [analog(0)] },
{ name: 'VCC', x: 44.75, y: 68.5, number: 3, signals: [{ type: 'power', signal: 'VCC' }] },
]; I figured out that while in the general sense GND and VCC are not the correct names (names like END1/END2 or FIXED1/FIXED2 are probably more accurate), these names will make more sense for beginners, and they are very common in tutorial (if you google for "potentiometer pinout" you'll see many images calling these pins GND/Ground and VCC/5V). Thoughts?
It sounds like one possible solution. How about the "drag" event for the tip? Would that work?
Perhaps you can take advantage of the SVG transform matrix to do that for you? |
For the pin modes, I don't mind calling them vcc and ground if that is easier for beginners to comprehend. I will add that soon.
I tried that. Adding
|
Thanks!
That makes sense. So I guess adding a global listener is that way to go. |
Thanks Søren! I updated the preview on wokwi.com with the new code, and now the mouse feels much smoother. I think it's perfect! Other than the rotation issue, is there anything else left to fix? Also, I see the the pin positions are a bit off: |
The rotation issue is the last hurdle. I don't know what happened to the pin positions, but it shouldn't be too hard to fix :) |
Anything I can do to help with this?
I added a new |
I was playing around with it yesterday, but hit the hurdle that |
I see you are using A different approach would be to use the width value you already have in your code ( Or maybe I'm just speaking nonsense? |
I found the right API for the job. I use a transformation matrix to convert a point in page space to a point in the #caseRect space. Simple to implement and should handle all kinds of transformations you could think of applying, except for the zoom.
I fixed the rotation issue. Thank you for the suggestion of using the |
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! I just tried the latest version on Wokwi, with 42° rotation, and it works like a charm! Well done!
https://wokwi.com/arduino/projects/299391106457534985
Left some comments, and we also need to fix pinInfo (should be quite easy now - basically, wrap the slide potentiometer with a <wokwi-show-pins>
in one of the stories, and it should do the trick).
Also, can you please rebase on top of master to fix the merge conflicts in index.ts / react-types.ts?
… spinkelben/slide-potentiometer
I have address all your comments. Feel free to re-open if you think I didn't resolve it completely.
I just merged the changes from master into the branch. Do you want be to do a rebase instead? I am not sure how PRs are completed with GitHub. If I were in control I would do a squash merge. That's what I am used to from Azure DevOps, but I don't know if GitHub has a similar feature. |
Thank you! I'm at a friend's wedding, but will have a look when I get home.
That's okay, I'm going to squash merge |
No rush, it took a month to get this far, a few more days doesn't make a huge difference 😉. Enjoy the wedding! 🎉 |
True, I'm just excited about it ;-)
…On Sun, May 23, 2021, 11:33 PM Søren Ranneries ***@***.***> wrote:
Thank you! I'm at a friend's wedding, but will have a look when I get home.
No rush, it took a month to get this far, a few more days doesn't make a
huge difference 😉
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#63 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGZ3HW2BLECJ3LFPU5ULJLTPFRCDANCNFSM43GNNMIA>
.
|
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.
Final round of changes :-)
@@ -0,0 +1,20 @@ | |||
import { html } from 'lit-html'; | |||
import { action } from '@storybook/addon-actions'; |
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.
unused import? or did you want to attach an action to the potentiometer input event?
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 never became good friends with storybook, what would be the advantage of adding the action on input event? :)
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 means that when you move the potentiometer, you'll see the events firing in the "Actions" tab:
pot-actions.mp4
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 see. Still not 100 % what you get from that, but it is quick to wire up, so I have done 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.
Thank you!
It's just a quick way to test that the component emits the events correctly. There's an issue where it doesn't show the detail
value of the events, otherwise this would also show users the information contained in events.
Alright, I released this as wokwi-element 0.37.0, and it's now also available on Wokwi: https://wokwi.com/arduino/projects/297604176384360973 and docs: https://docs.wokwi.com/parts/wokwi-slide-potentiometer |
feat: Slide potentiometer #56
Work in progress, but submitting PR early to get feedback.