Skip to content

Commit

Permalink
#3 resolved with autoconnect feature
Browse files Browse the repository at this point in the history
  • Loading branch information
sainsaji committed Feb 16, 2024
1 parent 312ace2 commit fdfadb0
Show file tree
Hide file tree
Showing 21 changed files with 1,700 additions and 1,656 deletions.
Binary file modified SquareLine_Files/autosave/knobOS_autosave00.zip
Binary file not shown.
Binary file modified SquareLine_Files/autosave/knobOS_autosave01.zip
Binary file not shown.
Binary file modified SquareLine_Files/autosave/knobOS_autosave02.zip
Binary file not shown.
Binary file modified SquareLine_Files/autosave/knobOS_autosave03.zip
Binary file not shown.
Binary file modified SquareLine_Files/autosave/knobOS_autosave04.zip
Binary file not shown.
Binary file modified SquareLine_Files/autosave/knobOS_autosave05.zip
Binary file not shown.
Binary file modified SquareLine_Files/autosave/knobOS_autosave06.zip
Binary file not shown.
Binary file modified SquareLine_Files/autosave/knobOS_autosave07.zip
Binary file not shown.
Binary file modified SquareLine_Files/autosave/knobOS_autosave08.zip
Binary file not shown.
Binary file modified SquareLine_Files/autosave/knobOS_autosave09.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion SquareLine_Files/knobOS.sll

Large diffs are not rendered by default.

3,263 changes: 1,610 additions & 1,653 deletions SquareLine_Files/knobOS.spj

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions SquareLine_Files/knobOS_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ def ConnectToWifi(event_struct):
def lockLaptop(event_struct):
return


def loadFlashScreen(event_struct):
return

2 changes: 2 additions & 0 deletions libraries/lv_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,8 @@








1 change: 0 additions & 1 deletion libraries/ui/src/screens/ui_FlashScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,4 @@ void ui_FlashScreen_screen_init(void)


lv_obj_add_event_cb(ui_roundButton, ui_event_roundButton_roundButton, LV_EVENT_ALL, NULL);

}
27 changes: 27 additions & 0 deletions libraries/ui/src/screens/ui_SettingsScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,33 @@ void ui_SettingsScreen_screen_init(void)
lv_obj_clear_flag(ui_Image1, LV_OBJ_FLAG_SCROLLABLE); /// Flags
lv_img_set_zoom(ui_Image1, 100);

