-
Notifications
You must be signed in to change notification settings - Fork 508
Implement generalized analog input module #1054
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
Conversation
so AnalogIn is being imported twice in this exsample import board
from analogio import AnalogIn
from kmk.modules.analogin import AnalogIn Other note where is this suppose to be placed you import the stuff above in code.py analog = AnalogIn(
[
AnalogInput(AnalogIn(board.A0)),
AnalogInput(AnalogIn(board.A1)),
AnalogInput(AnalogIn(board.A2)),
],
[
[AnalogKey(KC.X), AnalogKey(KC.Y), AnalogKey(KC.Z)],
[KC.TRNS, KC.NO, AnalogKey(KC.W, threshold=96)],
],
)
keyboard.modules.append(analog) |
oh and is the analog = AnalogIn(
[
AnalogInput(AnalogIn(board.A0)),
AnalogInput(AnalogIn(board.A1)),
AnalogInput(AnalogIn(board.A2)),
],
[
[AnalogKey(KC.X), AnalogKey(KC.Y), AnalogKey(KC.Z)],
[KC.TRNS, KC.NO, AnalogKey(KC.W, threshold=96)],
],
) edit "AnalogInputs" not AnalogInput |
also a minimum change for on_change needs to be added either as a override-able value or just a 1 or 2% min-max (pots like to float a little and hopping between 1-10 units all the time keeps triggering it |
question... I've added pulls to the analogin branch does this need redone or if you merge it it will the draft update? Now is there any good way to pass a int to this so we don't have to copy pasta what is effectively the same code SLD0 = AnalogEvent(
on_change=lambda self, event, keyboard : KC.MIDI_CC(7, event.value, channel=0).on_press(keyboard),
)
SLD1 = AnalogEvent(
on_change=lambda self, event, keyboard : KC.MIDI_CC(7, event.value, channel=1).on_press(keyboard),
)
SLD2 = AnalogEvent(
on_change=lambda self, event, keyboard : KC.MIDI_CC(7, event.value, channel=2).on_press(keyboard),
)
SLD3 = AnalogEvent(
on_change=lambda self, event, keyboard : KC.MIDI_CC(7, event.value, channel=3).on_press(keyboard),
) |
I had to change all the names midway through, because I didn't notice that CP already uses the name
Yes, you have to import
Why use midi keys in the first place? Just use the midi API directly. |
b89a698
to
40b6c85
Compare
Are there any fundamental issues within the scope of this PR left unaddressed, or can we merge? |
40b6c85
to
de85bbf
Compare
de85bbf
to
66521e2
Compare
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.
LGTM
Question, was the original plan to make some modules that need/ provide some use for this first so it won't sit without use like pot did originally for a hall effect keyboard there should be no reason to not be able to just add a normal keymap and it makes the map in the backend. also speaking of hall effects. this won't work with layer keys. nothing is done when swapping layers to set the state back and it remains locked on. same for other keys |
No. Why are we having this discussion for the n-th time?
That discussion has evolved into pages upon pages of unfocused rubber ducking. That is fine, that's kind of what the chat is for, in a sense. It does not, however, have any tangible "scope".
No it doesn't. We've been over this.
Modules are mainly for peripherals. A hall effect keyboard would need a specific scanner in order to work with the rest of KMK. Once again, this is not the intendend use of this module and out of scope for this PR. |
Ok so just thinking about the peripherals then. they will press keys, someone changes a layer for other macros and its in an active state. filters are currently still locked to the input and not the event meaning a midi pitch bend on one layer and a joystick on another wont work without the midi making sure the value is down sampled say you make a midi keyboard and you swap layers one the fly for different instruments or groupings. your midi key is stuck until you go back. say its a joystick being uses as a wasd controller (legit had someone ask about that at one point) this is all that's needed when the other structures are there #----keymin-enabled--------both-disabled---------keymax-enabled
#------------thresmin--------deadzone-------thresmax-------#analog-max
class AnalogJoyKey(AnalogEvent):
def __init__(self, keymin, keymax, thresmin, thresmax):
self.keymin = keymin
self.keymax = keymax
self.thresmin = thresmin
self.thresmax = thresmax
self.minpressed = False
self.maxpressed = False
def on_change(self, event, keyboard):
if event.value >= self.thresmax and not self.maxpressed:
self.maxpressed = True
keyboard.pre_process_key(self.keymax, True)
elif event.value <= self.thresmax and self.maxpressed:
self.maxpressed = False
keyboard.pre_process_key(self.keymax, False)
if event.value <= self.thresmin and not self.minpressed:
self.minpressed = True
keyboard.pre_process_key(self.keymin, True)
elif event.value >= self.thresmin and self.minpressed:
self.minpressed = False
keyboard.pre_process_key(self.keymin, False)
def on_stop(self, event, keyboard):
pass
def layer_change(self, event, keyboard, ingress):
if ingress:
self.on_change(event, keyboard)
else: #egress
self.minpressed = False
keyboard.pre_process_key(self.keymin, False)
self.maxpressed = False
keyboard.pre_process_key(self.keymax, False) think about how user will use it and what they want to use it for, but seeing this
right but you said it with encoder. it went bad because people kept wanting other functionality out of it and it got bloated it needs to have a way of providing "almost" everything a module or user could need or the resources to form that need (eg timedelta for velocity calculations) And if were missing something it should not result in a format change for existing users and modules. I'm trying to look at this as if I were to give my friend who knows a little programing. the module and the docs and to tell them to make something. and asking what they would want to make |
It's a toggle. You change layers, it stays toggled. Literally intended behaviour, exactly the same as toggles in the main keymap are expected to work.
I'm getting really tired of repeating myself. The filters are for normalizing the analog readings. They are supposed to be independend of any downstream actions.
Same as the first: If I don't "release" a key intentionally, I'd expect it to stay active until I do so.
Ok. So? Is you having no idea a technical limitation of the framework?
There's a description of what it does in plain english right above the code snippet.
That's not what I said. I said it was poorly designed from the start, especially without extensibility in mind.
Cool. You can use their input to suggest neat new ways to use it that we haven't thought of yet. |
Draft of a better analog input module as mentioned in #638.