Skip to content

Commit

Permalink
Merge pull request #16 from Aharoni-Lab/dev-usb
Browse files Browse the repository at this point in the history
Dev usb
  • Loading branch information
daharoni authored Aug 31, 2020
2 parents e42af8c + f291b81 commit ced5094
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 16 deletions.
6 changes: 4 additions & 2 deletions source/Miniscope-DAQ-QT-Software.pro
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =

# Add Icon
RC_ICONS = miniscope_icon.ico

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
Expand Down Expand Up @@ -64,8 +66,8 @@ win32 {
# #DEPENDPATH +=

# For libusb
LIBS += -LC:/libusb-1.0.23/MS64/dll/ -llibusb-1.0
INCLUDEPATH += C:/libusb-1.0.23/include/libusb-1.0
# LIBS += -LC:/libusb-1.0.23/MS64/dll/ -llibusb-1.0
# INCLUDEPATH += C:/libusb-1.0.23/include/libusb-1.0

} else {
CONFIG += link_pkgconfig
Expand Down
19 changes: 19 additions & 0 deletions source/Miniscope_V4_BNO.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Item {
signal vidPropChangedSignal(string name, double displayValue, double i2cValue, double i2cValue2)
signal takeScreenShotSignal()
signal dFFSwitchChanged(bool value)
signal saturationSwitchChanged(bool value)

Keys.onPressed: {
if (event.key === Qt.Key_H) {
Expand Down Expand Up @@ -89,6 +90,20 @@ Item {
Layout.row: 0
}

Switch {
id: saturationSwitch
objectName: "saturationSwitch"
text: qsTr("Show Saturation")
hoverEnabled: false

font.bold: true
font.family: "Arial"
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
Layout.column: 2
Layout.row: 0

}

Text{
id: droppedFrameCount
objectName: "droppedFrameCount"
Expand Down Expand Up @@ -274,6 +289,10 @@ Item {
target: dFFSwitch
onClicked: dFFSwitchChanged(dFFSwitch.checked)
}
Connections{
target: saturationSwitch
onClicked: saturationSwitchChanged(saturationSwitch.checked)
}

states: [
State{
Expand Down
2 changes: 1 addition & 1 deletion source/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "datasaver.h"
#include "behaviortracker.h"

#include <libusb.h>
//#include <libusb.h>

//#define DEBUG

Expand Down
22 changes: 21 additions & 1 deletion source/behaviorCam.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Item {
signal calibrateCameraStart()
signal calibrateCameraQuit()

signal saturationSwitchChanged(bool value)

Keys.onPressed: {
if (event.key === Qt.Key_H) {
if (root.state == "controlsShown")
Expand Down Expand Up @@ -211,7 +213,7 @@ Item {
font.bold: true
font.weight: Font.Normal
radius: 4
enabled: true
enabled: false
Layout.column: 0
Layout.row: 0
// TODO: Make hovering color change work.
Expand All @@ -230,6 +232,19 @@ Item {
}
}

Switch {
id: saturationSwitch
objectName: "saturationSwitch"
text: qsTr("Show Saturation")
hoverEnabled: false

font.bold: true
font.family: "Arial"
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
Layout.column: 2
Layout.row: 0
}

Text{
id: droppedFrameCount
objectName: "droppedFrameCount"
Expand Down Expand Up @@ -323,6 +338,7 @@ Item {
font.weight: Font.Normal
radius: 4
enabled: true
visible: false
background: Rectangle {
id: camPropsRect
radius: camProps.radius
Expand Down Expand Up @@ -427,6 +443,10 @@ Item {
target: beta
onValueChangedSignal: vidPropChangedSignal(beta.objectName, displayValue, i2cValue, i2cValue2)
}
Connections{
target: saturationSwitch
onClicked: saturationSwitchChanged(saturationSwitch.checked)
}


states: [
Expand Down
20 changes: 17 additions & 3 deletions source/behaviorcam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,24 @@ void BehaviorCam::createView()
// --------------------

rootObject = view->rootObject();

QObject::connect(rootObject, SIGNAL( saturationSwitchChanged(bool) ),
this, SLOT( handleSaturationSwitchChanged(bool) ));

configureBehavCamControls();
vidDisplay = rootObject->findChild<VideoDisplay*>("vD");
vidDisplay->setMaxBuffer(FRAME_BUFFER_SIZE);
vidDisplay->setWindowScaleValue(m_ucBehavCam["windowScale"].toDouble(1));

// Turn on or off saturation display
if (m_ucBehavCam["showSaturation"].toBool(false))
if (m_ucBehavCam["showSaturation"].toBool(false)) {
vidDisplay->setShowSaturation(1);
else
rootObject->findChild<QQuickItem*>("saturationSwitch")->setProperty("checked", true);
}
else {
vidDisplay->setShowSaturation(0);
rootObject->findChild<QQuickItem*>("saturationSwitch")->setProperty("checked", false);
}

QObject::connect(rootObject, SIGNAL( takeScreenShotSignal() ),
this, SLOT( handleTakeScreenShotSignal() ));
Expand All @@ -158,6 +166,7 @@ void BehaviorCam::createView()

// Open OpenCV properties dialog for behav cam
if (!isMiniCAM) {
rootObject->findChild<QQuickItem*>("camProps")->setProperty("visible", true);
QObject::connect(rootObject, SIGNAL( camPropsClicked() ), this, SLOT( handleCamPropsClicked()));
QObject::connect(this, SIGNAL( openCamPropsDialog()), behavCamStream, SLOT( openCamPropsDialog()));
}
Expand Down Expand Up @@ -445,7 +454,7 @@ void BehaviorCam::sendNewFrame(){
else
tempFrame2 = QImage(frameBuffer[f].data, frameBuffer[f].cols, frameBuffer[f].rows, frameBuffer[f].step, QImage::Format_RGB888);

vidDisplay->setDisplayFrame(tempFrame2.copy());
vidDisplay->setDisplayFrame(tempFrame2);

vidDisplay->setBufferUsed(usedFrames->available());
if (f > 0) // This is just a quick cheat so I don't have to wrap around for (f-1)
Expand Down Expand Up @@ -617,3 +626,8 @@ void BehaviorCam::handleInitCommandsRequest()
qDebug() << "Reinitializing device.";
sendInitCommands();
}

void BehaviorCam::handleSaturationSwitchChanged(bool checked)
{
vidDisplay->setShowSaturation(checked);
}
1 change: 1 addition & 0 deletions source/behaviorcam.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public slots:
void handleTakeScreenShotSignal();
void close();
void handleInitCommandsRequest();
void handleSaturationSwitchChanged(bool checked);

void handleCamPropsClicked() { emit openCamPropsDialog();}
void handleSetRoiClicked();
Expand Down
2 changes: 1 addition & 1 deletion source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "backend.h"

#define VERSION_NUMBER "0.200"
#define VERSION_NUMBER "1.00"
// TODO: have exit button close everything

// For Window's deployment
Expand Down
3 changes: 2 additions & 1 deletion source/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ Window {
"Your OpenGL verions: " + OpenGLInfo.majorVersion + "." + OpenGLInfo.minorVersion + "<br/>" +
"Developed by the <a href='https://aharoni-lab.github.io/'>Aharoni Lab</a>, UCLA <br/> " +
"Overview of the UCLA Miniscope project: <a href='http://www.miniscope.org'>click here</a> <br/>" +
"Miniscope Wiki for newest projects: <a href='https://github.com/Aharoni-Lab/Miniscope-v4/wiki'>click here</a> <br/>" +
"Miniscope Discussion Board: <a href='https://groups.google.com/d/forum/miniscope'>click here</a> <br/>" +
"Please submit issues, comments, suggestions to the Miniscope DAQ Software Github Repositories: <a href='https://github.com/Aharoni-Lab/Miniscope-DAQ-QT-Software'>click here</a> <br/>" +
"Please submit issues, comments, suggestions to the Miniscope DAQ Software Github Repository: <a href='https://github.com/Aharoni-Lab/Miniscope-DAQ-QT-Software'>click here</a> <br/>" +
"Miniscope Twitter Link: <a href='https://twitter.com/MiniscopeTeam'>click here</a> <br/> <br/>" +
"Icons from <a href='https://icons8.com/'>icon8</a>"
verticalAlignment: Text.AlignVCenter
Expand Down
17 changes: 14 additions & 3 deletions source/miniscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,23 @@ void Miniscope::createView()
this, SLOT( handlePropChangedSignal(QString, double, double, double) ));
QObject::connect(rootObject, SIGNAL( dFFSwitchChanged(bool) ),
this, SLOT( handleDFFSwitchChange(bool) ));
QObject::connect(rootObject, SIGNAL( saturationSwitchChanged(bool) ),
this, SLOT( handleSaturationSwitchChanged(bool) ));

configureMiniscopeControls();
vidDisplay = rootObject->findChild<VideoDisplay*>("vD");
vidDisplay->setMaxBuffer(FRAME_BUFFER_SIZE);
vidDisplay->setWindowScaleValue(m_ucMiniscope["windowScale"].toDouble(1));

// Turn on or off show saturation display
if (m_ucMiniscope["showSaturation"].toBool(false))
if (m_ucMiniscope["showSaturation"].toBool(false)) {
vidDisplay->setShowSaturation(1);
else
rootObject->findChild<QQuickItem*>("saturationSwitch")->setProperty("checked", true);
}
else {
vidDisplay->setShowSaturation(0);
rootObject->findChild<QQuickItem*>("saturationSwitch")->setProperty("checked", false);
}

if (m_headOrientationStreamState)
bnoDisplay = rootObject->findChild<QQuickItem*>("bno");
Expand Down Expand Up @@ -479,7 +485,7 @@ void Miniscope::sendNewFrame(){

// vidDisplay->setDisplayFrame(tempFrame2.copy());
// TODO: Check to see if we can get rid of .copy() here
vidDisplay->setDisplayFrame(tempFrame2.copy());
vidDisplay->setDisplayFrame(tempFrame2);
}
else if (m_displatState == "dFF") {
// TODO: Implement this better. I am sure it can be sped up a lot. Maybe do most of it in a shader
Expand Down Expand Up @@ -631,6 +637,11 @@ void Miniscope::handleDFFSwitchChange(bool checked)
m_displatState = "Raw";
}

void Miniscope::handleSaturationSwitchChanged(bool checked)
{
vidDisplay->setShowSaturation(checked);
}

void Miniscope::handleSetExtTriggerTrackingState(bool state)
{
m_extTriggerTrackingState = state;
Expand Down
1 change: 1 addition & 0 deletions source/miniscope.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public slots:
void handlePropChangedSignal(QString type, double displayValue, double i2cValue, double i2cValue2);
void handleTakeScreenShotSignal();
void handleDFFSwitchChange(bool checked);
void handleSaturationSwitchChanged(bool checked);
void handleSetExtTriggerTrackingState(bool state);
void handleRecordStart(); // Currently used to toggle LED on and off
void handleRecordStop(); // Currently used to toggle LED on and off
Expand Down
Binary file added source/miniscope_icon.ico
Binary file not shown.
4 changes: 2 additions & 2 deletions userConfigs/UserConfigExample_Dual_MiniCAM_PLUS_V4.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
{
"deviceName": "MiniCAM1",
"deviceType": "Minicam-Mono-XGA",
"deviceID": 2,
"deviceID": 3,
"showSaturation": true,
"ROI": {
"notes": "This defines the bounding box of the portion of the video that is saved to disk",
Expand Down Expand Up @@ -75,7 +75,7 @@
"filterBadData": true
},
"streamHeadOrientation_OLD": true,
"deviceID": 3,
"deviceID": 0,
"showSaturation": true,
"compressionOptions": ["MJPG","MJ2C","XVID","FFV1"],
"compression": "FFV1",
Expand Down
2 changes: 1 addition & 1 deletion userConfigs/UserConfigExample_MiniCAM.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"deviceName": "MiniCAM0",
"deviceType": "Minicam-Mono-XGA",
"deviceID": 2,
"deviceID": 1,
"showSaturation": true,
"ROI": {
"notes": "This defines the bounding box of the portion of the video that is saved to disk",
Expand Down
2 changes: 1 addition & 1 deletion userConfigs/UserConfigExample_V4_BNO_Miniscope.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"filterBadData": true
},
"streamHeadOrientation_OLD": true,
"deviceID": 1,
"deviceID": 0,
"showSaturation": true,
"compressionOptions": ["MJPG","MJ2C","XVID","FFV1"],
"compression": "FFV1",
Expand Down

0 comments on commit ced5094

Please sign in to comment.