veebch / btcticker

ePaper Cryptocurrency Ticker
GNU General Public License v3.0
309 stars 70 forks source link

Service running, no display #123

Closed JBP3D closed 8 months ago

JBP3D commented 10 months ago

Followed the steps, everything is running and had no errors but the display does not show anything

veebch commented 10 months ago

There are some waveshare test codes in their repository. Can you display to the screen when you run them?

EDIT: You might have V2 of the screen, if so see line 40 of the code. You need to comment out a line and then uncomment the one above

JBP3D commented 10 months ago

There are some waveshare test codes in their repository. Can you display to the screen when you run them?

EDIT: You might have V2 of the screen, if so see line 40 of the code. You need to comment out a line and then uncomment the one above

Thank you for the quick reply! My screen indeed has a sticker V2 on it so I'll try that and will update.

JBP3D commented 10 months ago

There are some waveshare test codes in their repository. Can you display to the screen when you run them?

EDIT: You might have V2 of the screen, if so see line 40 of the code. You need to comment out a line and then uncomment the one above

Schermafbeelding 2023-12-08 220929

I did this but it's still not showing. Did I do it right?

veebch commented 10 months ago

That looks good. What does output does the code give to the terminal when you run it?

JBP3D commented 10 months ago

Hey sorry for the late response, had a few busy days.

I'm not sure what you mean with the output? I just used the commands to start the service and rebooted. using status shows btcticker is active running

Schermafbeelding 2023-12-10 115600

veebch commented 10 months ago

You can stop that service and then try running it interactively from the command line using the command python3 btcticker.py --log DEBUG

The first thing I would do is try to get some waveshare test code running on it. That will help you narrow down the problem...

E-IG88 commented 8 months ago

I'm having the same issue. Was this ever resolved and if so, how? I'm running a Raspberry Pi 4B with a V2 screen. After running "python btcticker.py --log DEBUG", I get the following traceback errors.

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/gpiozero/pins/pi.py", line 408, in pin pin = self.pins[info]


