// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_calendar.c
// Function: lv_calendar_signal
static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void * param)
{
    lv_res_t res;

    /* Include the ancient signal function */
    res = ancestor_signal(calendar, sign, param);
    if(res != LV_RES_OK) return res;
    if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);

    if(sign == LV_SIGNAL_CLEANUP) {
        /*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
    } else if(sign == LV_SIGNAL_PRESSING) {
        lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
        lv_area_t header_area;
        lv_area_copy(&header_area, &calendar->coords);
        header_area.y2 = header_area.y1 + get_header_height(calendar);

        lv_indev_t * indev = lv_indev_get_act();
        lv_point_t p;
        lv_indev_get_point(indev, &p);

        /*If the header is pressed mark an arrow as pressed*/
        if(lv_area_is_point_on(&header_area, &p)) {
            if(p.x < header_area.x1 + lv_area_get_width(&header_area) / 2) {
                if(ext->btn_pressing != -1) lv_obj_invalidate(calendar);
                ext->btn_pressing = -1;
            } else {
                if(ext->btn_pressing != 1) lv_obj_invalidate(calendar);
                ext->btn_pressing = 1;
            }

            ext->pressed_date.year  = 0;
            ext->pressed_date.month = 0;
            ext->pressed_date.day   = 0;
        }
        /*If a day is pressed save it*/
        else if(calculate_touched_day(calendar, &p)) {
            if(ext->btn_pressing != 0) lv_obj_invalidate(calendar);
            ext->btn_pressing = 0;
        }
        /*ELse set a deafault state*/
        else {
            if(ext->btn_pressing != 0) lv_obj_invalidate(calendar);
            ext->btn_pressing       = 0;
            ext->pressed_date.year  = 0;
            ext->pressed_date.month = 0;
            ext->pressed_date.day   = 0;
        }
    } else if(sign == LV_SIGNAL_PRESS_LOST) {
        lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
        ext->btn_pressing       = 0;
        lv_obj_invalidate(calendar);

    } else if(sign == LV_SIGNAL_RELEASED) {
        lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
        if(ext->btn_pressing < 0) {
            if(ext->showed_date.month <= 1) {
                ext->showed_date.month = 12;
                ext->showed_date.year--;
            } else {
                ext->showed_date.month--;
            }
        } else if(ext->btn_pressing > 0) {
            if(ext->showed_date.month >= 12) {
                ext->showed_date.month = 1;
                ext->showed_date.year++;
            } else {
                ext->showed_date.month++;
            }
        } else if(ext->pressed_date.year != 0) {
            res = lv_event_send(calendar, LV_EVENT_VALUE_CHANGED, NULL);
            if(res != LV_RES_OK) return res;
        }

        ext->btn_pressing = 0;
        lv_obj_invalidate(calendar);
    } else if(sign == LV_SIGNAL_CONTROL) {
        uint8_t c               = *((uint8_t *)param);
        lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
        if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
            if(ext->showed_date.month >= 12) {
                ext->showed_date.month = 1;
                ext->showed_date.year++;
            } else {
                ext->showed_date.month++;
            }
            lv_obj_invalidate(calendar);
        } else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) {
            if(ext->showed_date.month <= 1) {
                ext->showed_date.month = 12;
                ext->showed_date.year--;
            } else {
                ext->showed_date.month--;
            }
            lv_obj_invalidate(calendar);
        }
    }

    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %r14
