// File: jkingan[P]ladyheather/heathui.cpp
// Function: dump_cal_file()
void dump_cal_file()
{
FILE *file;

   if(edit_buffer[0] == 0) {
      file = topen("luxcal.scr", "w");
      if(file == 0) {
         sprintf(out, "ERROR: could not write file: luxcal.scr");
         edit_error(out);
         return;
      }
   }
   else {
//    strupr(edit_buffer);
      if(strstr(edit_buffer, ".") == 0) strcat(edit_buffer, ".scr");
      file = topen(edit_buffer, "w");
      if(file == 0) {
         sprintf(out, "ERROR: could not write file: %s", edit_buffer);
         edit_error(out);
         return;
      }
   }
   if(file == 0) return;

   fprintf(file, "&c0                     ;exit calibration mode\n");
   fprintf(file, "&s  %.4f   SERIAL     ;serial number\n", vref_b);
   fprintf(file, "&v  %.6f VREF       ;ADC reference voltage\n", vref_m);
   fprintf(file, "gd& %.6f %.6f   ;battery/led voltage calibration\n", vcal_m, vcal_b);
   fprintf(file, "go& %.6f %.6f   ;battery current calibration\n", batti_m, batti_b);
   fprintf(file, "g3& %.6f %.6f   ;led current calibration\n", ledi_m, ledi_b);
   fprintf(file, "gt& %.6f %.6f   ;temp sensor 1 calibration\n", temp1_m, temp1_b);
   fprintf(file, "g5& %.6f %.6f   ;temp sensor 2 calibration\n", temp2_m, temp2_b);
   fprintf(file, "gp& %.6f %.6f   ;lux sensor calibration\n", lux1_m, lux1_b);
   fprintf(file, "g1& %.6f %.6f   ;lumen sensor calibration\n", lux2_m, lux2_b);
   fprintf(file, "gl& %.6f %.6f   ;r/b color temperature calibration\n", rb_m, rb_b);
   fprintf(file, "g0& %.6f %.6f   ;aux ADC channel calibration\n", adc2_m, adc2_b);

   fclose(file);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq 0x356681(%rip), %rax    # 0x39e4c0
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x47e8d
leaq 0x131e11(%rip), %rdi    # 0x179c5f
leaq 0x13c7f6(%rip), %rsi    # 0x18464b
callq 0x9b20
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x47e8b
leaq 0x353594(%rip), %rdi    # 0x39b400
leaq 0x131dcf(%rip), %rsi    # 0x179c42
movb $0x0, %al
callq 0x9060
leaq 0x35357f(%rip), %rdi    # 0x39b400
callq 0x30d60
jmp 0x480cf
jmp 0x47f06
leaq 0x35662c(%rip), %rdi    # 0x39e4c0
leaq 0x14df2d(%rip), %rsi    # 0x195dc8
callq 0x9090
cmpq $0x0, %rax
jne 0x47eb9
leaq 0x356613(%rip), %rdi    # 0x39e4c0
leaq 0x13a8ac(%rip), %rsi    # 0x182760
callq 0x96a0
leaq 0x356600(%rip), %rdi    # 0x39e4c0
leaq 0x13c784(%rip), %rsi    # 0x18464b
callq 0x9b20
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x47f04
leaq 0x353522(%rip), %rdi    # 0x39b400
leaq 0x131d85(%rip), %rsi    # 0x179c6a
leaq 0x3565d4(%rip), %rdx    # 0x39e4c0
movb $0x0, %al
callq 0x9060
leaq 0x353506(%rip), %rdi    # 0x39b400
callq 0x30d60
jmp 0x480cf
jmp 0x47f06
cmpq $0x0, -0x8(%rbp)
jne 0x47f12
jmp 0x480cf
movq -0x8(%rbp), %rdi
leaq 0x131d6d(%rip), %rsi    # 0x179c8a
movb $0x0, %al
callq 0x9550
movq -0x8(%rbp), %rdi
leaq 0x232419(%rip), %rax    # 0x27a348
movsd (%rax), %xmm0
leaq 0x131d80(%rip), %rsi    # 0x179cba
movb $0x1, %al
callq 0x9550
movq -0x8(%rbp), %rdi
leaq 0x2323f4(%rip), %rax    # 0x27a340
movsd (%rax), %xmm0
leaq 0x131d89(%rip), %rsi    # 0x179ce0
movb $0x1, %al
callq 0x9550
movq -0x8(%rbp), %rdi
leaq 0x232407(%rip), %rax    # 0x27a370
movsd (%rax), %xmm0
leaq 0x232404(%rip), %rax    # 0x27a378
movsd (%rax), %xmm1
leaq 0x131d8d(%rip), %rsi    # 0x179d0c
movb $0x2, %al
callq 0x9550
movq -0x8(%rbp), %rdi
leaq 0x2323ef(%rip), %rax    # 0x27a380
movsd (%rax), %xmm0
leaq 0x2323ec(%rip), %rax    # 0x27a388
movsd (%rax), %xmm1
leaq 0x131d97(%rip), %rsi    # 0x179d3e
movb $0x2, %al
callq 0x9550
movq -0x8(%rbp), %rdi
leaq 0x2323d7(%rip), %rax    # 0x27a390
movsd (%rax), %xmm0
leaq 0x2323d4(%rip), %rax    # 0x27a398
movsd (%rax), %xmm1
leaq 0x131d9d(%rip), %rsi    # 0x179d6c
movb $0x2, %al
callq 0x9550
movq -0x8(%rbp), %rdi
leaq 0x23236f(%rip), %rax    # 0x27a350
movsd (%rax), %xmm0
leaq 0x23236c(%rip), %rax    # 0x27a358
movsd (%rax), %xmm1
leaq 0x131d9f(%rip), %rsi    # 0x179d96
movb $0x2, %al
callq 0x9550
movq -0x8(%rbp), %rdi
leaq 0x232357(%rip), %rax    # 0x27a360
movsd (%rax), %xmm0
leaq 0x232354(%rip), %rax    # 0x27a368
movsd (%rax), %xmm1
leaq 0x131da3(%rip), %rsi    # 0x179dc2
movb $0x2, %al
callq 0x9550
movq -0x8(%rbp), %rdi
leaq 0x23236f(%rip), %rax    # 0x27a3a0
movsd (%rax), %xmm0
leaq 0x23236c(%rip), %rax    # 0x27a3a8
movsd (%rax), %xmm1
leaq 0x131da7(%rip), %rsi    # 0x179dee
movb $0x2, %al
callq 0x9550
movq -0x8(%rbp), %rdi
leaq 0x232357(%rip), %rax    # 0x27a3b0
movsd (%rax), %xmm0
leaq 0x232354(%rip), %rax    # 0x27a3b8
movsd (%rax), %xmm1
leaq 0x131da8(%rip), %rsi    # 0x179e17
movb $0x2, %al
callq 0x9550
movq -0x8(%rbp), %rdi
leaq 0x23234f(%rip), %rax    # 0x27a3d0
movsd (%rax), %xmm0
leaq 0x23234c(%rip), %rax    # 0x27a3d8
movsd (%rax), %xmm1
leaq 0x131dab(%rip), %rsi    # 0x179e42
movb $0x2, %al
callq 0x9550
movq -0x8(%rbp), %rdi
leaq 0x232317(%rip), %rax    # 0x27a3c0
movsd (%rax), %xmm0
leaq 0x232314(%rip), %rax    # 0x27a3c8
movsd (%rax), %xmm1
leaq 0x131db7(%rip), %rsi    # 0x179e76
movb $0x2, %al
callq 0x9550
movq -0x8(%rbp), %rdi
callq 0x9380
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)