当前位置: 首页>>代码示例>>Python>>正文


Python Emotiv.running方法代码示例

本文整理汇总了Python中emokit.emotiv.Emotiv.running方法的典型用法代码示例。如果您正苦于以下问题:Python Emotiv.running方法的具体用法?Python Emotiv.running怎么用?Python Emotiv.running使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在emokit.emotiv.Emotiv的用法示例。


在下文中一共展示了Emotiv.running方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Emotiv

# 需要导入模块: from emokit.emotiv import Emotiv [as 别名]
# 或者: from emokit.emotiv.Emotiv import running [as 别名]
    alphalist = []
    for (f,S) in spectrum:
        if f>=8 and f<=12:
            alphalist.append(S)
    alpha = np.mean(alphalist)

    return alpha
    

if __name__ == "__main__":
    headset = Emotiv()
    routine = gevent.spawn(headset.setup)
    gevent.sleep(0)
    try:
        while True:
            buffin = []
            for i in xrange(128):
                packet = headset.dequeue()
                buffin.append(packet.sensors['F3']['value'])
                #print packet.gyro_x, packet.gyro_y, packet.battery
                gevent.sleep(0)
            alpha = getAlphaPower(buffin)
            print alpha
    except KeyboardInterrupt:
        headset.running = False
        headset.close()
        gevent.kill(routine, KeyboardInterrupt)
    finally:
        headset.close()
        gevent.kill(routine)
    sys.exit()
开发者ID:Hugo-W,项目名称:Imperial-festival,代码行数:33,代码来源:getAlphaAndFiltering.py

示例2: main

# 需要导入模块: from emokit.emotiv import Emotiv [as 别名]
# 或者: from emokit.emotiv.Emotiv import running [as 别名]
def main():
    """
    Creates pygame window and graph drawing workers for each sensor.
    """
    global gheight
    pygame.init()
    screen = pygame.display.set_mode((800, 600))
    graphers = []
    recordings = []
    recording = False
    record_packets = []
    updated = False
    cursor_x, cursor_y = 400, 300
    for name in 'AF3 F7 F3 FC5 T7 P7 O1 O2 P8 T8 FC6 F4 F8 AF4'.split(' '):
        graphers.append(Grapher(screen, name, len(graphers)))
    fullscreen = False
    emotiv = Emotiv(display_output=False) # False/True
    routine = gevent.spawn(emotiv.setup) # add routine var
    gevent.sleep(0)
    while emotiv.running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                emotiv.running = False
                gevent.kill(routine) #ME!!
                emotiv.close()          
#                return
                break
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    emotiv.running = False
                    gevent.kill(routine) #ME!!   
                    emotiv.close()
#                    return
                    break
                elif event.key == pygame.K_f:
                    if fullscreen:
                        screen = pygame.display.set_mode((800, 600))
                        fullscreen = False
                    else:
                        screen = pygame.display.set_mode((800, 600), FULLSCREEN, 16)
                        fullscreen = True
                elif event.key == pygame.K_r:
                    if not recording:
                        record_packets = []
                        recording = True
                    else:
                        recording = False
                        recordings.append(list(record_packets))
                        record_packets = None
        packets_in_queue = 0
        try:
            while packets_in_queue < 8 and emotiv.running:
                packet = emotiv.dequeue()
                if abs(packet.gyro_x) > 1:
                    cursor_x = max(0, min(cursor_x, 800))
                    cursor_x -= packet.gyro_x
                if abs(packet.gyro_y) > 1:
                    cursor_y += packet.gyro_y
                    cursor_y = max(0, min(cursor_y, 600))
                map(lambda x: x.update(packet), graphers)
                if recording:
                    record_packets.append(packet)
                updated = True
                packets_in_queue += 1
        except Exception, ex:
            print ex

        if updated:
            screen.fill((75, 75, 75))
            map(lambda x: x.draw(), graphers)
            pygame.draw.rect(screen, (255, 255, 255), (cursor_x - 5, cursor_y - 5, 10, 10), 0)
            pygame.display.flip()
            updated = False
        gevent.sleep(0)
开发者ID:Hugo-W,项目名称:Imperial-festival,代码行数:76,代码来源:render.py


注:本文中的emokit.emotiv.Emotiv.running方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。