mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-05 16:00:06 +01:00
improved the dev mode switching and some other things
This commit is contained in:
22
actions.py
22
actions.py
@@ -2,6 +2,7 @@ import subprocess
|
||||
import tracemalloc
|
||||
import data_centre.length_setter as length_setter
|
||||
import sys
|
||||
import shlex
|
||||
import os
|
||||
from pythonosc import osc_message_builder
|
||||
from pythonosc import dispatcher
|
||||
@@ -26,6 +27,7 @@ class Actions(object):
|
||||
self.python_capture = self.capture = Capture(self.tk, self.message_handler, self.data)
|
||||
self.capture = None
|
||||
self.serial_port_process = None
|
||||
self.openframeworks_process = None
|
||||
self.set_capture_object('value')
|
||||
self.server = self.setup_osc_server()
|
||||
|
||||
@@ -347,16 +349,14 @@ class Actions(object):
|
||||
|
||||
def check_if_should_start_openframeworks(self):
|
||||
if self.data.settings['other']['VIDEO_BACKEND']['value'] == 'openframeworks':
|
||||
subprocess.Popen(["make run --directory=~/openFrameworks/apps/myApps/c_o_n_j_u_r" ], shell=True)
|
||||
|
||||
self.openframeworks_process = subprocess.Popen(['/home/pi/openFrameworks/apps/myApps/c_o_n_j_u_r/bin/c_o_n_j_u_r'])
|
||||
print('conjur pid is {}'.format(self.openframeworks_process.pid))
|
||||
def exit_openframeworks(self):
|
||||
self.video_driver.osc_client.send_message("/exit", True)
|
||||
|
||||
def toggle_of_screen_size(self, value):
|
||||
if value == 'dev':
|
||||
self.data.update_conjur_dev_mode(value)
|
||||
self.video_driver.osc_client.send_message("/dev_mode", True)
|
||||
else:
|
||||
self.video_driver.osc_client.send_message("/dev_mode", False)
|
||||
|
||||
def switch_video_backend(self, state):
|
||||
if state == 'openframeworks':
|
||||
@@ -450,6 +450,7 @@ class Actions(object):
|
||||
self.exit_openframeworks()
|
||||
self.exit_osc_server('','')
|
||||
self.stop_serial_port_process()
|
||||
self.stop_openframeworks_process()
|
||||
self.toggle_x_autorepeat()
|
||||
self.tk.destroy()
|
||||
|
||||
@@ -528,6 +529,17 @@ class Actions(object):
|
||||
self.serial_port_process.kill()
|
||||
self.serial_port_process = None
|
||||
|
||||
def restart_openframeworks(self):
|
||||
self.exit_openframeworks()
|
||||
self.stop_openframeworks_process()
|
||||
self.check_if_should_start_openframeworks()
|
||||
|
||||
def stop_openframeworks_process(self):
|
||||
if self.openframeworks_process is not None:
|
||||
print('killing process')
|
||||
self.openframeworks_process.kill()
|
||||
self.openframeworks_process = None
|
||||
|
||||
def try_pull_code_and_reset(self):
|
||||
#self.message_handler.set_message('INFO', 'checkin fo updates pls wait')
|
||||
recur_repo = git.Repo("~/r_e_c_u_r")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import json
|
||||
import xml.etree.ElementTree as ET
|
||||
import os
|
||||
from random import randint
|
||||
import inspect
|
||||
@@ -20,6 +21,7 @@ class Data(object):
|
||||
EMPTY_SLOT = dict(name='', location='', length=-1, start=-1, end=-1, rate=1)
|
||||
PATH_TO_DATA_OBJECTS = '/home/pi/r_e_c_u_r/json_objects/'
|
||||
PATH_TO_EXTERNAL_DEVICES = '/media/pi'
|
||||
PATH_TO_CONJUR_DATA = '/home/pi/openFrameworks/apps/myApps/c_o_n_j_u_r/bin/data/settings.xml'
|
||||
|
||||
def __init__(self, message_handler):
|
||||
self.message_handler = message_handler
|
||||
@@ -56,6 +58,7 @@ class Data(object):
|
||||
self.midi_mappings = self._read_json(self.MIDI_MAPPING_JSON)
|
||||
self.analog_mappings = self._read_json(self.ANALOG_MAPPING_JSON)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def create_empty_bank():
|
||||
empty_slot = dict(name='', location='', length=-1, start=-1, end=-1, rate=1)
|
||||
@@ -70,6 +73,13 @@ class Data(object):
|
||||
with open('{}{}'.format(self.PATH_TO_DATA_OBJECTS, file_name), 'w') as data_file:
|
||||
json.dump(data, data_file, indent=4, sort_keys=True)
|
||||
|
||||
def update_conjur_dev_mode(self, value):
|
||||
print(value)
|
||||
tree = ET.parse(self.PATH_TO_CONJUR_DATA)
|
||||
tag = tree.find("isDevMode")
|
||||
tag.text = str(int(value == 'dev'))
|
||||
tree.write(self.PATH_TO_CONJUR_DATA)
|
||||
|
||||
def get_setting_and_folder_from_name(self, setting_name):
|
||||
for folder_key , folder_item in self.settings.items():
|
||||
for setting_key, setting_item in folder_item.items():
|
||||
|
||||
@@ -163,6 +163,11 @@
|
||||
"options": [],
|
||||
"value": null
|
||||
},
|
||||
"RESTART_OPENFRAMEWORKS": {
|
||||
"action": "restart_openframeworks",
|
||||
"options": [],
|
||||
"value": null
|
||||
},
|
||||
"QUIT": {
|
||||
"action": "quit_the_program",
|
||||
"options": [],
|
||||
|
||||
@@ -128,7 +128,7 @@ class AltVideoPlayer:
|
||||
if self.rate is None:
|
||||
self.rate = 1
|
||||
|
||||
new_rate = amount #self.rate + amount
|
||||
new_rate = self.rate + amount
|
||||
print('new rate is being set to {}'.format(new_rate))
|
||||
if new_rate >= -3 and new_rate <= 3:
|
||||
self.client.send_message("/player/{}/speed".format(self.name[0]), new_rate)
|
||||
|
||||
Reference in New Issue
Block a user