EU1KY AA
panvswr2.c File Reference
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <complex.h>
#include "LCD.h"
#include "touch.h"
#include "font.h"
#include "config.h"
#include "ff.h"
#include "crash.h"
#include "dsp.h"
#include "gen.h"
#include "oslfile.h"
#include "stm32746g_discovery_lcd.h"
#include "screenshot.h"
#include "panvswr2.h"
#include "panfreq.h"
#include "smith.h"
#include "textbox.h"
#include "generator.h"
#include "FreqCounter.h"

Macros

#define X0   51
 
#define Y0   18
 
#define WWIDTH   400
 
#define WHEIGHT   200
 
#define WY(offset)   ((WHEIGHT + Y0) - (offset))
 
#define WGRIDCOLOR   LCD_COLOR_DARKGRAY
 
#define RED1   LCD_RGB(245,0,0)
 
#define RED2   LCD_RGB(235,0,0)
 
#define WGRIDCOLORBR   LCD_RGB(160,160,96)
 
#define SMITH_CIRCLE_BG   LCD_BLACK
 
#define SMITH_LINE_FG   LCD_GREEN
 
#define MAX(a, b)   (((a)>(b))?(a):(b))
 
#define MIN(a, b)   (((a)<(b))?(a):(b))
 
#define SMOOTHWINDOW   3
 
#define SMOOTHOFS   (SMOOTHWINDOW/2)
 
#define SMOOTHWINDOW_HI   7
 
#define SMOOTHOFS_HI   (SMOOTHWINDOW_HI/2)
 
#define SM_INTENSITY   64
 
#define M_BGCOLOR   LCD_RGB(0,0,64)
 
#define M_FGCOLOR   LCD_RGB(255,255,0)
 
#define S11OFFS(s11)   ((int)roundf(((s11 - graphmin) * WHEIGHT) / grange) + 1)
 
#define LimitR   1999.f
 
#define RXOFFS(rx)   ((int)roundf(((rx - graphmin_r) * WHEIGHT) / grange_r) + 1)
 
#define XX0   190
 
#define YY0   42
 
#define XXM1   175
 
#define YYM1   250
 
#define XXM2   225
 
#define YYM2   250
 

Enumerations

enum  GRAPHTYPE {
  GRAPH_VSWR, GRAPH_VSWR_Z, GRAPH_VSWR_RX, GRAPH_RX,
  GRAPH_SMITH, GRAPH_S11
}
 

Functions

void ShowF (void)
 
static void DrawRX ()
 
static void DrawSmith ()
 
static float complex SmoothRX (int idx, int useHighSmooth)
 
void SWR_Exit (void)
 
static void SWR_2 (void)
 
void SWR_Mute (void)
 
static void SWR_3 (void)
 
void SWR_SetFrequency (void)
 
void QuMeasure (void)
 
void QuCalibrate (void)
 
void DrawX_Scale (float maxRXi, float minRXi)
 
void Beep (int duration)
 
unsigned long GetUpper (int i)
 
unsigned long GetLower (int i)
 
void DrawFootText (void)
 
int GetBandNr (unsigned long freq)
 
static void WK_InvertPixel (LCDPoint p)
 
static int swroffset (float swr)
 
static int Z_offset (float Z)
 
static float S11Calc (float swr)
 
static int IsFinHamBands (uint32_t f_kHz)
 
static void DrawCursor ()
 
static void DrawCursorText ()
 
static void DrawCursorTextWithS11 ()
 
static void DrawAutoText (void)
 
static void DrawBottomText (void)
 
static void DrawSavingText (void)
 
static void DrawSavedText (void)
 
static void DecrCursor ()
 
static void IncrCursor ()
 
static void DrawGrid (GRAPHTYPE grType)
 
static void ScanRXFast (void)
 
static void ScanRX (int selector)
 
static void DrawVSWR (void)
 
static void LoadBkups ()
 
static void DrawHelp (void)
 
static float nicenum (float x, int round)
 
static void DrawS11 ()
 
static void DrawRX (int SelQu, int SelEqu)
 
static void RedrawWindow ()
 
static void save_snapshot (void)
 
int TouchTest ()
 
int Scan200 (uint8_t line, int index1)
 
int ShowFreq (int indx)
 
void ShowResult (int indx)
 
uint32_t GetFrequency (uint32_t f0)
 
static void ShowFr (void)
 
void setup_GPIO (void)
 
void Tune_SWR_Proc (void)
 
void MultiSWR_Proc (void)
 
void zoomMinus (void)
 
