[ create a new paste ] login | about

Link: http://codepad.org/G2hrVoi6    [ raw code | fork ]

meigrafd - Python, pasted on Jul 21:
os.environ["SDL_FBDEV"] = "/dev/fb0"
# default screen size
width  = 320
height = 240

# colors    R    G    B
white   = (255, 255, 255)
red     = (255,   0,   0)
green   = (  0, 255,   0)
blue    = (  0,   0, 255)
black   = (  0,   0,   0)
cyan    = ( 50, 255, 255)
magenta = (255,   0, 255)
yellow  = (255, 255,   0)
orange  = (255, 127,   0)

# --- init screen ---
size = (width, height)
pygame.init()
window = pygame.display.set_mode(size)
window.fill(black)
xmax = width - 2
ymax = height - 1
# fonts
font0 = pygame.font.SysFont("droidsans", 21)
font1 = pygame.font.SysFont("droidsans", 15)
font2 = pygame.font.SysFont("droidsans", 83)
font3 = pygame.font.SysFont("droidsans", 33)
font4 = pygame.font.SysFont("freemono", 26)
font0.set_bold(1)
font3.set_bold(1)
# images
image = dict()
image["off48"] = pygame.image.load("/home/webide/repositories/my-pi-projects/Securasp/Icons/status_off48.png").convert_alpha()
image["on72"] = pygame.image.load("/home/webide/repositories/my-pi-projects/Securasp/Icons/status_on72.png").convert_alpha()
image["warning72"] = pygame.image.load("/home/webide/repositories/my-pi-projects/Securasp/Icons/status_warning72.png").convert_alpha()

# ----------------------------------------------------------

def screenborder(lines=1, color=white):
    # Draw Screen Border
    pygame.draw.line( window, color, (0,0), (xmax,0), lines )
    pygame.draw.line( window, color, (0,0), (0,ymax), lines )
    pygame.draw.line( window, color, (0,ymax), (xmax,ymax), lines )
    pygame.draw.line( window, color, (xmax,0), (xmax,ymax+2), lines )
    # 2.parallele
    pygame.draw.line( window, color, (0,ymax*0.20), (xmax,ymax*0.20), lines )

def alertscreen():
    window.fill(red)
    screenborder()
    label0 = font0.render("SECURITY BREACH!!!", 1, black) 
    window.blit(label0, (50,10))
    window.blit(image["warning72"], (110,100))

def offlinescreen():
    window.fill(red)
    screenborder()
    label0 = font0.render("FHEM offline!!!", 1, black) 
    window.blit(label0, (50,10))
    window.blit(image["warning72"], (110,100))

def armedscreen():
    window.fill(green)
    screenborder()
    label0 = font0.render("SYSTEM ARMED!!!", 1, black)
    label1 = font1.render("Please leave house or disarm system", 1, black)
    label2 = font1.render("within 30 seconds before alarm is raised!", 1, black) 
    window.blit(label0, (60,10))
    window.blit(label1, (10,180))
    window.blit(label2, (10,200))
    window.blit(image["on72"], (120,100))

def offscreen(wetter):
    #degree = u"°C"
    degree = u"°C"
    wetter = wetter
    d1 = wetter.get('d1')
    t1 = wetter.get('t1')
    l1 = wetter.get('l1')
    i1 = wetter.get('i1')
    d2 = wetter.get('d2')
    t2 = wetter.get('t2')
    l2 = wetter.get('l2')
    i2 = wetter.get('i2')
    d3 = wetter.get('d3')
    t3 = wetter.get('t3')
    l3 = wetter.get('l3')
    i3 = wetter.get('i3')
    now = datetime.datetime.now()
    vtime = now.strftime("%H:%M")
    vtag = now.strftime("%Y-%m-%d")

    window.fill(black)
    screenborder()
    pygame.draw.line( window, white, (0,ymax*0.5),(xmax,ymax*0.5), 1 )
    pygame.draw.line( window, white, (xmax*0.33,ymax*0.5),(xmax*0.33,ymax), 1 )
    #mittlere senkrechte
    pygame.draw.line( window, white, (xmax*0.5,ymax*0.2),(xmax*0.5,ymax*0.5), 1 )
    pygame.draw.line( window, white, (xmax*0.66,ymax*0.5),(xmax*0.66,ymax), 1 )

    label0 = font0.render("System Status", 1, red)
    labeld1 = font1.render("heute", 1, white)
    labeld2 = font1.render(d2, 1, white) 
    labeld3 = font1.render(d3, 1, white) 
    window.blit(label0, (10,10))
    window.blit(labeld1, (35,120))
    window.blit(labeld2, (120,120))
    window.blit(labeld3, (225,120))
    icon2 = pygame.image.load("/home/webide/repositories/my-pi-projects/Securasp/Icons/weather/d_"+i1+"_S.png").convert_alpha()
    icon3 = pygame.image.load("/home/webide/repositories/my-pi-projects/Securasp/Icons/weather/d_"+i2+"_S.png").convert_alpha()
    icon4 = pygame.image.load("/home/webide/repositories/my-pi-projects/Securasp/Icons/weather/d_"+i3+"_S.png").convert_alpha()
    window.blit( image["off48"], (240,0))
    window.blit( icon2, (30,140))
    window.blit( icon3, (130,140))
    window.blit( icon4, (235,140))
    labelt1 = font1.render(t1+"/"+l1+degree, 1, white)
    labelt2 = font1.render(t2+"/"+l2+degree, 1, white)
    labelt3 = font1.render(t3+"/"+l3+degree, 1, white)
    window.blit( labelt1, (30,190))
    window.blit( labelt2, (130,190))
    window.blit( labelt3, (235,190))
    labelx1 = font1.render(vtag, 1, white)
    labelx2 = font3.render(vtime, 1, white)
    labelx3 = font1.render("aktuelles Wetter", 1, white)
    window.blit( labelx1, (45,50))
    window.blit( labelx2, (30,80))
    window.blit( labelx3, (185,50))
    (temp, rain, wind) = weather_curr_get()
    labelx4 = font1.render(temp+degree, 1, white)
    labelx5 = font1.render(rain, 1, white)
    labelx6 = font1.render(wind, 1, white)
    window.blit( labelx4, (185,65))
    window.blit( labelx5, (185,80))


Create a new paste based on this one


Comments: