awawa-dev / HyperHDR

Highly optimized open source ambient lighting implementation based on modern digital video and audio stream analysis for Windows, macOS and Linux (x86 and Raspberry Pi / ARM).
http://www.hyperhdr.eu/
MIT License
1.07k stars 111 forks source link

First two leds remain on after closing HyperHDR #601

Closed ruredi87 closed 8 months ago

ruredi87 commented 1 year ago

Bug report, debug log and your config file (FULL LOGS ARE MANDATORY)

log.txt System report.txt HyperHDR-20.0.0.0beta0-Backup-2023-07-18.zip

Steps to reproduce

What is expected?

---I expect all leds to turn off when i terminate hyperhdr process.

What is actually happening?

---First 2 leds remain on after I turn off hyperhdr precess.

HyperinNg does not has this issue. This link has video for you to understand issue better. In this video I am launching hyperion and closing after a few seconds. You can see all leds turning off but in hyperhdr first 2 leds powering on itself even i terminate hyperhdr.

https://photos.app.goo.gl/LJon35MXNhBE6KcbA

Normally I was using version v19 I just downloaded the beta to test this issue.

Also thank you for your work sir.

System

awawa-dev commented 1 year ago

Hi Please change the LED device to debug: it writes colors to the file so it can be confirmed if the problem exists.

awawa-dev commented 1 year ago

I tested it few times using your configuration and it's always zeroes on exit:

 [{58,255,0}{55,255,0}{53,255,0}{48,255,0}{44,255,0}{40,255,0}{38,255,0}{35,255,0}{32,255,1}{29,255,1}{26,255,2}{23,255,2}{19,255,3}{16,255,4}{13,255,5}{11,255,5}{9,255,6}{7,255,7}{6,255,7}{5,255,8}{4,255,9}{3,255,10}{1,255,12}{0,255,14}{0,255,16}{0,255,19}{0,255,23}{0,255,28}{0,255,34}{0,255,42}{0,255,56}{0,255,72}{0,255,85}{0,255,99}{0,255,113}{0,255,128}{0,255,141}{0,255,154}{0,255,164}{0,253,175}{0,251,183}{0,250,189}{0,249,194}{0,247,199}{0,246,204}{0,246,209}{0,245,214}{0,243,218}{0,240,224}{0,236,229}{0,234,232}{0,231,235}{0,228,238}{0,224,241}{0,220,243}{0,217,245}{0,213,247}{0,204,249}{0,197,251}{0,191,252}{0,186,252}{0,179,253}{0,171,253}{0,165,254}{0,159,254}{0,152,255}{0,142,255}{0,133,255}{0,129,255}{0,122,255}{0,117,255}{0,140,255}{0,131,255}{0,120,255}{0,106,255}{0,94,255}{0,85,255}{0,78,255}{0,70,255}{0,61,255}{1,51,255}{2,42,255}{3,36,255}{3,31,255}{4,26,255}{5,22,255}{5,19,255}{6,13,255}{8,9,255}{8,7,255}{9,5,255}{10,4,255}{10,3,255}{12,2,255}{15,1,255}{16,0,255}{19,0,255}{22,0,255}{23,0,255}{28,0,255}{33,0,255}{40,0,254}{43,0,253}{50,0,252}{54,0,252}{59,0,251}{67,0,250}{76,0,249}{83,0,248}{90,0,248}{74,0,249}{77,0,249}{81,0,249}{85,0,248}{88,0,248}{93,0,248}{99,0,247}{105,0,247}{111,0,246}{116,0,246}{122,0,246}{129,0,245}{135,0,245}{143,0,243}{150,0,243}{160,0,241}{167,0,241}{176,0,239}{190,0,236}{205,0,232}{217,0,228}{226,0,225}{236,0,220}{244,0,213}{250,0,205}{254,0,196}{255,0,185}{255,0,174}{255,0,162}{255,0,150}{255,1,132}{255,3,114}{255,5,102}{255,6,91}{255,8,81}{255,9,68}{255,10,59}{255,12,48}{255,15,36}{255,19,25}{255,23,11}{255,30,0}{255,37,0}{255,53,0}{255,70,0}{255,83,0}{255,97,0}{255,111,0}{255,125,0}{255,139,0}{255,153,0}{255,165,0}{255,177,0}{255,187,0}{255,195,0}{255,204,0}{255,210,0}{255,213,0}{255,215,0}{255,215,0}{255,217,0}{255,217,0}{255,219,0}{255,219,0}{254,221,0}{254,221,0}{254,222,0}{253,223,0}{253,225,0}{252,225,0}{252,225,0}{252,227,0}{251,227,0}{251,227,0}{252,225,0}{252,225,0}{251,227,0}{250,229,0}{249,231,0}{248,231,0}{248,233,0}{247,235,0}{247,235,0}{246,237,0}{245,239,0}{243,241,0}{243,242,0}{241,243,0}{239,245,0}{237,246,0}{234,247,0}{230,248,0}{226,249,0}{223,250,0}{218,251,0}{213,251,0}{202,252,0}{191,254,0}{181,254,0}{171,255,0}{159,255,0}{148,255,0}{137,255,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0,0}{0,0,0}{0,0,0}{0,0,0}{0,0,0}{0,0,0}{0,0,0}{0,0,0}{0,0,0}{0,0,0}{0,0,0}{0,0,0}{0,0,0}{0,0,0}{0,0,0}{0,0,0}{0,0,0}{0,0,0}{0,0,0}]

