The task is this, I get the picture data via PIL - list(img.getdata()) I need to send them via SPI - I can send a maximum to list(img.getdata())[:4000] , that is 4000 bytes.

How to force or write in Python to send all the data?

Python 2.7, Raspberry Pi

  • @jfs via SPI you will not send them. Well, my chip will not be able to show them then - Insider
  • @jfs my chip takes it all if there is a header, color palette and data from the image. In JPEG, as far as I know, it is missing. - Insider
  • @jfs answer below, I should have come up already. I was told that I need. - Insider
  • @jfs I asked a question about how to share this data, I was answered. The rest as you ask is completely off topic. Question and Answer are perfect. Do not immediately minus the question! - Insider

1 answer 1

You need to break the picture into chunks of 4000 bytes, and send these chunks. You can do it like this:

 def chunks(l, n): for i in xrange(0, len(l), n): yield l[i:i+n] data = list(img.getdata()) for chunk in chunks(data, 4000): send(chunk)