Skip to content

Commit

Permalink
fix HassView note format
Browse files Browse the repository at this point in the history
add a space between function two parameters

replace tab with space in main

update lcd bk thread name

remove spaces between function variables

use define to set config default value
  • Loading branch information
morris13579 committed May 20, 2023
1 parent 6d46d8a commit 48e0113
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 73 deletions.
2 changes: 1 addition & 1 deletion 1.Firmware/src/app/Accounts/ACT_Motor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions 1.Firmware/src/app/Pages/HASS/HassView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using namespace Page;
#define ITEM_PAD 60
/*
* 默认视图显示: 圆点,原点所在位置 label_value
* 此函数根据需要增加或 hidden 对象
* 默认视图显示: 圆点,原点所在位置 label_value
* 此函数根据需要增加或 hidden 对象
*/
void HassView::SetPlaygroundMode(int16_t mode)
{
Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions 1.Firmware/src/app/Pages/Setting/Setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion 1.Firmware/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion 1.Firmware/src/hal/hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions 1.Firmware/src/hal/lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -64,7 +64,7 @@ void HAL::lcd_brightness_init() {
account->Subscribe("MotorStatus");
xTaskCreatePinnedToCore(
TaskLcdBrightnessUpdate,
"MotorThread",
"LcdBkThread",
4096,
nullptr,
2,
Expand Down
70 changes: 35 additions & 35 deletions 1.Firmware/src/hal/nvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
}
Expand All @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}
50 changes: 25 additions & 25 deletions 1.Firmware/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion 1.Firmware/src/port/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 48e0113

Please sign in to comment.