No changes between revisions
/Designs/Tools/Oscilloscope/SW/PC_side/gnuradio/ARM_QTgui.grc
0,0 → 1,211
<?xml version='1.0' encoding='ASCII'?>
<flow_graph>
<timestamp>Sat Nov 12 20:35:22 2011</timestamp>
<block>
<key>options</key>
<param>
<key>id</key>
<value>top_block</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>title</key>
<value></value>
</param>
<param>
<key>author</key>
<value></value>
</param>
<param>
<key>description</key>
<value></value>
</param>
<param>
<key>window_size</key>
<value>1280, 1024</value>
</param>
<param>
<key>generate_options</key>
<value>qt_gui</value>
</param>
<param>
<key>category</key>
<value>Custom</value>
</param>
<param>
<key>run_options</key>
<value>prompt</value>
</param>
<param>
<key>run</key>
<value>True</value>
</param>
<param>
<key>realtime_scheduling</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(10, 10)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>variable</key>
<param>
<key>id</key>
<value>samp_rate</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>value</key>
<value>250000</value>
</param>
<param>
<key>_coordinate</key>
<value>(14, 171)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>gr_file_source</key>
<param>
<key>id</key>
<value>gr_file_source_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>file</key>
<value>/dev/ttyUSB0</value>
</param>
<param>
<key>type</key>
<value>short</value>
</param>
<param>
<key>repeat</key>
<value>True</value>
</param>
<param>
<key>vlen</key>
<value>1</value>
</param>
<param>
<key>_coordinate</key>
<value>(71, 385)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>gr_short_to_float</key>
<param>
<key>id</key>
<value>gr_short_to_float_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>_coordinate</key>
<value>(397, 317)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>qtgui_sink_x</key>
<param>
<key>id</key>
<value>qtgui_sink_x_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>type</key>
<value>float</value>
</param>
<param>
<key>name</key>
<value>QT GUI Plot</value>
</param>
<param>
<key>fftsize</key>
<value>1024</value>
</param>
<param>
<key>wintype</key>
<value>firdes.WIN_BLACKMAN_hARRIS</value>
</param>
<param>
<key>fc</key>
<value>0</value>
</param>
<param>
<key>bw</key>
<value>samp_rate</value>
</param>
<param>
<key>plotfreq</key>
<value>True</value>
</param>
<param>
<key>plotwaterfall</key>
<value>True</value>
</param>
<param>
<key>plottime</key>
<value>True</value>
</param>
<param>
<key>plotconst</key>
<value>True</value>
</param>
<param>
<key>gui_hint</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(664, 226)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<connection>
<source_block_id>gr_file_source_0</source_block_id>
<sink_block_id>gr_short_to_float_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>gr_short_to_float_0</source_block_id>
<sink_block_id>qtgui_sink_x_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
</flow_graph>
/Designs/Tools/Oscilloscope/SW/PC_side/gnuradio/ARM_WX_scope.grc
0,0 → 1,223
<?xml version='1.0' encoding='ASCII'?>
<flow_graph>
<timestamp>Sat Nov 12 20:32:46 2011</timestamp>
<block>
<key>options</key>
<param>
<key>id</key>
<value>top_block</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>title</key>
<value></value>
</param>
<param>
<key>author</key>
<value></value>
</param>
<param>
<key>description</key>
<value></value>
</param>
<param>
<key>window_size</key>
<value>1280, 1024</value>
</param>
<param>
<key>generate_options</key>
<value>wx_gui</value>
</param>
<param>
<key>category</key>
<value>Custom</value>
</param>
<param>
<key>run_options</key>
<value>prompt</value>
</param>
<param>
<key>run</key>
<value>True</value>
</param>
<param>
<key>realtime_scheduling</key>
<value></value>
</param>
<param>
<key>_coordinate</key>
<value>(10, 10)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>variable</key>
<param>
<key>id</key>
<value>samp_rate</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>value</key>
<value>250000</value>
</param>
<param>
<key>_coordinate</key>
<value>(10, 170)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>gr_file_source</key>
<param>
<key>id</key>
<value>gr_file_source_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>file</key>
<value>/dev/ttyUSB0</value>
</param>
<param>
<key>type</key>
<value>short</value>
</param>
<param>
<key>repeat</key>
<value>True</value>
</param>
<param>
<key>vlen</key>
<value>1</value>
</param>
<param>
<key>_coordinate</key>
<value>(72, 385)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>gr_short_to_float</key>
<param>
<key>id</key>
<value>gr_short_to_float_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>_coordinate</key>
<value>(383, 350)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<block>
<key>wxgui_scopesink2</key>
<param>
<key>id</key>
<value>wxgui_scopesink2_0</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>type</key>
<value>float</value>
</param>
<param>
<key>title</key>
<value>Scope Plot</value>
</param>
<param>
<key>samp_rate</key>
<value>samp_rate</value>
</param>
<param>
<key>v_scale</key>
<value>0</value>
</param>
<param>
<key>v_offset</key>
<value>0</value>
</param>
<param>
<key>t_scale</key>
<value>0</value>
</param>
<param>
<key>ac_couple</key>
<value>False</value>
</param>
<param>
<key>xy_mode</key>
<value>False</value>
</param>
<param>
<key>num_inputs</key>
<value>1</value>
</param>
<param>
<key>win_size</key>
<value></value>
</param>
<param>
<key>grid_pos</key>
<value></value>
</param>
<param>
<key>notebook</key>
<value></value>
</param>
<param>
<key>trig_mode</key>
<value>gr.gr_TRIG_MODE_AUTO</value>
</param>
<param>
<key>y_axis_label</key>
<value>Counts</value>
</param>
<param>
<key>_coordinate</key>
<value>(671, 292)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
</block>
<connection>
<source_block_id>gr_file_source_0</source_block_id>
<sink_block_id>gr_short_to_float_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>gr_short_to_float_0</source_block_id>
<sink_block_id>wxgui_scopesink2_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
</flow_graph>
/Designs/Tools/Oscilloscope/SW/PC_side/gnuradio/setup_serial.sh
0,0 → 1,4
#!/bin/bash
stty -F /dev/ttyUSB0 igncr -echo onocr icrnl speed 1000000
 
