// File: jkingan[P]ladyheather/heathui.cpp
// Function: edit_pps_freq(int)
void edit_pps_freq(int chan)
{
double freq;
double duty;
int old_width;

   // set lat/lon/altitude
   if(edit_buffer[0] == 0) return;

   freq = 1.0;
   duty = 0.50;
   if     (rcvr_type == NVS_RCVR)   sscanf(edit_buffer, "%lf", &duty);
   else if(rcvr_type == CS_RCVR)    sscanf(edit_buffer, "%lf", &freq);
   else if((rcvr_type == ESIP_RCVR) && (chan == 0)) sscanf(edit_buffer, "%lf", &duty);
   else if((rcvr_type == SS_RCVR) && (chan == 0))   sscanf(edit_buffer, "%lf", &duty);
   else if(rcvr_type == TM4_RCVR)   sscanf(edit_buffer, "%lf", &freq);
   else if(rcvr_type == ZYFER_RCVR) sscanf(edit_buffer, "%lf", &duty);
   else sscanf(edit_buffer, "%lf %lf", &freq, &duty);


   if(rcvr_type == CS_RCVR) {
   }
   else if((rcvr_type == ESIP_RCVR) && (chan == 0)) { // PPS pulse width
      if((duty < 1.0) || (duty > 500.0)) {
         edit_error("PPS width must be 1..500 msecs");
      }
      else {
         old_width = esip_pps_width;
         esip_pps_width = (int) duty;
         set_pps(user_pps_enable, pps_polarity,  cable_delay, pps1_delay,  pps_threshold, 4);
         esip_pps_width = old_width;
         request_pps_info();
      }
      return;
   }
   else if(rcvr_type == SS_RCVR) {
      old_width = (int) ss_pps_width;
      ss_pps_width = (int) (duty*1000.0);
      set_pps(user_pps_enable, pps_polarity,  cable_delay, pps1_delay,  pps_threshold, 4);
      ss_pps_width = (double) old_width;
      request_pps_info();
   }
   else if(rcvr_type == TM4_RCVR) {
   }
   else if(rcvr_type == ZYFER_RCVR) {
   }
   else if((chan == 1) && ((rcvr_type == NVS_RCVR) || ((rcvr_type == VENUS_RCVR) && !saw_timing_msg)) ) {
      edit_error("Receiver does not support PPS2");
      return;
   }
   else if(freq < 0.0) {
      edit_error("Frequency must be >= 0.0");
      return;
   }
   else if(duty <= 0.0) {
      edit_error("Duty cycle / pulse width must be > 0.0");
      return;
   }
   else if(duty >= 1.0) {  // duty is a pulse width in microseconds (or nanoseconds)
      if(rcvr_type == ESIP_RCVR) duty = freq * (duty/1.0E9);  // convert nanoeconds to duty cycle
      else if(rcvr_type == NVS_RCVR) duty = freq * (duty/1.0E9);  // convert nanoeconds to duty cycle
      else duty = freq * (duty/1.0E6);  // convert microseconds to duty cycle
      if(duty >= 1.0) {
         edit_error("Pulse width too long for specified frequency");
         return;
      }
   }

   if(chan == 0) set_pps_freq(chan, freq, duty, pps_polarity, cable_delay, pps1_delay, 1);
   else          set_pps_freq(chan, freq, duty, 0,            cable_delay, pps2_delay, 1); // rising edge gggg
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
leaq 0x357cce(%rip), %rax    # 0x39e4c0
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x467ff
jmp 0x46cc4
movsd 0x128861(%rip), %xmm0   # 0x16f068
movsd %xmm0, -0x10(%rbp)
movsd 0x12887c(%rip), %xmm0   # 0x16f090
movsd %xmm0, -0x18(%rbp)
leaq 0x231290(%rip), %rax    # 0x277ab0
cmpq $0x800, (%rax)          # imm = 0x800
jne 0x46847
leaq 0x357c90(%rip), %rdi    # 0x39e4c0
leaq 0x14f5a1(%rip), %rsi    # 0x195dd8
leaq -0x18(%rbp), %rdx
movb $0x0, %al
callq 0x9370
jmp 0x46964
leaq 0x231262(%rip), %rax    # 0x277ab0
cmpq $0x20000, (%rax)        # imm = 0x20000
jne 0x46875
leaq 0x357c62(%rip), %rdi    # 0x39e4c0
leaq 0x14f573(%rip), %rsi    # 0x195dd8
leaq -0x10(%rbp), %rdx
movb $0x0, %al
callq 0x9370
jmp 0x46962
movl $0x80000000, %ecx       # imm = 0x80000000
leaq 0x23122f(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x468aa
cmpl $0x0, -0x4(%rbp)
jne 0x468aa
leaq 0x357c2d(%rip), %rdi    # 0x39e4c0
leaq 0x14f53e(%rip), %rsi    # 0x195dd8
leaq -0x18(%rbp), %rdx
movb $0x0, %al
callq 0x9370
jmp 0x46960
movabsq $0x800000000, %rcx      # imm = 0x800000000
leaq 0x2311f5(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x468e1
cmpl $0x0, -0x4(%rbp)
jne 0x468e1
leaq 0x357bf3(%rip), %rdi    # 0x39e4c0
leaq 0x14f504(%rip), %rsi    # 0x195dd8
leaq -0x18(%rbp), %rdx
movb $0x0, %al
callq 0x9370
jmp 0x4695e
movabsq $0x400000000, %rcx      # imm = 0x400000000
leaq 0x2311be(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x46912
leaq 0x357bc2(%rip), %rdi    # 0x39e4c0
leaq 0x14f4d3(%rip), %rsi    # 0x195dd8
leaq -0x10(%rbp), %rdx
movb $0x0, %al
callq 0x9370
jmp 0x4695c
leaq 0x231197(%rip), %rax    # 0x277ab0
cmpq $0x100000, (%rax)       # imm = 0x100000
jne 0x4693d
leaq 0x357b97(%rip), %rdi    # 0x39e4c0
leaq 0x14f4a8(%rip), %rsi    # 0x195dd8
leaq -0x18(%rbp), %rdx
movb $0x0, %al
callq 0x9370
jmp 0x4695a
leaq 0x357b7c(%rip), %rdi    # 0x39e4c0
leaq 0x14f489(%rip), %rsi    # 0x195dd4
leaq -0x10(%rbp), %rdx
leaq -0x18(%rbp), %rcx
movb $0x0, %al
callq 0x9370
jmp 0x4695c
jmp 0x4695e
jmp 0x46960
jmp 0x46962
jmp 0x46964
leaq 0x231145(%rip), %rax    # 0x277ab0
cmpq $0x20000, (%rax)        # imm = 0x20000
jne 0x46979
jmp 0x46c57
movl $0x80000000, %ecx       # imm = 0x80000000
leaq 0x23112b(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x46a3b
cmpl $0x0, -0x4(%rbp)
jne 0x46a3b
movsd 0x1286c8(%rip), %xmm0   # 0x16f068
ucomisd -0x18(%rbp), %xmm0
ja 0x469ba
movsd -0x18(%rbp), %xmm0
movsd 0x12883c(%rip), %xmm1   # 0x16f1f0
ucomisd %xmm1, %xmm0
jbe 0x469c8
leaq 0x133156(%rip), %rdi    # 0x179b17
callq 0x30d60
jmp 0x46a36
leaq 0x326581(%rip), %rax    # 0x36cf50
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
cvttsd2si -0x18(%rbp), %ecx
leaq 0x326570(%rip), %rax    # 0x36cf50
movl %ecx, (%rax)
leaq 0x326518(%rip), %rax    # 0x36cf01
movb (%rax), %cl
leaq 0x326506(%rip), %rax    # 0x36cef8
movl (%rax), %eax
leaq 0x3265ad(%rip), %rdx    # 0x36cfa8
movsd (%rdx), %xmm0
leaq 0x3265b2(%rip), %rdx    # 0x36cfb8
movsd (%rdx), %xmm1
leaq 0x3264eb(%rip), %rdx    # 0x36cefc
movss (%rdx), %xmm2
movl $0x4, %edx
movzbl %cl, %edi
movzbl %al, %esi
callq 0x91b20
movl -0x1c(%rbp), %ecx
leaq 0x326521(%rip), %rax    # 0x36cf50
movl %ecx, (%rax)
callq 0x91720
jmp 0x46cc4
movabsq $0x800000000, %rcx      # imm = 0x800000000
leaq 0x231064(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x46ae0
leaq 0x32652c(%rip), %rax    # 0x36cf88
cvttsd2si (%rax), %eax
movl %eax, -0x1c(%rbp)
movsd 0x1285c5(%rip), %xmm0   # 0x16f030
mulsd -0x18(%rbp), %xmm0
cvttsd2si %xmm0, %eax
cvtsi2sd %eax, %xmm0
leaq 0x326509(%rip), %rax    # 0x36cf88
movsd %xmm0, (%rax)
leaq 0x326477(%rip), %rax    # 0x36cf01
movb (%rax), %cl
leaq 0x326465(%rip), %rax    # 0x36cef8
movl (%rax), %eax
leaq 0x32650c(%rip), %rdx    # 0x36cfa8
movsd (%rdx), %xmm0
leaq 0x326511(%rip), %rdx    # 0x36cfb8
movsd (%rdx), %xmm1
leaq 0x32644a(%rip), %rdx    # 0x36cefc
movss (%rdx), %xmm2
movl $0x4, %edx
movzbl %cl, %edi
movzbl %al, %esi
callq 0x91b20
cvtsi2sdl -0x1c(%rbp), %xmm0
leaq 0x3264b6(%rip), %rax    # 0x36cf88
movsd %xmm0, (%rax)
callq 0x91720
jmp 0x46c53
movabsq $0x400000000, %rcx      # imm = 0x400000000
leaq 0x230fbf(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x46afb
jmp 0x46c51
leaq 0x230fae(%rip), %rax    # 0x277ab0
cmpq $0x100000, (%rax)       # imm = 0x100000
jne 0x46b10
jmp 0x46c4f
cmpl $0x1, -0x4(%rbp)
jne 0x46b53
leaq 0x230f93(%rip), %rax    # 0x277ab0
cmpq $0x800, (%rax)          # imm = 0x800
je 0x46b42
leaq 0x230f83(%rip), %rax    # 0x277ab0
cmpq $0x80, (%rax)
jne 0x46b53
leaq 0x325acb(%rip), %rax    # 0x36c608
cmpl $0x0, (%rax)
jne 0x46b53
leaq 0x132fed(%rip), %rdi    # 0x179b36
callq 0x30d60
jmp 0x46cc4
xorps %xmm0, %xmm0
ucomisd -0x10(%rbp), %xmm0
jbe 0x46b6e
leaq 0x132ff1(%rip), %rdi    # 0x179b55
callq 0x30d60
jmp 0x46cc4
xorps %xmm0, %xmm0
ucomisd -0x18(%rbp), %xmm0
jb 0x46b89
leaq 0x132fef(%rip), %rdi    # 0x179b6e
callq 0x30d60
jmp 0x46cc4
movsd -0x18(%rbp), %xmm0
movsd 0x1284d2(%rip), %xmm1   # 0x16f068
ucomisd %xmm1, %xmm0
jb 0x46c47
movl $0x80000000, %ecx       # imm = 0x80000000
leaq 0x230f04(%rip), %rax    # 0x277ab0
cmpq %rcx, (%rax)
jne 0x46bd2
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movsd 0x128465(%rip), %xmm2   # 0x16f028
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x46c24
leaq 0x230ed7(%rip), %rax    # 0x277ab0
cmpq $0x800, (%rax)          # imm = 0x800
jne 0x46c03
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movsd 0x128434(%rip), %xmm2   # 0x16f028
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x46c22
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movsd 0x12842b(%rip), %xmm2   # 0x16f040
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x46c24
movsd -0x18(%rbp), %xmm0
movsd 0x128437(%rip), %xmm1   # 0x16f068
ucomisd %xmm1, %xmm0
jb 0x46c45
leaq 0x132f57(%rip), %rdi    # 0x179b95
callq 0x30d60
jmp 0x46cc4
jmp 0x46c47
jmp 0x46c49
jmp 0x46c4b
jmp 0x46c4d
jmp 0x46c4f
jmp 0x46c51
jmp 0x46c53
jmp 0x46c55
jmp 0x46c57
cmpl $0x0, -0x4(%rbp)
jne 0x46c95
movl -0x4(%rbp), %edi
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
leaq 0x326287(%rip), %rax    # 0x36cef8
movl (%rax), %esi
leaq 0x32632e(%rip), %rax    # 0x36cfa8
movsd (%rax), %xmm2
leaq 0x326333(%rip), %rax    # 0x36cfb8
movsd (%rax), %xmm3
movl $0x1, %edx
callq 0xcb480
jmp 0x46cc4
movl -0x4(%rbp), %edi
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
leaq 0x3262ff(%rip), %rax    # 0x36cfa8
movsd (%rax), %xmm2
leaq 0x32630c(%rip), %rax    # 0x36cfc0
movsd (%rax), %xmm3
xorl %esi, %esi
movl $0x1, %edx
callq 0xcb480
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)