1 // ---------------------------------------------------------------------------- 2 // digiscope.h, Miniature Oscilloscope/Phasescope Widget 3 // 4 // Copyright (C) 2006 5 // Dave Freese, W1HKJ 6 // 7 // This file is part of fldigi. Adapted in part from code contained in 8 // gmfsk source code distribution. 9 // gmfsk Copyright (C) 2001, 2002, 2003 10 // Tomi Manninen (oh2bns@sral.fi) 11 // Copyright (C) 2004 12 // Lawrence Glaister (ve7it@shaw.ca) 13 // 14 // Fldigi is free software: you can redistribute it and/or modify 15 // it under the terms of the GNU General Public License as published by 16 // the Free Software Foundation, either version 3 of the License, or 17 // (at your option) any later version. 18 // 19 // Fldigi is distributed in the hope that it will be useful, 20 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 // GNU General Public License for more details. 23 // 24 // You should have received a copy of the GNU General Public License 25 // along with fldigi. If not, see <http://www.gnu.org/licenses/>. 26 // ---------------------------------------------------------------------------- 27 28 #ifndef DIGISCOPE_H 29 #define DIGISCOPE_H 30 31 #include <FL/Fl_Widget.H> 32 33 #include "complex.h" 34 35 class Digiscope : public Fl_Widget { 36 public: 37 #define DEFAULT_WIDTH 100 38 #define DEFAULT_HEIGHT 100 39 #define MAX_LEN 4096 //1024 40 #define MAX_ZLEN 1024 41 #define NUM_GRIDS 100 42 enum scope_mode { 43 SCOPE, 44 PHASE, 45 PHASE1, 46 PHASE2, 47 PHASE3, 48 RTTY, 49 XHAIRS, 50 WWV, 51 DOMDATA, 52 DOMWF, 53 BLANK 54 }; 55 56 private: 57 scope_mode _mode; 58 double _buf[MAX_LEN]; 59 cmplx _zdata[MAX_ZLEN]; 60 //int _zlen; 61 int _zptr; 62 unsigned char *vidbuf; 63 unsigned char *vidline; 64 int _len; 65 int linecnt; 66 double _phase; 67 double _quality; 68 double _flo, _fhi, _amp; 69 double _x[NUM_GRIDS], _y[NUM_GRIDS]; 70 bool _highlight; 71 scope_mode phase_mode; 72 73 protected: 74 double _y_user1, _y_user2; 75 double _x_user1, _x_user2; 76 bool _x_graticule; 77 bool _y_graticule; 78 79 public: 80 Digiscope(int, int, int, int, const char *label = ""); 81 ~Digiscope(); 82 int handle(int); 83 void resize(int x, int y, int w, int h); 84 void draw(); 85 void draw_scope(); 86 void draw_phase(); 87 void draw_rtty(); 88 void draw_xy(); 89 void draw_video(); 90 void data(double *data, int len, bool scale = true); 91 void phase(double ph, double ql, bool hl); 92 void video(double *data, int len, bool dir ); 93 void zdata(cmplx *z, int len); 94 void rtty(double flo, double fhi, double amp); 95 void mode(scope_mode md); mode()96 scope_mode mode() { return _mode;};\ xaxis(int n,double y1)97 void xaxis(int n, double y1) { 98 if (n < NUM_GRIDS) _y[n] = y1; 99 } yaxis(int n,double x1)100 void yaxis(int n, double x1) { 101 if (n < NUM_GRIDS) _x[n] = x1; 102 } xaxis_1(double y1)103 void xaxis_1(double y1) { _y[1] = y1; } xaxis_2(double y2)104 void xaxis_2(double y2) { _y[2] = y2; } yaxis_1(double x1)105 void yaxis_1(double x1) { _x[1] = x1; } yaxis_2(double x2)106 void yaxis_2(double x2) { _x[2] = x2; } clear_axis()107 void clear_axis() { 108 for (int i = 0; i < NUM_GRIDS; i++) 109 _x[i] = _y[i] = 0; 110 } 111 x_user1()112 double x_user1() { return _x_user1; } x_user1(double val)113 void x_user1(double val) { _x_user1 = val; } x_user2()114 double x_user2() { return _x_user2; } x_user2(double val)115 void x_user2(double val) { _x_user2 = val; } 116 y_user1()117 double y_user1() { return _y_user1; } y_user1(double val)118 void y_user1(double val) { _y_user1 = val; } y_user2()119 double y_user2() { return _y_user2; } y_user2(double val)120 void y_user2(double val) { _y_user2 = val; } 121 x_graticule()122 bool x_graticule() { return _x_graticule; } x_graticule(bool b)123 void x_graticule(bool b) { _x_graticule = b; } 124 y_graticule()125 bool y_graticule() { return _y_graticule; } y_graticule(bool b)126 void y_graticule(bool b) { _y_graticule = b; } 127 }; 128 129 #endif 130