Ejemplo n.º 1
0
void sim_mode_cb(GtkWidget *widget, gpointer data) {
  BAND* band;
  BANDSTACK_ENTRY *entry;

fprintf(stderr,"sim_mode_cb\n");
  band=band_get_current_band();
  entry=bandstack_entry_get_current();
  if(function) {
    entry->mode--;
    if(entry->mode<0) {
      entry->mode=MODES-1;
    }
  } else {
    entry->mode++;
    if(entry->mode>=MODES) {
      entry->mode=0;
    }
  }
  setMode(entry->mode);

  FILTER* band_filters=filters[entry->mode];
  FILTER* band_filter=&band_filters[entry->filter];
  setFilter(band_filter->low,band_filter->high);

  vfo_update(NULL);
}
Ejemplo n.º 2
0
void sim_filter_cb(GtkWidget *widget, gpointer data) {
  BAND* band;
  BANDSTACK_ENTRY *entry;

fprintf(stderr,"sim_filter_cb\n");
  band=band_get_current_band();
  entry=bandstack_entry_get_current();
  // note order of filter reversed (largest first)
  if(function) {
    entry->filter++;
    if(entry->filter>=FILTERS) {
      entry->filter=0;
    }
  } else {
    entry->filter--;
    if(entry->filter<0) {
      entry->filter=FILTERS-1;
    }
  }

  FILTER* band_filters=filters[entry->mode];
  FILTER* band_filter=&band_filters[entry->filter];
  setFilter(band_filter->low,band_filter->high);

  vfo_update(NULL);

}
Ejemplo n.º 3
0
static void band_select_cb(GtkWidget *widget, gpointer data) {
  GtkWidget *label;
  int b=(int)data;
  BANDSTACK_ENTRY *entry;
  if(b==band_get_current()) {
    entry=bandstack_entry_next();
  } else {
    BAND* band=band_set_current(b);
    entry=bandstack_entry_get_current();
    gtk_widget_override_background_color(last_band, GTK_STATE_NORMAL, &white);
    last_band=widget;
    gtk_widget_override_background_color(last_band, GTK_STATE_NORMAL, &gray);
  }
  setMode(entry->mode);
  FILTER* band_filters=filters[entry->mode];
  FILTER* band_filter=&band_filters[entry->filter];
  setFilter(band_filter->low,band_filter->high);
  setFrequency(entry->frequencyA);

  BAND *band=band_get_current_band();
  set_alex_rx_antenna(band->alexRxAntenna);
  set_alex_tx_antenna(band->alexTxAntenna);
  set_alex_attenuation(band->alexAttenuation);

  vfo_update(NULL);

  setFrequency(entry->frequencyA);
}
Ejemplo n.º 4
0
void sim_band_cb(GtkWidget *widget, gpointer data) {
  BAND* band;
  BANDSTACK_ENTRY *entry;
fprintf(stderr,"sim_band_cb\n");
  int b=band_get_current();
  if(function) {
    b--;
    if(b<0) {
      b=BANDS-1;
    }
#ifdef LIMESDR
    if(protocol!=LIMESDR_PROTOCOL) {
      if(b==band3400) {
        b=band6;
      }
    }
#endif
  } else {
    b++;
    if(b>=BANDS) {
      b=0;
    }
#ifdef LIMESDR
    if(protocol!=LIMESDR_PROTOCOL) {
      if(b==band70) { 
        b=bandGen;
      }
    }
#endif
  }
  band=band_set_current(b);
  entry=bandstack_entry_get_current();

  setFrequency(entry->frequencyA);
  setMode(entry->mode);
  FILTER* band_filters=filters[entry->mode];
  FILTER* band_filter=&band_filters[entry->filter];
  setFilter(band_filter->low,band_filter->high);

  band=band_get_current_band();
  set_alex_rx_antenna(band->alexRxAntenna);
  set_alex_tx_antenna(band->alexTxAntenna);
  set_alex_attenuation(band->alexAttenuation);
  vfo_update(NULL);
}
Ejemplo n.º 5
0
Archivo: vfo.c Proyecto: g0orx/pihpsdr
GtkWidget* vfo_init(int width,int height,GtkWidget *parent) {

fprintf(stderr,"vfo_init: width=%d height=%d\n", width, height);
  parent_window=parent;
  my_width=width;
  my_height=height;

  vfo = gtk_drawing_area_new ();
  gtk_widget_set_size_request (vfo, width, height);

  /* Signals used to handle the backing surface */
  g_signal_connect (vfo, "draw",
            G_CALLBACK (vfo_draw_cb), NULL);
  g_signal_connect (vfo,"configure-event",
            G_CALLBACK (vfo_configure_event_cb), NULL);

  /* Event signals */
  g_signal_connect (vfo, "button-press-event",
            G_CALLBACK (vfo_press_event_cb), NULL);
  g_signal_connect(vfo,"scroll_event",
            G_CALLBACK(vfo_scroll_event_cb),NULL);
  gtk_widget_set_events (vfo, gtk_widget_get_events (vfo)
                     | GDK_BUTTON_PRESS_MASK
                     | GDK_SCROLL_MASK);

fprintf(stderr,"vfo_init: set Frequency,Mode,Filter\n");
  BAND *band=band_get_current_band();
  BANDSTACK_ENTRY* entry=bandstack_entry_get_current();
  setFrequency(entry->frequencyA);
  setMode(entry->mode);
  FILTER* band_filters=filters[entry->mode];
  FILTER* band_filter=&band_filters[entry->filter];
  setFilter(band_filter->low,band_filter->high);

  set_alex_rx_antenna(band->alexRxAntenna);
  set_alex_tx_antenna(band->alexTxAntenna);
  set_alex_attenuation(band->alexAttenuation);

  return vfo;
}
Ejemplo n.º 6
0
void ant_menu(GtkWidget *parent) {
  int i;

  parent_window=parent;

  dialog=gtk_dialog_new();
  gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(parent_window));
  gtk_window_set_decorated(GTK_WINDOW(dialog),FALSE);

  GdkRGBA color;
  color.red = 1.0;
  color.green = 1.0;
  color.blue = 1.0;
  color.alpha = 1.0;
  gtk_widget_override_background_color(dialog,GTK_STATE_FLAG_NORMAL,&color);

  GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog));

  GtkWidget *grid=gtk_grid_new();
  gtk_grid_set_column_spacing (GTK_GRID(grid),10);
  //gtk_grid_set_row_spacing (GTK_GRID(grid),10);
  //gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE);
  //gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);

  GtkWidget *close_b=gtk_button_new_with_label("Close ANT");
  g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL);
  gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1);

  if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL) {
    GtkWidget *rx_ant_label=gtk_label_new("Receive");
    //gtk_widget_override_font(rx_ant_label, pango_font_description_from_string("Arial 18"));
    gtk_widget_show(rx_ant_label);
    gtk_grid_attach(GTK_GRID(grid),rx_ant_label,0,1,1,1);

    GtkWidget *rx1_label=gtk_label_new("1");
    //gtk_widget_override_font(rx1_label, pango_font_description_from_string("Arial 18"));
    gtk_widget_show(rx1_label);
    gtk_grid_attach(GTK_GRID(grid),rx1_label,1,1,1,1);

    GtkWidget *rx2_label=gtk_label_new("2");
    //gtk_widget_override_font(rx2_label, pango_font_description_from_string("Arial 18"));
    gtk_widget_show(rx2_label);
    gtk_grid_attach(GTK_GRID(grid),rx2_label,2,1,1,1);

    GtkWidget *rx3_label=gtk_label_new("3");
    //gtk_widget_override_font(rx3_label, pango_font_description_from_string("Arial 18"));
    gtk_widget_show(rx3_label);
    gtk_grid_attach(GTK_GRID(grid),rx3_label,3,1,1,1);

    GtkWidget *ext1_label=gtk_label_new("EXT1");
    //gtk_widget_override_font(ext1_label, pango_font_description_from_string("Arial 18"));
    gtk_widget_show(ext1_label);
    gtk_grid_attach(GTK_GRID(grid),ext1_label,4,1,1,1);

    GtkWidget *ext2_label=gtk_label_new("EXT2");
    //gtk_widget_override_font(ext2_label, pango_font_description_from_string("Arial 18"));
    gtk_widget_show(ext2_label);
    gtk_grid_attach(GTK_GRID(grid),ext2_label,5,1,1,1);

    GtkWidget *xvtr_label=gtk_label_new("XVTR");
    //gtk_widget_override_font(xvtr_label, pango_font_description_from_string("Arial 18"));
    gtk_widget_show(xvtr_label);
    gtk_grid_attach(GTK_GRID(grid),xvtr_label,6,1,1,1);

    GtkWidget *tx_ant_label=gtk_label_new("Transmit");
    //gtk_widget_override_font(tx_ant_label, pango_font_description_from_string("Arial 18"));
    gtk_widget_show(tx_ant_label);
    gtk_grid_attach(GTK_GRID(grid),tx_ant_label,7,1,1,1);

    GtkWidget *tx1_label=gtk_label_new("1");
    //gtk_widget_override_font(tx1_label, pango_font_description_from_string("Arial 18"));
    gtk_widget_show(tx1_label);
    gtk_grid_attach(GTK_GRID(grid),tx1_label,8,1,1,1);

    GtkWidget *tx2_label=gtk_label_new("2");
    //gtk_widget_override_font(tx2_label, pango_font_description_from_string("Arial 18"));
    gtk_widget_show(tx2_label);
    gtk_grid_attach(GTK_GRID(grid),tx2_label,9,1,1,1);

    GtkWidget *tx3_label=gtk_label_new("3");
    //gtk_widget_override_font(tx3_label, pango_font_description_from_string("Arial 18"));
    gtk_widget_show(tx3_label);
    gtk_grid_attach(GTK_GRID(grid),tx3_label,10,1,1,1);

    for(i=0;i<HAM_BANDS;i++) {
      BAND *band=band_get_band(i);

      GtkWidget *band_label=gtk_label_new(band->title);
      //gtk_widget_override_font(band_label, pango_font_description_from_string("Arial 18"));
      gtk_widget_show(band_label);
      gtk_grid_attach(GTK_GRID(grid),band_label,0,i+2,1,1);

      GtkWidget *rx1_b=gtk_radio_button_new(NULL);
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rx1_b), band->alexRxAntenna==0);
      gtk_widget_show(rx1_b);
      gtk_grid_attach(GTK_GRID(grid),rx1_b,1,i+2,1,1);
      g_signal_connect(rx1_b,"pressed",G_CALLBACK(rx_ant_cb),(gpointer)((i<<4)+0));

      GtkWidget *rx2_b=gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(rx1_b));
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rx2_b), band->alexRxAntenna==1);
      gtk_widget_show(rx2_b);
      gtk_grid_attach(GTK_GRID(grid),rx2_b,2,i+2,1,1);
      g_signal_connect(rx2_b,"pressed",G_CALLBACK(rx_ant_cb),(gpointer)((i<<4)+1));

      GtkWidget *rx3_b=gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(rx2_b));
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rx3_b), band->alexRxAntenna==2);
      gtk_widget_show(rx3_b);
      gtk_grid_attach(GTK_GRID(grid),rx3_b,3,i+2,1,1);
      g_signal_connect(rx3_b,"pressed",G_CALLBACK(rx_ant_cb),(gpointer)((i<<4)+2));

      GtkWidget *ext1_b=gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(rx3_b));
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ext1_b), band->alexRxAntenna==3);
      gtk_widget_show(ext1_b);
      gtk_grid_attach(GTK_GRID(grid),ext1_b,4,i+2,1,1);
      g_signal_connect(ext1_b,"pressed",G_CALLBACK(rx_ant_cb),(gpointer)((i<<4)+3));

      GtkWidget *ext2_b=gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(ext1_b));
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ext2_b), band->alexRxAntenna==4);
      gtk_widget_show(ext2_b);
      gtk_grid_attach(GTK_GRID(grid),ext2_b,5,i+2,1,1);
      g_signal_connect(ext2_b,"pressed",G_CALLBACK(rx_ant_cb),(gpointer)((i<<4)+4));

      GtkWidget *xvtr_b=gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(ext2_b));
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (xvtr_b), band->alexRxAntenna==5);
      gtk_widget_show(xvtr_b);
      gtk_grid_attach(GTK_GRID(grid),xvtr_b,6,i+2,1,1);
      g_signal_connect(xvtr_b,"pressed",G_CALLBACK(rx_ant_cb),(gpointer)((i<<4)+5));

      GtkWidget *ant_band_label=gtk_label_new(band->title);
      //gtk_widget_override_font(ant_band_label, pango_font_description_from_string("Arial 18"));
      gtk_widget_show(ant_band_label);
      gtk_grid_attach(GTK_GRID(grid),ant_band_label,7,i+2,1,1);

      GtkWidget *tx1_b=gtk_radio_button_new(NULL);
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tx1_b), band->alexTxAntenna==0);
      gtk_widget_show(tx1_b);
      gtk_grid_attach(GTK_GRID(grid),tx1_b,8,i+2,1,1);

      GtkWidget *tx2_b=gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(tx1_b));
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tx2_b), band->alexTxAntenna==1);
      gtk_widget_show(tx2_b);
      gtk_grid_attach(GTK_GRID(grid),tx2_b,9,i+2,1,1);
      g_signal_connect(tx2_b,"pressed",G_CALLBACK(tx_ant_cb),(gpointer)((i<<4)+1));

      GtkWidget *tx3_b=gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(tx2_b));
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tx3_b), band->alexTxAntenna==2);
      gtk_widget_show(tx3_b);
      gtk_grid_attach(GTK_GRID(grid),tx3_b,10,i+2,1,1);
      g_signal_connect(tx3_b,"pressed",G_CALLBACK(tx_ant_cb),(gpointer)((i<<4)+2));

    }
  }