I will test tomorrow using logic analyzer on esp8266 to see if it changes something.

awawa-dev commented 1 year ago

Which firmware for esp8266 do you use in both cases?

awawa-dev commented 1 year ago

One more thing: please disable esp8266 handshake to check if it solves it. Hyperion doesnt use it.

ruredi87 commented 1 year ago

One more thing: please disable esp8266 handshake to check if it solves it. Hyperion doesnt use it.

Thank you sir , disabling handshake solved it. I could not think of it

Also It was doing this behavior with both wled and hyperserial. currently I am using it with hyperserial with 1000000 baud.

awawa-dev commented 1 year ago

I suspect your esp8266 board may have reset after HyperHDR shut down when QT was restoring the state of the serial port (DTR/RTS) that was changed by the esp8266 handshake and hence those randomly lit LEDs. Unfortunately, in QT6.2 (which is used by the Windows port) we have no influence on this mechanism, but it's still not typical esp8266 behavior and so far I haven't encountered anything like that. I will verify it on my esp boards.

ruredi87 commented 1 year ago

Sir I was saying myself wish I did not closed issue, thankfully you opened again. I forgot to say I have this behavior when I first boot my pc. Esp powering via usb which connected to my pc as you figure. For example; I am watching movie generally before I go to bed. When I boot my pc at mornings first to leds are powering on. Sometimes I see in the mornings 2 leds are open by itself. I did not connect anything between d2 pin and led data,. I dont know ,s this can cause issue or not but Maybe you can implement anything about it. I just wanted to inform you. Thanks again.

awawa-dev commented 1 year ago

It turned out to be a very interesting case though :) But from what I see it's only related to 'esp handshake'. I tested your configuration under a logic analyzer and it's what I suspected: while QT is restoring the DTR/RST serial port state, the esp8266 performs a spontaneous and abrupt reset generating noise for a short period of time that can be misinterpreted by the LEDs. Not exactly a HyperHDR bug, but I think I can implement a workaround since the 'esp hadshake' option is generally recommended and should not be disabled.

@ruredi87 could you test a Windows setup from these artifacts? https://github.com/awawa-dev/HyperHDR/actions/runs/5592286408 WITH ENABLED THE 'ESP HANDSHAKE'

If it doesn't work please attach new logs, because I'm out of ideas and since most other boards are using rather problematic-free modern CDC I wont replace working solution just for rather old esp8266... unfortunately QT dropped very important feature for proper serial port handling in newer versions and I'm not sure about the workaround.

obraz

ruredi87 commented 1 year ago

Thank you for your response

I tested it enabled handshake with your new artifact but problem still persist. Your "the esp8266 performs a spontaneous and abrupt reset generating noise for a short period of time that can be misinterpreted by the LED" probably true becaue I noticed the leds are which remains on after shutdown are flashing when I start hyperhdr. It is not a big deal for me I can do start-stop hyperion when 2 leds powered at first boot. But I am thinking while I am using wled, esp8266 was writing off to all leds. You know wled has an option like "enable leds after reboot". Maybe hyperserial can do it also while it booting.

Also here are logs file. I am copying logs before I close hyperhdr. If there is better way to pull logs you can tell me but I could not find. LOG.txt

awawa-dev commented 1 year ago

Can you turn on the LED driver and then turn it off (I miss closing the COM part in the logs)? Also before proceeding with testing please disconnect and reconnect the ESP to the computer.

But I am thinking while I am using wled, esp8266 was writing off to all leds. You know wled has an option like "enable leds after reboot". Maybe hyperserial can do it also while it booting.

Well, that would probably solve the problem. But WLED stores the geometry of the LEDs, HyperSerialEsp8266 starts empty and gets the geometry (LEDs number) from the PC/Adalight later. We need to know for how many LEDs we need to prepare and send a frame and esp8266 is rather limited in memory. But I can think of a new feature for esp8266, a new option in configuration that user can enable for custom firmware to power off all LEDs while booting.

ruredi87 commented 1 year ago

Log-unplug-plug whileconnected.txt

Sorry I could not understand you clearly. I unplugged and plugged it back while hyperhdr is running but it did not recover it slef I had to restart hyperhdr.

Is esp not the driver?. If I close the hyperhdr first I cant take the log.

awawa-dev commented 1 year ago

Disconnect and reconnect esp before starting HyperHDR to clear serial port state to defaults in the system. Then start HyperHDR, check if esp is working fine then stop the LED driver in the HyperHDR remote tab and take the logs. BTW latest uploaded logs are empty.

ruredi87 commented 1 year ago

Got it, here is log file log.txt

