Locks up after 3 seconds in camera mode, waits for UP/DOWN button press
Derpalupagus opened this issue · 3 comments
In Camera mode, image runs for 3 seconds and then freezes. Unfreezes after UP or DOWN button press and then freezes 3 seconds later. Tried the latest code and verified no tabs, still freezes up predictably.
Found it - pygame.display.update() on Line 220 is inside the if(showBtns < 25) loop, so once showBtns reaches 25, the display will no longer update untila button is pressed. Solution is to outdent the pygame.display.update() in Line 220 to outside of the if(showBtns < 25) loop. Correct structure follows:
# Add buttons (show for X seconds)
if (showBtns < 25):
fnt = pygame.font.Font(None, 15)
mode_buttons = {'PWR ->':(280,40), ' UP ->':(280,100), 'DOWN->':(280,160), 'MODE->':(280,220)}
for k,v in mode_buttons.items():
text_surface = fnt.render('%s'%k, True, GRAY)
rect = text_surface.get_rect(center=v)
lcd.blit(text_surface, rect)
showBtns = showBtns + 1
# Add Data to screen
fnt = pygame.font.Font(None, 15)
cur_date = datetime.datetime.now().strftime('%a %d %b %H : %M : %S %Z %Y')
text_surface = fnt.render(cur_date, True, GRAY)
lcd.blit(text_surface, (10,220))
text = "Min = {0:.0f} C".format(min(pixels_d))
text_surface = fnt.render(text, True, GRAY)
lcd.blit(text_surface, (10,20))
text = "Max = {0:.0f} C".format(max(pixels_d))
text_surface = fnt.render(text, True, GRAY)
lcd.blit(text_surface, (10,30))
pygame.display.update()
# GPIO Button Press
Updated raspitherm.py. I also noticed that the touch() call on line 238 wasn't outdented properly either. It should line up with the If statements, but note that the touch library for pygame have unfixed issues in low level C library for some touch screens (inc. the one from Adafruit). So you may have to comment out line 238 if touch doesn't work. There are touch related test programs in tools/ directory. I haven't checked to see if this was fixed in Raspbian Buster yet.
The snapshot touch() funciton works using tslib, or least it does for me. I just hadn't gotten that far into the project yet. Everything else looks like it's working fine now.