#stty -F /dev/ttyUSB0 3000000
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/Designs/Tools/Oscilloscope/SW/PC_side/gnuradio/top_block.py
0,0 → 1,84
#!/usr/bin/env python
##################################################
# Gnuradio Python Flow Graph
# Title: Top Block
# Generated: Sat Nov 12 20:35:22 2011
##################################################
 
from PyQt4 import Qt
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio.eng_option import eng_option
from gnuradio.gr import firdes
from gnuradio.qtgui import qtgui
from optparse import OptionParser
import sip
import sys
 
class top_block(gr.top_block, Qt.QWidget):
 
def __init__(self):
gr.top_block.__init__(self, "Top Block")
Qt.QWidget.__init__(self)
self.setWindowTitle("Top Block")
self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
self.top_scroll_layout = Qt.QVBoxLayout()
self.setLayout(self.top_scroll_layout)
self.top_scroll = Qt.QScrollArea()
self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
self.top_scroll_layout.addWidget(self.top_scroll)
self.top_scroll.setWidgetResizable(True)
self.top_widget = Qt.QWidget()
self.top_scroll.setWidget(self.top_widget)
self.top_layout = Qt.QVBoxLayout(self.top_widget)
self.top_grid_layout = Qt.QGridLayout()
self.top_layout.addLayout(self.top_grid_layout)
 
 
##################################################
# Variables
##################################################
self.samp_rate = samp_rate = 250000
 
##################################################
# Blocks
##################################################
self.qtgui_sink_x_0 = qtgui.sink_f(
1024, #fftsize
firdes.WIN_BLACKMAN_hARRIS, #wintype
0, #fc
samp_rate, #bw
"QT GUI Plot", #name
True, #plotfreq
True, #plotwaterfall
True, #plottime
True, #plotconst
)
self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
self.top_layout.addWidget(self._qtgui_sink_x_0_win)
self.gr_short_to_float_0 = gr.short_to_float()
self.gr_file_source_0 = gr.file_source(gr.sizeof_short*1, "/dev/ttyUSB0", True)
 
##################################################
# Connections
##################################################
self.connect((self.gr_file_source_0, 0), (self.gr_short_to_float_0, 0))
self.connect((self.gr_short_to_float_0, 0), (self.qtgui_sink_x_0, 0))
 
