diff --git a/1.Firmware/src/app/Accounts/ACT_Motor.cpp b/1.Firmware/src/app/Accounts/ACT_Motor.cpp index 1282e44..1f56c80 100644 --- a/1.Firmware/src/app/Accounts/ACT_Motor.cpp +++ b/1.Firmware/src/app/Accounts/ACT_Motor.cpp @@ -22,7 +22,7 @@ static int onEvent(Account* account, Account::EventParam_t* param) { case MOTOR_CMD_CHANGE_MODE: /* code */ - HAL::update_motor_mode(info->motor_mode , info->init_position); + HAL::update_motor_mode(info->motor_mode, info->init_position); HAL::motor_shake(2, 2); break; case MOTOR_CMD_CHECKOUT_PAGE: diff --git a/1.Firmware/src/app/Pages/HASS/HassView.cpp b/1.Firmware/src/app/Pages/HASS/HassView.cpp index 04fbafb..ad5af48 100644 --- a/1.Firmware/src/app/Pages/HASS/HassView.cpp +++ b/1.Firmware/src/app/Pages/HASS/HassView.cpp @@ -5,8 +5,8 @@ using namespace Page; #define ITEM_PAD 60 /* -* 默认视图显示: 圆点,原点所在位置 label_value -* 此函数根据需要增加或 hidden 对象 + * 默认视图显示: 圆点,原点所在位置 label_value + * 此函数根据需要增加或 hidden 对象 */ void HassView::SetPlaygroundMode(int16_t mode) { @@ -27,8 +27,8 @@ void HassView::SetCtrView(lv_obj_t* obj) if (device->is_set_value) { /* - * temporarily no display - * we can't get the status of the device + * temporarily no display + * we can't get the status of the device */ } if (!device->is_set_value && device->is_on_off) { PlaygroundView::OnOffView(); diff --git a/1.Firmware/src/app/Pages/Setting/Setting.cpp b/1.Firmware/src/app/Pages/Setting/Setting.cpp index bfa34e9..d8ab5de 100644 --- a/1.Firmware/src/app/Pages/Setting/Setting.cpp +++ b/1.Firmware/src/app/Pages/Setting/Setting.cpp @@ -155,7 +155,7 @@ void Setting::SettingEventHandler(lv_event_t* event, lv_event_code_t code) } if ( lv_obj_has_state(obj, LV_STATE_USER_1) ){ printf("LV_STATE_USER_1 \n"); - lv_obj_clear_state(obj , LV_STATE_USER_1); + lv_obj_clear_state(obj, LV_STATE_USER_1); return; } else { lv_obj_add_state(obj, LV_STATE_EDITED); @@ -182,7 +182,7 @@ void Setting::SettingEventHandler(lv_event_t* event, lv_event_code_t code) HAL::encoder_disable(); View->SetPlaygroundMode(LCD_BK_TIMEOUT_SETTING_VIEW); Model->SetPlaygroundMode(SETTING_MODE_LCD_BK_TIMEOUT); - Model->ChangeMotorModeWithInitPosition(MOTOR_BOUND_LCD_BK_TIMEOUT , Model->knob_value ); + Model->ChangeMotorModeWithInitPosition(MOTOR_BOUND_LCD_BK_TIMEOUT, Model->knob_value ); break; case LCD_BK_BRIGHTNESS_SETTING_VIEW: #if DEBUG_PRINT @@ -191,7 +191,7 @@ void Setting::SettingEventHandler(lv_event_t* event, lv_event_code_t code) HAL::encoder_disable(); View->SetPlaygroundMode(LCD_BK_BRIGHTNESS_SETTING_VIEW); Model->SetPlaygroundMode(SETTING_MODE_LCD_BK_BRIGHTNESS); - Model->ChangeMotorModeWithInitPosition(MOTOR_BOUND_LCD_BK_BRIGHTNESS , Model->knob_value ); + Model->ChangeMotorModeWithInitPosition(MOTOR_BOUND_LCD_BK_BRIGHTNESS, Model->knob_value ); break; } } else { diff --git a/1.Firmware/src/config.h b/1.Firmware/src/config.h index ae83bfd..b8911df 100644 --- a/1.Firmware/src/config.h +++ b/1.Firmware/src/config.h @@ -29,7 +29,10 @@ // The owner of the X-Knob #define MQTT_HOST "dingmos" -#define DEBUG_PRINT 1 + +#define LCD_BK_DEFAULT_BRIGHTNESS 50 +#define LCD_BK_DEFAULT_TIMEOUT 5 +#define DEBUG_PRINT 1 #endif \ No newline at end of file diff --git a/1.Firmware/src/hal/hal.h b/1.Firmware/src/hal/hal.h index 3554de8..d2eab78 100644 --- a/1.Firmware/src/hal/hal.h +++ b/1.Firmware/src/hal/hal.h @@ -31,7 +31,7 @@ namespace HAL void motor_init(void); // void TaskMotorUpdate(void *pvParameters); int get_motor_position(void); - void update_motor_mode(int mode,int init_position); + void update_motor_mode(int mode, int init_position); void motor_shake(int strength, int delay_time); void surface_dial_init(void); diff --git a/1.Firmware/src/hal/lcd.cpp b/1.Firmware/src/hal/lcd.cpp index 0cc6a0c..74d642b 100644 --- a/1.Firmware/src/hal/lcd.cpp +++ b/1.Firmware/src/hal/lcd.cpp @@ -40,7 +40,7 @@ void TaskLcdBrightnessUpdate(void *pvParameters) { printf("turn on LCD bk\n"); #endif } - //printf("status %d %d %d %d %d\n" , last_btn_status , now_btn_status , last_motor_position , now_motor_position , timeout); + //printf("status %d %d %d %d %d\n", last_btn_status, now_btn_status, last_motor_position, now_motor_position, timeout); last_btn_status = now_btn_status; last_motor_position = now_motor_position; vTaskDelay(LCD_BRIGHTNESS_TASK_PERIOD); @@ -64,7 +64,7 @@ void HAL::lcd_brightness_init() { account->Subscribe("MotorStatus"); xTaskCreatePinnedToCore( TaskLcdBrightnessUpdate, - "MotorThread", + "LcdBkThread", 4096, nullptr, 2, diff --git a/1.Firmware/src/hal/nvs.cpp b/1.Firmware/src/hal/nvs.cpp index 939bde3..fdedb74 100644 --- a/1.Firmware/src/hal/nvs.cpp +++ b/1.Firmware/src/hal/nvs.cpp @@ -10,13 +10,13 @@ NvsConfig ncv_config; void nvs_init(){ Preferences prefs; // 聲明Preferences對象 prefs.begin(CONFIG_NAMESPACE); // 打開命名空間mynamespace - uint8_t value = prefs.getUChar(INIT_KEY , 0); + uint8_t value = prefs.getUChar(INIT_KEY, 0); if(value != INIT_VALUE){ prefs.putUChar(FFAT_KEY, 0); - set_lcd_bk_brightness(50); //default lcd bk - set_lcd_bk_timeout(5); //default lcd bk time out 5mins - set_wifi_config("",""); - set_mqtt_config(MQTT_SERVER , MQTT_PORT , MQTT_USER , MQTT_PASSWORD , MQTT_HOST ); + set_lcd_bk_brightness(LCD_BK_DEFAULT_BRIGHTNESS); //default lcd bk + set_lcd_bk_timeout(LCD_BK_DEFAULT_TIMEOUT); //default lcd bk time out 5mins + set_wifi_config(WIFI_SSID, WIFI_PASSWORD); + set_mqtt_config(MQTT_SERVER, MQTT_PORT, MQTT_USER, MQTT_PASSWORD, MQTT_HOST ); set_init_ffat(0); prefs.putUChar(INIT_KEY, INIT_VALUE); } @@ -34,37 +34,37 @@ void nvs_init(){ ncv_config.mqtt_password = prefs.getString(MQTT_PASSWORD_KEY, ""); ncv_config.mqtt_topic = prefs.getString(MQTT_TPOIC_KEY, ""); #if DEBUG_PRINT - printf("get FFAT_KEY Config: %d\n" , ncv_config.init_ffat_flag ); - printf("get LCD_BK_TIME_OUT_KEY Config: %d\n" , ncv_config.lcd_bk_timeout ); - printf("get LCD_BK_BRIGHTNESS_KEY Config: %d\n" , ncv_config.lcd_bk_brightness ); - printf("get WIFI_SSID_KEY Config: %s\n" , ncv_config.wifi_ssid ); - printf("get WIFI_PASSWORD_KEY Config: %s\n" , ncv_config.wifi_password ); - printf("get MQTT_HOST_KEY Config: %s\n" , ncv_config.mqtt_host ); - printf("get MQTT_PORT_KEY Config: %d\n" , ncv_config.mqtt_port ); - printf("get MQTT_USERNAME_KEY Config: %s\n" , ncv_config.mqtt_username ); - printf("get MQTT_PASSWORD_KEY Config: %s\n" , ncv_config.mqtt_password ); - printf("get MQTT_TPOIC_KEY Config: %s\n" , ncv_config.mqtt_topic ); + printf("get FFAT_KEY Config: %d\n", ncv_config.init_ffat_flag ); + printf("get LCD_BK_TIME_OUT_KEY Config: %d\n", ncv_config.lcd_bk_timeout ); + printf("get LCD_BK_BRIGHTNESS_KEY Config: %d\n", ncv_config.lcd_bk_brightness ); + printf("get WIFI_SSID_KEY Config: %s\n", ncv_config.wifi_ssid ); + printf("get WIFI_PASSWORD_KEY Config: %s\n", ncv_config.wifi_password ); + printf("get MQTT_HOST_KEY Config: %s\n", ncv_config.mqtt_host ); + printf("get MQTT_PORT_KEY Config: %d\n", ncv_config.mqtt_port ); + printf("get MQTT_USERNAME_KEY Config: %s\n", ncv_config.mqtt_username ); + printf("get MQTT_PASSWORD_KEY Config: %s\n", ncv_config.mqtt_password ); + printf("get MQTT_TPOIC_KEY Config: %s\n", ncv_config.mqtt_topic ); #endif prefs.end(); } uint8_t get_init_ffat(){ #if DEBUG_PRINT - printf("get FFAT_KEY Config: %d\n" , ncv_config.init_ffat_flag ); + printf("get FFAT_KEY Config: %d\n", ncv_config.init_ffat_flag ); #endif return ncv_config.init_ffat_flag; } uint16_t get_lcd_bk_brightness(){ #if DEBUG_PRINT - //printf("get LCD_BK_BRIGHTNESS_KEY Config: %d\n" , ncv_config.lcd_bk_brightness ); + //printf("get LCD_BK_BRIGHTNESS_KEY Config: %d\n", ncv_config.lcd_bk_brightness ); #endif return ncv_config.lcd_bk_brightness; } uint16_t get_lcd_bk_timeout(){ #if DEBUG_PRINT - printf("get LCD_BK_TIME_OUT_KEY Config: %d\n" , ncv_config.lcd_bk_timeout ); + printf("get LCD_BK_TIME_OUT_KEY Config: %d\n", ncv_config.lcd_bk_timeout ); #endif return ncv_config.lcd_bk_timeout; } @@ -73,8 +73,8 @@ void get_wifi_config(String &ssid,String &password){ ssid = ncv_config.wifi_ssid; password = ncv_config.wifi_password; #if DEBUG_PRINT - printf("get WIFI_SSID_KEY Config: %s\n" , ncv_config.wifi_ssid.c_str() ); - printf("get WIFI_PASSWORD_KEY Config: %s\n" , ncv_config.wifi_password.c_str() ); + printf("get WIFI_SSID_KEY Config: %s\n", ncv_config.wifi_ssid.c_str() ); + printf("get WIFI_PASSWORD_KEY Config: %s\n", ncv_config.wifi_password.c_str() ); #endif } @@ -85,11 +85,11 @@ void get_mqtt_config(String &host,uint16_t &port,String &username,String &passwo password = ncv_config.mqtt_password; topic = ncv_config.mqtt_topic; #if DEBUG_PRINT - printf("get MQTT_HOST_KEY Config: %s\n" , ncv_config.mqtt_host.c_str() ); - printf("get MQTT_PORT_KEY Config: %d\n" , ncv_config.mqtt_port ); - printf("get MQTT_USERNAME_KEY Config: %s\n" , ncv_config.mqtt_username.c_str() ); - printf("get MQTT_PASSWORD_KEY Config: %s\n" , ncv_config.mqtt_password.c_str() ); - printf("get MQTT_TPOIC_KEY Config: %s\n" , ncv_config.mqtt_topic.c_str() ); + printf("get MQTT_HOST_KEY Config: %s\n", ncv_config.mqtt_host.c_str() ); + printf("get MQTT_PORT_KEY Config: %d\n", ncv_config.mqtt_port ); + printf("get MQTT_USERNAME_KEY Config: %s\n", ncv_config.mqtt_username.c_str() ); + printf("get MQTT_PASSWORD_KEY Config: %s\n", ncv_config.mqtt_password.c_str() ); + printf("get MQTT_TPOIC_KEY Config: %s\n", ncv_config.mqtt_topic.c_str() ); #endif } @@ -100,7 +100,7 @@ void set_init_ffat(uint8_t value){ prefs.end(); ncv_config.init_ffat_flag = value; #if DEBUG_PRINT - printf("set FFAT_KEY Config: %d\n" , value ); + printf("set FFAT_KEY Config: %d\n", value ); #endif } @@ -111,7 +111,7 @@ void set_lcd_bk_brightness(uint16_t value){ prefs.end(); ncv_config.lcd_bk_brightness = value; #if DEBUG_PRINT - printf("set LCD_BK_BRIGHTNESS_KEY Config: %d\n" , value ); + printf("set LCD_BK_BRIGHTNESS_KEY Config: %d\n", value ); #endif } @@ -122,7 +122,7 @@ void set_lcd_bk_timeout(uint16_t value){ prefs.end(); ncv_config.lcd_bk_timeout = value; #if DEBUG_PRINT - printf("set LCD_BK_TIME_OUT_KEY Config: %d\n" , value ); + printf("set LCD_BK_TIME_OUT_KEY Config: %d\n", value ); #endif } @@ -135,8 +135,8 @@ void set_wifi_config(String ssid,String password){ ncv_config.wifi_ssid = ssid; ncv_config.wifi_password = password; #if DEBUG_PRINT - printf("set WIFI_SSID_KEY Config: %s\n" , ssid.c_str() ); - printf("set WIFI_PASSWORD_KEY Config: %s\n" , password.c_str() ); + printf("set WIFI_SSID_KEY Config: %s\n", ssid.c_str() ); + printf("set WIFI_PASSWORD_KEY Config: %s\n", password.c_str() ); #endif } @@ -155,10 +155,10 @@ void set_mqtt_config(String host,uint16_t port,String username,String password,S ncv_config.mqtt_password = password; ncv_config.mqtt_topic = topic; #if DEBUG_PRINT - printf("set MQTT_HOST_KEY Config: %s\n" , host.c_str() ); - printf("set MQTT_PORT_KEY Config: %d\n" , port ); - printf("set MQTT_USERNAME_KEY Config: %s\n" , username.c_str() ); - printf("set MQTT_PASSWORD_KEY Config: %s\n" , password.c_str() ); - printf("set MQTT_TPOIC_KEY Config: %s\n" , topic.c_str() ); + printf("set MQTT_HOST_KEY Config: %s\n", host.c_str() ); + printf("set MQTT_PORT_KEY Config: %d\n", port ); + printf("set MQTT_USERNAME_KEY Config: %s\n", username.c_str() ); + printf("set MQTT_PASSWORD_KEY Config: %s\n", password.c_str() ); + printf("set MQTT_TPOIC_KEY Config: %s\n", topic.c_str() ); #endif } diff --git a/1.Firmware/src/main.cpp b/1.Firmware/src/main.cpp index 85815a5..393cf98 100644 --- a/1.Firmware/src/main.cpp +++ b/1.Firmware/src/main.cpp @@ -9,37 +9,37 @@ void push_handler(ButtonEvent* btn, int event) { - if (event == ButtonEvent::EVENT_PRESSED) - { - Serial.println("button pressed"); - } else if (event == ButtonEvent::EVENT_LONG_PRESSED) { - Serial.println("button long pressed"); - } - if (event == ButtonEvent::EVENT_DOUBLE_CLICKED) { - Serial.println("button double clicked"); - } else if (event == ButtonEvent::EVENT_SHORT_CLICKED) { - Serial.println("button short clicked"); - } else if (event == ButtonEvent::EVENT_CLICKED) { - Serial.println("button clicked"); - } + if (event == ButtonEvent::EVENT_PRESSED) + { + Serial.println("button pressed"); + } else if (event == ButtonEvent::EVENT_LONG_PRESSED) { + Serial.println("button long pressed"); + } + if (event == ButtonEvent::EVENT_DOUBLE_CLICKED) { + Serial.println("button double clicked"); + } else if (event == ButtonEvent::EVENT_SHORT_CLICKED) { + Serial.println("button short clicked"); + } else if (event == ButtonEvent::EVENT_CLICKED) { + Serial.println("button clicked"); + } } void setup() { - HAL::Init(); - nvs_init(); - ffat_init(); - strip_init(); - // HWSerial.begin(115200); - display_init(); - App_Init(); - // INIT_DONE(); + HAL::Init(); + nvs_init(); + ffat_init(); + strip_init(); + // HWSerial.begin(115200); + display_init(); + App_Init(); + // INIT_DONE(); } void loop() { - unsigned long currentMillis = millis(); + unsigned long currentMillis = millis(); - strip_start(currentMillis); + strip_start(currentMillis); - HAL::Update(); - // delay(10); + HAL::Update(); + // delay(10); } diff --git a/1.Firmware/src/port/display.cpp b/1.Firmware/src/port/display.cpp index 42a34d2..a8f7f58 100644 --- a/1.Firmware/src/port/display.cpp +++ b/1.Firmware/src/port/display.cpp @@ -26,7 +26,7 @@ void display_init(void) //pinMode(TFT_BLK, OUTPUT); //digitalWrite(TFT_BLK, HIGH); HAL::lcd_brightness_init(); - HAL::set_lcd_brightness( get_lcd_bk_brightness() ); + HAL::set_lcd_brightness(get_lcd_bk_brightness()); #endif lv_init(); lv_port_disp_init(&screen);