@@ -13,22 +13,22 @@ namespace iot {
1313// 这里仅定义 Screen 的属性和方法,不包含具体的实现
1414class Screen : public Thing {
1515public:
16- Screen () : Thing(" Screen" , " 这是一个屏幕,可设置主题和亮度 " ) {
16+ Screen () : Thing(" Screen" , " A screen that can set theme and brightness " ) {
1717 // 定义设备的属性
18- properties_.AddStringProperty (" theme" , " 主题 " , [this ]() -> std::string {
18+ properties_.AddStringProperty (" theme" , " Current theme " , [this ]() -> std::string {
1919 auto theme = Board::GetInstance ().GetDisplay ()->GetTheme ();
2020 return theme;
2121 });
2222
23- properties_.AddNumberProperty (" brightness" , " 当前亮度百分比 " , [this ]() -> int {
23+ properties_.AddNumberProperty (" brightness" , " Current brightness percentage " , [this ]() -> int {
2424 // 这里可以添加获取当前亮度的逻辑
2525 auto backlight = Board::GetInstance ().GetBacklight ();
2626 return backlight ? backlight->brightness () : 100 ;
2727 });
2828
2929 // 定义设备可以被远程执行的指令
30- methods_.AddMethod (" SetTheme " , " 设置屏幕主题 " , ParameterList ({
31- Parameter (" theme_name" , " 主题模式, light 或 dark" , kValueTypeString , true )
30+ methods_.AddMethod (" set_theme " , " Set the screen theme " , ParameterList ({
31+ Parameter (" theme_name" , " Valid string values are \" light\" and \" dark\" " , kValueTypeString , true )
3232 }), [this ](const ParameterList& parameters) {
3333 std::string theme_name = static_cast <std::string>(parameters[" theme_name" ].string ());
3434 auto display = Board::GetInstance ().GetDisplay ();
@@ -37,8 +37,8 @@ class Screen : public Thing {
3737 }
3838 });
3939
40- methods_.AddMethod (" SetBrightness " , " 设置亮度 " , ParameterList ({
41- Parameter (" brightness" , " 0到100之间的整数 " , kValueTypeNumber , true )
40+ methods_.AddMethod (" set_brightness " , " Set the brightness " , ParameterList ({
41+ Parameter (" brightness" , " An integer between 0 and 100 " , kValueTypeNumber , true )
4242 }), [this ](const ParameterList& parameters) {
4343 uint8_t brightness = static_cast <uint8_t >(parameters[" brightness" ].number ());
4444 auto backlight = Board::GetInstance ().GetBacklight ();
0 commit comments