def get_samp_rate(self):
return self.samp_rate
 
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.qtgui_sink_x_0.set_frequency_range(0, self.samp_rate)
 
if __name__ == '__main__':
parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
(options, args) = parser.parse_args()
qapp = Qt.QApplication(sys.argv)
tb = top_block()
tb.start()
tb.show()
qapp.exec_()
tb.stop()
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/Designs/Tools/Oscilloscope/SW/PC_side/qscope/Makefile
0,0 → 1,215
#############################################################################
# Makefile for building: qscope
# Generated by qmake (2.01a) (Qt 4.7.4) on: so 11 12 19:21:14 2011
# Project: qscope.pro
# Template: app
# Command: /usr/bin/qmake -o Makefile qscope.pro
#############################################################################
 
####### Compiler, tools and options
 
CC = gcc
CXX = g++
DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I.
LINK = g++
LFLAGS = -m64 -Wl,-O1
LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread
AR = ar cqs
RANLIB =
QMAKE = /usr/bin/qmake
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
SED = sed
COPY_FILE = $(COPY)
COPY_DIR = $(COPY) -r
STRIP = strip
INSTALL_FILE = install -m 644 -p
INSTALL_DIR = $(COPY_DIR)
INSTALL_PROGRAM = install -m 755 -p
DEL_FILE = rm -f
SYMLINK = ln -f -s
DEL_DIR = rmdir
MOVE = mv -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
 
####### Output directory
 
OBJECTS_DIR = ./
 
####### Files
 
SOURCES = main.cpp \
scope.cpp moc_scope.cpp
OBJECTS = main.o \
scope.o \
moc_scope.o
DIST = /usr/share/qt4/mkspecs/common/g++.conf \
/usr/share/qt4/mkspecs/common/unix.conf \
/usr/share/qt4/mkspecs/common/linux.conf \
/usr/share/qt4/mkspecs/qconfig.pri \
/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \
/usr/share/qt4/mkspecs/features/qt_functions.prf \
/usr/share/qt4/mkspecs/features/qt_config.prf \
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
/usr/share/qt4/mkspecs/features/default_pre.prf \
/usr/share/qt4/mkspecs/features/release.prf \
/usr/share/qt4/mkspecs/features/default_post.prf \
/usr/share/qt4/mkspecs/features/warn_on.prf \
/usr/share/qt4/mkspecs/features/qt.prf \
/usr/share/qt4/mkspecs/features/unix/thread.prf \
/usr/share/qt4/mkspecs/features/moc.prf \
/usr/share/qt4/mkspecs/features/resources.prf \
/usr/share/qt4/mkspecs/features/uic.prf \
/usr/share/qt4/mkspecs/features/yacc.prf \
/usr/share/qt4/mkspecs/features/lex.prf \
/usr/share/qt4/mkspecs/features/include_source_dir.prf \
qscope.pro
QMAKE_TARGET = qscope
DESTDIR =
TARGET = qscope
 
first: all
####### Implicit rules
 
.SUFFIXES: .o .c .cpp .cc .cxx .C
 
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
 
.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
 
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
 
.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
 
.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
 
####### Build rules
 
all: Makefile $(TARGET)
 
$(TARGET): $(OBJECTS)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
 
