// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/main.c
// Function: main
int main(int argc, char *argv[]) {
  
  printf("lv_init\n");
  /*LittlevGL init*/
  lv_init();
  
  /*Linux frame buffer device init*/
  fbdev_init();

  /*A small buffer for LittlevGL to draw the screen's content*/
  static lv_color_t buf[DISP_BUF_SIZE];

  /*Initialize a descriptor for the buffer*/
  static lv_disp_buf_t disp_buf;
  lv_disp_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);

  /*Initialize and register a display driver*/
  lv_disp_drv_t disp_drv;
  lv_disp_drv_init(&disp_drv);
  disp_drv.buffer = &disp_buf;
  disp_drv.flush_cb = fbdev_flush;
  lv_disp_drv_register(&disp_drv);
  
  /*Initialize and register an input device*/
  lv_indev_drv_t indev_drv;
  lv_indev_drv_init(&indev_drv);             /*Descriptor of a input device driver*/
  indev_drv.type = LV_INDEV_TYPE_POINTER;    /*Touch pad is a pointer-like device*/
  indev_drv.read_cb = xpt7603_read;      /*Set your driver function*/
  lv_indev_drv_register(&indev_drv);         /*Finally register the driver*/
  
  /* Demo Code - replace this with yours */
  /*Create a "Hello world!" label*/
  lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);
  lv_label_set_text(label, "Hello world!");
  lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
  
  /*Create a button*/
  lv_obj_t * btnLabel;

  lv_obj_t * btn1 = lv_btn_create(lv_scr_act(), NULL);
  lv_obj_set_event_cb(btn1, event_handler);
  lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, 0);

  btnLabel = lv_label_create(btn1, NULL);
  lv_label_set_text(btnLabel, "Press Me");
  
  printf("starting loop\n");
  while(1) {
    lv_tick_inc(5);
    lv_task_handler();
    usleep(5000);
  }
  
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0x65dc4(%rip), %rdi     # 0x68004
movb $0x0, %al
callq 0x2080
callq 0x6630
callq 0x66b20
leaq 0x86ce8(%rip), %rdi     # 0x88f40
leaq 0x7a4e1(%rip), %rsi     # 0x7c740
xorl %eax, %eax
movl %eax, %edx
movl $0x6400, %ecx           # imm = 0x6400
callq 0xd660
leaq -0x50(%rbp), %rdi
callq 0xd5a0
leaq 0x86cc3(%rip), %rax     # 0x88f40
movq %rax, -0x48(%rbp)
leaq 0x649f8(%rip), %rax     # 0x66c80
movq %rax, -0x38(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xd6c0
leaq -0x80(%rbp), %rdi
callq 0xdd30
movb $0x1, -0x80(%rbp)
leaq 0x65037(%rip), %rax     # 0x672e0
movq %rax, -0x78(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xdd80
callq 0x23a0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x29820
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
leaq 0x65d31(%rip), %rsi     # 0x6800d
callq 0x2a630
movq -0x88(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
xorl %r8d, %r8d
movl %r8d, %ecx
callq 0x8500
callq 0x23a0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1fe90
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
leaq 0x9e(%rip), %rsi        # 0x23c0
callq 0x9b00
movq -0x98(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %r8d, %r8d
movl %r8d, %edx
movl %r8d, %ecx
callq 0x8500
movq -0x98(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x29820
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
leaq 0x65cb5(%rip), %rsi     # 0x6801a
callq 0x2a630
leaq 0x65cb2(%rip), %rdi     # 0x68023
movb $0x0, %al
callq 0x2080
movl $0x5, %edi
callq 0xdfc0
callq 0x42c00
movl $0x1388, %edi           # imm = 0x1388
callq 0x2110
jmp 0x2378
nopw %cs:(%rax,%rax)