Skip to content

Commit

Permalink
更新 maqueen.ts, _locales/zh-cn/maqueen-strings.json, _locales/zh-tw/ma…
Browse files Browse the repository at this point in the history
…queen-strings.json, _locales/zh-cn/maqueen-jsdoc-strings.json
  • Loading branch information
LinDong88 committed Dec 4, 2024
1 parent c9b7ac7 commit d255107
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 67 deletions.
2 changes: 1 addition & 1 deletion _locales/zh-cn/maqueen-jsdoc-strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"Maqueen_V5.IR_callbackUserV2": "当接收到红外时运行",
"Maqueen_V5.IR_readV2": "红外的值,返回值为0-255",
"Maqueen_V5.readPatrol": "读取巡线传感器状态,将小车放在白纸上返回为0,将小车放在空中/黑纸上返回为1",
"Maqueen_V5.readPatrolData": "读取巡线传感器数据,返回值1500左右(空中/黑纸 3000左右(白纸)",
"Maqueen_V5.readPatrolData": "读取巡线传感器数据,返回值1500左右(空中/黑纸) 3000左右(白纸)",
"Maqueen_V5.I2CInit": "初始化MaqueenV5直到成功",
"Maqueen_V5.patrolSpeed": "巡线速度设置 ",
"Maqueen_V5.setRgblLed": " 设置RGB车灯颜色",
Expand Down
4 changes: 2 additions & 2 deletions _locales/zh-cn/maqueen-strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"Maqueen_V5.readLightIntensity|block": "读取光线值 %type ",
"Maqueen_V5.getBatteryData|block": "读取电池电量 %type ",
"Maqueen_V5.BleCmdDefault|block": "麦昆V5蓝牙默认控制配置%cmd",
"Maqueen_V5.BleGetCmd|block": "获取蓝牙命令",
"Maqueen_V5.BlecallbackUser|block": "当接收到蓝牙命令"
"Maqueen_V5.BleGetCmd|block": "获取麦昆V5蓝牙命令",
"Maqueen_V5.BlecallbackUser|block": "当接收到麦昆V5蓝牙命令"

}
4 changes: 2 additions & 2 deletions _locales/zh-tw/maqueen-strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@
"Maqueen_V5.readLightIntensity|block": "讀取光線值 %type ",
"Maqueen_V5.getBatteryData|block": "讀取電池電量 %type ",
"Maqueen_V5.BleCmdDefault|block": "麥昆V5藍牙默認控制配置%cmd",
"Maqueen_V5.BleGetCmd|block": "獲取藍牙命令",
"Maqueen_V5.BlecallbackUser|block": "當接收到藍牙命令"
"Maqueen_V5.BleGetCmd|block": "獲取麥昆V5藍牙命令",
"Maqueen_V5.BlecallbackUser|block": "當接收到麥昆V5藍牙命令"
}
71 changes: 9 additions & 62 deletions maqueen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ namespace Maqueen_V5 {
return version
}
/**
* Read ultrasonic sensor.
* Read ultrasonic sensor(uint cm).
*/
let state1 = 0;
//% blockId=V5_ultrasonic_sensor block="read ultrasonic sensor |%unit "
Expand Down Expand Up @@ -838,7 +838,7 @@ namespace Maqueen_V5 {

}
/**
* Get the state of the patrol sensor
* Get the state of the patrol sensor. placing the cart on white paper returns 0 and placing the cart on air/black paper returns 1
* @param eline Select the inspection sensor enumeration
*/
//% weight=20
Expand Down Expand Up @@ -890,7 +890,7 @@ namespace Maqueen_V5 {
}

/**
* Control the Maqueen steering Angle
* Control the Maqueen steering Angle(0-180)
* @param eline Select the inspection sensor enumeration
*/

Expand Down Expand Up @@ -988,7 +988,7 @@ namespace Maqueen_V5 {
}
}
/**
* Turn off all RGB
* Turn off RGB
* @param type to type ,eg: DirectionType.Left
*/
//% block="Close |%type RGB Car Lights "
Expand All @@ -998,7 +998,7 @@ namespace Maqueen_V5 {
setRgblLed(type,CarLightColors.Black);
}
/**
* Reading light intensity
* Reading light intensity(0-1023)
*/
//% block="Read Light Values %type"
//% weight=16
Expand All @@ -1017,7 +1017,7 @@ namespace Maqueen_V5 {

}
/**
* Getting battery level
* Getting battery level(0-100)
*/
//% block="Read battery Values %type"
//% weight=16
Expand All @@ -1035,7 +1035,7 @@ namespace Maqueen_V5 {
return temp_data;
}
/**
* Bluetooth commands control the configuration by default
* Bluetooth of Maqueen V5 commands control the configuration by default
* @param Received Bluetooth command
*/
//% block="Maqueen_v5 Default Bluetooth command control %cmd"
Expand Down Expand Up @@ -1110,7 +1110,7 @@ namespace Maqueen_V5 {
}

/**
* Get Bluetooth commands
* Get commands from Bluetooth of Maqueen V5
*/
let Ble_state: number;
let Ble_cmd: number;
Expand All @@ -1125,7 +1125,7 @@ namespace Maqueen_V5 {
return temp_data;
}
/**
* When Bluetooth data is received
* When Bluetooth data from Maqueen V5 is received
* @param value describe value here, eg: 5
*/
//% weight=2
Expand All @@ -1150,58 +1150,5 @@ namespace Maqueen_V5 {
})


export enum HueInterpolationDirection {
Clockwise,
CounterClockwise,
Shortest
}

function writeBuff(index: number, rgb: number) {
let r = (rgb >> 16) * (_brightness / 255);
let g = ((rgb >> 8) & 0xFF) * (_brightness / 255);
let b = ((rgb) & 0xFF) * (_brightness / 255);
neopixel_buf[index * 3 + 0] = Math.round(g)
neopixel_buf[index * 3 + 1] = Math.round(r)
neopixel_buf[index * 3 + 2] = Math.round(b)
}

function hsl(h: number, s: number, l: number): number {
h = Math.round(h);
s = Math.round(s);
l = Math.round(l);

h = h % 360;
s = Math.clamp(0, 99, s);
l = Math.clamp(0, 99, l);
let c = Math.idiv((((100 - Math.abs(2 * l - 100)) * s) << 8), 10000); //chroma, [0,255]
let h1 = Math.idiv(h, 60);//[0,6]
let h2 = Math.idiv((h - h1 * 60) * 256, 60);//[0,255]
let temp = Math.abs((((h1 % 2) << 8) + h2) - 256);
let x = (c * (256 - (temp))) >> 8;//[0,255], second largest component of this color
let r$: number;
let g$: number;
let b$: number;
if (h1 == 0) {
r$ = c; g$ = x; b$ = 0;
} else if (h1 == 1) {
r$ = x; g$ = c; b$ = 0;
} else if (h1 == 2) {
r$ = 0; g$ = c; b$ = x;
} else if (h1 == 3) {
r$ = 0; g$ = x; b$ = c;
} else if (h1 == 4) {
r$ = x; g$ = 0; b$ = c;
} else if (h1 == 5) {
r$ = c; g$ = 0; b$ = x;
}
let m = Math.idiv((Math.idiv((l * 2 << 8), 100) - c), 2);
let r = r$ + m;
let g = g$ + m;
let b = b$ + m;

return (r << 16) + (g << 8) + b;
}


}

0 comments on commit d255107

Please sign in to comment.