summaryrefslogtreecommitdiffstats
path: root/src/kserialview.h
blob: 8735d9de4eb17c8be140f4b13ee0ec758dd945ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/***************************************************************************
 *   Copyright (C) 2005 by Mark Six                                        *
 *   marksix@xs4all.nl                                                     *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
 ***************************************************************************/
#ifndef KSERIALVIEW_H
#define KSERIALVIEW_H

#include <tdetoolbar.h>
#include <ktextedit.h>
#include <klineedit.h>
#include <tqcheckbox.h>
#include <tqpushbutton.h>
#include <tqfont.h>
#include <tqpopupmenu.h>

#include "kport.h"

class KSerialWindow : public KTextEdit 
{
	Q_OBJECT
  
	
	public:
		KSerialWindow( TQWidget *parent ) : KTextEdit( parent ) {
			setWrapColumnOrWidth( 80 ) ; 				// Serial window is a terminal
			setWrapPolicy( TQTextEdit::Anywhere ) ;
			setWordWrap( TQTextEdit::FixedColumnWidth ) ; 
			setFont( TDEGlobalSettings::fixedFont()  ) ;  // Use default fixed font
		}
		virtual ~KSerialWindow() {} ;
		
	protected:
		virtual void keyPressEvent( TQKeyEvent *e ) 
		{ 
			emit keyPressed( e->ascii() ) ; 
		}
		
		virtual void mousePressEvent( TQMouseEvent *e ) {
		}
		virtual void mouseReleaseEvent( TQMouseEvent *e ) {}
		virtual TQPopupMenu *createPopupMenu( const TQPoint &pos ) 
		{ 
			TQPopupMenu *menu = new TQPopupMenu( this ) ;
			menu->insertItem( "clear view", this, TQT_SLOT( clearView() ) ) ;
			return menu ; 
		}
	public slots:
		void clearView() {
			clear() ;
		}

	signals:
		void keyPressed( int key ) ;
	
} ;

class KSerialView : public TQWidget
{
	Q_OBJECT
  
	public:
    	KSerialView( CPicoBlaze *cpu, TQWidget *parent );
	    ~KSerialView();
	
		KPort * rxPort, * txPort, * statusPort ;
		
	public slots:
		void transmit( unsigned char ) ;
		void receive() ;
		void keyPressed( int key ) ;
	
	protected:
		KSerialWindow *view ;
		
		unsigned char rxFifo[ 16 ] ;
		unsigned char fifoPtr ;		
		
		unsigned char getReceiveFlags() ;
		unsigned char getTransmitFlags() ;
		void setStatusBits( unsigned char ) ;
		
		CPicoBlaze * m_cpu ;

		KLineEdit *txPortID, *rxPortID, *statusPortID ;
		TQCheckBox *m_statusBits[ 8 ] ;

		TQColor m_backgroundColor ;
		TQPushButton *m_clearButton ;

	public slots:
		void updateTxId( const TQString & ) ; 
		void updateRxId( const TQString & ) ;
		void updateStatusId( const TQString & ) ;
		void txFlagsChanged( bool en ) ;
};

#endif