callq *0x4b659(%rip)          # 0x5e370
cmpb $0x1, %al
jne 0x1306e
movzbl %bpl, %eax
movb $0x1, %bl
addl $-0x7, %eax
cmpl $0xb, %eax
ja 0x13090
leaq 0x28904(%rip), %rcx     # 0x3b63c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x289cf(%rip), %rsi     # 0x3b717
movq %r15, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x684b
movq %r14, %rdi
callq 0x6747
movb $0x0, 0x10(%rax)
jmp 0x13088
movq %r14, %rdi
callq 0x6747
movq %rax, %rbp
movq 0x20(%r14), %r15
leaq 0x30(%rsp), %r12
movq %r15, (%r12)
shrl $0x10, %r15d
movq %r14, %rdi
callq 0x13e27
addl %r15d, %eax
movw %ax, 0x6(%r12)
callq 0x35b3
leaq 0x4(%rsp), %r13
movq %rax, %rdi
movq %r13, %rsi
callq 0x3661
movq %r12, %rdi
movq %r13, %rsi
callq 0x268e3
testb %al, %al
je 0x12e71
movswl 0x4(%rsp), %ecx
movswl 0x30(%rsp), %esi
movl 0x34(%rsp), %eax
subl %esi, %eax
incl %eax
movw $0x2, %di
cwtd
idivw %di
movswl %ax, %edx
addl %esi, %edx
movb 0x10(%rbp), %al
cmpl %ecx, %edx
movq %rbp, %r15
jle 0x13021
movb $-0x1, %bpl
cmpb $-0x1, %al
je 0x12e01
movq %r14, %rdi
callq 0x493a
movb %bpl, 0x10(%r15)
jmp 0x1304a
movq %r14, %rdi
callq 0x6747
movq %rax, %r15
cmpb $0x0, 0x10(%rax)
js 0x1300d
je 0x13055
movb 0x6(%r15), %al
cmpb $0xc, %al
jl 0x13072
movb $0x1, 0x6(%r15)
incw 0x4(%r15)
jmp 0x1307c
movzbl (%r15), %ebp
movq %r14, %rdi
callq 0x6747
movl %ebp, %ecx
andb $-0x3, %cl
cmpb $0x11, %cl
jne 0x12fef
movb 0x6(%rax), %cl
cmpb $0xc, %cl
jl 0x13051
incw 0x4(%rax)
movb $0x1, %cl
jmp 0x13085
movq %rbp, 0x8(%rsp)
movq 0x20(%r14), %r15
leaq 0x10(%rsp), %r12
movq %r15, (%r12)
movq %r14, %rdi
xorl %esi, %esi
callq 0x13da2
movq %rax, %r13
movzwl 0x1a(%rax), %eax
addw %r15w, %ax
movw %ax, (%r12)
shrq $0x20, %r15
subw 0x1c(%r13), %r15w
movw %r15w, 0x4(%r12)
movzwl 0x22(%r14), %r15d
movq %r14, %rdi
callq 0x13e27
movl %eax, %ebp
movq %r14, %rdi
callq 0x6747
movq 0x38(%rax), %rax
movq 0x28(%rax), %rcx
movzbl 0x10(%rcx), %ecx
addw %r15w, %bp
addl %ecx, %ebp
addw 0x16(%rax), %bp
addw 0x18(%rax), %bp
subw 0x16(%r13), %bp
movw %bp, 0x2(%r12)
leaq 0x4(%rsp), %rsi
movq %r12, %rdi
callq 0x268e3
testb %al, %al
je 0x13031
movswl 0x14(%rsp), %eax
movswl 0x10(%rsp), %r8d
subl %r8d, %eax
incl %eax
pushq $0x7
popq %rcx
cltd
idivl %ecx
movl %eax, %ecx
movswl 0x16(%rsp), %eax
movswl 0x12(%rsp), %r9d
subl %r9d, %eax
incl %eax
pushq $0x6
popq %rdi
cltd
idivl %edi
movl %eax, %esi
movswl 0x4(%rsp), %eax
subl %r8d, %eax
cltd
idivl %ecx
movl %eax, %ebp
movl $0xff, %r15d
movl %eax, %ecx
andl %r15d, %ecx
movswl 0x6(%rsp), %eax
subl %r9d, %eax
cltd
idivl %esi
imull $0x7, %eax, %edx
andl $0xfe, %eax
cmpl $0x6, %eax
pushq $0x23
popq %rax
cmovbl %edx, %eax
cmpl $0x7, %ecx
cmovael %edi, %ebp
addl %eax, %ebp
movq %r14, %rdi
callq 0x6747
andl %ebp, %r15d
movzwl 0x4(%rax), %r12d
movzwl %r12w, %edi
movq %rax, 0x18(%rsp)
movb 0x6(%rax), %r13b
movsbl %r13b, %esi
movl %edi, 0x24(%rsp)
movl %esi, 0x20(%rsp)
callq 0x13e43
movzbl %al, %ecx
cmpl %ecx, %r15d
jae 0x130a1
movl %eax, %r15d
leal -0x1(%r13), %eax
xorl %ecx, %ecx
cmpb $0x1, %r13b
sete %cl
movzbl %al, %eax
pushq $0xc
popq %rdx
cmovnel %eax, %edx
subl %ecx, %r12d
movq 0x18(%rsp), %r13
movw %r12w, 0x14(%r13)
movb %dl, 0x16(%r13)
movzwl %r12w, %edi
movsbl %dl, %esi
callq 0x13e99
subb %r15b, %bpl
addb %al, %bpl
incb %bpl
movq 0x8(%rsp), %r15
movq %r13, %rdi
jmp 0x13122
cmpl $0x14, %ebp
je 0x12ffd
cmpl $0x12, %ebp
jne 0x13090
movb 0x6(%rax), %cl
cmpb $0x1, %cl
jg 0x13083
decw 0x4(%rax)
movb $0xc, %cl
jmp 0x13085
movb 0x6(%r15), %al
cmpb $0x1, %al
jg 0x13076
movb $0xc, 0x6(%r15)
decw 0x4(%r15)
jmp 0x1307c
movb $0x1, %bpl
cmpb $0x1, %al
jne 0x12df9
jmp 0x12e01
movq 0x8(%rsp), %r15
cmpb $0x0, 0x10(%r15)
je 0x13045
movq %r14, %rdi
callq 0x493a
movb $0x0, 0x10(%r15)
andl $0x0, 0x14(%r15)
jmp 0x13090
incb %cl
jmp 0x13085
cmpw $0x0, 0x14(%r15)
je 0x1307c
pushq $0xe
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x4caf
cmpb $0x1, %al
je 0x1307c
movl %eax, %ebx
jmp 0x13090
incb %al
jmp 0x13078
decb %al
movb %al, 0x6(%r15)
movb $0x0, 0x10(%r15)
jmp 0x13088
decb %cl
movb %cl, 0x6(%rax)
movq %r14, %rdi
callq 0x493a
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, 0x28(%rsp)
movb %al, 0x3(%rsp)
movl 0x24(%rsp), %edi
movl 0x20(%rsp), %esi
movl %ecx, %r13d
callq 0x13e99
movzbl %al, %eax
addl %r13d, %eax
cmpl %eax, %r15d
jae 0x130e6
movq 0x18(%rsp), %rdi
movw %r12w, 0x14(%rdi)
movq 0x28(%rsp), %rax
movb %al, 0x16(%rdi)
subb 0x3(%rsp), %bpl
incb %bpl
movq 0x8(%rsp), %r15
jmp 0x13122
cmpl $0x29, %r15d
movq 0x8(%rsp), %r15
movq 0x18(%rsp), %rdi
movq 0x28(%rsp), %r13
ja 0x13126
leal 0x1(%r13), %ecx
xorl %edx, %edx
cmpb $0xc, %r13b
sete %dl
movzbl %cl, %ecx
pushq $0x1
popq %rsi
cmovnel %ecx, %esi
addl %edx, %r12d
movw %r12w, 0x14(%rdi)
movb %sil, 0x16(%rdi)
subl %eax, %ebp
incb %bpl
movb %bpl, 0x17(%rdi)
cmpb $0x0, 0x10(%r15)
je 0x13135
movq %r14, %rdi
callq 0x493a
movb $0x0, 0x10(%r15)
jmp 0x13090