refactoring pep8 & pylint

This commit is contained in:
Bartosz Kościów 2017-04-25 20:58:35 +02:00
parent 736bb0547b
commit 38a6bee88f
14 changed files with 51 additions and 39 deletions

View File

@ -1 +1,2 @@
__author__ = 'kosci' """GfxLCD module"""
__author__ = 'Bartosz Kosciow'

View File

@ -1 +1,2 @@
__author__ = 'kosci' """abstracts/interfaces"""
__author__ = 'Bartosz Kosciow'

View File

@ -1,9 +1,9 @@
import RPi.GPIO import RPi.GPIO
import sys import sys
import random
sys.path.append("../../") sys.path.append("../../")
from gfxlcd.driver.ili9325.gpio import GPIO as ILIGPIO from gfxlcd.driver.ili9325.gpio import GPIO as ILIGPIO
from gfxlcd.driver.ili9325.ili9325 import ILI9325 from gfxlcd.driver.ili9325.ili9325 import ILI9325
import random
RPi.GPIO.setmode(RPi.GPIO.BCM) RPi.GPIO.setmode(RPi.GPIO.BCM)

View File

@ -1,9 +1,9 @@
import RPi.GPIO import RPi.GPIO
import sys import sys
import random
sys.path.append("../../") sys.path.append("../../")
from gfxlcd.driver.nju6450.gpio import GPIO from gfxlcd.driver.nju6450.gpio import GPIO
from gfxlcd.driver.nju6450.nju6450 import NJU6450 from gfxlcd.driver.nju6450.nju6450 import NJU6450
import random
RPi.GPIO.setmode(RPi.GPIO.BCM) RPi.GPIO.setmode(RPi.GPIO.BCM)

View File

@ -1,10 +1,10 @@
import RPi.GPIO import RPi.GPIO
import sys import sys
RPi.GPIO.setmode(RPi.GPIO.BCM) import random
sys.path.append("../../") sys.path.append("../../")
from gfxlcd.driver.ssd1306.spi import SPI from gfxlcd.driver.ssd1306.spi import SPI
from gfxlcd.driver.ssd1306.ssd1306 import SSD1306 from gfxlcd.driver.ssd1306.ssd1306 import SSD1306
import random RPi.GPIO.setmode(RPi.GPIO.BCM)
def hole(o, x, y): def hole(o, x, y):
@ -24,7 +24,10 @@ def hole(o, x, y):
def draw_points(o): def draw_points(o):
for _ in range(0, 50): 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): def draw_net(o):

View File

@ -1 +1,2 @@
__author__ = 'kosci' """drawing module"""
__author__ = 'Bartosz Kosciow'

View File

@ -101,8 +101,8 @@ class Page(Pixel, metaclass=abc.ABCMeta):
page = start_page page = start_page
for value in rows: for value in rows:
for x in range(pos_x2-pos_x1+1): for x_diff in range(pos_x2-pos_x1+1):
self.buffer[pos_x1+x][page] |= value self.buffer[pos_x1+x_diff][page] |= value
page += 1 page += 1
def get_page_value(self, column, page): def get_page_value(self, column, page):

View File

@ -5,6 +5,7 @@ import math
class Pixel(object): class Pixel(object):
"""Pixel class""" """Pixel class"""
def __init__(self, driver): def __init__(self, driver):
self.driver = driver
self.options['color'] = { self.options['color'] = {
'R': 255, 'G': 255, 'B': 255 'R': 255, 'G': 255, 'B': 255
} }
@ -20,27 +21,27 @@ class Pixel(object):
"""dummy fuction""" """dummy fuction"""
pass pass
def draw_rect(self, x1, y1, x2, y2): def draw_rect(self, pos_x1, pos_y1, pos_x2, pos_y2):
"""draw a rectangle""" """draw a rectangle"""
self.draw_line(x1, y1, x2, y1) self.draw_line(pos_x1, pos_y1, pos_x2, pos_y1)
self.draw_line(x1, y2, x2, y2) self.draw_line(pos_x1, pos_y2, pos_x2, pos_y2)
self.draw_line(x1, y1, x1, y2) self.draw_line(pos_x1, pos_y1, pos_x1, pos_y2)
self.draw_line(x2, y1, x2, 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""" """draw a circle"""
err = 0 err = 0
offset_x = radius offset_x = radius
offset_y = 0 offset_y = 0
while offset_x >= offset_y: while offset_x >= offset_y:
self.draw_pixel(x + offset_x, y + offset_y) self.draw_pixel(pos_x + offset_x, pos_y + offset_y)
self.draw_pixel(x + offset_y, y + offset_x) self.draw_pixel(pos_x + offset_y, pos_y + offset_x)
self.draw_pixel(x - offset_y, y + offset_x) self.draw_pixel(pos_x - offset_y, pos_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(x - offset_x, y - offset_y) self.draw_pixel(pos_x - offset_x, pos_y - offset_y)
self.draw_pixel(x - offset_y, y - offset_x) self.draw_pixel(pos_x - offset_y, pos_y - offset_x)
self.draw_pixel(x + offset_y, y - offset_x) self.draw_pixel(pos_x + offset_y, pos_y - offset_x)
self.draw_pixel(x + offset_x, y - offset_y) self.draw_pixel(pos_x + offset_x, pos_y - offset_y)
if err <= 0: if err <= 0:
offset_y += 1 offset_y += 1
err += 2*offset_y + 1 err += 2*offset_y + 1
@ -48,7 +49,7 @@ class Pixel(object):
offset_x -= 1 offset_x -= 1
err -= 2*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""" """draw an arc"""
start = start * math.pi / 180 start = start * math.pi / 180
end = end * math.pi / 180 end = end * math.pi / 180
@ -58,22 +59,22 @@ class Pixel(object):
offset_y = 0 offset_y = 0
while offset_x >= offset_y: while offset_x >= offset_y:
if start <= math.atan2(offset_y, offset_x) <= end: 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: 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: 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: 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: 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: 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: 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: 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: if err <= 0:
offset_y += 1 offset_y += 1

View File

@ -1 +1,2 @@
__author__ = 'kosci' """driver module"""
__author__ = 'Bartosz Kosciow'

View File

@ -1 +1,2 @@
__author__ = 'kosci' """driver/ili9325 module"""
__author__ = 'Bartosz Kosciow'

View File

@ -1 +1,2 @@
__author__ = 'kosci' """driver/nju6450 module"""
__author__ = 'Bartosz Kosciow'

View File

@ -1,6 +1,6 @@
"""NJU6450 gpio driver class""" """NJU6450 gpio driver class"""
import time import time
import RPi.GPIO # pylint: disable=I0011,F0401 import RPi.GPIO # pylint: disable=I0011,F0401
from gfxlcd.abstract.driver import Driver from gfxlcd.abstract.driver import Driver
RPi.GPIO.setmode(RPi.GPIO.BCM) RPi.GPIO.setmode(RPi.GPIO.BCM)

View File

@ -1 +1,2 @@
__author__ = 'kosci' """driver/ssd1306 module"""
__author__ = 'Bartosz Kosciow'

View File

@ -36,7 +36,8 @@ class SSD1306(Page, Chip):
self.driver.cmd(0xd3) # set display offset self.driver.cmd(0xd3) # set display offset
self.driver.cmd(0x00) # not 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(0x80) # set divide ratio
self.driver.cmd(0xd9) # set pre-charge period self.driver.cmd(0xd9) # set pre-charge period