-
Notifications
You must be signed in to change notification settings - Fork 488
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
Implement generalized analog input module #1054
base: main
Are you sure you want to change the base?
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. |
Draft of a better analog input module as mentioned in #638.