Hi,

We want to make some model TV Sets for the windows of the Radio Shops in 
Wimborne Model Town and have obtained a 1.5 inch OLED Display.  This is a 
general OLED display module, 1.5inch diagonal, 128*128 pixels, 16-bit grey 
level, with embedded controller, communicating via SPI or I2C interface.

Using the supplied example code it works quite well, but when I try to display 
an image that I've produced I'm getting the following error:

Traceback (most recent call last):
  File "display_tv_screensv02.py", line 87, in <module>
    main()
  File "display_tv_screensv02.py", line 80, in main
    display_image()
  File "display_tv_screensv02.py", line 63, in display_image
    OLED.OLED_ShowImage(image,0,0)
  File "/home/pi/TV_SW/OLED_Driver.py", line 294, in OLED_ShowImage
    Pixels_Color = ((Pixels[2*i, j]&0x0f)<<4) | ((Pixels[2*i+1, j]&0x0f))
IndexError: image index out of range

The supplied image has the following properties (as provided by The Gimp:

Size in Pixels: 128 x 128
Print size:  45.2 × 45.2 millimeters
Resolution:  71.9836 × 71.9836 ppi
Color space:  Indexed color (16 colors)
Precision:  8-bit gamma integer
File Type:  Windows BMP image
Number of pixels:  16384

My image has these properties (I've tweaked it in The Gimp to get as close a 
match as possible:

Size in Pixels: 128 x 95
Print size:  45.2 x 33.5 millimeters
Resolution:  71.9328 × 72.0299 ppi
Color space:  Grayscale
Precision:  8-bit gamma integer
File Type:  Windows BMP image
Number of pixels:  12160

Could the problem be something to do with the aspect ratio?  Will my image 
always have to be square?

Any ideas would be welcomed.

Here is the corresponding code from the supplied Python Module (line 294 is 
the one containing:

Line 294 is the one containing:  Pixels_Color = ((Pixels[2*i, j]&0x0f)<<4) | 
((Pixels[2*i+1, j]&0x0f))

def OLED_ShowImage(self, Image, Xstart, Ystart):
        if (Image == None):
            return
        #self.OLED_Clear(0x00)
        self.OLED_SetWindows ( Xstart, Ystart, self.OLED_Dis_Column , 
self.OLED_Dis_Page)
        Pixels = Image.load()
        for j in range(0, self.OLED_Dis_Page):
            for i in range(0, int(self.OLED_Dis_Column/2)):
                #print '0 = ',Pixels[2 * i, j] & 0x0f
                #print '1 = ',Pixels[2 * i + 1, j]
                Pixels_Color = ((Pixels[2*i, j]&0x0f)<<4) | ((Pixels[2*i+1, 
j]&0x0f))
                #print 'Pixels_Color',Pixels_Color
                self.OLED_WriteData(Pixels_Color)
                '''         
                Pixels_Color1 = (Pixels[2 * i, j][0]  + Pixels[2 * i, j][1]  + 
Pixels[2 * i, j][2])/3#RGB Data
                Pixels_Color2 = (Pixels[2 * i + 1, j][0]  + Pixels[2 * i + 1, 
j][1]  + Pixels[2 * i + 1, j][2] )/3#RGB Data
                Pixels_Color8b24b1 = Pixels_Color1 * 15 /255
                Pixels_Color8b24b2 = Pixels_Color2 * 15 /255 
                Pixels_Color = Pixels_Color8b24b1 | (Pixels_Color8b24b2 << 4)
                print 'Pixels_Color[1, j]',Pixels_Color
                self.OLED_WriteData(Pixels_Color)
                #self.OLED_SetColor(Pixels_Color , 1, 1)
                '''
-- 



                Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2020-08-04 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk

Reply via email to