Skip to content

Commit aaae127

Browse files
authored
Merge pull request #2434 from entrylabs/develop-hw
[4.21.0] 하드웨어 1.9.38 PR
2 parents 88a71b2 + 572d911 commit aaae127

File tree

4 files changed

+202
-57
lines changed

4 files changed

+202
-57
lines changed

src/class/engine.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,17 @@ Entry.Engine = class Engine {
898898
Entry.container.mapEntityIncludeCloneOnScene(this.raiseEvent, eventName);
899899
}
900900

901+
/**
902+
* @param {string} eventName
903+
* @param {string} value
904+
*/
905+
fireEventWithValue(eventName, value) {
906+
if (this.state !== EntryEngineState.run) {
907+
return;
908+
}
909+
return Entry.container.mapEntityIncludeCloneOnScene(this.raiseKeyEvent, [eventName, value]);
910+
}
911+
901912
/**
902913
* this is callback function for map.
903914
* @param {Entry.EntryObject} object

src/class/hw_lite.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,15 @@ export default class HardwareLite {
144144

145145
isHwLiteSupportAgent() {
146146
const userAgentString = navigator.userAgent.toLowerCase();
147-
return (
148-
userAgentString.indexOf('chrome') >= 0 &&
149-
userAgentString.indexOf('window') < 0 &&
150-
userAgentString.indexOf('electron') < 0
151-
);
147+
148+
// INFO: 디바이스가 모바일이거나 일렉트론이면 1차적으로 제외
149+
if (userAgentString.includes('mobile') || userAgentString.includes('electron')) {
150+
return false;
151+
} else if (userAgentString.includes('whale') || userAgentString.includes('edge') || userAgentString.includes('chrome')) {
152+
return true;
153+
} else {
154+
return false;
155+
}
152156
}
153157

154158
refreshHardwareLiteBlockMenu() {

src/playground/blocks/hardware/block_iCOBOT.js

Lines changed: 124 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,14 @@ Entry.iCOBOT.setLanguage = function() {
213213
icobot_motor_135_degrees: "135°",
214214
icobot_motor_150_degrees: "150°",
215215
icobot_motor_180_degrees: "180°",
216+
icobot_motor_210_degrees: "210°",
217+
icobot_motor_225_degrees: "225°",
218+
icobot_motor_240_degrees: "240°",
219+
icobot_motor_270_degrees: "270°",
220+
icobot_motor_300_degrees: "300°",
221+
icobot_motor_315_degrees: "315°",
222+
icobot_motor_330_degrees: "330°",
223+
icobot_motor_360_degrees: "360°",
216224
}
217225
},
218226
en: {
@@ -314,6 +322,14 @@ Entry.iCOBOT.setLanguage = function() {
314322
icobot_motor_135_degrees: "135°",
315323
icobot_motor_150_degrees: "150°",
316324
icobot_motor_180_degrees: "180°",
325+
icobot_motor_210_degrees: "210°",
326+
icobot_motor_225_degrees: "225°",
327+
icobot_motor_240_degrees: "240°",
328+
icobot_motor_270_degrees: "270°",
329+
icobot_motor_300_degrees: "300°",
330+
icobot_motor_315_degrees: "315°",
331+
icobot_motor_330_degrees: "330°",
332+
icobot_motor_360_degrees: "360°",
317333
}
318334
}
319335
}
@@ -529,8 +545,8 @@ Entry.iCOBOT.getBlocks = function() {
529545
func: function(sprite, script)
530546
{
531547
var temp = Entry.hw.portData.SENSOR;
532-
var Temperature = temp[9];
533-
var Humidity = (temp[8])/100;
548+
var Temperature = temp[8];
549+
var Humidity = (temp[9])/100;
534550
var Discomfort_index = (((9/5)*Temperature) - (0.55*(1-Humidity)*(((9/5)*Temperature)-26)) + 32);
535551
return Discomfort_index;
536552
},
@@ -942,6 +958,41 @@ Entry.iCOBOT.getBlocks = function() {
942958
isNotFor: ['iCOBOT'],
943959
events: {},
944960
},
961+
962+
icobot_rgb_list: {
963+
color: EntryStatic.colorSet.block.default.HARDWARE,
964+
outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
965+
fontColor: '#fff',
966+
skeleton: 'basic_string_field',
967+
statements: [],
968+
template: '%1',
969+
params: [
970+
{
971+
type: 'Dropdown',
972+
options: [
973+
[Lang.Blocks.icobot_led_total, '0'],
974+
[Lang.Blocks.icobot_led_left_up, '1'],
975+
[Lang.Blocks.icobot_led_right_up, '2'],
976+
[Lang.Blocks.icobot_led_left_down, '3'],
977+
[Lang.Blocks.icobot_led_right_down, '4'],
978+
],
979+
value: '0',
980+
fontSize: 11,
981+
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
982+
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
983+
},
984+
],
985+
events: {},
986+
def: {
987+
params: [null],
988+
},
989+
paramsKeyMap: {
990+
PORT: 0,
991+
},
992+
func: function(sprite, script) {
993+
return script.getField('PORT');
994+
},
995+
},
945996

946997
// RGBLED - 종류 선택 및 On/Off
947998
icobot_digital_rgbled_onoff:
@@ -953,18 +1004,20 @@ Entry.iCOBOT.getBlocks = function() {
9531004
statements: [],
9541005
params: [
9551006
{
956-
type: 'Dropdown',
957-
options: [
958-
[Lang.Blocks.icobot_led_total, '0'],
959-
[Lang.Blocks.icobot_led_left_up, '1'],
960-
[Lang.Blocks.icobot_led_right_up, '2'],
961-
[Lang.Blocks.icobot_led_left_down, '3'],
962-
[Lang.Blocks.icobot_led_right_down, '4'],
963-
],
964-
value: '0',
965-
fontSize: 11,
966-
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
967-
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
1007+
type: 'Block',
1008+
accept: 'string',
1009+
// type: 'Dropdown',
1010+
// options: [
1011+
// [Lang.Blocks.icobot_led_total, '0'],
1012+
// [Lang.Blocks.icobot_led_left_up, '1'],
1013+
// [Lang.Blocks.icobot_led_right_up, '2'],
1014+
// [Lang.Blocks.icobot_led_left_down, '3'],
1015+
// [Lang.Blocks.icobot_led_right_down, '4'],
1016+
// ],
1017+
// value: '0',
1018+
// fontSize: 11,
1019+
// bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
1020+
// arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
9681021
},
9691022
{
9701023
type: 'Dropdown',
@@ -991,7 +1044,12 @@ Entry.iCOBOT.getBlocks = function() {
9911044
],
9921045
events: {},
9931046
def: {
994-
params: [null],
1047+
params: [
1048+
{
1049+
type: 'icobot_rgb_list',
1050+
},
1051+
null
1052+
],
9951053
type: 'icobot_digital_rgbled_onoff',
9961054
},
9971055
paramsKeyMap: {
@@ -1081,18 +1139,20 @@ Entry.iCOBOT.getBlocks = function() {
10811139
statements: [],
10821140
params: [
10831141
{
1084-
type: 'Dropdown',
1085-
options: [
1086-
[Lang.Blocks.icobot_led_total, '0'],
1087-
[Lang.Blocks.icobot_led_left_up, '1'],
1088-
[Lang.Blocks.icobot_led_right_up, '2'],
1089-
[Lang.Blocks.icobot_led_left_down, '3'],
1090-
[Lang.Blocks.icobot_led_right_down, '4'],
1091-
],
1092-
value: '0',
1093-
fontSize: 11,
1094-
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
1095-
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
1142+
type: 'Block',
1143+
accept: 'string',
1144+
// type: 'Dropdown',
1145+
// options: [
1146+
// [Lang.Blocks.icobot_led_total, '0'],
1147+
// [Lang.Blocks.icobot_led_left_up, '1'],
1148+
// [Lang.Blocks.icobot_led_right_up, '2'],
1149+
// [Lang.Blocks.icobot_led_left_down, '3'],
1150+
// [Lang.Blocks.icobot_led_right_down, '4'],
1151+
// ],
1152+
// value: '0',
1153+
// fontSize: 11,
1154+
// bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
1155+
// arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
10961156
},
10971157
{
10981158
type: 'Indicator',
@@ -1102,7 +1162,12 @@ Entry.iCOBOT.getBlocks = function() {
11021162
],
11031163
events: {},
11041164
def: {
1105-
params: [null],
1165+
params: [
1166+
{
1167+
type: 'icobot_rgb_list',
1168+
},
1169+
null
1170+
],
11061171
type: 'icobot_digital_rgbled_off',
11071172
},
11081173
paramsKeyMap: {
@@ -1167,18 +1232,20 @@ Entry.iCOBOT.getBlocks = function() {
11671232
statements: [],
11681233
params: [
11691234
{
1170-
type: 'Dropdown',
1171-
options: [
1172-
[Lang.Blocks.icobot_led_total, '0'],
1173-
[Lang.Blocks.icobot_led_left_up, '1'],
1174-
[Lang.Blocks.icobot_led_right_up, '2'],
1175-
[Lang.Blocks.icobot_led_left_down, '3'],
1176-
[Lang.Blocks.icobot_led_right_down, '4'],
1177-
],
1178-
value: '0',
1179-
fontSize: 11,
1180-
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
1181-
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
1235+
type: 'Block',
1236+
accept: 'string',
1237+
// type: 'Dropdown',
1238+
// options: [
1239+
// [Lang.Blocks.icobot_led_total, '0'],
1240+
// [Lang.Blocks.icobot_led_left_up, '1'],
1241+
// [Lang.Blocks.icobot_led_right_up, '2'],
1242+
// [Lang.Blocks.icobot_led_left_down, '3'],
1243+
// [Lang.Blocks.icobot_led_right_down, '4'],
1244+
// ],
1245+
// value: '0',
1246+
// fontSize: 11,
1247+
// bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
1248+
// arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
11821249
},
11831250
{
11841251
type: 'Block',
@@ -1201,7 +1268,9 @@ Entry.iCOBOT.getBlocks = function() {
12011268
events: {},
12021269
def: {
12031270
params: [
1204-
null,
1271+
{
1272+
type: 'icobot_rgb_list',
1273+
},
12051274
{
12061275
type: 'number',
12071276
params: ["0"],
@@ -1422,13 +1491,21 @@ Entry.iCOBOT.getBlocks = function() {
14221491
type: 'Dropdown',
14231492
options: [
14241493
[Lang.Blocks.icobot_motor_30_degrees, '0'],
1425-
[Lang.Blocks.icobot_motor_45_degrees, '1'],
1494+
[Lang.Blocks.icobot_motor_45_degrees, '1'],
14261495
[Lang.Blocks.icobot_motor_60_degrees, '2'],
1427-
[Lang.Blocks.icobot_motor_90_degrees, '3'],
1428-
[Lang.Blocks.icobot_motor_120_degrees, '4'],
1429-
[Lang.Blocks.icobot_motor_135_degrees, '5'],
1430-
[Lang.Blocks.icobot_motor_150_degrees, '6'],
1431-
[Lang.Blocks.icobot_motor_180_degrees, '7'],
1496+
[Lang.Blocks.icobot_motor_90_degrees, '3'],
1497+
[Lang.Blocks.icobot_motor_120_degrees, '4'],
1498+
[Lang.Blocks.icobot_motor_135_degrees, '5'],
1499+
[Lang.Blocks.icobot_motor_150_degrees, '6'],
1500+
[Lang.Blocks.icobot_motor_180_degrees, '7'],
1501+
[Lang.Blocks.icobot_motor_210_degrees, '8'],
1502+
[Lang.Blocks.icobot_motor_225_degrees, '9'],
1503+
[Lang.Blocks.icobot_motor_240_degrees, '10'],
1504+
[Lang.Blocks.icobot_motor_270_degrees, '11'],
1505+
[Lang.Blocks.icobot_motor_300_degrees, '12'],
1506+
[Lang.Blocks.icobot_motor_315_degrees, '13'],
1507+
[Lang.Blocks.icobot_motor_330_degrees, '14'],
1508+
[Lang.Blocks.icobot_motor_360_degrees, '15'],
14321509
],
14331510
value: '0',
14341511
fontSize: 11,

0 commit comments

Comments
 (0)