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

   c = toupper(c);

   if(c == 'A') {    // KA command - bang-bang autotune
      // ka0 = abort autotune
      // ka1 = do full tuneup with all settling delays
      // ka2 = don't wait for temp to get near setpoint
      // ka3 = don't wait for pid to stabilize
      if(bang_bang == 0) OLD_P_GAIN = P_GAIN;
      bang_bang = 1;
      sscanf(s, "%d", &bang_bang);
      if(kbd_cmd) enable_temp_control();
      do_temp_control = 1;

      if(bang_bang > 4) bang_bang = 1;
      else if(bang_bang == 0) {       // abort autotune
         P_GAIN = OLD_P_GAIN;
         calc_k_factors();
         if(kbd_cmd) clear_pid_display();
         if(kbd_cmd) show_pid_values();
      }
   }
   else if(c == 'D') {  // KD command - derivitive time constant
      D_TC = (DATA_SIZE) atof(s);
      calc_k_factors();
   }
   else if(c == 'F') {  // KF command - filter time constant
      FILTER_TC = (DATA_SIZE) atof(s);
      calc_k_factors();
   }
   else if(c == 'G') {  // KG command - scale factor (loop gain correction)
      k7 = (DATA_SIZE) atof(s);
      calc_k_factors();
   }
   else if(c == 'H') {  // KH command - PID debug (help) display
      pid_debug = toggle_value(pid_debug);
      if(pid_debug) osc_pid_debug = 0;
      if(kbd_cmd) clear_pid_display();
   }
   else if(c == 'I') {  // KI command - integral time constant
      I_TC = (DATA_SIZE) atof(s);
      calc_k_factors();
   }
   else if(c == 'K') {  // KK command - all major PID values
      if(kbd_cmd) enable_temp_control();
      do_temp_control = 1;
      FILTER_OFFSET = 0.0;

      #ifdef DOUBLE_DATA
         sscanf(s, "%lf%c%lf%c%lf%c%lf", &P_GAIN,&c, &D_TC,&c,  &FILTER_TC,&c, &I_TC);
      #else
         sscanf(s, "%f%c%f%c%f%c%f", &P_GAIN,&c, &D_TC,&c,  &FILTER_TC,&c, &I_TC);
      #endif

      calc_k_factors();
   }
   else if(c == 'L') {  // KL command - load distubance
      k6 = (DATA_SIZE) atof(s);
      calc_k_factors();
   }
   else if(c == 'N') {  // KN command - mark's medium values
      if(kbd_cmd) enable_temp_control();
      do_temp_control = 1;
      set_default_pid(1);
      if(0 && kbd_cmd) show_pid_values();
   }
   else if(c == 'O') {  // KO command - filter offset
      FILTER_OFFSET = (DATA_SIZE) atof(s);
      calc_k_factors();
   }
   else if(c == 'P') {  // KP command - pid gain
      P_GAIN = (DATA_SIZE) atof(s);
      calc_k_factors();
   }
   else if(c == 'R') {  // KR command - integrator reset
      k8 = (DATA_SIZE) atof(s);
      calc_k_factors();
   }
   else if(c == 'S') {  // KS command - scale factor (loop gain correction)
      k7 = (DATA_SIZE) atof(s);
      calc_k_factors();
   }
   else if(c == 'T') {  // KT command - pwm test
      #ifdef DOUBLE_DATA
         sscanf(s, "%lf%c%lf", &test_cool, &c, &test_heat);
      #else
         sscanf(s, "%f%c%f", &test_cool, &c, &test_heat);
      #endif

      if(test_heat || test_cool) {
         if(kbd_cmd) enable_temp_control();
         do_temp_control = 1;
      }
      if(++test_marker >= MAX_MARKER) test_marker = 1;
      if(test_marker < 0) test_marker = 1;
      mark_q_entry[test_marker] = plot_q_in;
   }
   else if(c == 'W') {  // KW command - Warren's slow values
      if(kbd_cmd) enable_temp_control();
      do_temp_control = 1;
      set_default_pid(0);
      if(0 && kbd_cmd) show_pid_values();
   }
   else if(c == 'X') {  // KX command - fast PID values
      if(kbd_cmd) enable_temp_control();
      do_temp_control = 1;
      set_default_pid(2);
      if(0 && kbd_cmd) show_pid_values();
   }
   else if(c == 'Y') {  // KY command - very fast PID values
      if(kbd_cmd) enable_temp_control();
      do_temp_control = 1;
      set_default_pid(3);
      if(0 && kbd_cmd) show_pid_values();
   }
   else if(c == 'Z') {  // KZ command - reset PID
      integrator = 0.0F;
      if(kbd_cmd) enable_temp_control();
      do_temp_control = 1;
   }
   else if(c == '9') {  // K9 command - autotune step size
      KL_TUNE_STEP = (DATA_SIZE) atof(s);
      calc_k_factors();
   }
   else if(c == '0') {  // K0 command - make temperature crude
      crude_temp = toggle_value(crude_temp);
   }
   else return 1;

   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movb %dil, -0x21(%rbp)
