# coding: utf-8
import modify_extract
#import extract
import udp
from plot import Display
import struct

ret = []  # to store csi
s = udp.udp_init(5563)  # create a udp handle
f = Display()  #initialize the realview procedure
f.display()

try:
    while True:  # a loop to receive the data
        csiInfo = []
        data, addr = udp.recv(s)  # receive a udp socket
        for i in range(1, len(data)):
            csiInfo.append(struct.unpack("!B",
                                         data[i])[0])  # decode csi from udp

        CSI_matrix = modify_extract.readFile(csiInfo)
        f.push(CSI_matrix)
        # print CSI_matrix
except KeyboardInterrupt:
    udp.close(s)  # close udp
    f.stop()  # close view
Esempio n. 2
0
    i=0

    lab(ip,(yellow),50,60,True,i)
    lab(temp,(yellow),50,150,True,i)
    lab(str(psutil.cpu_percent()),(yellow),50,250,True,i)
    lab(ram,(yellow),50,350,True,i)
    


    
while not done:


    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            udp.close()
            pygame.display.quit()
            done = True
            screen.close()
            pee
        if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
            done = True
            
            pygame.display.quit()
            pygame.quit()
            udp.close()
            poop

        #PAGE
        if event.type == pygame.KEYDOWN and event.key == pygame.K_7:
            
