I did originally post this in the python section but I think it might be better off here.
I'm building a screen for my truck to give speed, gps, fuel consumption ect. I can boot into the python / pygame application and in theory shutdown via an on screen button press, my issue is that if I boot into the application using rc.local the touch screen mouse is badly out of calibration and is very difficult to click on a button, the physical mouse is much more accurate but cant reach all areas of the screen.
If I boot into rc.local manually all is fine.
Here is the start of my code;
Text in rc.local;
Code: Select all
import pygame import time import os from pygame.locals import* pygame.init() pygame.font.init() #gameDisplay=pygame.display.set_mode ((800,400)) gameDisplay=pygame.display.set_mode ((800,400),pygame.FULLSCREEN) clock = pygame.time.Clock() #pygame.mouse.set_visible(False) darkblue = (0,0,100) blue = (0,0,255) red = (255,0,0) green = (0,255,0) yellow = (232,220,28) black = (0,0,0) gameExit = False #clock.tick(10) def button(text, x, y, width, hight, inactive_color, active_color, action = None): mouse = pygame.mouse.get_pos() click = pygame.mouse.get_pressed() if x + width > (mouse) > x and y + hight > (mouse )> y: pygame.draw.rect (gameDisplay, active_color, [x,y,width,hight],1) if click ==1 and action != None: if action == "quit": pygame.quit() if action == "call_menu": menu_screen() if action == "night": bl.set_brightness(50) if action == "day": bl.set_brightness(255) if action == "shutdown": os.system('sudo poweroff') # pygame.quit() else: pygame.draw.rect (gameDisplay, inactive_color, [x,y,width,hight],1) # text_to_button (text, blue, x, y, width, height) myfont = pygame.font.SysFont(None,35) textSurface = myfont.render(text,False, (yellow)) gameDisplay.blit(textSurface,(x + 20,y+10)) pygame.display.update()
sudo python /home/pi/truck_display.py &
Interestingly if I boot via rc.local at start-up the mouse appears near the top on the left, if I run rc.local manually the mouse is at the centre of the screen.
I have done an upgrade install incase it was a bug but no difference, any ideas??
Second dumb question, am I right in thinking that if I add 'disable_splash = 1' to /boot/config.txt that should remove the colour square at startup?? I have read some people have managed to remove it while others say its impossible, If I change it to 'disable_splash = 0' I get the colour square twice.
This is a bit of an issue at night as in the dark the screen lights up with the intensity of a thousand watt light bulb destroying any sort of night vision! If I have to I can blank the screen backlight upon shutdown and then return it once the program boots, this might be an issue if something throws a wobbly as if the code doesn't boot for any reason the backlight won't get turned on.
I am using the 7 inch touch screen with the latest version of stretch.