ui_AutoConnectPanel = lv_obj_create(ui_AppControls2);
lv_obj_set_width(ui_AutoConnectPanel, 158);
lv_obj_set_height(ui_AutoConnectPanel, 37);
lv_obj_set_x(ui_AutoConnectPanel, -12);
lv_obj_set_y(ui_AutoConnectPanel, 24);
lv_obj_set_align(ui_AutoConnectPanel, LV_ALIGN_CENTER);
lv_obj_set_flex_flow(ui_AutoConnectPanel, LV_FLEX_FLOW_ROW);
lv_obj_set_flex_align(ui_AutoConnectPanel, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
lv_obj_clear_flag(ui_AutoConnectPanel, LV_OBJ_FLAG_SCROLLABLE); /// Flags

ui_AutoConnectLabel = lv_label_create(ui_AutoConnectPanel);
lv_obj_set_width(ui_AutoConnectLabel, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_AutoConnectLabel, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_AutoConnectLabel, -31);
lv_obj_set_y(ui_AutoConnectLabel, 11);
lv_obj_set_align(ui_AutoConnectLabel, LV_ALIGN_CENTER);
lv_label_set_text(ui_AutoConnectLabel, "Auto Connect?");
lv_obj_set_style_text_font(ui_AutoConnectLabel, &lv_font_montserrat_12, LV_PART_MAIN | LV_STATE_DEFAULT);

ui_autoConnectSwitch = lv_switch_create(ui_AutoConnectPanel);
lv_obj_set_width(ui_autoConnectSwitch, 39);
lv_obj_set_height(ui_autoConnectSwitch, 20);
lv_obj_set_x(ui_autoConnectSwitch, -5);
lv_obj_set_y(ui_autoConnectSwitch, 45);
lv_obj_set_align(ui_autoConnectSwitch, LV_ALIGN_CENTER);


ui_ConnectionStatusLabel = lv_label_create(ui_SettingsScreen);
lv_obj_set_width(ui_ConnectionStatusLabel, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_ConnectionStatusLabel, LV_SIZE_CONTENT); /// 1
Expand Down
12 changes: 12 additions & 0 deletions libraries/ui/src/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

// SCREEN: ui_FlashScreen
void ui_FlashScreen_screen_init(void);
void ui_event_FlashScreen(lv_event_t * e);
lv_obj_t * ui_FlashScreen;
lv_obj_t * ui_logo;
lv_obj_t * ui_knobosLabel;
Expand Down Expand Up @@ -128,6 +129,9 @@ void ui_event_ConnectToWifiBtn(lv_event_t * e);
lv_obj_t * ui_ConnectToWifiBtn;
lv_obj_t * ui_Label1;
lv_obj_t * ui_Image1;
lv_obj_t * ui_AutoConnectPanel;
lv_obj_t * ui_AutoConnectLabel;
lv_obj_t * ui_autoConnectSwitch;
lv_obj_t * ui_ConnectionStatusLabel;


Expand All @@ -154,6 +158,14 @@ lv_obj_t * ui____initial_actions0;
///////////////////// ANIMATIONS ////////////////////

///////////////////// FUNCTIONS ////////////////////
void ui_event_FlashScreen(lv_event_t * e)
{
lv_event_code_t event_code = lv_event_get_code(e);
lv_obj_t * target = lv_event_get_target(e);
if(event_code == LV_EVENT_SCREEN_LOAD_START) {
loadFlashScreen(e);
}
}
void ui_event_roundButton_roundButton(lv_event_t * e)
{
lv_event_code_t event_code = lv_event_get_code(e);
Expand Down
4 changes: 4 additions & 0 deletions libraries/ui/src/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern "C" {
#include "ui_events.h"
// SCREEN: ui_FlashScreen
void ui_FlashScreen_screen_init(void);
void ui_event_FlashScreen(lv_event_t * e);
extern lv_obj_t * ui_FlashScreen;
extern lv_obj_t * ui_logo;
extern lv_obj_t * ui_knobosLabel;
Expand Down Expand Up @@ -129,6 +130,9 @@ void ui_event_ConnectToWifiBtn(lv_event_t * e);
extern lv_obj_t * ui_ConnectToWifiBtn;
extern lv_obj_t * ui_Label1;
extern lv_obj_t * ui_Image1;
extern lv_obj_t * ui_AutoConnectPanel;
extern lv_obj_t * ui_AutoConnectLabel;
extern lv_obj_t * ui_autoConnectSwitch;
extern lv_obj_t * ui_ConnectionStatusLabel;
// SCREEN: ui_LaptopControl
void ui_LaptopControl_screen_init(void);
Expand Down
5 changes: 5 additions & 0 deletions libraries/ui/src/ui_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ void lockLaptop(lv_event_t * e)
{
// Your code here
}

void loadFlashScreen(lv_event_t * e)
{
// Your code here
}
1 change: 1 addition & 0 deletions libraries/ui/src/ui_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
extern "C" {
#endif

void loadFlashScreen(lv_event_t * e);
void lightControlScreenLoaded(lv_event_t * e);
void brightnessLevelChange(lv_event_t * e);
void swithOnFunction(lv_event_t * e);
Expand Down
35 changes: 34 additions & 1 deletion ui/ui.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include <WiFi.h>
#include <ESP32Time.h>
#include <time.h>
#include <EEPROM.h>

#define EEPROM_SIZE 1


#if DEGUBVAL == 0
Expand All @@ -27,6 +30,7 @@ const int serverPort PROGMEM = 8080; // Port of the server

//Connection Variables
bool isConnected = false;
bool autoConnectState = false;

//Touch Initialization
CST816S touch(6, 7, 14, 5);
Expand Down Expand Up @@ -228,6 +232,16 @@ void lockLaptopTask(lv_event_t * e)
void settingsScreenLoaded(lv_event_t * e)
{
DEBUG_PRINTLN("\n Settings Screen Loaded");
lv_obj_t *autoConnectSwitch = ui_autoConnectSwitch;
if(EEPROM.get(0,autoConnectState)==1)
{
lv_obj_clear_state(autoConnectSwitch,lv_obj_get_state(autoConnectSwitch));
lv_obj_add_state(autoConnectSwitch, LV_EVENT_PRESSED);
}
else
{
lv_obj_clear_state(autoConnectSwitch,lv_obj_get_state(autoConnectSwitch));
}
if(isConnected)
{
lv_obj_t *connectButton = ui_ConnectToWifiBtn;
Expand Down Expand Up @@ -269,11 +283,26 @@ void homeScreenLoaded(lv_event_t * e)
}
}

void wifiAutoConnect(lv_event_t * e)
{
DEBUG_PRINTLN("\n WiFi AutoConnect Function");
EEPROM.get(0,autoConnectState)==0 ? autoConnectState = true : autoConnectState = false;
DEBUG_PRINTLN(autoConnectState);
EEPROM.put(0, autoConnectState);
EEPROM.commit();
DEBUG_PRINTLN("Auto Connect State is:");
DEBUG_PRINTLN(EEPROM.get(0,autoConnectState));
}

void setup()
{
#if DEGUB == 0
Serial.begin( 115200 ); /* prepare for possible serial debug */
#endif
EEPROM.begin(sizeof(autoConnectState));
DEBUG_PRINTLN("Auto Connect State is:");
autoConnectState = EEPROM.get(0,autoConnectState);
DEBUG_PRINTLN(autoConnectState);
touch.begin();
String LVGL_Arduino PROGMEM = "Hello Arduino! ";
LVGL_Arduino += String('V') + lv_version_major() + "." + lv_version_minor() + "." + lv_version_patch();
Expand Down Expand Up @@ -308,7 +337,11 @@ void setup()
lv_obj_add_event_cb(ui_LockLaptopBtn, lockLaptopTask, LV_EVENT_PRESSED, NULL);
lv_obj_add_event_cb(ui_SettingsScreen, settingsScreenLoaded, LV_EVENT_SCREEN_LOADED, NULL);
lv_obj_add_event_cb(ui_HomeScreen, homeScreenLoaded, LV_EVENT_SCREEN_LOADED, NULL);
lv_obj_add_event_cb(ui_FlashScreen, connectToWifiTask, LV_EVENT_SCREEN_LOADED, NULL);
if(autoConnectState)
{
lv_obj_add_event_cb(ui_HomeScreen, connectToWifiTask, LV_EVENT_SCREEN_LOADED, NULL);
}
lv_obj_add_event_cb(ui_autoConnectSwitch, wifiAutoConnect, LV_EVENT_CLICKED, NULL);

}

Expand Down

0 comments on commit fdfadb0

Please sign in to comment.