Skip to content

Commit f4f65c6

Browse files
author
Tomasz Scislo
committed
code refactoring
1 parent 47f017a commit f4f65c6

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

piFaceBitmaps.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
cad = pifacecad.PiFaceCAD()
44

5-
bitmaps = {}
6-
bitmaps['PLAY'] = {'idx': 0, 'bitmap': pifacecad.LCDBitmap([0x10, 0x18, 0x1c, 0x1e, 0x1c, 0x18, 0x10, 0x0])}
7-
bitmaps['PAUSE'] = {'idx': 1, 'bitmap': pifacecad.LCDBitmap([0x0, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x0, 0x0])}
8-
bitmaps['STOP'] = {'idx': 2, 'bitmap': pifacecad.LCDBitmap([0x0, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x0, 0x0])}
9-
bitmaps['ERROR'] = {'idx': 3, 'bitmap': pifacecad.LCDBitmap([0x0, 0x1b, 0xe, 0x4, 0xe, 0x1b, 0x0, 0x0])}
10-
bitmaps['CLOCK'] = {'idx': 4, 'bitmap': pifacecad.LCDBitmap([0x0, 0xe, 0x15, 0x17, 0x11, 0xe, 0x0, 0x0])}
5+
bitmaps = {'PLAY': {'idx': 0, 'bitmap': pifacecad.LCDBitmap([0x10, 0x18, 0x1c, 0x1e, 0x1c, 0x18, 0x10, 0x0])},
6+
'PAUSE': {'idx': 1, 'bitmap': pifacecad.LCDBitmap([0x0, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x0, 0x0])},
7+
'STOP': {'idx': 2, 'bitmap': pifacecad.LCDBitmap([0x0, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x0, 0x0])},
8+
'ERROR': {'idx': 3, 'bitmap': pifacecad.LCDBitmap([0x0, 0x1b, 0xe, 0x4, 0xe, 0x1b, 0x0, 0x0])},
9+
'CLOCK': {'idx': 4, 'bitmap': pifacecad.LCDBitmap([0x0, 0xe, 0x15, 0x17, 0x11, 0xe, 0x0, 0x0])}}
1110

1211
for bitmap in bitmaps:
1312
cad.lcd.store_custom_bitmap(bitmaps[bitmap]['idx'], bitmaps[bitmap]['bitmap'])

radioControl.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ def getCurrentListItem(self):
2828
return self.streams.get()[self.stationIdx]
2929

3030
def nextOnList(self):
31-
if self.getCurrentListItem()['isRadio'] == False:
31+
if not self.getCurrentListItem()['isRadio']:
3232
print('Next track...')
3333
self.piFaceThread.enableBacklight()
3434
subprocess.Popen(['mocp', '-f'])
3535

3636
def prevOnList(self):
37-
if self.getCurrentListItem()['isRadio'] == False:
37+
if not self.getCurrentListItem()['isRadio']:
3838
print('Prev track...')
3939
self.piFaceThread.enableBacklight()
4040
subprocess.Popen(['mocp', '-r'])

settings.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
dir_path = os.path.dirname(os.path.abspath(__file__))
55

6+
67
class Settings():
78
def __init__(self):
89
self.loadedJson = None

threads/piFaceThread.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ def handleDisplay(self):
9797
self.scrollCounter = 0
9898
else:
9999
self.scrollCounter += 1
100-
if self.firstLine['state'] != None:
100+
if self.firstLine['state'] is not None:
101101
cad.lcd.set_cursor(0, 0)
102102
cad.lcd.write_custom_bitmap(self.firstLine['state'])
103-
if self.firstLine['radioStation'] != None:
103+
if self.firstLine['radioStation'] is not None:
104104
cad.lcd.set_cursor(2, 0)
105105
cad.lcd.write(self.firstLine['radioStation'])
106106

threads/standbyThread.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def isDisabled(self):
2020
return False
2121

2222
def run(self):
23-
while (True):
23+
while True:
2424
if self.state == "ENABLED":
2525
self.now = datetime.datetime.now()
2626
self.piFaceThread.writeFirstLine(bitmaps['CLOCK']['idx'], self.now.strftime("%H:%M:%S"))

threads/statusThread.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def __init__(self):
1414
self.daemon = True
1515

1616
def run(self):
17-
while (True):
17+
while True:
1818
if self.state == "ENABLED":
1919
self.getPlaybackState()
2020
time.sleep(0.2)

0 commit comments

Comments
 (0)