void PANVSWR2_Proc (void)
 
void Quartz_proc (void)
 

Variables

uint8_t rqDel
 
static const HAM_BANDS hamBands []
 
static const uint32_t hamBandsNum = sizeof(hamBands) / sizeof(*hamBands)
 
static const uint32_t cx0 = 240
 
static const uint32_t cy0 = 120
 
static const int32_t smithradius = 100
 
static const char * modstr = "EU1KY AA v." AAVERSION " "
 
static uint32_t modstrw = 0
 
const char * BSSTR [] = {"2 kHz","4 kHz","10 kHz","20 kHz","40 kHz","100 kHz","200 kHz", "400 kHz", "1000 kHz", "2 MHz", "4 MHz", "10 MHz", "20 MHz", "30 MHz", "40 MHz", "100 MHz", "200 MHz", "250 Mhz", "300 MHz", "350 MHz", "400 MHz", "450 MHz", "500 MHz"}
 
const char * BSSTR_HALF [] = {"1 kHz","2 kHz","5 kHz","10 kHz","20 kHz","50 kHz","100 kHz", "200 kHz", "500 kHz", "1 MHz", "2 MHz", "5 MHz", "10 MHz", "15 MHz", "20 MHz", "50 MHz", "100 MHz", "125 MHz", "150 MHz", "175 MHz", "200 MHz", "225 MHz", "250 MHz"}
 
const uint32_t BSVALUES [] = {2,4,10,20,40,100,200, 400, 1000, 2000, 4000, 10000, 20000, 30000, 40000, 100000, 200000, 250000, 300000, 350000, 400000, 450000, 500000}
 
static uint32_t f1 = 14000000
 
static BANDSPAN span = BS400
 
static float fcur
 
static char buf [64]
 
static LCDPoint pt
 
static float complex values [WWIDTH+1]
 
static int isMeasured = 0
 
static uint32_t cursorPos = WWIDTH / 2
 
static GRAPHTYPE grType = GRAPH_VSWR
 
static uint32_t isSaved = 0
 
static uint32_t cursorChangeCount = 0
 
static uint32_t autofast = 0
 
static int loglog =0
 
volatile uint32_t autosleep_timer
 
static TEXTBOX_t SWR_ctx
 
int sFreq
 
int sCalib
 
static const TEXTBOX_t tb_menuQuartz []
 
static const TEXTBOX_t tb_menuQuartz2 []
 
static const TEXTBOX_t tb_menuSWR []
 
static uint32_t multi_fr [5] = {1850,21200,27800,3670,7150}
 
static uint32_t multi_bw [5] = {200,1000,200,400,100}
 
static BANDSPAN multi_bwNo [5] = {6,8,6,5,4}
 
static int beep
 
static uint32_t Fs
 
static uint32_t Fp
 
static float Cp
 
static float Rs
 
static uint32_t MinSWR
 
static uint32_t MinIndex
 
static int8_t lastR
 
static int8_t lastX
 
static int rMax
 
static int xMax
 
static bool reverse1
 
static float complex z200 [21] = { 0 }
 
char str [6]
 
int i
 
uint32_t freqx
 
static bool rqExitSWR
 
static uint8_t SWRLimit
 
static int Tone
 
static uint32_t fxs = 3600000ul
 
static uint32_t fxkHzs
 
static BANDSPANpBss
 
static uint32_t freqChg
 
uint8_t AUDIO1 =1
 
TEXTBOX_CTX_t Quartz_ctx
 
float C0
 

Macro Definition Documentation

#define LimitR   1999.f
#define M_BGCOLOR   LCD_RGB(0,0,64)
#define M_FGCOLOR   LCD_RGB(255,255,0)
#define MAX (   a,
 
)    (((a)>(b))?(a):(b))
#define MIN (   a,
 
)    (((a)<(b))?(a):(b))
#define RED1   LCD_RGB(245,0,0)
#define RED2   LCD_RGB(235,0,0)
#define RXOFFS (   rx)    ((int)roundf(((rx - graphmin_r) * WHEIGHT) / grange_r) + 1)
#define S11OFFS (   s11)    ((int)roundf(((s11 - graphmin) * WHEIGHT) / grange) + 1)
#define SM_INTENSITY   64
#define SMITH_CIRCLE_BG   LCD_BLACK
#define SMITH_LINE_FG   LCD_GREEN
#define SMOOTHOFS   (SMOOTHWINDOW/2)
#define SMOOTHOFS_HI   (SMOOTHWINDOW_HI/2)
#define SMOOTHWINDOW   3
#define SMOOTHWINDOW_HI   7
#define WGRIDCOLOR   LCD_COLOR_DARKGRAY
#define WGRIDCOLORBR   LCD_RGB(160,160,96)
#define WHEIGHT   200
#define WWIDTH   400
#define WY (   offset)    ((WHEIGHT + Y0) - (offset))
#define X0   51
#define XX0   190
#define XXM1   175
#define XXM2   225
#define Y0   18
#define YY0   42
#define YYM1   250
#define YYM2   250

