// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathui.cpp
// Function: edit_osc_pid_value(char, char*, int)
u08 edit_osc_pid_value(char c, char *s, int kbd_cmd)
{
   if(s == 0) return 'b';
   c = toupper(c);

   if((c == 'A') || (c == 'B')) {    // BA command - bang-bang autotune
   }
   else if(c == 'C') { // BC command - failed cable delay trick - does not work
      sscanf(s, "%lf", &trick_scale);
      if(trick_scale == 0.0) {
         set_pps(user_pps_enable, pps_polarity,  delay_value, pps1_delay, pps_threshold, 0);
         request_pps_info();
      }
      else {
         first_trick = 1;
         trick_value = 0.0;
      }
   }
   else if(c == 'D') {  // BD command - derivitive time constant
      sscanf(s, "%lf", &OSC_D_TC);
      calc_osc_k_factors();
   }
   else if(c == 'F') {  // BF command - filter time constant
      sscanf(s, "%lf", &OSC_FILTER_TC);
      calc_osc_k_factors();
   }
   else if(c == 'H') {  // BH command - PID debug (help) display
      osc_pid_debug = toggle_value(osc_pid_debug);
      if(osc_pid_debug) pid_debug = 0;
      if(kbd_cmd) clear_osc_pid_display();
   }
   else if(c == 'I') {  // BI command - integral time constant
      sscanf(s, "%lf", &OSC_I_TC);
      calc_osc_k_factors();
   }
   else if(c == 'K') {  // BK command - all major PID values
      OSC_FILTER_OFFSET = 0.0F;
      sscanf(s, "%lf%c%lf%c%lf%c%lf", &OSC_P_GAIN,&c, &OSC_D_TC,&c,  &OSC_FILTER_TC,&c, &OSC_I_TC);
      calc_osc_k_factors();
      if(kbd_cmd) enable_osc_control();
      if(0 && kbd_cmd) show_osc_pid_values();
   }
   else if(c == 'L') {  // BL command - load distubance
      sscanf(s, "%lf", &osc_k6);
      calc_osc_k_factors();
   }
   else if(c == 'N') {  // BN command - mark's values
      set_default_osc_pid(1);
      if(kbd_cmd) enable_osc_control();
      if(0 && kbd_cmd) show_osc_pid_values();
   }
   else if(c == 'O') {  // BO command - filter offset
      sscanf(s, "%lf", &OSC_FILTER_OFFSET);
      calc_osc_k_factors();
   }
   else if(c == 'P') {  // BP command - pid gain
      sscanf(s, "%lf", &OSC_P_GAIN);
      calc_osc_k_factors();
   }
   else if(c == 'Q') {  // BQ command - post-filter depth
//    sscanf(s, "%lf", &OSC_KL_TUNE_STEP);
//    sscanf(s, "%d", &osc_prefilter);
//    if(osc_prefilter > PRE_Q_SIZE) osc_prefilter = PRE_Q_SIZE;
//    opq_in = opq_count = 0;
      sscanf(s, "%d", &osc_postfilter);
      if(osc_postfilter > POST_Q_SIZE) osc_postfilter = POST_Q_SIZE;
      new_postfilter();
      calc_osc_k_factors();
   }
   else if(c == 'R') {  // BR command - integrator reset
      sscanf(s, "%lf", &osc_k8);
      calc_osc_k_factors();
   }
   else if(c == 'S') {  // BS command - scale factor (loop gain correction)
      sscanf(s, "%lf", &osc_k7);
      calc_osc_k_factors();
   }
   else if(c == 'W') {  // BW command - Warren's slow values
      set_default_osc_pid(0);
      if(kbd_cmd) enable_osc_control();
      if(0 && kbd_cmd) show_osc_pid_values();
   }
   else if(c == 'X') {  // BX command - John's values
      set_default_osc_pid(2);
      if(kbd_cmd) enable_osc_control();
      if(0 && kbd_cmd) show_osc_pid_values();
   }
   else if(c == 'Y') {  // BY command - TBD values
      set_default_osc_pid(3);
      if(kbd_cmd) enable_osc_control();
      if(0 && kbd_cmd) show_osc_pid_values();
   }
   else if(c == 'Z') {  // BZ command - reset PID
      reset_osc_pid(kbd_cmd);
   }
   else if(c == '0') {  // B0 command - turn off pid
      disable_osc_control();
   }
   else if(c == '1') {  // B1 command - turn pid on
      enable_osc_control();
   }
   else return 1;

   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
testq %rsi, %rsi
je 0x3135e
movl %edx, %r14d
movq %rsi, %rbx
movsbl %dil, %edi
callq 0x9700
movb %al, -0x11(%rbp)
movzbl %al, %ecx
movb $0x1, %al
addl $-0x30, %ecx
cmpl $0x2a, %ecx
ja 0x31551
leaq 0xc4e8d(%rip), %rdx     # 0xf61d8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
callq 0xef080
jmp 0x3154f
movb $0x62, %al
jmp 0x31551
pushq $0x2
jmp 0x31382
leaq 0xebe20(%rip), %rsi     # 0x11d190
leaq 0x2f8349(%rip), %rdx    # 0x3296c0
jmp 0x31540
pushq $0x1
jmp 0x31382
pushq $0x3
popq %rdi
jmp 0x31501
leaq 0xebe01(%rip), %rsi     # 0x11d190
leaq 0x2f831a(%rip), %rdx    # 0x3296b0
jmp 0x31540
leaq 0x2f82f6(%rip), %rbx    # 0x329698
movzbl (%rbx), %edi
callq 0x31279
movb %al, (%rbx)
testb %al, %al
je 0x313ba
leaq 0x2f8289(%rip), %rax    # 0x329640
movb $0x0, (%rax)
testl %r14d, %r14d
je 0x3154f
callq 0x312e5
jmp 0x3154f
leaq 0xebdbc(%rip), %rsi     # 0x11d190
leaq 0x2f833d(%rip), %r14    # 0x329718
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x9350
movsd (%r14), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x31564
jp 0x31564
leaq 0x2c6919(%rip), %rax    # 0x2f7d21
movzbl (%rax), %edi
leaq 0x2c6906(%rip), %rax    # 0x2f7d18
movzbl (%rax), %esi
leaq 0x2c69a4(%rip), %rax    # 0x2f7dc0
movsd (%rax), %xmm0
leaq 0x2c69b1(%rip), %rax    # 0x2f7dd8
movsd (%rax), %xmm1
leaq 0x2c68ea(%rip), %rax    # 0x2f7d1c
movss (%rax), %xmm2
xorl %edx, %edx
callq 0x61e97
callq 0x61bf1
jmp 0x3154f
leaq 0x2f8272(%rip), %rax    # 0x3296c0
andq $0x0, (%rax)
subq $0x8, %rsp
leaq 0x2f825b(%rip), %r10    # 0x3296b8
leaq -0x11(%rbp), %rcx
leaq 0x2f8248(%rip), %r11    # 0x3296b0
leaq 0xebeac(%rip), %rsi     # 0x11d31b
leaq 0x2f822a(%rip), %rdx    # 0x3296a0
leaq 0x2f822b(%rip), %r8     # 0x3296a8
movq %rbx, %rdi
movq %rcx, %r9
xorl %eax, %eax
pushq %r10
pushq %rcx
pushq %r11
callq 0x9350
addq $0x20, %rsp
callq 0xf02f3
jmp 0x31506
leaq 0xebcef(%rip), %rsi     # 0x11d190
leaq 0x2f8210(%rip), %rdx    # 0x3296b8
jmp 0x31540
leaq 0xdc9e8(%rip), %rsi     # 0x10de9c
leaq 0x2f81d1(%rip), %r14    # 0x32968c
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x9350
cmpl $0x259, (%r14)          # imm = 0x259
jl 0x314d8
movl $0x258, (%r14)          # imm = 0x258
callq 0xf0596
jmp 0x3154a
leaq 0xebcaa(%rip), %rsi     # 0x11d190
leaq 0x40e3a3(%rip), %rdx    # 0x43f890
jmp 0x31540
leaq 0xebc9a(%rip), %rsi     # 0x11d190
leaq 0x2f81ab(%rip), %rdx    # 0x3296a8
jmp 0x31540
xorl %edi, %edi
callq 0xf0617
testl %r14d, %r14d
je 0x3154f
callq 0xf0c6a
jmp 0x3154f
leaq 0xebc77(%rip), %rsi     # 0x11d190
leaq 0x40e360(%rip), %rdx    # 0x43f880
jmp 0x31540
leaq 0xebc67(%rip), %rsi     # 0x11d190
leaq 0x40e358(%rip), %rdx    # 0x43f888
jmp 0x31540
leaq 0xebc57(%rip), %rsi     # 0x11d190
leaq 0x2f8160(%rip), %rdx    # 0x3296a0
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9350
callq 0xf02f3
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movl %r14d, %edi
callq 0xf0545
jmp 0x3154f
leaq 0x2f81b5(%rip), %rax    # 0x329720
movl $0x1, (%rax)
leaq 0x2f81b0(%rip), %rax    # 0x329728
andq $0x0, (%rax)
jmp 0x3154f