// File: /workspace/github_cpp_makefile_star2_O1/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
movb %dil, -0x11(%rbp)
testq %rsi, %rsi
je 0x33fe1
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 0x341fe
leaq 0xd818a(%rip), %rdx     # 0x10c158
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
callq 0x10529b
jmp 0x341fc
movb $0x62, %al
jmp 0x341fe
movl $0x2, %edi
jmp 0x341ae
leaq 0xff187(%rip), %rsi     # 0x133180
leaq 0x30b6c0(%rip), %rdx    # 0x33f6c0
jmp 0x341ed
movl $0x1, %edi
jmp 0x341ae
movl $0x3, %edi
jmp 0x341ae
leaq 0xff160(%rip), %rsi     # 0x133180
leaq 0x30b689(%rip), %rdx    # 0x33f6b0
jmp 0x341ed
leaq 0x30b665(%rip), %rbx    # 0x33f698
movzbl (%rbx), %edi
callq 0x33ef8
movb %al, (%rbx)
testb %al, %al
je 0x3404b
leaq 0x30b5f8(%rip), %rcx    # 0x33f640
movb $0x0, (%rcx)
testl %r14d, %r14d
sete %cl
orb %al, %cl
jne 0x341fc
leaq 0x30a940(%rip), %rax    # 0x33e9a0
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x30aa85(%rip), %rax    # 0x33eaf0
movb %cl, (%rax)
callq 0xfb1a
jmp 0x341fc
leaq 0xff102(%rip), %rsi     # 0x133180
leaq 0x30b693(%rip), %r14    # 0x33f718
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x9360
movsd (%r14), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x34211
jp 0x34211
leaq 0x2d9c6f(%rip), %rax    # 0x30dd21
movzbl (%rax), %edi
leaq 0x2d9c5c(%rip), %rax    # 0x30dd18
movzbl (%rax), %esi
leaq 0x2d9cfa(%rip), %rax    # 0x30ddc0
movsd (%rax), %xmm0
leaq 0x2d9d07(%rip), %rax    # 0x30ddd8
movsd (%rax), %xmm1
leaq 0x2d9c40(%rip), %rax    # 0x30dd1c
movss (%rax), %xmm2
xorl %edx, %edx
callq 0x6ad1d
callq 0x6a9e7
jmp 0x341fc
leaq 0x30b5c8(%rip), %rax    # 0x33f6c0
movq $0x0, (%rax)
subq $0x8, %rsp
leaq 0x30b5ae(%rip), %r10    # 0x33f6b8
leaq -0x11(%rbp), %rcx
leaq 0x30b59b(%rip), %r11    # 0x33f6b0
leaq 0xff1ef(%rip), %rsi     # 0x13330b
leaq 0x30b57d(%rip), %rdx    # 0x33f6a0
leaq 0x30b57e(%rip), %r8     # 0x33f6a8
movq %rbx, %rdi
movq %rcx, %r9
xorl %eax, %eax
pushq %r10
pushq %rcx
pushq %r11
callq 0x9360
addq $0x20, %rsp
callq 0x10659d
jmp 0x341b3
leaq 0xff032(%rip), %rsi     # 0x133180
leaq 0x30b563(%rip), %rdx    # 0x33f6b8
jmp 0x341ed
leaq 0xefd13(%rip), %rsi     # 0x123e74
leaq 0x30b524(%rip), %r14    # 0x33f68c
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x9360
cmpl $0x259, (%r14)          # imm = 0x259
jl 0x34185
movl $0x258, (%r14)          # imm = 0x258
callq 0x10688f
jmp 0x341f7
leaq 0xfefed(%rip), %rsi     # 0x133180
leaq 0x4217d6(%rip), %rdx    # 0x455970
jmp 0x341ed
leaq 0xfefdd(%rip), %rsi     # 0x133180
leaq 0x30b4fe(%rip), %rdx    # 0x33f6a8
jmp 0x341ed
xorl %edi, %edi
callq 0x106913
testl %r14d, %r14d
je 0x341fc
callq 0x106fb7
jmp 0x341fc
leaq 0xfefba(%rip), %rsi     # 0x133180
leaq 0x421793(%rip), %rdx    # 0x455960
jmp 0x341ed
leaq 0xfefaa(%rip), %rsi     # 0x133180
leaq 0x42178b(%rip), %rdx    # 0x455968
jmp 0x341ed
leaq 0xfef9a(%rip), %rsi     # 0x133180
leaq 0x30b4b3(%rip), %rdx    # 0x33f6a0
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9360
callq 0x10659d
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movl %r14d, %edi
callq 0x10680b
jmp 0x341fc
leaq 0x30b508(%rip), %rax    # 0x33f720
movl $0x1, (%rax)
leaq 0x30b503(%rip), %rax    # 0x33f728
movq $0x0, (%rax)
jmp 0x341fc