Enumeration Type Documentation

enum GRAPHTYPE
Enumerator
GRAPH_VSWR 
GRAPH_VSWR_Z 
GRAPH_VSWR_RX 
GRAPH_RX 
GRAPH_SMITH 
GRAPH_S11 

Function Documentation

void Beep ( int  duration)
static void DecrCursor ( )
static
static void DrawAutoText ( void  )
static
static void DrawBottomText ( void  )
static
static void DrawCursor ( )
static
static void DrawCursorText ( )
static

1000.;

static void DrawCursorTextWithS11 ( )
static

1000.;

void DrawFootText ( void  )
static void DrawGrid ( GRAPHTYPE  grType)
static
static void DrawHelp ( void  )
static
static void DrawRX ( )
static
static void DrawRX ( int  SelQu,
int  SelEqu 
)
static
static void DrawS11 ( )
static
static void DrawSavedText ( void  )
static
static void DrawSavingText ( void  )
static
static void DrawSmith ( void  )
static
static void DrawVSWR ( void  )
static
void DrawX_Scale ( float  maxRXi,
float  minRXi 
)
int GetBandNr ( unsigned long  freq)
uint32_t GetFrequency ( uint32_t  f0)
unsigned long GetLower ( int  i)
unsigned long GetUpper ( int  i)
static void IncrCursor ( )
static
static int IsFinHamBands ( uint32_t  f_kHz)
static
static void LoadBkups ( )
static
void MultiSWR_Proc ( void  )
static float nicenum ( float  x,
int  round 
)
static
void PANVSWR2_Proc ( void  )
void Quartz_proc ( void  )
void QuCalibrate ( void  )
void QuMeasure ( void  )
static void RedrawWindow ( )
static
static float S11Calc ( float  swr)
static
static void save_snapshot ( void  )
static
int Scan200 ( uint8_t  line,
int  index1 
)
static void ScanRX ( int  selector)
static
static void ScanRXFast ( void  )
static
void setup_GPIO ( void  )
void ShowF ( void  )
static void ShowFr ( void  )
static
int ShowFreq ( int  indx)
void ShowResult ( int  indx)
static float complex SmoothRX ( int  idx,
int  useHighSmooth 
)
static
static void SWR_2 ( void  )
static
static void SWR_3 ( void  )
static
void SWR_Exit ( void  )
void SWR_Mute ( void  )
void SWR_SetFrequency ( void  )
static int swroffset ( float  swr)
static
int TouchTest ( )
void Tune_SWR_Proc ( void  )
static void WK_InvertPixel ( LCDPoint  p)
static
static int Z_offset ( float  Z)
static
void zoomMinus ( void  )

Variable Documentation