testq %rsi, %rsi
je 0x33b81
movl %edx, %r14d
movq %rsi, %r15
movsbl %dil, %edi
callq 0x9700
movb %al, -0x21(%rbp)
movzbl %al, %eax
movb $0x1, %bl
addl $-0x30, %eax
cmpl $0x2a, %eax
ja 0x33e7a
leaq 0xd8548(%rip), %rcx     # 0x10c0ac
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r15, %rdi
callq 0x9470
leaq 0x421cc4(%rip), %rax    # 0x455840
jmp 0x33e4f
movb $0x6b, %bl
jmp 0x33e7a
testl %r14d, %r14d
je 0x33b92
callq 0x106463
leaq 0x30c227(%rip), %rax    # 0x33fdc0
movb $0x1, (%rax)
movl $0x3, %edi
jmp 0x33e73
movq %r15, %rdi
callq 0x9470
leaq 0x30ba93(%rip), %rax    # 0x33f648
jmp 0x33e4f
movq %r15, %rdi
callq 0x9470
leaq 0x421c6f(%rip), %rax    # 0x455838
jmp 0x33e4f
movq %r15, %rdi
callq 0x9470
leaq 0x30ba8b(%rip), %rax    # 0x33f668
jmp 0x33e4f
leaq 0x30ba53(%rip), %rbx    # 0x33f63c
cmpl $0x0, (%rbx)
jne 0x33c04
leaq 0x30ba53(%rip), %rax    # 0x33f648
movsd (%rax), %xmm0
leaq 0x30ba78(%rip), %rax    # 0x33f678
movsd %xmm0, (%rax)
movl $0x1, (%rbx)
leaq 0xf0263(%rip), %rsi     # 0x123e74
movq %r15, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x9360
testl %r14d, %r14d
je 0x33c28
callq 0x106463
leaq 0x30c191(%rip), %rax    # 0x33fdc0
movb $0x1, (%rax)
movl (%rbx), %eax
cmpl $0x5, %eax
jl 0x33ea8
movl $0x1, (%rbx)
jmp 0x33e78
leaq 0x421bc1(%rip), %rax    # 0x455810
movq $0x0, (%rax)
testl %r14d, %r14d
je 0x33c60
callq 0x106463
leaq 0x30c159(%rip), %rax    # 0x33fdc0
movb $0x1, (%rax)
jmp 0x33e78
testl %r14d, %r14d
je 0x33c79
callq 0x106463
leaq 0x30c140(%rip), %rax    # 0x33fdc0
movb $0x1, (%rax)
movl $0x1, %edi
jmp 0x33e73
leaq 0x30b9b0(%rip), %rbx    # 0x33f644
movzbl (%rbx), %edi
callq 0x33ef8
movzbl %al, %eax
movl %eax, (%rbx)
jmp 0x33e78
movq %r15, %rdi
callq 0x9470
leaq 0x30b9bb(%rip), %rax    # 0x33f670
jmp 0x33e4f
leaq 0x30b97f(%rip), %rbx    # 0x33f640
movzbl (%rbx), %edi
callq 0x33ef8
movb %al, (%rbx)
testb %al, %al
je 0x33cd9
leaq 0x30b9c2(%rip), %rcx    # 0x33f698
movb $0x0, (%rcx)
testl %r14d, %r14d
sete %cl
orb %al, %cl
jne 0x33e78
leaq 0x30acb2(%rip), %rax    # 0x33e9a0
xorl %ebx, %ebx
movb %bl, (%rax)
leaq 0x30adf7(%rip), %rax    # 0x33eaf0
movb %bl, (%rax)
callq 0xfb1a
jmp 0x33e7a
movq %r15, %rdi
callq 0x9470
leaq 0x30b93c(%rip), %rax    # 0x33f650
jmp 0x33e4f
movq %r15, %rdi
callq 0x9470
leaq 0x421b20(%rip), %rax    # 0x455848
jmp 0x33e4f
leaq 0xff5e1(%rip), %rsi     # 0x133315
leaq 0x30b8f5(%rip), %rbx    # 0x33f630
leaq 0x30b8e6(%rip), %r12    # 0x33f628
leaq -0x21(%rbp), %rcx
movq %r15, %rdi
movq %rbx, %rdx
movq %r12, %r8
xorl %eax, %eax
callq 0x9360
movsd (%r12), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x33d74
jp 0x33d74
movsd (%rbx), %xmm1
ucomisd %xmm0, %xmm1
jne 0x33d74
jnp 0x33d88
testl %r14d, %r14d
je 0x33d7e
callq 0x106463
leaq 0x30c03b(%rip), %rax    # 0x33fdc0
movb $0x1, (%rax)
leaq 0x30b8a9(%rip), %rax    # 0x33f638
movl (%rax), %ecx
leal 0x1(%rcx), %edx
cmpl $0x9, %ecx
movl $0x1, %ecx
cmovgel %ecx, %edx
testl %edx, %edx
cmovsl %ecx, %edx
movl %edx, (%rax)
leaq 0x1e757b(%rip), %rax    # 0x21b328
movq (%rax), %rax
movslq %edx, %rcx
leaq 0x1e74f6(%rip), %rdx    # 0x21b2b0
movq %rax, (%rdx,%rcx,8)
jmp 0x33e78
movq %r15, %rdi
callq 0x9470
leaq 0x30b886(%rip), %rax    # 0x33f658
jmp 0x33e4f
testl %r14d, %r14d
je 0x33dde
callq 0x106463
leaq 0x30bfdb(%rip), %rax    # 0x33fdc0
movb $0x1, (%rax)
leaq 0x30b879(%rip), %rax    # 0x33f668
movq $0x0, (%rax)
subq $0x8, %rsp
leaq 0x30b85f(%rip), %r10    # 0x33f660
leaq -0x21(%rbp), %rcx
leaq 0x30b84c(%rip), %r11    # 0x33f658
leaq 0xff4f8(%rip), %rsi     # 0x13330b
leaq 0x30b82e(%rip), %rdx    # 0x33f648
leaq 0x30b82f(%rip), %r8     # 0x33f650
xorl %ebx, %ebx
movq %r15, %rdi
movq %rcx, %r9
xorl %eax, %eax
pushq %r10
pushq %rcx
pushq %r11
callq 0x9360
addq $0x20, %rsp
callq 0x1052ff
jmp 0x33e7a
movq %r15, %rdi
callq 0x9470
leaq 0x30b811(%rip), %rax    # 0x33f660
movsd %xmm0, (%rax)
callq 0x1052ff
jmp 0x33e78
testl %r14d, %r14d
je 0x33e64
callq 0x106463
leaq 0x30bf55(%rip), %rax    # 0x33fdc0
movb $0x1, (%rax)
movl $0x2, %edi
callq 0x10541b
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
testl %r14d, %r14d
je 0x33e93
callq 0x106463
leaq 0x30bf26(%rip), %rax    # 0x33fdc0
movb $0x1, (%rax)
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x10541b
jmp 0x33e7a
testl %eax, %eax
jne 0x33e78
leaq 0x30b7c5(%rip), %rax    # 0x33f678
movsd (%rax), %xmm0
leaq 0x30b78a(%rip), %rax    # 0x33f648
movsd %xmm0, (%rax)
callq 0x1052ff
testl %r14d, %r14d
je 0x33e78
leaq 0x30b76d(%rip), %rax    # 0x33f640
cmpb $0x0, (%rax)
jne 0x33ef1
leaq 0x30aac1(%rip), %rax    # 0x33e9a0
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x30ac06(%rip), %rax    # 0x33eaf0
movb %cl, (%rax)
callq 0xfb1a
callq 0x1054b7
jmp 0x33e78