KeyError: PinInfo(number=11, name='GPIO17', names=frozenset({'BCM17', 'J8:11', 17, '17', 'WPI0', 'GPIO17', 'BOARD11'}), pull='', row=6, col=1, interfaces=frozenset({'', 'spi', 'uart', 'dpi', 'gpio'}))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/btcticker/btcticker.py", line 40, in <module>
    from waveshare_epd import epd2in7_V2 as epd2in7 #(comment out line above and uncomment this line if you're using v2)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/btcticker/waveshare_epd/epd2in7_V2.py", line 31, in <module>
    from . import epdconfig
  File "/home/pi/btcticker/waveshare_epd/epdconfig.py", line 276, in <module>
    implementation = RaspberryPi()
                     ^^^^^^^^^^^^^
  File "/home/pi/btcticker/waveshare_epd/epdconfig.py", line 52, in __init__
    self.GPIO_RST_PIN    = gpiozero.LED(self.RST_PIN)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 103, in __call__
    self = super().__call__(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/gpiozero/output_devices.py", line 192, in __init__
    super().__init__(pin, active_high=active_high,
  File "/usr/lib/python3/dist-packages/gpiozero/output_devices.py", line 74, in __init__
    super().__init__(pin, pin_factory=pin_factory)
  File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 75, in __init__
    super().__init__(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 549, in __init__
    pin = self.pin_factory.pin(pin)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/gpiozero/pins/pi.py", line 410, in pin
    pin = self.pin_class(self, info)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/gpiozero/pins/lgpio.py", line 126, in __init__
    lgpio.gpio_claim_input(
  File "/usr/lib/python3/dist-packages/lgpio.py", line 755, in gpio_claim_input
    return _u2i(_lgpio._gpio_claim_input(handle&0xffff, lFlags, gpio))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/lgpio.py", line 458, in _u2i
    raise error(error_text(v))
lgpio.error: 'GPIO busy'
veebch commented 8 months ago

There are a couple of lines in the code that need to be uncommented. Have a look in main.py

E-IG88 commented 8 months ago

@veebch When you reference main.py, I'm assuming your talking about btcticker.py. I have already uncommented line 40 and commented out the one above it as shown below. I also searched the rest of the btcticker.py file for anything with the keyword "v2" and the only other section that has something starts at line 431 but I'm not sure what to do, if anything.

line 39: #from waveshare_epd import epd2in7 line 40: from waveshare_epd import epd2in7_V2 as epd2in7

# Also change to V2 if using a V2 screen
epd.Init_4Gray()
epd.display_4Gray(epd.getbuffer_4Gray(img))
epd.sleep()
thekeys = initkeys()
# Have to remove and add key events to make them work again
removekeyevent(thekeys)
addkeyevent(thekeys)
logging.info("Sent image to screen")
return
veebch commented 8 months ago

You're right.... btcticker.py

You shouldn't need to change the 431 bit. Can you get the waveshare demos to work?

The error looks like something in the gpiozero library. Maybe looking at whether using that library on a pi4 needs some tweaks.

E-IG88 commented 8 months ago

I've downloaded demos from Waveshare and can successfully display a "Hello World" demo to the screen so I know the e-ink display is working properly.

veebch commented 8 months ago

Then it looks like gpiozero is doing it:

EDIT https://github.com/gpiozero/gpiozero/issues/1101

E-IG88 commented 8 months ago

@veebch This was it. I was running the script at the same time, or not closing Geany before running the code in the terminal. lgpio reserves that pin and won't let another process use it until it's been closed. I'm getting a lot closer now but still no display on the screen although it looks like it's trying to write to the screen. This is my latest output in terminal when running python3 btcticker.py --log DEBUG

username@raspberrypi2:~/btcticker $ python3 btcticker.py --log DEBUG Traceback (most recent call last): File "/home/username/.local/bin/tzupdate", line 5, in from tzupdate import main ModuleNotFoundError: No module named 'tzupdate' INFO:root:epd2in7 BTC Frame INFO:root:{'display': {'cycle': True, 'inverted': False, 'orientation': 180, 'trendingmode': False}, 'ticker': {'currency': 'bitcoin,ripple,ethereum', 'exchange': 'default', 'fiatcurrency': 'gbp,usd,btc', 'sparklinedays': 7, 'updatefrequency': 300}} DEBUG:root:Setup GPIO keys DEBUG:root:Add key events INFO:root:Getting Data DEBUG:root:https://api.coingecko.com/api/v3/coins/bitcoin/market_chart/range?vs_currency=gbp&from=1706620854&to=1707225654 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.coingecko.com:443 DEBUG:urllib3.connectionpool:https://api.coingecko.com:443 "GET /api/v3/coins/bitcoin/market_chart/range?vs_currency=gbp&from=1706620854&to=1707225654 HTTP/1.1" 429 187 DEBUG:root:Got price for the last 7 days from CoinGecko DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy release DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy release DEBUG:waveshare_epd.epd2in7_V2:Horizontal ERROR:root:list index out of range DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy release DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy release DEBUG:waveshare_epd.epd2in7_V2:Horizontal Traceback (most recent call last): File "/home/username/btcticker/btcticker.py", line 545, in fullupdate pricestack, ATH = getData(config, other) ^^^^^^^^^^^^^^^^^^^^^^ File "/home/username/btcticker/btcticker.py", line 160, in getData timeseriesarray = rawtimeseries['prices']


KeyError: 'prices'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/username/btcticker/btcticker.py", line 641, in main
    lastcoinfetch = fullupdate(config, lastcoinfetch)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/btcticker/btcticker.py", line 557, in fullupdate
    display_image(image)
  File "/home/username/btcticker/btcticker.py", line 435, in display_image
    epd.display_4Gray(epd.getbuffer_4Gray(img))
  File "/home/username/btcticker/waveshare_epd/epd2in7_V2.py", line 450, in display_4Gray
    temp1 = image[i*2+j]
            ~~~~~^^^^^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/username/btcticker/btcticker.py", line 663, in <module>
    main()
  File "/home/username/btcticker/btcticker.py", line 652, in main
    display_image(image)
  File "/home/username/btcticker/btcticker.py", line 435, in display_image
    epd.display_4Gray(epd.getbuffer_4Gray(img))
  File "/home/username/btcticker/waveshare_epd/epd2in7_V2.py", line 450, in display_4Gray
    temp1 = image[i*2+j]
            ~~~~~^^^^^^^
IndexError: list index out of range
veebch commented 8 months ago

Progress!

The Error reporting from the code needs to be better here, it's showing that the return code of the url call is 429, which means coingecko are refusing to return data, due to too many calls. Go for a cup of tea, and that error should be gone when you come back.

E-IG88 commented 8 months ago

Great, thanks! I will try it again later. Just out of curiosity, is it normal for all the other errors to occur if coingecko API refuses the connection, in particular "IndexError: list index out of range" ?

veebch commented 8 months ago

Since the code was written, coingecko seem to be a lot more frequently throttling connections. That said, the code should spot the error code and stop gracefully, rather than try to run without data. I'll make that tweak next chance I get.

E-IG88 commented 8 months ago

Unfortunately, I don't think this works even if you wait. Have you tried lately? I've manually tried to hit coingecko's API (api.coingecko.com/api/v3/ping) and wait until I get {"gecko_says":"(V3) To the Moon!"} and then try to run the script and I still get the 429 return code. Is there a way to limit the # of calls btcticker makes to coingecko? Perhaps in config.yaml or elsewhere?

veebch commented 8 months ago

The cup of tea rule has served me well in the past. I imagine you're hitting the url via your computer, which hasn't been throttled. If you get no error when accessing it via curl from the pi, that might be an issue

E-IG88 commented 8 months ago

@veebch I finally got Coingecko to return an HTTP 200 OK. Still no display but I'm really close. Based from what I see near the bottom of my latest traceback, it's still complaining about something related to the V2 screen. Does any of this make sense to you? Really appreciate all the help you've provided!

DEBUG:PIL.PngImagePlugin:STREAM b'IHDR' 16 13 DEBUG:PIL.PngImagePlugin:STREAM b'tEXt' 41 57 DEBUG:PIL.PngImagePlugin:STREAM b'pHYs' 110 9 DEBUG:PIL.PngImagePlugin:STREAM b'IDAT' 131 3077 DEBUG:root:Getting token Image from Image directory DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy release DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy release DEBUG:waveshare_epd.epd2in7_V2:Vertical DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy release DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy release DEBUG:waveshare_epd.epd2in7_V2:Horizontal ERROR:root:list index out of range DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy release DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy DEBUG:waveshare_epd.epd2in7_V2:e-Paper busy release DEBUG:waveshare_epd.epd2in7_V2:Horizontal Traceback (most recent call last): File "/home/user/btcticker/btcticker.py", line 550, in fullupdate display_image(image) File "/home/user/btcticker/btcticker.py", line 435, in display_image epd.display_4Gray(epd.getbuffer_4Gray(img)) File "/home/user/btcticker/waveshare_epd/epd2in7_V2.py", line 450, in display_4Gray temp1 = image[i*2+j]


IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/user/btcticker/btcticker.py", line 641, in main
lastcoinfetch = fullupdate(config, lastcoinfetch)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/btcticker/btcticker.py", line 557, in fullupdate
display_image(image)
File "/home/user/btcticker/btcticker.py", line 435, in display_image
epd.display_4Gray(epd.getbuffer_4Gray(img))
File "/home/user/btcticker/waveshare_epd/epd2in7_V2.py", line 450, in display_4Gray
temp1 = image[i*2+j]
~~~~~^^^^^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/user/btcticker/btcticker.py", line 663, in
main()
File "/home/user/btcticker/btcticker.py", line 652, in main
display_image(image)
File "/home/user/btcticker/btcticker.py", line 435, in display_image
epd.display_4Gray(epd.getbuffer_4Gray(img))
File "/home/user/btcticker/waveshare_epd/epd2in7_V2.py", line 450, in display_4Gray
temp1 = image[i*2+j]
~~~~~^^^^^^^
IndexError: list index out of range
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
veebch commented 8 months ago

It's something in the waveshare code by the looks of it

E-IG88 commented 8 months ago

I was thinking the same thing. I'm curious if you've confirmed with anyone that a V2 screen has successfully been able to get this project working since it looks like the code was originally designed for V1 and then after, they tried to port over the waveshare code to make it work for V2 which seems super buggy. I also am finding it difficult to find a V1 screen anymore, as it seems everything is Rev2.2. If you know of any online marketplace that sells the older version, please keep me posted.

E-IG88 commented 8 months ago

@veebch I got to the root of the issue. This was indeed an issue with the Waveshare code.

In e-Paper\RaspberryPi_JetsonNano\python\lib\waveshare_epd\epd2in7_V2.py, change line 447 and 48000 in line 479 to 5808. The problem is thought to have been accidentally corrected by an engineer when adding a new screen. We will fix it in the next app update

https://github.com/waveshareteam/e-Paper/issues/322

veebch commented 8 months ago

Excellent! Closing this issue as it seems to be a waveshare bug

EDIT: For clarity, the 48000 that appears in line 447 and 479 needs to be changed to 5808 on both lines in waveshare_epd\epd2in7_V2.py