Makefile: qscope.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \
/usr/share/qt4/mkspecs/common/unix.conf \
/usr/share/qt4/mkspecs/common/linux.conf \
/usr/share/qt4/mkspecs/qconfig.pri \
/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \
/usr/share/qt4/mkspecs/features/qt_functions.prf \
/usr/share/qt4/mkspecs/features/qt_config.prf \
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
/usr/share/qt4/mkspecs/features/default_pre.prf \
/usr/share/qt4/mkspecs/features/release.prf \
/usr/share/qt4/mkspecs/features/default_post.prf \
/usr/share/qt4/mkspecs/features/warn_on.prf \
/usr/share/qt4/mkspecs/features/qt.prf \
/usr/share/qt4/mkspecs/features/unix/thread.prf \
/usr/share/qt4/mkspecs/features/moc.prf \
/usr/share/qt4/mkspecs/features/resources.prf \
/usr/share/qt4/mkspecs/features/uic.prf \
/usr/share/qt4/mkspecs/features/yacc.prf \
/usr/share/qt4/mkspecs/features/lex.prf \
/usr/share/qt4/mkspecs/features/include_source_dir.prf \
/usr/lib/x86_64-linux-gnu/libQtGui.prl \
/usr/lib/x86_64-linux-gnu/libQtCore.prl
$(QMAKE) -o Makefile qscope.pro
/usr/share/qt4/mkspecs/common/g++.conf:
/usr/share/qt4/mkspecs/common/unix.conf:
/usr/share/qt4/mkspecs/common/linux.conf:
/usr/share/qt4/mkspecs/qconfig.pri:
/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri:
/usr/share/qt4/mkspecs/features/qt_functions.prf:
/usr/share/qt4/mkspecs/features/qt_config.prf:
/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
/usr/share/qt4/mkspecs/features/default_pre.prf:
/usr/share/qt4/mkspecs/features/release.prf:
/usr/share/qt4/mkspecs/features/default_post.prf:
/usr/share/qt4/mkspecs/features/warn_on.prf:
/usr/share/qt4/mkspecs/features/qt.prf:
/usr/share/qt4/mkspecs/features/unix/thread.prf:
/usr/share/qt4/mkspecs/features/moc.prf:
/usr/share/qt4/mkspecs/features/resources.prf:
/usr/share/qt4/mkspecs/features/uic.prf:
/usr/share/qt4/mkspecs/features/yacc.prf:
/usr/share/qt4/mkspecs/features/lex.prf:
/usr/share/qt4/mkspecs/features/include_source_dir.prf:
/usr/lib/x86_64-linux-gnu/libQtGui.prl:
/usr/lib/x86_64-linux-gnu/libQtCore.prl:
qmake: FORCE
@$(QMAKE) -o Makefile qscope.pro
 
dist:
@$(CHK_DIR_EXISTS) .tmp/qscope1.0.0 || $(MKDIR) .tmp/qscope1.0.0
$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/qscope1.0.0/ && $(COPY_FILE) --parents scope.h .tmp/qscope1.0.0/ && $(COPY_FILE) --parents main.cpp scope.cpp .tmp/qscope1.0.0/ && (cd `dirname .tmp/qscope1.0.0` && $(TAR) qscope1.0.0.tar qscope1.0.0 && $(COMPRESS) qscope1.0.0.tar) && $(MOVE) `dirname .tmp/qscope1.0.0`/qscope1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/qscope1.0.0
 
 
clean:compiler_clean
-$(DEL_FILE) $(OBJECTS)
-$(DEL_FILE) *~ core *.core
 
 
####### Sub-libraries
 
distclean: clean
-$(DEL_FILE) $(TARGET)
-$(DEL_FILE) Makefile
 
 
check: first
 
mocclean: compiler_moc_header_clean compiler_moc_source_clean
 
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
 
compiler_moc_header_make_all: moc_scope.cpp
compiler_moc_header_clean:
-$(DEL_FILE) moc_scope.cpp
moc_scope.cpp: scope.h
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) scope.h -o moc_scope.cpp
 
compiler_rcc_make_all:
compiler_rcc_clean:
compiler_image_collection_make_all: qmake_image_collection.cpp
compiler_image_collection_clean:
-$(DEL_FILE) qmake_image_collection.cpp
compiler_moc_source_make_all:
compiler_moc_source_clean:
compiler_uic_make_all:
compiler_uic_clean:
compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
compiler_yacc_impl_make_all:
compiler_yacc_impl_clean:
compiler_lex_make_all:
compiler_lex_clean:
compiler_clean: compiler_moc_header_clean
 
####### Compile
 
main.o: main.cpp scope.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
 
scope.o: scope.cpp scope.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o scope.o scope.cpp
 
moc_scope.o: moc_scope.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_scope.o moc_scope.cpp
 
####### Install
 
install: FORCE
 
uninstall: FORCE
 
FORCE:
 
/Designs/Tools/Oscilloscope/SW/PC_side/qscope/qscope
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:executable
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/Designs/Tools/Oscilloscope/SW/PC_side/qscope/main.cpp
0,0 → 1,33
// qscope, Roman Pavelka, 2011
 
#include <QApplication>
#include <QPushButton>
#include <QVBoxLayout>
 
#include "scope.h"
 