#ifdef LIMESDR
  if(protocol==LIMESDR_PROTOCOL) {
    BAND *band=band_get_current_band();

    GtkWidget *rx1_none=gtk_radio_button_new_with_label(NULL,"RX 1: NONE");
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rx1_none), band->alexRxAntenna==0);
    gtk_widget_show(rx1_none);
    gtk_grid_attach(GTK_GRID(grid),rx1_none,0,1,1,1);
    g_signal_connect(rx1_none,"pressed",G_CALLBACK(rx_lime_ant_cb),(gpointer)0);

    GtkWidget *rx1_lnah=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(rx1_none),"RX1: LNAH");
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rx1_lnah), band->alexRxAntenna==1);
    gtk_widget_show(rx1_lnah);
    gtk_grid_attach(GTK_GRID(grid),rx1_lnah,0,2,1,1);
    g_signal_connect(rx1_lnah,"pressed",G_CALLBACK(rx_lime_ant_cb),(gpointer)+1);

    GtkWidget *rx1_lnal=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(rx1_lnah),"RX1: LNAL");
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rx1_lnal), band->alexRxAntenna==2);
    gtk_widget_show(rx1_lnal);
    gtk_grid_attach(GTK_GRID(grid),rx1_lnal,0,3,1,1);
    g_signal_connect(rx1_lnal,"pressed",G_CALLBACK(rx_lime_ant_cb),(gpointer)2);

    GtkWidget *rx1_lnaw=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(rx1_lnal),"RX1: LNAW");
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rx1_lnaw), band->alexRxAntenna==3);
    gtk_widget_show(rx1_lnaw);
    gtk_grid_attach(GTK_GRID(grid),rx1_lnaw,0,4,1,1);
    g_signal_connect(rx1_lnaw,"pressed",G_CALLBACK(rx_lime_ant_cb),(gpointer)3);
  }
