Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Change Input #185

Answered by pschatzmann
Grassbaecker asked this question in Q&A
Discussion options

is it posible to change the input after setup in Runtime so that my following code will run

void testAuxIn(bool Detect) {
Serial.println();
Serial.print("Detect");
Serial.println(Detect);
if(!Detect) {
kitcfg.input_device = AUDIO_HAL_ADC_INPUT_LINE2; //LineIn
if(Analogin==1) {
//Last Mic
OUTon = true;
Analogin = 2;
}
} else {
kitcfg.input_device = AUDIO_HAL_ADC_INPUT_LINE1; //Mic
if(Analogin==2) {
//Last Linein
Analogin = 1;
if(BlueAudioState<1) {
//No BlueAudio
OUTon = false;
}
}
}
AuxInChange--;
}

with regarts bernhard

You must be logged in to vote

I am not really sure what you are trying to do: But if you want to change the input_device you have to call kit.end() and kit:begin(kitcfg) with the changed configuration.

Replies: 6 comments 11 replies

Comment options

I am not really sure what you are trying to do: But if you want to change the input_device you have to call kit.end() and kit:begin(kitcfg) with the changed configuration.

You must be logged in to vote
1 reply
Comment options

ok thanks

What i want do have ist that my input is change when i plug the LineIN conector in or out and also the output will mute if Mic is activatet

Answer selected by pschatzmann
Comment options

To my knowledge there is no functionality to detect if LineIn is plugged in.

The only strategy I could think of is actually switch alternatively between the 2 in order to detect if you have a signal. You could use the VolumePrint class to determine the volume.

This will however only work if your board is not messed up and can separate between line 1 (microphone) and line 2 (aux in).

You must be logged in to vote
1 reply
Comment options

there is functionality
byte AuxDetectPin = kit.pinAuxin(); give me the corect pinnuber on my lyrat
digitalRead(AuxDetectPin) would give me on setup the right value
attachInterrupt(AuxDetectPin, AuxDetectIRQ, CHANGE); call an funtion to raise an int who is corect check in loop and call my change analogin function

but now i have the proplem the kit.end(); call brings my system to reboot even i have comment out all core0 function
but without change all will run on core1 kit and core0 ArduinoFFT with Output on Oled and i hope soon also on FastLed

very Strange also that all my Oled libs that works well on normal ESP32 Devkit not do on lyrat on Defauld Core1

Comment options

Oh, I didn't know that this is working. Did you do a pinMode(AuxDetectPin, INPUT_PULLUP); ?
If you are using SPI for your Oled I suggest to change AUDIOKIT_SETUP_SD in AudioKitSettings.h to #define AUDIOKIT_SETUP_SD 0 to deactivate the SPI used by the SD card

You must be logged in to vote
3 replies
Comment options

has the same result

the call of kit.end wil bring reboot
when i coment out kit.end and begin the function would print the corect valus but not change input
is there ah plan to have more then one input channels on futur kit version so it is able to have both input and only change the mix or read command?

Comment options

and my oled is I2C
and also have kitcfg.sd_active = false; in my setup for no SD fntionality

Comment options

Oh, I didn't know that this is working. Did you do a pinMode(AuxDetectPin, INPUT_PULLUP); ? If you are using SPI for your Oled I suggest to change AUDIOKIT_SETUP_SD in AudioKitSettings.h to #define AUDIOKIT_SETUP_SD 0 to deactivate the SPI used by the SD card

yes i did pinMode(AuxDetectPin, INPUT_PULLUP);
but i must also tell you than you must give ah delay after couse
InitAlnalogAudio(digitalRead(AuxDetectPin)); will fail without delay before //or better not fail bring wrong value

so my solution was one digitalRead for trash between pinmode and initanalogaudio

with greets bernhard

Comment options

Well, you could directly use the driver functions. I assume that you have a es8388 based board:
https://github.com/pschatzmann/arduino-audiokit/blob/main/src/audio_driver/es8388/es8388.h

You must be logged in to vote
2 replies
Comment options

yes it have 8388 codec chip

but when i read the link this look i must be back from "AudioLibs/AudioKit.h" to "AudioKitHAL.h" wehre the
auto cfg = kit.defaultConfig(AudioInputOutput); not was corect work and i was nothing here on output what i have write there

so it look i must to be satisfied with your great work on audioKit and have only one analog input on boot and hope i be abel to bring A2DP as second input to run

thanks in advance Bernhard

Comment options

yes it have 8388 codec chip

but when i read the link this look i must be back from "AudioLibs/AudioKit.h" to "AudioKitHAL.h" wehre the auto cfg = kit.defaultConfig(AudioInputOutput); not was corect work and i was nothing here on output what i have write there

so it look i must to be satisfied with your great work on audioKit and have only one analog input on boot and hope i be abel to bring A2DP as second input to run

thanks in advance Bernhard

I thought you wanted to switch the input which could be done with es8388_config_adc_input

Comment options

I2C is used to communicate with the Codec. I am not sure what you need to do to avoid any conflicts. If you selected the Wire library to be used in the config here is the implementation: https://github.com/pschatzmann/arduino-audiokit/blob/main/src/audio_hal/i2c_wire.cpp

I just double checked: you would need to use Wire1 for your oled

You must be logged in to vote
3 replies
Comment options

Wire1??? is ther any other I2C on Lyrat

Comment options

Yes read the first sentence of my last answer! You will need to use another channel...

Comment options

it look i am too stupid for i do not find any other I2C on hardware referene but thanks for your help

Comment options

Oh, this has nothing to do with hardware. Wire and Wire1 are defined in the ESP32 Wire library

You must be logged in to vote
1 reply
Comment options

there is good news now after my afternoon nap the A2DP work as second but primary input is meanig when bluetoothaudio state lower 1 it is read the analogin

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /