Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# G19_basic
Empty file modified Verdana.ttf
100644 → 100755
Empty file.
Empty file modified license.txt
100644 → 100755
Empty file.
Empty file modified logitech/__init__.py
100644 → 100755
Empty file.
Empty file modified logitech/applets/__init__.py
100644 → 100755
Empty file.
Empty file modified logitech/applets/simple_bg_light/__init__.py
100644 → 100755
Empty file.
Empty file modified logitech/applets/simple_bg_light/simple_bg_light.py
100644 → 100755
Empty file.
Empty file modified logitech/applets/simple_clock/__init__.py
100644 → 100755
Empty file.
Empty file modified logitech/applets/simple_clock/simple_clock.py
100644 → 100755
Empty file.
Empty file modified logitech/applets/simple_display_brightness/__init__.py
100644 → 100755
Empty file.
Empty file.
Empty file modified logitech/applets/simple_slideshow/__init__.py
100644 → 100755
Empty file.
Empty file modified logitech/applets/simple_slideshow/simple_slideshow.py
100644 → 100755
Empty file.
Empty file modified logitech/applets/simple_timer/__init__.py
100644 → 100755
Empty file.
Empty file modified logitech/applets/simple_timer/simple_timer.py
100644 → 100755
Empty file.
Empty file modified logitech/applets/xplanet/__init__.py
100644 → 100755
Empty file.
Empty file modified logitech/applets/xplanet/xplanet.py
100644 → 100755
Empty file.
5 changes: 3 additions & 2 deletions logitech/g19.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,9 @@ def __init__(self, resetOnStart=False):
self.handleIf1 = self.__lcd_device.open()
self.handleIfMM = self.__kbd_device.open()
config = self.__lcd_device.configurations[0]
#print len(config.interfaces[0])
iface0 = config.interfaces[0][0]
iface1 = config.interfaces[1][0]
iface1 = config.interfaces[0][1]

try:
self.handleIfMM.setConfiguration(1)
Expand Down Expand Up @@ -461,4 +462,4 @@ def main():
lg19.stop_event_handling()

if __name__ == '__main__':
main()
main()
Empty file modified logitech/g19_config.py
100644 → 100755
Empty file.
Empty file modified logitech/g19_keys.py
100644 → 100755
Empty file.
Empty file modified logitech/g19_mapper.py
100644 → 100755
Empty file.
Empty file modified logitech/g19_menu.py
100644 → 100755
Empty file.
Empty file modified logitech/g19_qt.py
100644 → 100755
Empty file.
Empty file modified logitech/g19_receivers.py
100644 → 100755
Empty file.
Empty file modified logitech/runnable.py
100644 → 100755
Empty file.
Empty file modified readme.txt
100644 → 100755
Empty file.
149 changes: 149 additions & 0 deletions videos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
from logitech.g19 import G19
import time
import os
import random
import cv2
import ctypes
import subprocess
import signal
import sys
import thread

class AUDIOPLAYER:
def __init__(self):
pass

def play(self, path):
self.audio = subprocess.Popen(['mplayer', '-msglevel','all=-1', '-novideo', '-slave', path], stderr=subprocess.PIPE)

def stop(self):
self.audio.send_signal(2)


class COLOR:
def __init__(self, lg19):
self.lg19 = lg19

def userInput(self):
inp = raw_input()
val = inp.split(' ')
if len(val) != 3:
print 'Syntax Error. Combination is "255 0 0"'
return False
for i in val:
try:
j = int(i)
except:
print 'Needs integer {}'.format(i)
return False
if j<0 or j>255:
print 'Wrong color code {}'.format(j)
return False
self.value = val
return True

def setColor(self):
self.lg19.set_bg_color(int(self.value[0]), int(self.value[1]), int(self.value[2]))

def play(self):
print 'Enter rgb color in "255 128 128" format'
while True:
if self.userInput():
self.setColor()
print '[+] Settings applied'
else:
print '[-] Changes not applied'

class VIDEOPLAYER:
def __init__(self, lg19):
self.libc = ctypes.CDLL('libc.so.6')
self.lg19 = lg19


def play(self, path):
videoFile = cv2.VideoCapture(path)
nFrames = int(videoFile.get(cv2.CAP_PROP_FRAME_COUNT))
fps = videoFile.get(cv2.CAP_PROP_FPS)
frame_gap = 1/fps
uexpected_time = int(frame_gap * 1000000)
usleep = uexpected_time

for i in xrange(nFrames):
t1 = time.time()
self.libc.usleep(usleep)
try:
ret, frame = videoFile.read()
frame = cv2.resize(frame, (320, 240))
frame = cv2.transpose(frame)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2BGR565)
data = frame.flatten('C').tolist()
except:
return
self.lg19.send_frame(data)
t2 = time.time()
time_taken = t2-t1
utime_taken = int(time_taken*1000000)
uextra_time = utime_taken - uexpected_time
usleep = int(usleep - uextra_time)
if usleep < 1:
usleep = 1


class WALLPAPER:
def __init__(self, lg19):
self.lg19 = lg19

def load(self, path):
self.lg19.load_image(path)

class ROULETTE:
def __init__(self, path=''):
self.root = path

def pick(self, include_hidden=False, extension=''):
while True:
dirs = os.listdir(self.root)
pick = random.choice(dirs)
path = os.path.join(self.root, pick)
if os.path.isfile(path) and pick.endswith(extension):
if include_hidden==True or not pick.startswith('.'):
break
return path


if __name__=="__main__":
def signal_handler(signal, frame):
print('Quitting')
audio.stop()
sys.exit(0)

video_dir = '/home/sumit/data/multimedia/video/'
image_dir = 'wallpaper'
lg19 = G19()
audio = AUDIOPLAYER()
video = VIDEOPLAYER(lg19)
color = COLOR(lg19)
wallpaper = WALLPAPER(lg19)