#endif


  gtk_container_add(GTK_CONTAINER(content),grid);

  sub_menu=dialog;

  gtk_widget_show_all(dialog);

}
Ejemplo n.º 7
0
static void rx_lime_ant_cb(GtkWidget *widget, gpointer data) {
  int ant=((int)data)&0xF;
  BAND *band=band_get_current_band();
  band->alexRxAntenna=ant;
  set_alex_rx_antenna(ant);
}
Ejemplo n.º 8
0
static void new_protocol_high_priority(int run) {
    unsigned char buffer[1444];
    BAND *band=band_get_current_band();

    memset(buffer, 0, sizeof(buffer));

    buffer[0]=high_priority_sequence>>24;
    buffer[1]=high_priority_sequence>>16;
    buffer[2]=high_priority_sequence>>8;
    buffer[3]=high_priority_sequence;

    buffer[4]=run;
    if(mode==modeCWU || mode==modeCWL) {
      if(tune) {
        buffer[4]|=0x02;
      }
    } else {
      if(isTransmitting()) {
        buffer[4]|=0x02;
      }
    }

    long rxFrequency=ddsFrequency;
    if(mode==modeCWU) {
      rxFrequency-=cw_keyer_sidetone_frequency;
    } else if(mode==modeCWL) {
      rxFrequency+=cw_keyer_sidetone_frequency;
    }
    long phase=(long)((4294967296.0*(double)rxFrequency)/122880000.0);

// rx
    buffer[9]=phase>>24;
    buffer[10]=phase>>16;
    buffer[11]=phase>>8;
    buffer[12]=phase;

// tx (no split yet)
    long long txFrequency=ddsFrequency;
    if(ctun) {
      txFrequency+=ddsOffset;
    }
    phase=(long)((4294967296.0*(double)txFrequency)/122880000.0);

    buffer[329]=phase>>24;
    buffer[330]=phase>>16;
    buffer[331]=phase>>8;
    buffer[332]=phase;

    int power=0;
    if(isTransmitting()) {
      if(tune) {
        power=tune_drive_level;
      } else {
        power=drive_level;
      }
    }

    buffer[345]=power&0xFF;

    if(isTransmitting()) {
      buffer[1401]=band->OCtx;
      if(tune) {
        if(OCmemory_tune_time!=0) {
          struct timeval te;
          gettimeofday(&te,NULL);
          long long now=te.tv_sec*1000LL+te.tv_usec/1000;
          if(tune_timeout>now) {
            buffer[1401]|=OCtune;
          }
        } else {
          buffer[1401]|=OCtune;
        }
      }
    } else {
      buffer[1401]=band->OCrx;
    }
// alex HPF filters
/*
if              (frequency <  1800000) HPF <= 6'b100000;        // bypass
else if (frequency <  6500000) HPF <= 6'b010000;        // 1.5MHz HPF   
else if (frequency <  9500000) HPF <= 6'b001000;        // 6.5MHz HPF
else if (frequency < 13000000) HPF <= 6'b000100;        // 9.5MHz HPF
else if (frequency < 20000000) HPF <= 6'b000001;        // 13MHz HPF
else                                               HPF <= 6'b000010;    // 20MHz HPF
*/



    long filters=0x00000000;

    if(isTransmitting()) {
      filters=0x08000000;
    }

// set HPF
    if(ddsFrequency<1800000L) {
        filters|=ALEX_BYPASS_HPF;
    } else if(ddsFrequency<6500000L) {
        filters|=ALEX_1_5MHZ_HPF;
    } else if(ddsFrequency<9500000L) {
        filters|=ALEX_6_5MHZ_HPF;
    } else if(ddsFrequency<13000000L) {
        filters|=ALEX_9_5MHZ_HPF;
    } else if(ddsFrequency<20000000L) {
        filters|=ALEX_13MHZ_HPF;
    } else {
        filters|=ALEX_20MHZ_HPF;
    }
// alex LPF filters
/*
if (frequency > 32000000)   LPF <= 7'b0010000;             // > 10m so use 6m LPF^M
else if (frequency > 22000000) LPF <= 7'b0100000;       // > 15m so use 12/10m LPF^M
else if (frequency > 15000000) LPF <= 7'b1000000;       // > 20m so use 17/15m LPF^M
else if (frequency > 8000000)  LPF <= 7'b0000001;       // > 40m so use 30/20m LPF  ^M
else if (frequency > 4500000)  LPF <= 7'b0000010;       // > 80m so use 60/40m LPF^M
else if (frequency > 2400000)  LPF <= 7'b0000100;       // > 160m so use 80m LPF  ^M
else LPF <= 7'b0001000;             // < 2.4MHz so use 160m LPF^M
*/

    if(ddsFrequency>32000000) {
        filters|=ALEX_6_BYPASS_LPF;
    } else if(ddsFrequency>22000000) {
        filters|=ALEX_12_10_LPF;
    } else if(ddsFrequency>15000000) {
        filters|=ALEX_17_15_LPF;
    } else if(ddsFrequency>8000000) {
        filters|=ALEX_30_20_LPF;
    } else if(ddsFrequency>4500000) {
        filters|=ALEX_60_40_LPF;
    } else if(ddsFrequency>2400000) {
        filters|=ALEX_80_LPF;
    } else {
        filters|=ALEX_160_LPF;
    }


    switch(band->alexRxAntenna) {
        case 0:  // ANT 1
          break;
        case 1:  // ANT 2
          break;
        case 2:  // ANT 3
          break;
        case 3:  // EXT 1
          filters|=ALEX_RX_ANTENNA_EXT2;
          break;
        case 4:  // EXT 2
          filters|=ALEX_RX_ANTENNA_EXT1;
          break;
        case 5:  // XVTR
          filters|=ALEX_RX_ANTENNA_XVTR;
          break;
        default:
          // invalid value - set to 0
          band->alexRxAntenna=0;
          break;
    }

    if(isTransmitting()) {
      switch(band->alexTxAntenna) {
        case 0:  // ANT 1
          filters|=ALEX_TX_ANTENNA_1;
          break;
        case 1:  // ANT 2
          filters|=ALEX_TX_ANTENNA_2;
          break;
        case 2:  // ANT 3
          filters|=ALEX_TX_ANTENNA_3;
          break;
        default:
          // invalid value - set to 0
          filters|=ALEX_TX_ANTENNA_1;
          band->alexRxAntenna=0;
          break;
         
      }
    } else {
      switch(band->alexRxAntenna) {
        case 0:  // ANT 1
          filters|=ALEX_TX_ANTENNA_1;
          break;
        case 1:  // ANT 2
          filters|=ALEX_TX_ANTENNA_2;
          break;
        case 2:  // ANT 3
          filters|=ALEX_TX_ANTENNA_3;
          break;
        case 3:  // EXT 1
        case 4:  // EXT 2
        case 5:  // XVTR
          switch(band->alexTxAntenna) {
            case 0:  // ANT 1
              filters|=ALEX_TX_ANTENNA_1;
              break;
            case 1:  // ANT 2
              filters|=ALEX_TX_ANTENNA_2;
              break;
            case 2:  // ANT 3
              filters|=ALEX_TX_ANTENNA_3;
              break;
          }
          break;
      }
    }

    buffer[1432]=(filters>>24)&0xFF;
    buffer[1433]=(filters>>16)&0xFF;
    buffer[1434]=(filters>>8)&0xFF;
    buffer[1435]=filters&0xFF;

    //buffer[1442]=attenuation;
    buffer[1443]=attenuation;

//fprintf(stderr,"high_priority[4]=0x%02X\n", buffer[4]);
//fprintf(stderr,"filters=%04X\n", filters);

    if(sendto(data_socket,buffer,sizeof(buffer),0,(struct sockaddr*)&high_priority_addr,high_priority_addr_length)<0) {
        fprintf(stderr,"sendto socket failed for high priority\n");
        exit(1);
    }

    high_priority_sequence++;
}
Ejemplo n.º 9
0
static void new_protocol_high_priority(int run,int tx,int drive) {
    unsigned char buffer[1444];
    BAND *band=band_get_current_band();

//fprintf(stderr,"new_protocol_high_priority: run=%d tx=%d drive=%d tx_ant=0x%08x rx_ant=0x%08x\n", run, tx, drive, alex_tx_antenna, alex_rx_antenna);
    memset(buffer, 0, sizeof(buffer));

    buffer[0]=high_priority_sequence>>24;
    buffer[1]=high_priority_sequence>>16;
    buffer[2]=high_priority_sequence>>8;
    buffer[3]=high_priority_sequence;

    buffer[4]=run|(tx<<1);

    long phase=(long)((4294967296.0*(double)ddsFrequency)/122880000.0);

// rx
    buffer[9]=phase>>24;
    buffer[10]=phase>>16;
    buffer[11]=phase>>8;
    buffer[12]=phase;

// tx (no split yet)
    buffer[329]=phase>>24;
    buffer[330]=phase>>16;
    buffer[331]=phase>>8;
    buffer[332]=phase;


    buffer[345]=drive;


    if(isTransmitting()) {
        buffer[1401]=band->OCtx;
        if(tune) {
            if(OCmemory_tune_time!=0) {
                struct timeval te;
                gettimeofday(&te,NULL);
                long long now=te.tv_sec*1000LL+te.tv_usec/1000;
                if(tune_timeout>now) {
                    buffer[1401]|=OCtune;
                }
            } else {
                buffer[1401]|=OCtune;
            }
        }
    } else {
        buffer[1401]=band->OCrx;
    }
// alex HPF filters
    /*
    if              (frequency <  1800000) HPF <= 6'b100000;        // bypass
    else if (frequency <  6500000) HPF <= 6'b010000;        // 1.5MHz HPF
    else if (frequency <  9500000) HPF <= 6'b001000;        // 6.5MHz HPF
    else if (frequency < 13000000) HPF <= 6'b000100;        // 9.5MHz HPF
    else if (frequency < 20000000) HPF <= 6'b000001;        // 13MHz HPF
    else                                               HPF <= 6'b000010;    // 20MHz HPF
    */



    long filters=0x00000000;
// set HPF
    if(ddsFrequency<1800000L) {
        filters|=ALEX_BYPASS_HPF;
    } else if(ddsFrequency<6500000L) {
        filters|=ALEX_1_5MHZ_HPF;
    } else if(ddsFrequency<9500000L) {
        filters|=ALEX_6_5MHZ_HPF;
    } else if(ddsFrequency<13000000L) {
        filters|=ALEX_9_5MHZ_HPF;
    } else if(ddsFrequency<20000000L) {
        filters|=ALEX_13MHZ_HPF;
    } else {
        filters|=ALEX_20MHZ_HPF;
    }
// alex LPF filters
    /*
    if (frequency > 32000000)   LPF <= 7'b0010000;             // > 10m so use 6m LPF^M
    else if (frequency > 22000000) LPF <= 7'b0100000;       // > 15m so use 12/10m LPF^M
    else if (frequency > 15000000) LPF <= 7'b1000000;       // > 20m so use 17/15m LPF^M
    else if (frequency > 8000000)  LPF <= 7'b0000001;       // > 40m so use 30/20m LPF  ^M
    else if (frequency > 4500000)  LPF <= 7'b0000010;       // > 80m so use 60/40m LPF^M
    else if (frequency > 2400000)  LPF <= 7'b0000100;       // > 160m so use 80m LPF  ^M
    else LPF <= 7'b0001000;             // < 2.4MHz so use 160m LPF^M
    */

    if(ddsFrequency>32000000) {
        filters|=ALEX_6_BYPASS_LPF;
    } else if(ddsFrequency>22000000) {
        filters|=ALEX_12_10_LPF;
    } else if(ddsFrequency>15000000) {
        filters|=ALEX_17_15_LPF;
    } else if(ddsFrequency>8000000) {
        filters|=ALEX_30_20_LPF;
    } else if(ddsFrequency>4500000) {
        filters|=ALEX_60_40_LPF;
    } else if(ddsFrequency>2400000) {
        filters|=ALEX_80_LPF;
    } else {
        filters|=ALEX_160_LPF;
    }


    switch(band->alexRxAntenna) {
    case 0:  // ANT 1
        break;
    case 1:  // ANT 2
        break;
    case 2:  // ANT 3
        break;
    case 3:  // EXT 1
        //filters|=ALEX_RX_ANTENNA_EXT1;
        filters|=ALEX_RX_ANTENNA_EXT2;
        break;
    case 4:  // EXT 2
        //filters|=ALEX_RX_ANTENNA_EXT2;
        filters|=ALEX_RX_ANTENNA_EXT1;
        break;
    case 5:  // XVTR
        filters|=ALEX_RX_ANTENNA_XVTR;
        break;
    }

    if(isTransmitting()) {
        switch(band->alexTxAntenna) {
        case 0:  // ANT 1
            filters|=ALEX_TX_ANTENNA_1;
            break;
        case 1:  // ANT 2
            filters|=ALEX_TX_ANTENNA_2;
            break;
        case 2:  // ANT 3
            filters|=ALEX_TX_ANTENNA_3;
            break;
        }
    } else {
        switch(band->alexRxAntenna) {
        case 0:  // ANT 1
            filters|=ALEX_TX_ANTENNA_1;
            break;
        case 1:  // ANT 2
            filters|=ALEX_TX_ANTENNA_2;
            break;
        case 2:  // ANT 3
            filters|=ALEX_TX_ANTENNA_3;
            break;
        case 3:  // EXT 1
        case 4:  // EXT 2
        case 5:  // XVTR
            switch(band->alexTxAntenna) {
            case 0:  // ANT 1
                filters|=ALEX_TX_ANTENNA_1;
                break;
            case 1:  // ANT 2
                filters|=ALEX_TX_ANTENNA_2;
                break;
            case 2:  // ANT 3
                filters|=ALEX_TX_ANTENNA_3;
                break;
            }
            break;
        }
    }

    //filters|=alex_attenuation;

    if(tx) {
        filters|=0x08000000;
    }

    /*
        buffer[1420]=filters>>24;
        buffer[1421]=filters>>16;
        buffer[1422]=filters>>8;
        buffer[1423]=filters;
    */

    buffer[1432]=filters>>24;
    buffer[1433]=filters>>16;
    buffer[1434]=filters>>8;
    buffer[1435]=filters;

    //buffer[1442]=attenuation;
    buffer[1443]=attenuation;

//fprintf(stderr,"[4]=%02X\n", buffer[4]);
//fprintf(stderr,"filters=%04X\n", filters);

    if(sendto(data_socket,buffer,sizeof(buffer),0,(struct sockaddr*)&high_priority_addr,high_priority_addr_length)<0) {
        fprintf(stderr,"sendto socket failed for high priority\n");
        exit(1);
    }

    high_priority_sequence++;
}