class Window : public QWidget
{
public:
Window(QWidget *parent = 0);
};
 
Window::Window(QWidget *parent)
: QWidget(parent)
{
Scope *scope = new Scope;
 
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(scope);
setLayout(layout);
}
 
 
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Window window;
window.setGeometry(500, 100, 460, 740);
window.show();
return app.exec();
}
/Designs/Tools/Oscilloscope/SW/PC_side/qscope/moc_scope.cpp
0,0 → 1,84
/****************************************************************************
** Meta object code from reading C++ file 'scope.h'
**
** Created: Mon Aug 15 00:34:35 2011
** by: The Qt Meta Object Compiler version 62 (Qt 4.7.2)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
 
#include "scope.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'scope.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 62
#error "This file was generated using the moc from 4.7.2. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
 
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_Scope[] = {
 
// content:
5, // revision
0, // classname
0, 0, // classinfo
3, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
 
// slots: signature, parameters, type, tag, flags
7, 6, 6, 6, 0x0a,
21, 17, 6, 6, 0x0a,
35, 17, 6, 6, 0x0a,
 
0 // eod
};
 
static const char qt_meta_stringdata_Scope[] = {
"Scope\0\0getData()\0val\0setScale(int)\0"
"setShift(int)\0"
};
 
const QMetaObject Scope::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_Scope,
qt_meta_data_Scope, 0 }
};
 
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &Scope::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
 
const QMetaObject *Scope::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
 
void *Scope::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_Scope))
return static_cast<void*>(const_cast< Scope*>(this));
return QWidget::qt_metacast(_clname);
}
 
int Scope::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: getData(); break;
case 1: setScale((*reinterpret_cast< int(*)>(_a[1]))); break;
case 2: setShift((*reinterpret_cast< int(*)>(_a[1]))); break;
default: ;
}
_id -= 3;
}
return _id;
}
QT_END_MOC_NAMESPACE
/Designs/Tools/Oscilloscope/SW/PC_side/qscope/scope.cpp
0,0 → 1,151
#include "scope.h"
 
#include <QPainter>
#include <QString>
 
#include <iostream>
#include <stdio.h>
 
using namespace std;
 
void UI(void);
 
Scope::Scope(QWidget *parent) { // CONSTRUCTOR, graphic stuff
dataAquired=0;
 
// data=new int[LEN*sizeof(int)]; ;
 
int i;
for(i=0;i<LEN;i++) // buffer init
data[i]=0;
 
scale=DEF_SCALE; // default coords: data[i] = (data[i] + shift)/scale;
shift=DEF_SHIFT;
scaleSlider = new QSlider(Qt::Horizontal,this);
scaleSlider->setRange(1, 256);
scaleSlider->setValue(DEF_SCALE);
connect(scaleSlider, SIGNAL(valueChanged(int)), this, SLOT(setScale(int)));
shiftSlider = new QSlider(Qt::Horizontal,this);
shiftSlider->setRange(0, +60000);
shiftSlider->setValue(DEF_SHIFT);
connect(shiftSlider, SIGNAL(valueChanged(int)), this, SLOT(setShift(int)));
 
updateTimer = new QTimer(this);
updateTimer->start(TICK);
connect(updateTimer, SIGNAL(timeout()), this, SLOT(getData()));
labels[1] = new QLabel(this);
/*QString tempStr;
tempStr.setNum(shift);
labels[1]->setText("Zero level: " + tempStr);
labels[1]->setGeometry (20, 550, 200, 20);
labels[1]->show();
shiftSlider->setGeometry(QRect(20,580,400,60));
shiftSlider->show();*/
 
 
labels[2] = new QLabel(this);
this->UI();/*
tempStr.setNum(scale);
labels[2]->setText("Divisor: " + tempStr);
labels[2]->setGeometry (20, 630, 400, 20);
labels[2]->show();
scaleSlider->setGeometry(QRect(20,660,400,60));
scaleSlider->show();*/
}
 
