diff --git a/gfxlcd/__init__.py b/gfxlcd/__init__.py index 7c2d50b..3b83c1b 100644 --- a/gfxlcd/__init__.py +++ b/gfxlcd/__init__.py @@ -1 +1,2 @@ -__author__ = 'kosci' +"""GfxLCD module""" +__author__ = 'Bartosz Kosciow' diff --git a/gfxlcd/abstract/__init__.py b/gfxlcd/abstract/__init__.py index 7c2d50b..3dd8799 100644 --- a/gfxlcd/abstract/__init__.py +++ b/gfxlcd/abstract/__init__.py @@ -1 +1,2 @@ -__author__ = 'kosci' +"""abstracts/interfaces""" +__author__ = 'Bartosz Kosciow' \ No newline at end of file diff --git a/gfxlcd/demos/ili_2.py b/gfxlcd/demos/ili_2.py index 6bc7fd1..4d8d91d 100644 --- a/gfxlcd/demos/ili_2.py +++ b/gfxlcd/demos/ili_2.py @@ -1,9 +1,9 @@ import RPi.GPIO import sys +import random sys.path.append("../../") from gfxlcd.driver.ili9325.gpio import GPIO as ILIGPIO from gfxlcd.driver.ili9325.ili9325 import ILI9325 -import random RPi.GPIO.setmode(RPi.GPIO.BCM) diff --git a/gfxlcd/demos/nju_2.py b/gfxlcd/demos/nju_2.py index 52483c0..7b593ac 100644 --- a/gfxlcd/demos/nju_2.py +++ b/gfxlcd/demos/nju_2.py @@ -1,9 +1,9 @@ import RPi.GPIO import sys +import random sys.path.append("../../") from gfxlcd.driver.nju6450.gpio import GPIO from gfxlcd.driver.nju6450.nju6450 import NJU6450 -import random RPi.GPIO.setmode(RPi.GPIO.BCM) diff --git a/gfxlcd/demos/ssd_2.py b/gfxlcd/demos/ssd_2.py index e01ca28..cc7d4b9 100644 --- a/gfxlcd/demos/ssd_2.py +++ b/gfxlcd/demos/ssd_2.py @@ -1,10 +1,10 @@ import RPi.GPIO import sys -RPi.GPIO.setmode(RPi.GPIO.BCM) +import random sys.path.append("../../") from gfxlcd.driver.ssd1306.spi import SPI from gfxlcd.driver.ssd1306.ssd1306 import SSD1306 -import random +RPi.GPIO.setmode(RPi.GPIO.BCM) def hole(o, x, y): @@ -24,7 +24,10 @@ def hole(o, x, y): def draw_points(o): for _ in range(0, 50): - hole(o, random.randint(2, o.width- 10), random.randint(2, o.height-10)) + hole(o, + random.randint(2, o.width - 10), + random.randint(2, o.height - 10) + ) def draw_net(o): diff --git a/gfxlcd/drawing/__init__.py b/gfxlcd/drawing/__init__.py index 7c2d50b..d25812e 100644 --- a/gfxlcd/drawing/__init__.py +++ b/gfxlcd/drawing/__init__.py @@ -1 +1,2 @@ -__author__ = 'kosci' +"""drawing module""" +__author__ = 'Bartosz Kosciow' \ No newline at end of file diff --git a/gfxlcd/drawing/page.py b/gfxlcd/drawing/page.py index 3ed8c57..6e6ca58 100644 --- a/gfxlcd/drawing/page.py +++ b/gfxlcd/drawing/page.py @@ -101,8 +101,8 @@ class Page(Pixel, metaclass=abc.ABCMeta): page = start_page for value in rows: - for x in range(pos_x2-pos_x1+1): - self.buffer[pos_x1+x][page] |= value + for x_diff in range(pos_x2-pos_x1+1): + self.buffer[pos_x1+x_diff][page] |= value page += 1 def get_page_value(self, column, page): diff --git a/gfxlcd/drawing/pixel.py b/gfxlcd/drawing/pixel.py index f07383e..c2c22ac 100644 --- a/gfxlcd/drawing/pixel.py +++ b/gfxlcd/drawing/pixel.py @@ -5,6 +5,7 @@ import math class Pixel(object): """Pixel class""" def __init__(self, driver): + self.driver = driver self.options['color'] = { 'R': 255, 'G': 255, 'B': 255 } @@ -20,27 +21,27 @@ class Pixel(object): """dummy fuction""" pass - def draw_rect(self, x1, y1, x2, y2): + def draw_rect(self, pos_x1, pos_y1, pos_x2, pos_y2): """draw a rectangle""" - self.draw_line(x1, y1, x2, y1) - self.draw_line(x1, y2, x2, y2) - self.draw_line(x1, y1, x1, y2) - self.draw_line(x2, y1, x2, y2) + self.draw_line(pos_x1, pos_y1, pos_x2, pos_y1) + self.draw_line(pos_x1, pos_y2, pos_x2, pos_y2) + self.draw_line(pos_x1, pos_y1, pos_x1, pos_y2) + self.draw_line(pos_x2, pos_y1, pos_x2, pos_y2) - def draw_circle(self, x, y, radius): + def draw_circle(self, pos_x, pos_y, radius): """draw a circle""" err = 0 offset_x = radius offset_y = 0 while offset_x >= offset_y: - self.draw_pixel(x + offset_x, y + offset_y) - self.draw_pixel(x + offset_y, y + offset_x) - self.draw_pixel(x - offset_y, y + offset_x) - self.draw_pixel(x - offset_x, y + offset_y) - self.draw_pixel(x - offset_x, y - offset_y) - self.draw_pixel(x - offset_y, y - offset_x) - self.draw_pixel(x + offset_y, y - offset_x) - self.draw_pixel(x + offset_x, y - offset_y) + self.draw_pixel(pos_x + offset_x, pos_y + offset_y) + self.draw_pixel(pos_x + offset_y, pos_y + offset_x) + self.draw_pixel(pos_x - offset_y, pos_y + offset_x) + self.draw_pixel(pos_x - offset_x, pos_y + offset_y) + self.draw_pixel(pos_x - offset_x, pos_y - offset_y) + self.draw_pixel(pos_x - offset_y, pos_y - offset_x) + self.draw_pixel(pos_x + offset_y, pos_y - offset_x) + self.draw_pixel(pos_x + offset_x, pos_y - offset_y) if err <= 0: offset_y += 1 err += 2*offset_y + 1 @@ -48,7 +49,7 @@ class Pixel(object): offset_x -= 1 err -= 2*offset_x + 1 - def draw_arc(self, x, y, radius, start, end): + def draw_arc(self, pos_x, pos_y, radius, start, end): """draw an arc""" start = start * math.pi / 180 end = end * math.pi / 180 @@ -58,22 +59,22 @@ class Pixel(object): offset_y = 0 while offset_x >= offset_y: if start <= math.atan2(offset_y, offset_x) <= end: - self.draw_pixel(x + offset_x, y + offset_y) + self.draw_pixel(pos_x + offset_x, pos_y + offset_y) if start <= math.atan2(offset_x, offset_y) <= end: - self.draw_pixel(x + offset_y, y + offset_x) + self.draw_pixel(pos_x + offset_y, pos_y + offset_x) if start <= math.atan2(offset_x, -offset_y) <= end: - self.draw_pixel(x - offset_y, y + offset_x) + self.draw_pixel(pos_x - offset_y, pos_y + offset_x) if start <= math.atan2(offset_y, -offset_x) <= end: - self.draw_pixel(x - offset_x, y + offset_y) + self.draw_pixel(pos_x - offset_x, pos_y + offset_y) if start <= math.atan2(-offset_y, -offset_x) + 2*math.pi <= end: - self.draw_pixel(x - offset_x, y - offset_y) + self.draw_pixel(pos_x - offset_x, pos_y - offset_y) if start <= math.atan2(-offset_x, -offset_y) + 2*math.pi <= end: - self.draw_pixel(x - offset_y, y - offset_x) + self.draw_pixel(pos_x - offset_y, pos_y - offset_x) if start <= math.atan2(-offset_x, offset_y) + 2*math.pi <= end: - self.draw_pixel(x + offset_y, y - offset_x) + self.draw_pixel(pos_x + offset_y, pos_y - offset_x) if start <= math.atan2(-offset_y, offset_x) + 2*math.pi <= end: - self.draw_pixel(x + offset_x, y - offset_y) + self.draw_pixel(pos_x + offset_x, pos_y - offset_y) if err <= 0: offset_y += 1 diff --git a/gfxlcd/driver/__init__.py b/gfxlcd/driver/__init__.py index 7c2d50b..9e335e9 100644 --- a/gfxlcd/driver/__init__.py +++ b/gfxlcd/driver/__init__.py @@ -1 +1,2 @@ -__author__ = 'kosci' +"""driver module""" +__author__ = 'Bartosz Kosciow' \ No newline at end of file diff --git a/gfxlcd/driver/ili9325/__init__.py b/gfxlcd/driver/ili9325/__init__.py index 7c2d50b..95e8fad 100644 --- a/gfxlcd/driver/ili9325/__init__.py +++ b/gfxlcd/driver/ili9325/__init__.py @@ -1 +1,2 @@ -__author__ = 'kosci' +"""driver/ili9325 module""" +__author__ = 'Bartosz Kosciow' \ No newline at end of file diff --git a/gfxlcd/driver/nju6450/__init__.py b/gfxlcd/driver/nju6450/__init__.py index 7c2d50b..01b79d8 100644 --- a/gfxlcd/driver/nju6450/__init__.py +++ b/gfxlcd/driver/nju6450/__init__.py @@ -1 +1,2 @@ -__author__ = 'kosci' +"""driver/nju6450 module""" +__author__ = 'Bartosz Kosciow' \ No newline at end of file diff --git a/gfxlcd/driver/nju6450/gpio.py b/gfxlcd/driver/nju6450/gpio.py index 5605e95..b52d09b 100644 --- a/gfxlcd/driver/nju6450/gpio.py +++ b/gfxlcd/driver/nju6450/gpio.py @@ -1,6 +1,6 @@ """NJU6450 gpio driver class""" import time -import RPi.GPIO # pylint: disable=I0011,F0401 +import RPi.GPIO # pylint: disable=I0011,F0401 from gfxlcd.abstract.driver import Driver RPi.GPIO.setmode(RPi.GPIO.BCM) diff --git a/gfxlcd/driver/ssd1306/__init__.py b/gfxlcd/driver/ssd1306/__init__.py index 7c2d50b..31c4620 100644 --- a/gfxlcd/driver/ssd1306/__init__.py +++ b/gfxlcd/driver/ssd1306/__init__.py @@ -1 +1,2 @@ -__author__ = 'kosci' +"""driver/ssd1306 module""" +__author__ = 'Bartosz Kosciow' \ No newline at end of file diff --git a/gfxlcd/driver/ssd1306/ssd1306.py b/gfxlcd/driver/ssd1306/ssd1306.py index 88aff42..4b595a1 100644 --- a/gfxlcd/driver/ssd1306/ssd1306.py +++ b/gfxlcd/driver/ssd1306/ssd1306.py @@ -36,7 +36,8 @@ class SSD1306(Page, Chip): self.driver.cmd(0xd3) # set display offset self.driver.cmd(0x00) # not offset - self.driver.cmd(0xd5) # set display clock divide ratio/oscillator frequency + # set display clock divide ratio/oscillator frequency + self.driver.cmd(0xd5) self.driver.cmd(0x80) # set divide ratio self.driver.cmd(0xd9) # set pre-charge period