#include "screens.h"
#include "actions.h"
#include "fonts.h"
#include "images.h"
#include "styles.h"
#include "ui.h"
#include "vars.h"
#include <Arduino.h>
#include <string.h>
#include <string.h>
objects_t objects;
lv_obj_t *tick_value_change_obj;

void create_screen_main() {
  lv_obj_t *obj = lv_obj_create(0);
  objects.mainScr = obj;
  lv_obj_set_pos(obj, 0, 0);
  lv_obj_set_size(obj, 240, 240);
  // lv_obj_add_event_cb(obj, action_switch_screens, LV_EVENT_GESTURE, (void
  // *)0);
  {
    lv_obj_t *parent_obj = obj;
    {
      lv_obj_t *obj = lv_led_create(parent_obj);
      objects.alarmLED = obj;
      lv_obj_set_size(obj, 100, 100);
      lv_obj_center(obj);
      lv_led_set_color(obj, lv_color_hex(0xffff4411));
      lv_led_set_brightness(obj, 0);
      lv_obj_set_style_shadow_width(obj, 20, LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_obj_set_style_shadow_spread(obj, 16, LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN);
    }

    {
      // tempArc
      lv_obj_t *obj = lv_arc_create(parent_obj);
      lv_obj_add_flag(obj, LV_OBJ_FLAG_ADV_HITTEST);
      lv_obj_set_ext_click_area(obj, 10);
      objects.temp_arc = obj;
      lv_obj_set_pos(obj, 15, 15);
      lv_obj_set_size(obj, 210, 210);
      lv_arc_set_range(obj, 10, 30);
      lv_arc_set_value(obj, 23 * 2);
      lv_obj_add_event_cb(obj, action_zoom_set_temp, LV_EVENT_PRESSED,
                          (void *)1);
      lv_obj_add_event_cb(obj, action_zoom_set_temp, LV_EVENT_RELEASED,
                          (void *)0);
      lv_obj_add_event_cb(obj, action_zoom_set_temp, LV_EVENT_PRESSING,
                          (void *)1);
      // lv_obj_add_event_cb(obj, action_zoom_set_temp, LV_EVENT_GESTURE, (void
      // *)1);
      add_style_arc(obj);
    }
    // invisibleMenuBtn
    {
      lv_obj_t *btn = lv_button_create(parent_obj);
      lv_obj_remove_style_all(btn);
      lv_obj_set_size(btn, 100, 60);
      lv_obj_set_align(btn, LV_ALIGN_CENTER);
      lv_obj_add_event_cb(btn, showMenuScreen, LV_EVENT_LONG_PRESSED, NULL);
      // lv_obj_add_flag(btn,LV_OBJ_FLAG_CLICKABLE);
      // tempTxt
      lv_obj_t *obj = lv_label_create(parent_obj);
      objects.temp_txt = obj;
      lv_obj_set_align(obj, LV_ALIGN_CENTER);
      lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_label_set_text(obj, "");
      lv_obj_set_style_text_font(obj, &lv_font_montserrat_38,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
    }
    {
      // humTxt
      lv_obj_t *obj = lv_label_create(parent_obj);
      objects.hum_txt = obj;
      lv_obj_set_pos(obj, 91, 141);
      lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_obj_align(obj, LV_ALIGN_CENTER, 0, 25);
      lv_label_set_text(obj, "");
      lv_obj_set_style_text_font(obj, &lv_font_montserrat_18,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
    }

    {
      // pressTxt
      lv_obj_t *obj = lv_label_create(parent_obj);
      objects.press_txt = obj;
      lv_obj_set_pos(obj, 81, 78);
      lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_obj_align(obj, LV_ALIGN_CENTER, 0, -25);
      lv_label_set_text(obj, "");
      lv_obj_set_style_text_font(obj, &lv_font_montserrat_18,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
    }
    {
      // timeTxt
      lv_obj_t *obj = lv_label_create(parent_obj);
      objects.time_txt = obj;
      lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_obj_align(obj, LV_ALIGN_CENTER, 0, -60);
      lv_label_set_text(obj, "");
      lv_obj_set_style_text_font(obj, &lv_font_montserrat_18,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
    }

    {
      // outTemp
      lv_obj_t *obj = lv_label_create(parent_obj);
      objects.outTemp_txt = obj;
      lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_obj_align(obj, LV_ALIGN_CENTER, 0, 55);
      lv_label_set_text(obj, ICON_THERMOMETER_SNOW "--°C");
      lv_obj_set_style_text_font(obj, &Bootstrap_Icons_18,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
    }
    {
      // Heating active
      lv_obj_t *obj = lv_label_create(parent_obj);
      objects.heaterIcn = obj;
      // lv_obj_set_pos(obj, 120-9, 205);
      lv_obj_align(obj, LV_ALIGN_BOTTOM_MID, 0, -5);
      lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_label_set_text(obj, ICON_FIRE);
      lv_obj_set_style_text_font(obj, &Bootstrap_Icons_18,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
    }
    {
      // Buffer_enabled
      lv_obj_t *obj = lv_label_create(parent_obj);
      objects.bufferIcn = obj;
      // lv_obj_set_pos(obj, 140, 200);
      lv_obj_align(obj, LV_ALIGN_BOTTOM_MID, 25, -10);
      lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_label_set_text(obj, ICON_THERMOMETER_SUN);
      lv_obj_set_style_text_font(obj, &Bootstrap_Icons_18,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
    }
    {
      // wifi_strength
      lv_obj_t *obj = lv_label_create(parent_obj);
      objects.wifiIcn = obj;
      lv_obj_align(obj, LV_ALIGN_BOTTOM_MID, -25, -10);
      lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_label_set_text(obj, ICON_WIFI_HIGH);
      lv_obj_set_style_text_font(obj, &Bootstrap_Icons_18,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
    }

    /*{
        // panel_arc
        lv_obj_t *obj = lv_obj_create(parent_obj);
        objects.panel_arc = obj;
        lv_obj_set_pos(obj, 58, 78);
        lv_obj_set_size(obj, 125, 162);
        lv_obj_set_style_bg_opa(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
        lv_obj_set_style_border_width(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
    }*/
  }
}

void create_screen_chart() {
  lv_obj_t *obj = lv_obj_create(0);
  objects.chartScr = obj;
  lv_obj_set_pos(obj, 0, 0);
  lv_obj_set_size(obj, 240, 240);
  lv_obj_add_event_cb(obj, action_switch_screens, LV_EVENT_GESTURE, (void *)1);
  lv_obj_set_style_bg_color(obj, lv_color_hex(0xff000000),
                            LV_PART_MAIN | LV_STATE_DEFAULT);
  {
    lv_obj_t *parent_obj = obj;
    {
      lv_obj_t *btn_back = lv_button_create(parent_obj);
      lv_obj_remove_style_all(btn_back);
      lv_obj_set_size(btn_back, 40, 40);
      lv_obj_align(btn_back, LV_ALIGN_BOTTOM_MID, -30, -10);
      lv_obj_add_event_cb(btn_back, showMainScreen, LV_EVENT_RELEASED, NULL);
      lv_obj_t *lbl_btn_back = lv_label_create(btn_back);
      lv_obj_set_size(lbl_btn_back, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_obj_center(lbl_btn_back);
      lv_label_set_text(lbl_btn_back, LV_SYMBOL_HOME);

      lv_obj_t *btn_dbg = lv_button_create(parent_obj);
      lv_obj_remove_style_all(btn_dbg);
      lv_obj_set_size(btn_dbg, 40, 40);
      lv_obj_align(btn_dbg, LV_ALIGN_BOTTOM_MID, 30, -10);
      lv_obj_add_event_cb(btn_dbg, showDebugScreen, LV_EVENT_RELEASED, NULL);
      lv_obj_t *lbl_btn_dbg = lv_label_create(btn_dbg);
      lv_obj_set_size(lbl_btn_dbg, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_obj_center(lbl_btn_dbg);
      lv_label_set_text(lbl_btn_dbg, LV_SYMBOL_SETTINGS);
      /*Create a container*/
      lv_obj_t *main_cont = lv_obj_create(parent_obj);
      lv_obj_remove_style_all(main_cont);
      lv_obj_set_size(main_cont, 173, 125);
      lv_obj_set_pos(main_cont, 41, 62);

      /*Create a transparent wrapper for the chart and the scale.
       *Set a large width, to make it scrollable on the main container*/
      lv_obj_t *wrapper = lv_obj_create(main_cont);
      lv_obj_remove_style_all(wrapper);
      lv_obj_set_size(wrapper, 173 * 3, lv_pct(100));
      // chart
      lv_obj_t *chart = lv_chart_create(wrapper);
      objects.chart = chart;
      lv_obj_set_style_pad_all(chart, 0, LV_STATE_ANY | LV_PART_MAIN);
      lv_obj_set_pos(chart, 0, 0);
      lv_obj_set_width(chart, lv_pct(100));
      lv_obj_set_height(chart, lv_pct(100) - 22);
      lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_Y, 100, 350);
      lv_chart_set_point_count(chart, 48 * 12);
      lv_obj_add_event_cb(chart, action_show_cursors_cb, LV_EVENT_VALUE_CHANGED,
                          NULL);
      lv_chart_set_div_line_count(chart, 6, 48);
      lv_obj_add_event_cb(chart, chartDrawingCB, LV_EVENT_ALL, NULL);
      objects.chart_cursor = lv_chart_add_cursor(
          chart, lv_color_hex(0xc3c3c3),
          (lv_dir_t)(LV_DIR_LEFT | LV_DIR_BOTTOM | LV_DIR_TOP));
      lv_obj_set_style_line_width(chart, 1, LV_PART_CURSOR | LV_STATE_DEFAULT);
      lv_obj_set_style_line_dash_gap(chart, 3,
                                     LV_PART_CURSOR | LV_STATE_DEFAULT);
      lv_obj_set_style_line_dash_width(chart, 1,
                                       LV_PART_CURSOR | LV_STATE_DEFAULT);
      lv_obj_set_style_radius(chart, 2, LV_PART_CURSOR | LV_STATE_DEFAULT);
      lv_obj_set_style_width(chart, 2, LV_PART_CURSOR | LV_STATE_DEFAULT);
      lv_obj_set_style_height(chart, 2, LV_PART_CURSOR | LV_STATE_DEFAULT);
      lv_obj_set_style_bg_color(chart,
                                lv_color_darken(lv_color_hex(0xff8ff321), 10),
                                LV_PART_CURSOR | LV_STATE_DEFAULT);

      objects.chart_series = lv_chart_add_series(
          chart, lv_color_hex(0xff8ff321), LV_CHART_AXIS_PRIMARY_Y);
      /*uint32_t i;
      for(i = 5; i < 36; i++) {
          lv_chart_set_next_value(chart, objects.chart_series, i);
      }*/
      // xScale
      lv_chart_set_ext_y_array(chart, objects.chart_series, history.temp);
      lv_obj_t *obj = lv_scale_create(wrapper);
      objects.x_scale = obj;
      lv_obj_set_size(obj, lv_pct(100) - 3, 22);
      lv_obj_align_to(obj, chart, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
      lv_scale_set_mode(obj, LV_SCALE_MODE_HORIZONTAL_BOTTOM);
      lv_scale_set_range(obj, -48, 0);
      lv_scale_set_total_tick_count(obj, 48);

      lv_obj_add_event_cb(obj, draw_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
      lv_scale_set_major_tick_every(obj, 6);
      lv_scale_set_label_show(obj, true);
      lv_obj_set_style_text_font(obj, &lv_font_montserrat_10,
                                 LV_PART_INDICATOR | LV_STATE_DEFAULT);
      lv_obj_set_style_line_width(obj, 1, LV_PART_INDICATOR | LV_STATE_DEFAULT);
      lv_obj_set_style_length(obj, 7, LV_PART_INDICATOR | LV_STATE_DEFAULT);
      lv_obj_set_style_line_width(obj, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_obj_set_style_line_width(obj, 1, LV_PART_ITEMS | LV_STATE_DEFAULT);
      lv_obj_set_style_length(obj, 4, LV_PART_ITEMS | LV_STATE_DEFAULT);
    }
    {
      lv_obj_update_layout(objects.chart); // wi calculate real widget heights
      // yScale
      lv_obj_t *obj = lv_scale_create(parent_obj);
      objects.y_scale = obj;
      lv_obj_set_pos(obj, 15, 72);
      lv_obj_set_size(obj, 26, lv_obj_get_height(objects.chart) - 19);
      lv_scale_set_mode(obj, LV_SCALE_MODE_VERTICAL_LEFT);
      lv_scale_set_range(obj, 10, 35);
      lv_scale_set_total_tick_count(obj, 26);
      lv_scale_set_major_tick_every(obj, 5);
      lv_scale_set_label_show(obj, true);
      lv_obj_set_style_length(obj, 7, LV_PART_INDICATOR | LV_STATE_DEFAULT);
      lv_obj_set_style_text_font(obj, &lv_font_montserrat_10,
                                 LV_PART_INDICATOR | LV_STATE_DEFAULT);
      lv_obj_set_style_line_width(obj, 1, LV_PART_INDICATOR | LV_STATE_DEFAULT);
      lv_obj_set_style_line_width(obj, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_obj_set_style_line_width(obj, 1, LV_PART_ITEMS | LV_STATE_DEFAULT);
      lv_obj_set_style_length(obj, 3, LV_PART_ITEMS | LV_STATE_DEFAULT);
    }
    {
      // chartHeader
      lv_obj_t *obj = lv_label_create(parent_obj);
      objects.chart_header = obj;
      lv_obj_set_pos(obj, 1, 30);
      lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_label_set_text(obj, "Temperature");
      lv_obj_set_style_text_font(obj, &lv_font_montserrat_18,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_obj_set_style_align(obj, LV_ALIGN_TOP_MID,
                             LV_PART_MAIN | LV_STATE_DEFAULT);
    }
  }
}

void create_screen_debug() {
  lv_obj_t *obj = lv_obj_create(0);
  objects.debugScr = obj;
  lv_obj_set_pos(obj, 0, 0);
  lv_obj_set_size(obj, 240, 240);
  // lv_obj_add_event_cb(obj, action_switch_screens, LV_EVENT_GESTURE, (void
  // *)1);
  lv_obj_set_style_bg_color(obj, lv_color_hex(0xff000000),
                            LV_PART_MAIN | LV_STATE_DEFAULT);
  {
    lv_obj_t *parent_obj = obj;
    {
      lv_obj_t *btn_back = lv_button_create(parent_obj);
      lv_obj_remove_style_all(btn_back);
      lv_obj_set_size(btn_back, 40, 40);
      lv_obj_set_align(btn_back, LV_ALIGN_LEFT_MID);
      lv_obj_add_event_cb(btn_back, showMainScreen, LV_EVENT_RELEASED, NULL);
      lv_obj_t *lbl_btn = lv_label_create(btn_back);
      lv_obj_set_size(lbl_btn, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_obj_center(lbl_btn);
      lv_label_set_text(lbl_btn, LV_SYMBOL_HOME);
      lv_obj_t *btn_reboot = lv_button_create(parent_obj);
      lv_obj_remove_style_all(btn_reboot);
      lv_obj_set_size(btn_reboot, 40, 40);
      lv_obj_set_align(btn_reboot, LV_ALIGN_RIGHT_MID);
      lv_obj_add_event_cb(btn_reboot, rebootESP, LV_EVENT_RELEASED, NULL);
      lbl_btn = lv_label_create(btn_reboot);
      lv_obj_set_size(lbl_btn, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_obj_center(lbl_btn);
      lv_obj_set_style_text_font(lbl_btn, &Bootstrap_Icons_18,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_label_set_text(lbl_btn, ICON_POWER);
      /*Create a container*/
      lv_obj_t *main_cont = lv_obj_create(parent_obj);
      lv_obj_set_size(main_cont, 170, 170);
      lv_obj_center(main_cont);
      // lv_obj_remove_style_all(main_cont);
      lv_obj_t *wrapper = lv_obj_create(main_cont);
      lv_obj_remove_style_all(wrapper);
      lv_obj_set_size(wrapper, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_obj_t *obj = lv_label_create(main_cont);
      objects.debugTxt = obj;
      lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
    }
  }
}

void create_screen_menu() {
  lv_obj_t *obj = lv_obj_create(0);
  objects.menuScr = obj;
  lv_obj_set_pos(obj, 0, 0);
  lv_obj_set_size(obj, 240, 240);
  // lv_obj_add_event_cb(obj, action_switch_screens, LV_EVENT_GESTURE, (void
  // *)1);
  lv_obj_set_style_bg_color(obj, lv_color_hex(0xff000000),
                            LV_PART_MAIN | LV_STATE_DEFAULT);
  {
    lv_obj_t *parent_obj = obj;
    {
      // main
      lv_obj_t *btn = lv_button_create(parent_obj);
      lv_obj_set_size(btn, 70, 70);
      lv_obj_align(btn, LV_ALIGN_CENTER, -40, -40);
      lv_obj_add_event_cb(btn, showMainScreen, LV_EVENT_RELEASED, NULL);
      add_style_button(btn);
      lv_obj_t *lbl_btn = lv_label_create(btn);
      lv_obj_set_size(lbl_btn, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_obj_center(lbl_btn);
      lv_obj_set_style_text_font(lbl_btn, &Bootstrap_Icons_30,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_label_set_text(lbl_btn, ICON_THERMOMETER_HALF);
      // history
      btn = lv_button_create(parent_obj);
      lv_obj_set_size(btn, 70, 70);
      lv_obj_align(btn, LV_ALIGN_CENTER, 40, -40);
      lv_obj_add_event_cb(btn, showChartScreen, LV_EVENT_RELEASED, NULL);
      add_style_button(btn);
      lbl_btn = lv_label_create(btn);
      lv_obj_set_size(lbl_btn, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_obj_center(lbl_btn);
      lv_obj_set_style_text_font(lbl_btn, &Bootstrap_Icons_30,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_label_set_text(lbl_btn, ICON_GRAPH);
      // shutters
      btn = lv_button_create(parent_obj);
      lv_obj_set_size(btn, 70, 70);
      lv_obj_align(btn, LV_ALIGN_CENTER, -40, 40);
      lv_obj_add_event_cb(btn, showRolloScreen, LV_EVENT_RELEASED, NULL);
      add_style_button(btn);
      lbl_btn = lv_label_create(btn);
      lv_obj_set_size(lbl_btn, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_obj_center(lbl_btn);
      lv_obj_set_style_text_font(lbl_btn, &Bootstrap_Icons_30,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_label_set_text(lbl_btn, ICON_SHUTTER);
      // debug
      btn = lv_button_create(parent_obj);
      lv_obj_set_size(btn, 70, 70);
      lv_obj_align(btn, LV_ALIGN_CENTER, 40, 40);
      lv_obj_add_event_cb(btn, showDebugScreen, LV_EVENT_RELEASED, NULL);
      add_style_button(btn);
      lbl_btn = lv_label_create(btn);
      lv_obj_set_size(lbl_btn, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_obj_center(lbl_btn);
      lv_obj_set_style_text_font(lbl_btn, &Bootstrap_Icons_30,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_label_set_text(lbl_btn, ICON_MENU_LINES);
    }
  }
}

void create_screen_rollo_pos() {
  lv_obj_t *obj = lv_obj_create(0);
  objects.rollo_posScr = obj;
  lv_obj_set_pos(obj, 0, 0);
  lv_obj_set_size(obj, 240, 240);
  {
    lv_obj_t *parent_obj = obj;
    {
      lv_obj_t *obj = lv_arc_create(parent_obj);
      lv_obj_set_pos(obj, 93, 95);
      lv_obj_set_size(obj, 93, 87);
      lv_arc_set_range(obj, 0, 900);
      lv_arc_set_value(obj, 0);
      lv_arc_set_bg_start_angle(obj, 270);
      lv_arc_set_bg_end_angle(obj, 90);
      lv_obj_add_flag(obj, LV_OBJ_FLAG_ADV_HITTEST);
      add_style_arc(obj);
      lv_obj_set_style_arc_width(obj, 4, LV_PART_INDICATOR | LV_STATE_DEFAULT);
      lv_obj_set_style_arc_width(obj, 4, LV_PART_MAIN | LV_STATE_DEFAULT);
    }
    {
      lv_obj_t *obj = lv_slider_create(parent_obj);
      objects.rolloPosSldr = obj;
      lv_obj_set_pos(obj, 80, 68);
      lv_obj_set_size(obj, 3, 140);
      lv_slider_set_range(obj, 100, 0);
      lv_slider_set_value(obj, 50, LV_ANIM_OFF);
      add_style_slider(obj);
      lv_obj_set_style_bg_color(obj, lv_color_hex(0xffa2f321),
                                LV_PART_KNOB | LV_STATE_DEFAULT);
      lv_obj_set_style_pad_bottom(obj, 6, LV_PART_KNOB | LV_STATE_DEFAULT);
      lv_obj_set_style_pad_left(obj, 6, LV_PART_KNOB | LV_STATE_DEFAULT);
      lv_obj_set_style_pad_right(obj, 6, LV_PART_KNOB | LV_STATE_DEFAULT);
      lv_obj_set_style_pad_top(obj, 6, LV_PART_KNOB | LV_STATE_DEFAULT);
    }
    {
      lv_obj_t *obj = lv_btn_create(parent_obj);
      lv_obj_set_size(obj, 45, 50);
      lv_obj_align(obj, LV_ALIGN_CENTER, -95, 0);
      add_style_button(obj);
      lv_obj_add_event_cb(obj, showRolloScreen, LV_EVENT_RELEASED, NULL);
      {
        lv_obj_t *parent_obj = obj;
        {
          lv_obj_t *obj = lv_label_create(parent_obj);
          lv_obj_set_pos(obj, 0, 0);
          lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
          lv_obj_set_style_text_font(obj, &Bootstrap_Icons_30,
                                     LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_label_set_text(obj, ICON_ROTATE_CC);
          lv_obj_set_style_align(obj, LV_ALIGN_CENTER,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
        }
      }
    }
    {
      lv_obj_t *obj = lv_obj_create(parent_obj);
      objects.lamellaContainer = obj;
      lv_obj_set_pos(obj, 104, 63);
      lv_obj_set_size(obj, 18, 150);
      lv_obj_set_style_pad_left(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_obj_set_style_pad_top(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_obj_set_style_pad_right(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_obj_set_style_pad_bottom(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_obj_set_style_border_width(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_obj_clear_flag(
          obj, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_CLICK_FOCUSABLE |
                   LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_PRESS_LOCK |
                   LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_CHAIN_HOR |
                   LV_OBJ_FLAG_SCROLL_CHAIN_VER | LV_OBJ_FLAG_SCROLL_ELASTIC |
                   LV_OBJ_FLAG_SCROLL_MOMENTUM | LV_OBJ_FLAG_SCROLL_WITH_ARROW |
                   LV_OBJ_FLAG_SNAPPABLE);
      lv_obj_set_style_bg_color(obj, lv_color_hex(0xfffafafa),
                                LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_obj_set_style_bg_opa(obj, 200, LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_obj_set_style_text_color(obj, lv_color_hex(0xff000000),
                                  LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_obj_set_style_radius(obj, 5, LV_PART_MAIN | LV_STATE_DEFAULT);
      {
        lv_obj_t *parent_obj = obj;
        {
          // lam0
          lv_obj_t *obj = lv_label_create(parent_obj);
          objects.lam[0] = obj;
          lv_obj_set_pos(obj, 7, 3);
          lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
          lv_label_set_long_mode(obj, LV_LABEL_LONG_CLIP);
          lv_label_set_text(obj, "(");
          lv_obj_set_style_transform_pivot_x(obj, 3,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_pivot_y(obj, 7,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_rotation(obj, 0,
                                              LV_PART_MAIN | LV_STATE_DEFAULT);
        }
        {
          // lam1
          lv_obj_t *obj = lv_label_create(parent_obj);
          objects.lam[1] = obj;
          lv_obj_set_pos(obj, 7, 19);
          lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
          lv_label_set_text(obj, "(");
          lv_obj_set_style_transform_pivot_x(obj, 3,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_pivot_y(obj, 7,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_rotation(obj, 0,
                                              LV_PART_MAIN | LV_STATE_DEFAULT);
        }
        {
          // lam2
          lv_obj_t *obj = lv_label_create(parent_obj);
          objects.lam[2] = obj;
          lv_obj_set_pos(obj, 7, 35);
          lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
          lv_label_set_text(obj, "(");
          lv_obj_set_style_transform_pivot_x(obj, 3,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_pivot_y(obj, 7,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_rotation(obj, 0,
                                              LV_PART_MAIN | LV_STATE_DEFAULT);
        }
        {
          // lam3
          lv_obj_t *obj = lv_label_create(parent_obj);
          objects.lam[3] = obj;
          lv_obj_set_pos(obj, 7, 51);
          lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
          lv_label_set_text(obj, "(");
          lv_obj_set_style_transform_pivot_x(obj, 3,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_pivot_y(obj, 7,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_rotation(obj, 0,
                                              LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_bg_color(obj, lv_color_hex(0xffffffff),
                                    LV_PART_MAIN | LV_STATE_DEFAULT);
        }
        {
          // lam4
          lv_obj_t *obj = lv_label_create(parent_obj);
          objects.lam[4] = obj;
          lv_obj_set_pos(obj, 7, 67);
          lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
          lv_label_set_text(obj, "(");
          lv_obj_set_style_transform_pivot_x(obj, 3,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_pivot_y(obj, 7,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_rotation(obj, 0,
                                              LV_PART_MAIN | LV_STATE_DEFAULT);
        }
        {
          // lam5
          lv_obj_t *obj = lv_label_create(parent_obj);
          objects.lam[5] = obj;
          lv_obj_set_pos(obj, 7, 83);
          lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
          lv_label_set_text(obj, "(");
          lv_obj_set_style_transform_pivot_x(obj, 3,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_pivot_y(obj, 7,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_rotation(obj, 0,
                                              LV_PART_MAIN | LV_STATE_DEFAULT);
        }
        {
          // lam6
          lv_obj_t *obj = lv_label_create(parent_obj);
          objects.lam[6] = obj;
          lv_obj_set_pos(obj, 7, 99);
          lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
          lv_label_set_text(obj, "(");
          lv_obj_set_style_transform_pivot_x(obj, 3,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_pivot_y(obj, 7,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_rotation(obj, 0,
                                              LV_PART_MAIN | LV_STATE_DEFAULT);
        }
        {
          // lam7
          lv_obj_t *obj = lv_label_create(parent_obj);
          objects.lam[7] = obj;
          lv_obj_set_pos(obj, 7, 115);
          lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
          lv_label_set_text(obj, "(");
          lv_obj_set_style_transform_pivot_x(obj, 3,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_pivot_y(obj, 7,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_rotation(obj, 0,
                                              LV_PART_MAIN | LV_STATE_DEFAULT);
        }
        {
          // lam8
          lv_obj_t *obj = lv_label_create(parent_obj);
          objects.lam[8] = obj;
          lv_obj_set_pos(obj, 7, 131);
          lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
          lv_label_set_text(obj, "(");
          lv_obj_set_style_transform_pivot_x(obj, 3,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_pivot_y(obj, 7,
                                             LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_transform_rotation(obj, 0,
                                              LV_PART_MAIN | LV_STATE_DEFAULT);
        }
      }
    }
    {
      lv_obj_t *obj = lv_btn_create(parent_obj);
      lv_obj_set_size(obj, 45, 50);
      lv_obj_align(obj, LV_ALIGN_CENTER, 95, 0);
      add_style_button(obj);
      lv_obj_add_event_cb(obj, moveRolloMan, LV_EVENT_RELEASED, NULL);
      {
        lv_obj_t *parent_obj = obj;
        {
          lv_obj_t *obj = lv_label_create(parent_obj);
          lv_obj_set_pos(obj, 0, 0);
          lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
          lv_label_set_text(obj, "OK");
          lv_obj_set_style_align(obj, LV_ALIGN_CENTER,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
        }
      }
    }
    {
      lv_obj_t *obj = lv_label_create(parent_obj);
      lv_obj_align(obj, LV_ALIGN_CENTER, 0, -85);
      lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
      lv_label_set_text(
          obj, "\"Fenster Rechts\"\nmanuell Positionieren");
      lv_obj_set_style_text_align(obj, LV_TEXT_ALIGN_CENTER,
                                  LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_obj_set_style_text_font(obj, &Bootstrap_Icons_12,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
    }
  }

  //tick_screen_rollo_pos();
}

void create_screen_rollos() {
  lv_obj_t *obj = lv_obj_create(0);
  objects.rolloScr = obj;
  lv_obj_set_pos(obj, 0, 0);
  lv_obj_set_size(obj, 240, 240);

  {
    lv_obj_t *parent_obj = obj;
    {
      lv_obj_t *obj = lv_dropdown_create(parent_obj);
      objects.deviceDropdown = obj;
      lv_obj_set_pos(obj, 60, 16);
      lv_obj_set_size(obj, 120, LV_SIZE_CONTENT);
      lv_dropdown_set_options(obj, "Türe\nFenster\nAlle");
      lv_dropdown_set_selected(obj, 1);
      lv_obj_set_style_text_font(obj, &Bootstrap_Icons_12,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
      lv_obj_set_style_text_font(lv_dropdown_get_list(obj), &Bootstrap_Icons_12,
                                LV_PART_MAIN | LV_STATE_DEFAULT);
    }

    { //UP BTN
      lv_obj_t *obj = lv_btn_create(parent_obj);
      lv_obj_set_size(obj, 120, 60);
      lv_obj_align(obj, LV_ALIGN_CENTER, 0, -25);
      add_style_button(obj);
      lv_obj_add_event_cb(obj, moveRolloUp, LV_EVENT_RELEASED, NULL);
      {
        lv_obj_t *parent_obj = obj;
        {
          lv_obj_t *obj = lv_label_create(parent_obj);
          lv_obj_set_pos(obj, 0, 0);
          lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
          lv_label_set_text(obj, ICON_ARROW_UP_FILL);
          lv_obj_set_style_text_font(obj, &Bootstrap_Icons_30,
            LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_align(obj, LV_ALIGN_CENTER,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
        }
      }
    }

    { //DOWN BTN
      lv_obj_t *obj = lv_btn_create(parent_obj);
      lv_obj_set_size(obj, 120, 60);
      lv_obj_align(obj, LV_ALIGN_CENTER, 0, 55);
      add_style_button(obj);
      lv_obj_add_event_cb(obj, moveRolloDown, LV_EVENT_RELEASED, NULL);
      {
        lv_obj_t *parent_obj = obj;
        {
          lv_obj_t *obj = lv_label_create(parent_obj);
          lv_obj_set_pos(obj, 0, 0);
          lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
          lv_label_set_text(obj, ICON_ARROW_DOWN_FILL);
          lv_obj_set_style_text_font(obj, &Bootstrap_Icons_30,
            LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_align(obj, LV_ALIGN_CENTER,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
        }
      }
    }

    { //ROLLOPOS BTN
      lv_obj_t *obj = lv_btn_create(parent_obj);
      lv_obj_set_size(obj, 45, 50);
      lv_obj_align(obj, LV_ALIGN_CENTER, 95, 0);
      add_style_button(obj);
      lv_obj_add_event_cb(obj, showRolloPosScreen, LV_EVENT_RELEASED, NULL);
      {
        lv_obj_t *parent_obj = obj;
        {
          lv_obj_t *obj = lv_label_create(parent_obj);
          lv_obj_set_pos(obj, 0, 0);
          lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
          lv_label_set_text(obj, ICON_MENU_DOTS_V);
          lv_obj_set_style_text_font(obj, &Bootstrap_Icons_30,
            LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_align(obj, LV_ALIGN_CENTER,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
        }
      }
    }

    { //BACK BUTTON
      lv_obj_t *obj = lv_btn_create(parent_obj);
      lv_obj_set_size(obj, 45, 50);
      lv_obj_align(obj, LV_ALIGN_CENTER, -95, 0);
      add_style_button(obj);
      lv_obj_add_event_cb(obj, showMenuScreen, LV_EVENT_RELEASED, NULL);
      {
        lv_obj_t *parent_obj = obj;
        {
          lv_obj_t *obj = lv_label_create(parent_obj);
          lv_obj_set_pos(obj, 0, 0);
          lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
          lv_label_set_text(obj, ICON_ROTATE_CC);
          lv_obj_set_style_text_font(obj, &Bootstrap_Icons_30,
            LV_PART_MAIN | LV_STATE_DEFAULT);
          lv_obj_set_style_align(obj, LV_ALIGN_CENTER,
                                 LV_PART_MAIN | LV_STATE_DEFAULT);
        }
      }
    }
    
   
  }

  // tick_screen_rollos();
}

void tick_screen_rollo_pos() {}

void create_screens() {
  lv_disp_t *dispp = lv_disp_get_default();
  lv_theme_t *theme = lv_theme_default_init(
      dispp, lv_palette_main(LV_PALETTE_GREEN), lv_palette_main(LV_PALETTE_RED),
      true, LV_FONT_DEFAULT);
  lv_disp_set_theme(dispp, theme);

  create_screen_main();
  create_screen_chart();
  create_screen_debug();
  create_screen_menu();
  create_screen_rollos();
}