void Scope::UI(void) {
QString tempStr;
tempStr.setNum(shift);
labels[1]->setText("Zero level: " + tempStr);
labels[1]->setGeometry (20, 550, 200, 20);
labels[1]->show();
shiftSlider->setGeometry(QRect(20,580,400,60));
shiftSlider->show();
 
tempStr.setNum(scale);
labels[2]->setText("Divisor: " + tempStr);
labels[2]->setGeometry (20, 630, 400, 20);
labels[2]->show();
scaleSlider->setGeometry(QRect(20,660,400,60));
scaleSlider->show();
}
 
 
 
 
 
 
Scope::~Scope() {
delete [] data;
}
 
 
void Scope::paintEvent(QPaintEvent* event) {
 
QPainter painter(this);
 
if (dataAquired) {
painter.drawLine(LEFT-1,TOP,LEFT-1,TOP+HEIGHT); //vertical bound box lines
painter.drawLine(LEFT+WIDTH+1,TOP,LEFT+WIDTH+1,TOP+HEIGHT);
 
painter.drawLine(LEFT-1,TOP,LEFT+WIDTH+1,TOP); //horizontals bound box lines
painter.drawLine(LEFT-1,TOP+HEIGHT,LEFT+WIDTH+1,TOP+HEIGHT);
painter.drawLine(LEFT-1,TOP+HEIGHT/2,LEFT+WIDTH+1,TOP+HEIGHT/2);
 
int i;
for(i=0;i<LEN;i++) {
data[i] = (data[i] - shift)/scale;
}
 
for(i=0;i<LEN-1;i++) {
painter.drawLine(PIXPT_X*i+LEFT,TOP+HEIGHT/2-PIXPT_Y*data[i],PIXPT_X*(i+1)+LEFT,TOP+HEIGHT/2-data[i+1]*PIXPT_Y);
}
//cout << "Screen updated"<<endl;
}
}
 
 
void Scope::getData() {
char c='m';
 
cout << "Serial transfer start."<<endl;
FILE *serial=fopen("/dev/ttyUSB0","r+");
 
if (serial==NULL) {
cout << "Serial port error."<<endl;
} else {
//cout << "Serial port open."<<endl;
fwrite(&c,sizeof(char),1,serial); // poprosime o data
fread(buffer,sizeof(uint8_t),2*LEN,serial); // a berem je
// cout << "Serial transfer completed."<<endl;
fclose(serial);
int i;
for(i=0;i<LEN;i++) {
data[i]=buffer[2*i]*256+buffer[2*i+1];
// cout << 1*data[i] <<endl;
}
// cout << "Screen updating...."<<endl;
dataAquired=1;
update();
}
}
 
 
void Scope::setScale(int val) {
scale=val;
UI();
}
 
void Scope::setShift(int val) {
shift=val;
UI();
}
/Designs/Tools/Oscilloscope/SW/PC_side/qscope/scope.h
0,0 → 1,55
#ifndef SCOPE_H
#define SCOPE_H
 
#include <QWidget>
#include <QTimer>
#include <QSlider>
#include <stdint.h>
#include <QLabel>
 
#define TICK 250 // time in ms for one sample (LEN values)
#define LEN 100 // number of sampled values
 
#define DEF_SCALE 128 //divisor
#define DEF_SHIFT 37203
 
#define LEFT 10
#define TOP 10
#define PIXPT_X 4
#define PIXPT_Y 1
#define WIDTH (PIXPT_X*LEN)
#define HEIGHT (PIXPT_Y*512)
 
class Scope : public QWidget
{
Q_OBJECT
 
public:
Scope(QWidget *parent = 0);
~Scope();
 
public slots:
void getData();
void setScale(int val);
void setShift(int val);
 
protected:
void paintEvent(QPaintEvent *event);
 
private:
uint8_t buffer[2*LEN];
int data[LEN];
char dataAquired;
void UI(void);
int shift, scale;
 
QTimer *updateTimer;
QSlider *shiftSlider;
QSlider *scaleSlider;
 
QLabel * labels[5];
};
 
#endif
/Designs/Tools/Oscilloscope/SW/PC_side/qscope/qscope.pro
0,0 → 1,12
######################################################################
# Automatically generated by qmake (2.01a) Sun Aug 14 00:40:56 2011
######################################################################
 
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
 
# Input
HEADERS += scope.h
SOURCES += main.cpp scope.cpp
/Designs/Tools/Oscilloscope/SW/PC_side/stty_setting.sh
0,0 → 1,2
#!/bin/bash
stty -F /dev/ttyUSB0 1000000 raw -hupcl -echo -echok -echoctl