karawin / Ka-Radio32

esp32 version of Ka-Radio (https://github.com/karawin/Ka-Radio) by jp Cocatrix
529 stars 156 forks source link

encoder1 does not change the station #119

Closed dimaw closed 5 years ago

dimaw commented 5 years ago

I have configuration: esp32s + vs1053 + encoder in "1" mode (the station control and volume change when pushed and held), without display. Flashed KaraDio32 V1.9 R4. When I push and rotate volume is changed ok. But if I rotate only, stations not changes. In my config file (standard_adb.csv):

... P_ENC0_A,data,u8,255 P_ENC0_B,data,u8,255 P_ENC0_BTN,data,u8,255 P_ENC1_A,data,u8,16 P_ENC1_B,data,u8,17 P_ENC1_BTN,data,u8,5 ... O_LCD_TYPE,data,u8,255 O_LCD_ROTA,data,u8,0 O_LCD_OUT,data,u32,0 O_DDMM_FLAG,data,u8,0 ...

In logs all ok:

17:29:47.964 -> D (96492) addon: encoder value: 3 17:29:48.170 -> D (96692) addon: encoder value: 2 17:29:48.580 -> D (97092) addon: encoder value: 1 17:29:48.751 -> D (97292) addon: encoder value: 5 17:29:48.956 -> D (97492) addon: encoder value: 9 17:29:49.162 -> D (97692) addon: encoder value: 8 17:29:51.180 -> D (99692) addon: encoder value: 2 17:29:51.352 -> D (99892) addon: encoder value: 9 17:29:52.552 -> D (101092) addon: START/STOP State: 1 17:29:52.586 -> ##CLI.STOPPED# from addon stop 17:29:52.586 -> D (101092) vs1053: Decoder vs1053 stopped. 17:29:52.586 -> 17:29:52.586 -> I (101092) vs1053: watermark: 198 408 17:29:52.586 -> D (101102) renderer: Renderer volume: 800 17:29:52.963 -> D (101502) renderer: Renderer volume: 3F00 17:29:52.998 -> I (101512) webclient: watermark : 45c 1116 17:29:52.998 -> I (101522) wifi: Set ps type: 2 17:29:52.998 -> 17:29:58.850 -> D (107372) addon: encoder value: 2 17:29:59.058 -> D (107572) addon: encoder value: 4 17:30:00.254 -> D (108772) addon: encoder value: 11 17:30:00.458 -> D (108972) addon: encoder value: 11 17:30:00.630 -> D (109172) addon: encoder value: 19 17:30:00.836 -> D (109372) addon: encoder value: 24 17:30:01.041 -> D (109572) addon: encoder value: 27 17:30:01.250 -> D (109772) addon: encoder value: 30 17:30:01.454 -> D (109972) addon: encoder value: 40 17:30:02.001 -> D (110542) addon: encoder value: 36 17:30:03.032 -> D (111542) addon: encoder value: -11 17:30:03.205 -> D (111742) addon: encoder value: -13 17:30:03.411 -> D (111942) addon: encoder value: -13 17:30:03.616 -> D (112142) addon: encoder value: -11 17:30:03.823 -> D (112342) addon: encoder value: -15 17:30:09.829 -> D (118342) addon: START/STOP State: 0

nano111 commented 5 years ago

Did you use pullup resistors?

dimaw commented 5 years ago

Yes, this is standard rotary encoder KY-040, resistors built in: https://ru.aliexpress.com/item/2PCS-FREE-shipping-Rotary-Encoder-Module-Brick-Sensor-Development-for-Dropshipping-KY-040/32474584136.html

nano111 commented 5 years ago

Strange, if volume works the stations should also.No ideas,sorry.

karawin commented 5 years ago

What is the software version used? Do you have a lcd? No if i read your issue. the encoder change the station but the change is taken into account in 3 sec to let the user changes again. It is better with a lcd to show the station chosen before the start of the play. It seems that you click on the encoder after the station selection. So the palyer is stopped. Only the timeout select the chosen station.

dimaw commented 5 years ago

Can I change this timeout without recompiling? Maybe 1 sec will better for me (without display)? I try to wait 3 or more seconds after turning, nothing happens, stations not changed, look at timestamp:

07:15:20.295 -> D (95942) addon: encoder value: -10 07:15:20.467 -> D (96142) addon: encoder value: -12 07:15:20.674 -> D (96342) addon: encoder value: -11 07:15:37.238 -> I (112902) audio_player: Buffer fill 98%, 50600 // 51200 bytes 07:15:50.872 -> D (126542) addon: encoder value: 5 07:15:51.079 -> D (126742) addon: encoder value: 18 07:15:51.285 -> D (126942) addon: encoder value: 18 07:15:51.494 -> D (127142) addon: encoder value: 20 07:15:51.666 -> D (127342) addon: encoder value: 22 07:15:51.873 -> D (127542) addon: encoder value: 17 07:15:52.078 -> D (127742) addon: encoder value: -12 07:16:02.396 -> I (138072) audio_player: Buffer fill 93%, 47728 // 51200 bytes 07:16:17.067 -> D (152742) addon: START/STOP State: 1 07:16:17.101 -> ##CLI.STOPPED# from addon stop 07:16:17.101 -> D (152752) vs1053: Decoder vs1053 stopped.

karawin commented 5 years ago

Please turn the encoder one notch only and see what happen. The value must be 1 or -1

11:57.8: D (872747) addon: encoder value: 1 12:00.0: D (874997) decoder: Decoder stopped.

D (874997) decoder: MAD decoder stack: 496

12:01.0: I (875987) wifi: Set ps type: 2

CLI.NAMESET#: 26 RFM Thematique 2

CLI.URLSET#: rfm-wr14-mp3-128.scdn.arkena.com

CLI.PATHSET#: /rfm.mp3

CLI.PORTSET#: 80

CLI.OVOLSET#: 0

12:01.3: I (876277) wifi: Set ps type: 2

12:01.4: I (876287) wifi: Set ps type: 1

CLI.VOL#: 41

D (876287) renderer: Renderer volume: 800 I (876287) webserver: playstationInt: 26, g_device: 25 D (876287) eeprom: saveDeviceSettings 12:01.9: D (876707) renderer: Renderer volume: 800 12:01.9: I (876717) webclient: watermark : 3bc 956 I (876717) webclient: Webclient socket: 61, errno: 0 12:02.5: D (877327) webclient: contentType: 5 12:02.6: ##CLI.ICY0#: RFM Thematique 2 12:02.7: ##CLI.ICY3#: http:\/\/www.rfm.fr 12:02.8: ##CLI.ICY4#: Radio 12:02.9: ##CLI.ICY5#: 128 12:03.0: ##CLI.ICY6#: RFM Thematique 2 12:03.1: ##CLI.ICY7#: bitrate=128 D (877927) webclient: t1: 0x3ffc3078, cstatus: 2, icyfound: 1 metad:16000 Metaint:16000

D (877927) webclient: newlen: 844 len: 1436 chunked:0 pdata:3ffc2e2c 12:03.3: D (878127) renderer: Renderer volume: 800

CLI.PLAYING

One second or 3 or ten or anything else, without display it is unusable without the display. You cannot be sure of the station you select. Use the android application or the web interface.

dimaw commented 5 years ago

Understood thanks. In the terminal I set the type of display "0":

sys.lcd("0")

and now the encoder works in mode “1” correctly (in real the display is not connected).

Please provide in the next version the ability to change the timeout in the configuration file. This is useful for those who do not have a display.

karawin commented 5 years ago

Right. When type is 255, it doesn't work. I will modify the code to allow it to work. Thanks.