Skip to content

Commit

Permalink
updated documentation and implemented bpodgui plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
UmSenhorQualquer committed Oct 23, 2017
1 parent beab44b commit 712133c
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 10 deletions.
Binary file added docs/source/_static/pybpod-gui-menu.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions docs/source/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,22 @@ Configure the using the GUI
.. image:: /_static/rotary-encoder-module.png
:scale: 100 %


Add the Rotary Plugin to the PyBpod-GUI
================================================


In the GUI settings add the next configuration to the list of plugins

.. code:: python
GENERIC_EDITOR_PLUGINS_LIST = [
...
'pybpod_rotaryencoder_module',
]
After open the PyBpod-GUI a access the plugin in the Tools menu.

.. image:: /_static/pybpod-gui-menu.png
:scale: 100 %
6 changes: 6 additions & 0 deletions pybpod_rotaryencoder_module/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@
__email__ = ['ricardojvr@gmail.com']
__status__ = "Development"

__version__ = "0"

from pysettings import conf

conf += 'pybpod_rotaryencoder_module.settings'

from pybpod_rotaryencoder_module.module import RotaryEncoder as BpodModule
Empty file.
1 change: 1 addition & 0 deletions pybpod_rotaryencoder_module/models/projects/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from pybpod_rotaryencoder_module.models.projects.projects_rotaryencoder import ProjectsRotaryEncoder as Projects
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# !/usr/bin/python3
# -*- coding: utf-8 -*-
from pysettings import conf
if conf.PYFORMS_USE_QT5:
from PyQt5.QtGui import QIcon
else:
from PyQt4.QtGui import QIcon

from pybpod_rotaryencoder_module.module_gui import RotaryEncoderModuleGUI

class ProjectsRotaryEncoder(object):

def register_on_main_menu(self, mainmenu):
super(ProjectsRotaryEncoder, self).register_on_main_menu(mainmenu)

if len([m for m in mainmenu if 'Tools' in m.keys()]) == 0:
mainmenu.append({'Tools': []})

menu_index = 0
for i, m in enumerate(mainmenu):
if 'Tools' in m.keys(): menu_index=i; break

mainmenu[menu_index]['Tools'].append( '-' )
mainmenu[menu_index]['Tools'].append( {'Rotary encoder': self.open_rotaryencoder_plugin, 'icon': QIcon(conf.ROTARYENCODER_PLUGIN_ICON)} )

def open_rotaryencoder_plugin(self):
if not hasattr(self, 'rotaryencoder_plugin'):
self.rotaryencoder_plugin = RotaryEncoderModuleGUI(self)
self.rotaryencoder_plugin.show()
self.rotaryencoder_plugin.subwindow.resize(*conf.ROTARYENCODER_PLUGIN_WINDOW_SIZE)
else:
self.rotaryencoder_plugin.show()

return self.rotaryencoder_plugin
29 changes: 19 additions & 10 deletions pybpod_rotaryencoder_module/module_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
from pysettings import conf
if conf.PYFORMS_USE_QT5:
from PyQt5.QtCore import QTimer, QEventLoop
from PyQt5.QtWidgets import QMessageBox
else:
from PyQt4.QtCore import QTimer, QEventLoop
from PyQt4.QtGui import QMessageBox


class RotaryEncoderModuleGUI(RotaryEncoderModule, BaseWidget):

TITLE = 'Rotary encoder module'

def __init__(self):
BaseWidget.__init__(self, self.TITLE)
def __init__(self, parent_win=None):
BaseWidget.__init__(self, self.TITLE, parent_win=parent_win)
RotaryEncoderModule.__init__(self)

self._port = ControlText('Serial port', '/dev/ttyACM1')
Expand Down Expand Up @@ -129,14 +132,20 @@ def __toggle_connection_evt(self):
self._thresh_lower.enabled = False
self._thresh_upper.enabled = False
else:
self.open(self._port.value)
self._connect_btn.label = 'Connected'
self._stream.enabled = True
self._events.enabled = True
self._zero_btn.enabled = True
self._reset_threshs.enabled = True
self._thresh_lower.enabled = True
self._thresh_upper.enabled = True
try:
self.open(self._port.value)

self._connect_btn.label = 'Connected'
self._stream.enabled = True
self._events.enabled = True
self._zero_btn.enabled = True
self._reset_threshs.enabled = True
self._thresh_lower.enabled = True
self._thresh_upper.enabled = True
except Exception as err:
QMessageBox.critical(self, "Error", str(err))
self._connect_btn.checked = False




Expand Down
Binary file added pybpod_rotaryencoder_module/resources/rotary.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions pybpod_rotaryencoder_module/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import os


ROTARYENCODER_PLUGIN_ICON = os.path.join( os.path.dirname(__file__), 'resources', 'rotary.png' )


ROTARYENCODER_PLUGIN_WINDOW_SIZE = 300, 500

2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@

include_package_data=True,
packages=find_packages(),

package_data={'pybpod_rotaryencoder_module': ['resources/*.*',]}
)

0 comments on commit 712133c

Please sign in to comment.