Esempio n. 3
0
def main():
    flagquit=0
    global done
    screen = pygame.display.set_mode((RIGHT,BOTTOM),pygame.NOFRAME)


    

    screen_rect = screen.get_rect()
    




    font_music = pygame.font.Font('fonts/'+fonts[font_select], font_size)




    cycle=0
    

    while not done:
        
        if c[0]>pages:
            c[0]=0
        if c[2]>(len(bgs)-1):
            c[2]=0
        if c[3]>color_t:
            c[3]=0
        if c[4]>(len(fonts)-1):
            c[4]=0
        if c[5]>sm_total:
                c[5]=0
        if cycle>(len(c)-1):
            cycle=0
        if c[1]%2==1:
            debug=True
        else:
            debug=False


        
            

        #print bgs
        #print selection
        #print c[2]
        bg = pygame.image.load('image/bg/'+bgs[c[2]]).convert_alpha()
        bg= pygame.transform.scale(bg, (720,480))
        bgc=bg.copy()
        bgc.fill((255, 255, 255, 50), None, pygame.BLEND_RGBA_MULT)

        
        #print 'cant load', c[2]
        #screen.blit(bg, (00, 0))
        
        screen.blit(bg, (00, 0))


        #print c
        #print c[0]
        #print type(c[0])
        if c[0]==1:
            music(screen,bg,bgc)
        if c[0]==0:
            
            info(screen,bg,bgc)
        if c[0]==2:
            obd2(screen,bg,bgc,connection)
        if c[0]==3:
            speedmeter(screen,bg,bgc,connection,c)





        #cst=['page','debug','selection','color','font_select','sm','ypos','font_size']
        cst=['page','debug','bg','color','font_select','sm','font up','font down','y pos+','ypos --']
        clock=True
        if clock==True:
            font_clock = pygame.font.Font('fonts/'+fonts[c[4]], 50)
            #clockd=time.strftime("%I:%M %p")
            clockd=time.strftime("%I:%M")
            if clockd[0]=='0':
                clockd=clockd[1:]
            clock



            #string_label = font_clock.render(clockd+temp55,True,(yellow),(0,0,0))
            string_label = font_clock.render(clockd+temp55,True,(0,0,0))
            aa =string_label.get_rect()
            mid= aa[2]
            mid2=mid
            real=RIGHT-mid2
            real=real/2

            
            button = pygame.image.load('image/button2.png')
            button= pygame.transform.scale(button, (mid+60,100))
            screen.blit(button,(real-30,BOTTOM-50))
            screen.blit(string_label,(real,BOTTOM-50))

            
        if debug==True:
            #s.send(c[0],False,arduino)
            c[7]=c[6]
            c[9]=c[8]
            font_debug = pygame.font.Font('fonts/'+fonts[37], 30)

            #print page,'page'
            #print selection,'selection'
            #print color,'color'
            #print font_size,'font_size'
            #string=str(fonts[font_select])+str(font_select)
            #if page==3:
            #    string=str(speed)+' '+str(sm)

            #print yellow
            string=str(c[cycle])

            string_label = font_debug.render(string,True,(yellow))
            screen.blit(string_label,(5,50))


            string=cst[cycle]
            #22print string
            string_label = font_debug.render(string,True,(yellow))
            screen.blit(string_label,(5,400))

        pygame.display.flip()




        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                try:
                    
                    udp.close()
                except:
                    'poo'
                pygame.display.quit()
                done = True
                screen.close()
                pee
            if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                done = True
                
                pygame.display.quit()
                pygame.quit()
                udp.close()
                poop

            #PAGE
            if event.type == pygame.KEYDOWN and event.key == pygame.K_7:
                
                c[0]=c[0]+1
                



            if event.type == pygame.KEYDOWN and event.key == pygame.K_3: 
                cycle=cycle+1


            if event.type == pygame.KEYDOWN and event.key == pygame.K_2 :
                c[cycle]=c[cycle]+1





                    
            #DEBUG
            if event.type == pygame.KEYDOWN and event.key == pygame.K_d:
                if debug==True:
                    debug=False
                else:
                    debug=True
            #BG#
            if event.type == pygame.KEYDOWN and event.key == pygame.K_3:
                c[2]=c[2]+1
               
            #COLOR        
            if event.type == pygame.KEYDOWN and event.key == pygame.K_1:
                #print c[3]
                subprocess.call("shutdown -h now", shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            #RANDOM!!!     
            if event.type == pygame.KEYDOWN and event.key == pygame.K_0:
                #print c[3]
                cr=random.randint(0,(color_t))
                c[3]=cr

                br=random.randint(0,len(bgs))
                c[2]=br
                #print len(c[3])
                fr=random.randint(0,len(fonts))
                c[4]=fr

            #FONT#
            if event.type == pygame.KEYDOWN and event.key == pygame.K_5:
                c[4]=c[4]+1
                

            if event.type == pygame.KEYDOWN and event.key == pygame.K_6:
                c[5]=c[5]+1
                





                    
            if event.type == pygame.KEYDOWN and event.key == pygame.K_2 and cycle==8:
                #ypos=ypos-5
                c[8]=c[8]-1
                

            if event.type == pygame.KEYDOWN and event.key == pygame.K_2 and cycle==9:
                c[8]=c[8]+1

            if event.type == pygame.KEYDOWN and event.key == pygame.K_2 and cycle==6:
                c[6]=c[6]+3

            if event.type == pygame.KEYDOWN and event.key == pygame.K_2 and cycle==7:
                c[6]=c[6]-2

            if event.type == pygame.KEYDOWN and event.key == pygame.K_s:
                speed=speed+10

            if event.type == pygame.KEYDOWN and event.key == pygame.K_x:
                speed=speed-10
    clock2.tick(60)
Esempio n. 4
0
File: joy.py Progetto: mrwulff/ca
def main():
    flagquit = 0
    global done
    screen = pygame.display.set_mode((RIGHT, BOTTOM), pygame.NOFRAME)

    screen_rect = screen.get_rect()

    font_music = pygame.font.Font('fonts/' + fonts[font_select], font_size)

    cycle = 0

    while not done:

        if c[0] > pages:
            c[0] = 0
        if c[2] > (len(bgs) - 1):
            c[2] = 0
        if c[3] > color_t:
            c[3] = 0
        if c[4] > (len(fonts) - 1):
            c[4] = 0
        if c[5] > sm_total:
            c[5] = 0
        if cycle > (len(c) - 1):
            cycle = 0
        if c[1] % 2 == 1:
            debug = True
        else:
            debug = False

        #print bgs
        #print selection
        #print c[2]
        bg = pygame.image.load('image/bg/' + bgs[c[2]]).convert_alpha()
        bg = pygame.transform.scale(bg, (720, 480))
        bgc = bg.copy()
        bgc.fill((255, 255, 255, 50), None, pygame.BLEND_RGBA_MULT)

        #print 'cant load', c[2]
        #screen.blit(bg, (00, 0))

        screen.blit(bg, (00, 0))

        #print c
        #print c[0]
        #print type(c[0])
        if c[0] == 1:
            music(screen, bg, bgc)
        if c[0] == 0:

            info(screen, bg, bgc)
        if c[0] == 2:
            obd2(screen, bg, bgc, connection)
        if c[0] == 3:
            speedmeter(screen, bg, bgc, connection, c)

        #cst=['page','debug','selection','color','font_select','sm','ypos','font_size']
        cst = [
            'page', 'debug', 'bg', 'color', 'font_select', 'sm', 'font up',
            'font down', 'y pos+', 'ypos --'
        ]
        clock = True
        if clock == True:
            font_clock = pygame.font.Font('fonts/' + fonts[c[4]], 50)
            #clockd=time.strftime("%I:%M %p")
            clockd = time.strftime("%I:%M")
            if clockd[0] == '0':
                clockd = clockd[1:]
            clock

            #string_label = font_clock.render(clockd+temp55,True,(yellow),(0,0,0))
            string_label = font_clock.render(clockd + temp55, True, (0, 0, 0))
            aa = string_label.get_rect()
            mid = aa[2]
            mid2 = mid
            real = RIGHT - mid2
            real = real / 2

            button = pygame.image.load('image/button2.png')
            button = pygame.transform.scale(button, (mid + 60, 100))
            screen.blit(button, (real - 30, BOTTOM - 50))
            screen.blit(string_label, (real, BOTTOM - 50))

        if debug == True:
            #s.send(c[0],False,arduino)
            c[7] = c[6]
            c[9] = c[8]
            font_debug = pygame.font.Font('fonts/' + fonts[37], 30)

            #print page,'page'
            #print selection,'selection'
            #print color,'color'
            #print font_size,'font_size'
            #string=str(fonts[font_select])+str(font_select)
            #if page==3:
            #    string=str(speed)+' '+str(sm)

            #print yellow
            string = str(c[cycle])

            string_label = font_debug.render(string, True, (yellow))
            screen.blit(string_label, (5, 50))

            string = cst[cycle]
            #22print string
            string_label = font_debug.render(string, True, (yellow))
            screen.blit(string_label, (5, 400))

        pygame.display.flip()

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                try:

                    udp.close()
                except:
                    'poo'
                pygame.display.quit()
                done = True
                screen.close()
                pee
            if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                done = True

                pygame.display.quit()
                pygame.quit()
                udp.close()
                poop

            #PAGE
            if event.type == pygame.KEYDOWN and event.key == pygame.K_7:

                c[0] = c[0] + 1

            if event.type == pygame.KEYDOWN and event.key == pygame.K_3:
                cycle = cycle + 1

            if event.type == pygame.KEYDOWN and event.key == pygame.K_2:
                c[cycle] = c[cycle] + 1

            #DEBUG
            if event.type == pygame.KEYDOWN and event.key == pygame.K_d:
                if debug == True:
                    debug = False
                else:
                    debug = True
            #BG#
            if event.type == pygame.KEYDOWN and event.key == pygame.K_3:
                c[2] = c[2] + 1

            #COLOR
            if event.type == pygame.KEYDOWN and event.key == pygame.K_1:
                #print c[3]
                subprocess.call("shutdown -h now",
                                shell=True,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)
            #RANDOM!!!
            if event.type == pygame.KEYDOWN and event.key == pygame.K_0:
                #print c[3]
                cr = random.randint(0, (color_t))
                c[3] = cr

                br = random.randint(0, len(bgs))
                c[2] = br
                #print len(c[3])
                fr = random.randint(0, len(fonts))
                c[4] = fr

            #FONT#
            if event.type == pygame.KEYDOWN and event.key == pygame.K_5:
                c[4] = c[4] + 1

            if event.type == pygame.KEYDOWN and event.key == pygame.K_6:
                c[5] = c[5] + 1

            if event.type == pygame.KEYDOWN and event.key == pygame.K_2 and cycle == 8:
                #ypos=ypos-5
                c[8] = c[8] - 1

            if event.type == pygame.KEYDOWN and event.key == pygame.K_2 and cycle == 9:
                c[8] = c[8] + 1

            if event.type == pygame.KEYDOWN and event.key == pygame.K_2 and cycle == 6:
                c[6] = c[6] + 3

            if event.type == pygame.KEYDOWN and event.key == pygame.K_2 and cycle == 7:
                c[6] = c[6] - 2

            if event.type == pygame.KEYDOWN and event.key == pygame.K_s:
                speed = speed + 10

            if event.type == pygame.KEYDOWN and event.key == pygame.K_x:
                speed = speed - 10
    clock2.tick(60)
Esempio n. 5
0
#!/usr/bin/python3

import sys

sys.path.insert(1, '../src')

import udp
udp.PACKET_SIZE = 16

sock = udp.open('127.0.0.1', 8081)
pack = bytes('chrissx is lool.', 'utf-8')
req, cli = udp.accept(sock)
print(req)
udp.answer(sock, pack, cli)
udp.close(sock)