예제 #1
0
    def clearPage(self, page):
        x0 = 0
        y0 = page * 8
        x1 = 127
        y1 = y0

        for x in range(0, 8):
            Graphics.clearLine(x0, y0 + x, x1, y1)
        return
예제 #2
0
 def drawHorizontalSlider(self, size, lineNumber):
     pos = ((lineNumber - 1) * 8) + 1
     if size > 100:
         size = 100
     elif size < 0:
         size = 0
     width = int(127 * size / 100)
     self.clearPage(int(pos / 8))
     for x in range(1, 6):
         self._clearLine(0, pos + x, 127, pos + x)
         Graphics.draw_line(0, pos + x, width, pos + x)
     self.drawRectangle(0, pos + 1, 127, pos + 6, False)
     self.dis.update()
예제 #3
0
    def drawImage(self,bitmap,x,y):
        img = Image.open(bitmap)

        w = img.size[0]
        h = img.size[1]
        try:
            for i in range(0, w):
                for j in range(0, h):
                    xy = (i, j)
                    if img.getpixel(xy):
                        Graphics.draw_pixel(i+x, j+y, False)
                    else:
                        Graphics.draw_pixel(i+x, j+y, True)
        except: pass
예제 #4
0
    def drawImage(self, bitmap, x, y):
        dir = os.path.dirname(__file__)
        img = Image.open(dir + '/' + bitmap)

        w = img.size[0]
        h = img.size[1]
        try:
            for i in range(0, w):
                for j in range(0, h):
                    xy = (i, j)
                    if img.getpixel(xy):
                        Graphics.draw_pixel(i + x, j + y, False)
                    else:
                        Graphics.draw_pixel(i + x, j + y, True)
        except:
            pass
예제 #5
0
 def _draw_line(self, x0, y0, x1, y1):
     dx = abs(x1 - x0)
     dy = abs(y1 - y0)
     x, y = x0, y0
     sx = -1 if x0 > x1 else 1
     sy = -1 if y0 > y1 else 1
     if dx > dy:
         err = dx / 2.0
         while x != x1:
             #self.set(x, y)
             Graphics.draw_pixel(x, y, True)
             err -= dy
             if err < 0:
                 y += sy
                 err += dx
             x += sx
     else:
         err = dy / 2.0
         while y != y1:
             #self.set(x, y)
             Graphics.draw_pixel(x, y, True)
             err -= dx
             if err < 0:
                 x += sx
                 err += dy
             y += sy
     #self.set(x, y)
     Graphics.draw_pixel(x, y, True)
예제 #6
0
    def _clearLine(self, x0, y0, x1, y1):
        dx = x1 - x0
        dy = y1 - y0
        D = 2 * dy - dx
        Graphics.draw_pixel(x0, y0, on=False)
        y = y0

        for x in range(x0 + 1, x1 + 1):
            if D > 0:
                y += 1
                Graphics.draw_pixel(x, y, on=False)
                D += (2 * dy - 2 * dx)
            else:
                Graphics.draw_pixel(x, y, on=False)
                D += 2 * dy
        return
예제 #7
0
dis.set_page_address(0, 7)

# Clear display
dis.clear()

# Set font scale x2
f = Font(2)

# Print some large text
f.print_string(6, 0, "OLIMEX LTD")

# Change font to 5x7
f.scale = 1
f.print_string(0, 24, "MOD-OLED-128x64")
f.print_string(0, 32, "olimex.com")

# Send video buffer to display
dis.update()

# Make horizontal scroll
dis.horizontal_scroll_setup(dis.LEFT_SCROLL, 3, 3, 7)
dis.activate_scroll()

# Only the last scroll setup is active
dis.horizontal_scroll_setup(dis.LEFT_SCROLL, 4, 4, 7)
dis.activate_scroll()

# Draw line
Graphics.draw_pixel(0, 0)
Graphics.draw_line(0, 60, 100, 63)
dis.update()
예제 #8
0
 def drawCircle(self, x0, y0, r, fill):
     Graphics.draw_circle(x0, y0, r)
     if fill:
         for i in range(1, r):
             Graphics.draw_circle(x0, y0, i)
예제 #9
0
 def line(self, x0, y0, x1, y1):
     Graphics.draw_line(x0, y0, x1, y1)
예제 #10
0
# Set font scale x2
f = Font(2)

# Print some large text
f.print_string(6, 0, "B.Rathbone")

sDate = strftime('%d, %b %Y %H:%M:%S')

# Change font to 5x7
f.scale = 1
f.print_string(0, 24, sDate)
f.print_string(0, 32, " www.bobrathbone.com")
f.print_string(0, 44, "abcdefghijklmnopqrstu")

# Send video buffer to display
dis.update()

# Make horizontal scroll
dis.horizontal_scroll_setup(dis.LEFT_SCROLL, 3, 3, 7)
dis.activate_scroll()

# Only the last scroll setup is active
dis.horizontal_scroll_setup(dis.LEFT_SCROLL, 4, 4, 6)
dis.activate_scroll()

# Draw line
Graphics.draw_pixel(0, 0)
Graphics.draw_line(0, 60, 125, 60)
dis.update()
예제 #11
0
# Do additional configuration
dis.set_memory_addressing_mode(0)
dis.set_column_address(0, 127)
dis.set_page_address(0, 7)

# Clear display
dis.clear()


files = ["CLOWN1.BMP", "CLOWN2.BMP", "CLOWN3.BMP", "CLOWN4.BMP", "CLOWN5.BMP", "CLOWN6.BMP", "CLOWN7.BMP", "CLOWN8.BMP"]
while True:

    for file in files:
        img = Image.open("clowns/" + file)

        w = img.size[0]
        h = img.size[1]

        for i in range(0, w):
            for j in range(0, h):
                xy = (i, j)
                if img.getpixel(xy):
                    Graphics.draw_pixel(i, j, False)
                else:
                    Graphics.draw_pixel(i, j, True)


        dis.update()

예제 #12
0
# Do additional configuration
dis.set_memory_addressing_mode(0)
dis.set_column_address(0, 127)
dis.set_page_address(0, 7)

# Clear display
dis.clear()

files = [
    "CLOWN1.BMP", "CLOWN2.BMP", "CLOWN3.BMP", "CLOWN4.BMP", "CLOWN5.BMP",
    "CLOWN6.BMP", "CLOWN7.BMP", "CLOWN8.BMP"
]
while True:

    for file in files:
        img = Image.open("clowns/" + file)

        w = img.size[0]
        h = img.size[1]

        for i in range(0, w):
            for j in range(0, h):
                xy = (i, j)
                if img.getpixel(xy):
                    Graphics.draw_pixel(i, j, False)
                else:
                    Graphics.draw_pixel(i, j, True)

        dis.update()