// File: /workspace/github_cpp_makefile_star2_O3/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 0x340f8
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 0x342f2
leaq 0xd807b(%rip), %rdx     # 0x10c160
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
callq 0x105999
jmp 0x342f0
movb $0x62, %al
jmp 0x342f2
movl $0x2, %edi
jmp 0x342a2
leaq 0xff160(%rip), %rsi     # 0x133270
leaq 0x30b5a9(%rip), %rdx    # 0x33f6c0
jmp 0x342e1
movl $0x1, %edi
jmp 0x342a2
movl $0x3, %edi
jmp 0x342a2
leaq 0xff139(%rip), %rsi     # 0x133270
leaq 0x30b572(%rip), %rdx    # 0x33f6b0
jmp 0x342e1
leaq 0x30b54e(%rip), %rbx    # 0x33f698
movzbl (%rbx), %edi
callq 0x34013
movb %al, (%rbx)
testb %al, %al
je 0x34305
leaq 0x30b4dd(%rip), %rax    # 0x33f640
movb $0x0, (%rax)
jmp 0x342f0
leaq 0xff0fe(%rip), %rsi     # 0x133270
leaq 0x30b59f(%rip), %r14    # 0x33f718
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x9360
movsd (%r14), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x34325
jp 0x34325
leaq 0x2d9b7b(%rip), %rax    # 0x30dd21
movzbl (%rax), %edi
leaq 0x2d9b68(%rip), %rax    # 0x30dd18
movzbl (%rax), %esi
leaq 0x2d9c06(%rip), %rax    # 0x30ddc0
movsd (%rax), %xmm0
leaq 0x2d9c13(%rip), %rax    # 0x30ddd8
movsd (%rax), %xmm1
leaq 0x2d9b4c(%rip), %rax    # 0x30dd1c
movss (%rax), %xmm2
xorl %edx, %edx
callq 0x6add8
callq 0x6ab01
jmp 0x342f0
leaq 0x30b4d4(%rip), %rax    # 0x33f6c0
movq $0x0, (%rax)
subq $0x8, %rsp
leaq 0x30b4ba(%rip), %r10    # 0x33f6b8
leaq -0x11(%rbp), %rcx
leaq 0x30b4a7(%rip), %r11    # 0x33f6b0
leaq 0xff1eb(%rip), %rsi     # 0x1333fb
leaq 0x30b489(%rip), %rdx    # 0x33f6a0
leaq 0x30b48a(%rip), %r8     # 0x33f6a8
movq %rbx, %rdi
movq %rcx, %r9
xorl %eax, %eax
pushq %r10
pushq %rcx
pushq %r11
callq 0x9360
addq $0x20, %rsp
callq 0x106cb3
jmp 0x342a7
leaq 0xff02e(%rip), %rsi     # 0x133270
leaq 0x30b46f(%rip), %rdx    # 0x33f6b8
jmp 0x342e1
leaq 0xefcff(%rip), %rsi     # 0x123f54
leaq 0x30b430(%rip), %r14    # 0x33f68c
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x9360
cmpl $0x259, (%r14)          # imm = 0x259
jl 0x34279
movl $0x258, (%r14)          # imm = 0x258
callq 0x106f94
jmp 0x342eb
leaq 0xfefe9(%rip), %rsi     # 0x133270
leaq 0x421602(%rip), %rdx    # 0x455890
jmp 0x342e1
leaq 0xfefd9(%rip), %rsi     # 0x133270
leaq 0x30b40a(%rip), %rdx    # 0x33f6a8
jmp 0x342e1
xorl %edi, %edi
callq 0x107018
testl %r14d, %r14d
je 0x342f0
callq 0x1076ac
jmp 0x342f0
leaq 0xfefb6(%rip), %rsi     # 0x133270
leaq 0x4215bf(%rip), %rdx    # 0x455880
jmp 0x342e1
leaq 0xfefa6(%rip), %rsi     # 0x133270
leaq 0x4215b7(%rip), %rdx    # 0x455888
jmp 0x342e1
leaq 0xfef96(%rip), %rsi     # 0x133270
leaq 0x30b3bf(%rip), %rdx    # 0x33f6a0
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9360
callq 0x106cb3
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movl %r14d, %edi
callq 0x106f10
jmp 0x342f0
testl %r14d, %r14d
je 0x342f0
leaq 0x30a68f(%rip), %rax    # 0x33e9a0
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x30a7d4(%rip), %rax    # 0x33eaf0
movb %cl, (%rax)
callq 0xfa97
jmp 0x342f0
leaq 0x30b3f4(%rip), %rax    # 0x33f720
movl $0x1, (%rax)
leaq 0x30b3ef(%rip), %rax    # 0x33f728
movq $0x0, (%rax)
jmp 0x342f0