By the way issue did not happen when I did close led device then close hyperhdr. It is happening when I directly terminate hyperhdr process.

awawa-dev commented 1 year ago

Did you close HyperHDR from the context menu? Killing the process from taks manager probably doesn't allow for properly closing the port and restoring its old state. Then you must disconnect esp and reconnect esp again to restore the port to the defaults.

Run HyperHDR from the command line to have persistent logs: hyperhdr.exe -c And look for the line simililar to this one: 2023-07-19T13:26:48.587Z [LEDDEVICE_ADALIGHT] (ProviderRs232.cpp:132) Close UART: COM3 (restore DTR) Restoring DTR should prevent abrupt esp restart. And this latest logs looks OK.

ruredi87 commented 1 year ago

I took this log file from cmd window. log (2).txt

I am closing hyperhdr on taskbar from right bottom. I right click it then select close. You can see from this video at 0:28 same thing happening when I first launch hyperhdr if handshake is enabled. While with disabled handshake there is no problem nor I open or close hyperhdr. In this log handshake is enabled.

https://photos.app.goo.gl/LJon35MXNhBE6KcbA

Maybe I have issue because of my hardware or cabling. As I see there is no problem with others. So I dont want to take your time because of my hardware or connectivity issues.

I dont hyperhdr or hyperserial is causing the issue.As I said before sometimes I see 2 leds are on when I woke up in the mornings (this was happening also when I was using wled). So There can be problem on my computer port or something.

awawa-dev commented 1 year ago

Not using handshake is completely direct case scenario without esp reset. Do you have the issue when you see in logs 'restoring dtr' when closing? Noice that your esp8266 generating while booting in your setup is enough to cause your LED reaction: for diffent esp8266 model or LEDs may behave diffently. Do you use the level shifter?

ruredi87 commented 1 year ago

Do you use the level shifter? I dont use it.

I injected power from 1 point, rest of the leds are directly connected. I tried to sketch schematic quickly in fusion360.

Ekran Görüntüsü (3)

awawa-dev commented 1 year ago

Not sure if the missing level shifter is related or not. Best to avoid esp reset for your setup.

ruredi87 commented 1 year ago

Not sure if the missing level shifter is related or not. Best to avoid esp reset for your setup.

Yep you are right. Thank you for your time and your project.

awawa-dev commented 1 year ago

@ruredi87 could you test these attached firmwares? I added new option to clear first 16 LEDs at the start-up (can be configured for more). Compiled for 1Mb speed.

1Mb_clear_leds_esp8266.zip

ruredi87 commented 1 year ago

Sir I am grateful, thank you so much. Clearly I have another issue but with your firmware It is some kind of workaround. It is working as you expected. All lights goes off when I close hyperhdr, flashing is still there but your new firmware closes them. Also ıt does the job when I first booted esp. I am sharing another video so you can see. At the end of the video I unplugged and plugged back esp to my computer, these flashes are because of it but at the end all lights become off.

https://photos.app.goo.gl/p56WcxybcHC52p5eA

Also may you recompile for 224leds or if I can do may you give the source files. Thank you for your time.

awawa-dev commented 1 year ago

Great! The PR is already merged in the HyperSerialEsp8266 project (https://github.com/awawa-dev/HyperSerialEsp8266/pull/31) If 16 LEDs is working for you, you dont need to increase them. If you want a small and inexpensive upgrade in the future, I recommend the Raspberry Pi Pico or rp2040-zero instead of the esp8266.

ruredi87 commented 1 year ago

Great! The PR is already merged in the HyperSerialEsp8266 project (awawa-dev/HyperSerialEsp8266#31) If 16 LEDs is working for you, you dont need to increase them. If you want a small and inexpensive upgrade in the future, I recommend the Raspberry Pi Pico or rp2040-zero instead of the esp8266.

Thank you so much again.

awawa-dev commented 1 year ago

I tested HyperHDR on Windows QT 5.15 and compared it to Linux QT 5.15: It seems that resetting the esp on exit (when esp handshake is enabled) only happens on Windows, so there is an inconsistency in the QT serial port implementation across platforms, and that's probably why you're the first user to report it, since most use Linux.

ruredi87 commented 1 year ago

So You could reproduce issue on windows right. It is not only me

awawa-dev commented 1 year ago

Yes, but I'm not using esp8266 because it's a legacy solution. Just a general test if the LEDs are rendered after the release of the new version of HyperSerialEsp8266. Due to limited resources (and based on the assumption that QT works the same on any operating system) it is usually limited to Linux as the most popular distribution. Anyway, you can test this new version of Windows: it enforces avoiding unnecessary resets on exit, still the "esp handshake" will do a reset before the LED device is enabled in HyperHDR (this is done on purpose by design). https://github.com/awawa-dev/HyperHDR/actions/runs/5613885420 Overall it's your esp8266 is waking up your LEDs by itself, without any code, during booting up. If it was esp32 or rp2040 we could try another pin as the LED output, but esp8266 lacks even such basic feature as GPIO muxer and GPIO2 cannot be changed.