uint8_t AUDIO1 =1
uint32_t autofast = 0
static
volatile uint32_t autosleep_timer
int beep
static
const char* BSSTR[] = {"2 kHz","4 kHz","10 kHz","20 kHz","40 kHz","100 kHz","200 kHz", "400 kHz", "1000 kHz", "2 MHz", "4 MHz", "10 MHz", "20 MHz", "30 MHz", "40 MHz", "100 MHz", "200 MHz", "250 Mhz", "300 MHz", "350 MHz", "400 MHz", "450 MHz", "500 MHz"}
const char* BSSTR_HALF[] = {"1 kHz","2 kHz","5 kHz","10 kHz","20 kHz","50 kHz","100 kHz", "200 kHz", "500 kHz", "1 MHz", "2 MHz", "5 MHz", "10 MHz", "15 MHz", "20 MHz", "50 MHz", "100 MHz", "125 MHz", "150 MHz", "175 MHz", "200 MHz", "225 MHz", "250 MHz"}
const uint32_t BSVALUES[] = {2,4,10,20,40,100,200, 400, 1000, 2000, 4000, 10000, 20000, 30000, 40000, 100000, 200000, 250000, 300000, 350000, 400000, 450000, 500000}
char buf[64]
static
float C0
float Cp
static
uint32_t cursorChangeCount = 0
static
uint32_t cursorPos = WWIDTH / 2
static
const uint32_t cx0 = 240
static
const uint32_t cy0 = 120
static
uint32_t f1 = 14000000
static
float fcur
static
uint32_t Fp
static
uint32_t freqChg
static
uint32_t freqx
uint32_t Fs
static
uint32_t fxkHzs
static
uint32_t fxs = 3600000ul
static
GRAPHTYPE grType = GRAPH_VSWR
static
const HAM_BANDS hamBands[]
static
Initial value:
=
{
{1800ul, 2000ul},
{3500ul, 3800ul},
{7000ul, 7200ul},
{10100ul, 10150ul},
{14000ul, 14350ul},
{18068ul, 18168ul},
{21000ul, 21450ul},
{24890ul, 24990ul},
{28000ul, 29700ul},
{50000ul, 52000ul},
{144000ul, 146000ul},
{222000ul, 225000ul},
{430000ul, 440000ul},
{1240000ul, 1300000ul},
}
const uint32_t hamBandsNum = sizeof(hamBands) / sizeof(*hamBands)
static
int i
int isMeasured = 0
static
uint32_t isSaved = 0
static
int8_t lastR
static
int8_t lastX
static
int loglog =0
static
uint32_t MinIndex
static
uint32_t MinSWR
static
const char* modstr = "EU1KY AA v." AAVERSION " "
static
uint32_t modstrw = 0
static
uint32_t multi_bw[5] = {200,1000,200,400,100}
static
BANDSPAN multi_bwNo[5] = {6,8,6,5,4}
static
uint32_t multi_fr[5] = {1850,21200,27800,3670,7150}
static
BANDSPAN* pBss
static
LCDPoint pt
static
TEXTBOX_CTX_t Quartz_ctx
bool reverse1
static
int rMax
static
uint8_t rqDel
bool rqExitSWR
static
float Rs
static
int sCalib
int sFreq
const int32_t smithradius = 100
static
BANDSPAN span = BS400
static
char str[6]
TEXTBOX_t SWR_ctx
static
uint8_t SWRLimit
static
const TEXTBOX_t tb_menuQuartz[]
static
Initial value:
= {
(TEXTBOX_t){.x0 = 10, .y0 = 180, .text = "Set Frequency", .font = FONT_FRANBIG,.width = 180, .height = 34, .center = 1,
.border = 1, .fgcolor = M_FGCOLOR, .bgcolor = M_BGCOLOR, .cb = SWR_SetFrequency , .cbparam = 1, .next = (void*)&tb_menuQuartz[1] },
(TEXTBOX_t){.x0 = 200, .y0 = 180, .text = "Calibrate OPEN", .font = FONT_FRANBIG,.width = 220, .height = 34, .center = 1,
.border = 1, .fgcolor = M_FGCOLOR, .bgcolor = M_BGCOLOR, .cb = QuCalibrate , .cbparam = 1, .next = (void*)&tb_menuQuartz[2] },
(TEXTBOX_t){.x0 = 80, .y0 = 230, .text = "Start", .font = FONT_FRANBIG,.width = 100, .height = 34, .center = 1,
.border = 1, .fgcolor = M_FGCOLOR, .bgcolor = M_BGCOLOR, .cb = QuMeasure , .cbparam = 1, .next = (void*)&tb_menuQuartz[3] },
(TEXTBOX_t){ .x0 = 0, .y0 = 230, .text = "Exit", .font = FONT_FRANBIG, .width = 70, .height = 34, .center = 1,
.border = 1, .fgcolor = M_FGCOLOR, .bgcolor = LCD_RED, .cb = (void(*)(void))SWR_Exit, .cbparam = 1,},
}
Definition: textbox.h:15
void SWR_Exit(void)
Definition: panvswr2.c:1729
#define M_BGCOLOR
Definition: panvswr2.c:137
void QuCalibrate(void)
Definition: panvswr2.c:2224
uint16_t x0
Definition: textbox.h:22
void QuMeasure(void)
Definition: panvswr2.c:2245
Definition: font.h:18
void SWR_SetFrequency(void)
Definition: panvswr2.c:1800
static const TEXTBOX_t tb_menuQuartz[]
Definition: panvswr2.c:141
#define M_FGCOLOR
Definition: panvswr2.c:138
Definition: LCD.h:40
void(Delete(void))
Definition: mainwnd.c:360
const TEXTBOX_t tb_menuQuartz2[]
static
Initial value:
= {
(TEXTBOX_t){.x0 = 270, .y0 = 230, .text = "Start", .font = FONT_FRANBIG,.width = 100, .height = 34, .center = 1,
.border = 1, .fgcolor = M_FGCOLOR, .bgcolor = M_BGCOLOR, .cb = QuMeasure , .cbparam = 1, .next = (void*)&tb_menuQuartz2[1] },
(TEXTBOX_t){.x0 = 80, .y0 = 230, .text = "Set Frequency", .font = FONT_FRANBIG,.width = 180, .height = 34, .center = 1,
.border = 1, .fgcolor = M_FGCOLOR, .bgcolor = M_BGCOLOR, .cb = SWR_SetFrequency , .cbparam = 1, .next = (void*)&tb_menuQuartz2[2] },
(TEXTBOX_t){ .x0 = 0, .y0 = 230, .text = "Exit", .font = FONT_FRANBIG, .width = 70, .height = 34, .center = 1,
.border = 1, .fgcolor = M_FGCOLOR, .bgcolor = LCD_RED, .cb = (void(*)(void))SWR_Exit, .cbparam = 1,},
}
Definition: textbox.h:15
void SWR_Exit(void)
Definition: panvswr2.c:1729
#define M_BGCOLOR
Definition: panvswr2.c:137
static const TEXTBOX_t tb_menuQuartz2[]
Definition: panvswr2.c:152
uint16_t x0
Definition: textbox.h:22
void QuMeasure(void)
Definition: panvswr2.c:2245
Definition: font.h:18
void SWR_SetFrequency(void)
Definition: panvswr2.c:1800
#define M_FGCOLOR
Definition: panvswr2.c:138
Definition: LCD.h:40
void(Delete(void))
Definition: mainwnd.c:360
const TEXTBOX_t tb_menuSWR[]
static
Initial value:
= {
(TEXTBOX_t){.x0 = 70, .y0 = 210, .text = "Frequency", .font = FONT_FRANBIG,.width = 120, .height = 34, .center = 1,
.border = 1, .fgcolor = M_FGCOLOR, .bgcolor = M_BGCOLOR, .cb = SWR_SetFrequency , .cbparam = 1, .next = (void*)&tb_menuSWR[1] },
(TEXTBOX_t){.x0 = 280, .y0 = 210, .text = "SWR_2", .font = FONT_FRANBIG,.width = 100, .height = 34, .center = 1,
.border = 1, .fgcolor = M_FGCOLOR, .bgcolor = M_BGCOLOR, .cb = SWR_2 , .cbparam = 1, .next = (void*)&tb_menuSWR[2] },
(TEXTBOX_t){.x0 = 380, .y0 = 210, .text = "SWR_3", .font = FONT_FRANBIG,.width = 96, .height = 34, .center = 1,
.border = 1, .fgcolor = M_FGCOLOR, .bgcolor = M_BGCOLOR, .cb = SWR_3 , .cbparam = 1, .next = (void*)&tb_menuSWR[3] },
(TEXTBOX_t){.x0 = 190, .y0 = 210, .text = "Tone", .font = FONT_FRANBIG,.width = 90, .height = 34, .center = 1,
.border = 1, .fgcolor = M_FGCOLOR, .bgcolor = M_BGCOLOR, .cb = SWR_Mute , .cbparam = 1, .next = (void*)&tb_menuSWR[4] },
(TEXTBOX_t){ .x0 = 0, .y0 = 210, .text = "Exit", .font = FONT_FRANBIG, .width = 70, .height = 34, .center = 1,
.border = 1, .fgcolor = M_FGCOLOR, .bgcolor = LCD_RED, .cb = (void(*)(void))SWR_Exit, .cbparam = 1,},
}
Definition: textbox.h:15
void SWR_Mute(void)
Definition: panvswr2.c:1735
void SWR_Exit(void)
Definition: panvswr2.c:1729
#define M_BGCOLOR
Definition: panvswr2.c:137
uint16_t x0
Definition: textbox.h:22
static void SWR_3(void)
Definition: panvswr2.c:1762
Definition: font.h:18
void SWR_SetFrequency(void)
Definition: panvswr2.c:1800
#define M_FGCOLOR
Definition: panvswr2.c:138
Definition: LCD.h:40
static const TEXTBOX_t tb_menuSWR[]
Definition: panvswr2.c:163
void(Delete(void))
Definition: mainwnd.c:360
static void SWR_2(void)
Definition: panvswr2.c:1748
int Tone
static
float complex values[WWIDTH+1]
static
int xMax
static
float complex z200[21] = { 0 }
static