thread.start_new_thread(color.play, ())
pick_video = ROULETTE(video_dir)
pick_image = ROULETTE(image_dir)


while True:
for i in range(0):
path = pick_image.pick()
try: wallpaper.load(path)
except: print path
time.sleep(5)

path = pick_video.pick()

try:
print '[>] {}'.format(path)
audio.play(path)
video.play(path)
except:
print '[*] {}'.format(path)
audio.stop()

66 changes: 66 additions & 0 deletions wallpaper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from logitech.g19 import G19
import os
import random
import time
import thread

class WALLPAPER:
def __init__(self, lg19):
self.imgPath = 'wallpaper'
self.timeout = 60
self.lg19 = lg19

def reloadImages(self):
self.files = os.listdir(self.imgPath)
random.shuffle(self.files,random.random)

def changeImages(self):
for image in self.files:
self.lg19.load_image(os.path.join(self.imgPath, image))
time.sleep(self.timeout)

def play(self):
while True:
self.reloadImages()
self.changeImages()

class COLOR:
def __init__(self, lg19):
self.lg19 = lg19

def userInput(self):
inp = raw_input()
val = inp.split(' ')
if len(val) != 3:
print 'Syntax Error. Combination is "255 255 255"'
return False
for i in val:
try:
j = int(i)
except:
print 'Needs integer %s' % (i)
return False
if j<0 or j>255:
print 'Wrong value for color %d' % (j)
return False
self.value = val
return True

def setColor(self):
self.lg19.set_bg_color(int(self.value[0]), int(self.value[1]), int(self.value[2]))

def play(self):
print 'Enter color in "255 0 0" format'
while True:
if self.userInput():
self.setColor()
print '[+] Settings applied'
else:
print '[-] Changes not applied'

if __name__=="__main__":
lg19 = G19()
wp = WALLPAPER(lg19)
thread.start_new_thread(wp.play, ())
cl = COLOR(lg19)
cl.play()
Binary file added wallpaper/9.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
147 changes: 147 additions & 0 deletions wallpaper2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
from logitech.g19 import G19
import time
import os
import random
import cv2
import ctypes
import subprocess
import signal
import sys
import thread
import random

class AUDIOPLAYER:
def __init__(self):
pass

def play(self, path):
self.audio = subprocess.Popen(['mplayer', '-msglevel','all=-1', '-novideo', '-slave', path], stderr=subprocess.PIPE)

def stop(self):
self.audio.send_signal(2)


class COLOR:
def __init__(self, lg19):
self.lg19 = lg19

def userInput(self):
inp = raw_input()
val = inp.split(' ')
if len(val) != 3:
print 'Syntax Error. Combination is "255 0 0"'
return False
for i in val:
try:
j = int(i)
except:
print 'Needs integer {}'.format(i)
return False
if j<0 or j>255:
print 'Wrong color code {}'.format(j)
return False
self.value = val
return True

def setColor(self):
self.lg19.set_bg_color(int(self.value[0]), int(self.value[1]), int(self.value[2]))

def play(self):
print 'Enter rgb color in "255 128 128" format'
while True:
if self.userInput():
self.setColor()
print '[+] Settings applied'
else:
print '[-] Changes not applied'

class VIDEOPLAYER:
def __init__(self, lg19):
self.libc = ctypes.CDLL('libc.so.6')
self.lg19 = lg19


def play(self, path):
videoFile = cv2.VideoCapture(path)
nFrames = int(videoFile.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT))
fps = videoFile.get(cv2.cv.CV_CAP_PROP_FPS)
frame_gap = 1/fps
uexpected_time = int(frame_gap * 1000000)
usleep = uexpected_time

for i in xrange(nFrames):
t1 = time.time()
self.libc.usleep(usleep)
try:
ret, frame = videoFile.read()
frame = cv2.resize(frame, (320, 240))
frame = cv2.transpose(frame)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2BGR565)
data = frame.flatten('C').tolist()
except:
return
self.lg19.send_frame(data)
t2 = time.time()
time_taken = t2-t1
utime_taken = int(time_taken*1000000)
uextra_time = utime_taken - uexpected_time
usleep = int(usleep - uextra_time)
if usleep < 1:
usleep = 1


class WALLPAPER:
def __init__(self, lg19):
self.lg19 = lg19

def load(self, path):
img = cv2.imread(path)
img = cv2.resize(img, (320, 240))
img = cv2.transpose(img)
img = cv2.cvtColor(img, cv2.COLOR_BGR2BGR565)
data = img.flatten('C').tolist()
self.lg19.send_frame(data)

class ROULETTE:
def __init__(self, path=''):
self.root = path

def pick(self, include_hidden=False, extension=''):
while True:
dirs = os.listdir(self.root)
pick = random.choice(dirs)
path = os.path.join(self.root, pick)
if os.path.isfile(path) and pick.endswith(extension):
if include_hidden==True or not pick.startswith('.'):
break
return path


if __name__=="__main__":
def signal_handler(signal, frame):
print('Quitting')
audio.stop()
sys.exit(0)

video_dir = '/home/sumit/data/My Passport/multimedia/video/'
image_dir = 'wallpaper'
lg19 = G19()
audio = AUDIOPLAYER()
video = VIDEOPLAYER(lg19)
color = COLOR(lg19)
wallpaper = WALLPAPER(lg19)

thread.start_new_thread(color.play, ())
pick_video = ROULETTE(video_dir)
pick_image = ROULETTE(image_dir)


while True:
sleep = random.randint(1, 20)
path = pick_image.pick()
try: wallpaper.load(path)
except: print path
time.sleep(sleep)