mirror of
https://github.com/Febbweiss/mopidy-touchscreen.git
synced 2026-03-04 22:25:39 +00:00
10 FPS
We will save CPU. (In my computer around %10 less CPU is used now) Some adjustments so that the 10 FPS are not noticeable
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
|
change_speed = 2
|
||||||
|
|
||||||
|
|
||||||
class DynamicBackground():
|
class DynamicBackground():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -9,12 +11,15 @@ class DynamicBackground():
|
|||||||
def draw_background(self, surface):
|
def draw_background(self, surface):
|
||||||
same = True
|
same = True
|
||||||
for x in range(0, 3):
|
for x in range(0, 3):
|
||||||
if self.current[x] > self.target[x]:
|
if abs(self.current[x]-self.target[x]) < change_speed:
|
||||||
self.current[x] -= 1
|
self.current[x] = self.target[x]
|
||||||
elif self.current[x] < self.target[x]:
|
else:
|
||||||
self.current[x] += 1
|
if self.current[x] > self.target[x]:
|
||||||
if self.current != self.target:
|
self.current[x] -= change_speed
|
||||||
same = False
|
elif self.current[x] < self.target[x]:
|
||||||
|
self.current[x] += change_speed
|
||||||
|
if self.current != self.target:
|
||||||
|
same = False
|
||||||
#if same:
|
#if same:
|
||||||
# self.target = get_valid_color()
|
# self.target = get_valid_color()
|
||||||
surface.fill(self.current)
|
surface.fill(self.current)
|
||||||
|
|||||||
@@ -214,6 +214,9 @@ class BaseItem():
|
|||||||
|
|
||||||
|
|
||||||
class TextItem(BaseItem):
|
class TextItem(BaseItem):
|
||||||
|
|
||||||
|
scroll_speed = 2
|
||||||
|
|
||||||
def __init__(self, font, text, pos, size, center=False):
|
def __init__(self, font, text, pos, size, center=False):
|
||||||
self.font = font
|
self.font = font
|
||||||
self.text = text
|
self.text = text
|
||||||
@@ -253,7 +256,7 @@ class TextItem(BaseItem):
|
|||||||
if self.step > self.box.get_rect().width:
|
if self.step > self.box.get_rect().width:
|
||||||
self.step = -self.size[0]
|
self.step = -self.size[0]
|
||||||
else:
|
else:
|
||||||
self.step = self.step + 1
|
self.step = self.step + TextItem.scroll_speed
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return BaseItem.update(self)
|
return BaseItem.update(self)
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class TouchScreen(pykka.ThreadingActor, core.CoreListener):
|
|||||||
def start_thread(self):
|
def start_thread(self):
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
while self.running:
|
while self.running:
|
||||||
clock.tick(8)
|
clock.tick(10)
|
||||||
self.screen.blit(self.screen_manager.update(), (0, 0))
|
self.screen.blit(self.screen_manager.update(), (0, 0))
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
|
|||||||
Reference in New Issue
Block a user