Skip to content

Commit 627b111

Browse files
authored
Merge pull request #773 from entrylabs/develop-hw
1.9.58 PR
2 parents 38b4aad + 96380eb commit 627b111

15 files changed

+2912
-660
lines changed

app/firmwares/alux_nemo.hex

+1,413
Large diffs are not rendered by default.

app/modules/ProboConnect.js

+323-350
Large diffs are not rendered by default.

app/modules/alux_nemo.js

+727
Large diffs are not rendered by default.

app/modules/alux_nemo.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"id": "630101",
3+
"name": {
4+
"en": "NEMO",
5+
"ko": "네모"
6+
},
7+
"category": "module",
8+
"platform": ["win32", "darwin"],
9+
"icon": "alux_nemo.png",
10+
"module": "alux_nemo.js",
11+
"driver": {
12+
"win32-ia32": "CH34x_Install_Windows_v3_4/CH34x_Install_Windows_v3_4.exe",
13+
"win32-x64": "CH34x_Install_Windows_v3_4/CH34x_Install_Windows_v3_4.exe"
14+
},
15+
"url": "https://www.aluxonline.com/",
16+
"firmware": "alux_nemo",
17+
"firmwareBaudRate": 115200,
18+
"email": "[email protected]",
19+
"reconnect": true,
20+
"selectPort": true,
21+
"hardware": {
22+
"type": "serial",
23+
"control": "slave",
24+
"duration": 50,
25+
"vendor": "wch.cn",
26+
"baudRate": 115200,
27+
"lostTimer": 1000,
28+
"softwareReset": false,
29+
"firmwarecheck": false
30+
}
31+
}

app/modules/alux_nemo.png

5.63 KB
Loading

app/modules/choco.js

+141-122
Large diffs are not rendered by default.

app/modules/choco2.js

+141-122
Large diffs are not rendered by default.

app/modules/neo_cannon.js

+78-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
function Module() {
2-
this.tx_max_len = 14;
2+
this.tx_max_len = 68;
33
this.tx_data = new Array(this.tx_max_len);
4+
this.PIXEL_NUM = 18;
45

56
this.sensor_data = {
67
vibe: 0,
@@ -16,6 +17,26 @@ function Module() {
1617
d9: 0,
1718
d10: 0,
1819
angle_state: 0,
20+
neopixel: [
21+
{ r: 0, g: 0, b: 0 },
22+
{ r: 0, g: 0, b: 0 },
23+
{ r: 0, g: 0, b: 0 },
24+
{ r: 0, g: 0, b: 0 },
25+
{ r: 0, g: 0, b: 0 },
26+
{ r: 0, g: 0, b: 0 },
27+
{ r: 0, g: 0, b: 0 },
28+
{ r: 0, g: 0, b: 0 },
29+
{ r: 0, g: 0, b: 0 },
30+
{ r: 0, g: 0, b: 0 },
31+
{ r: 0, g: 0, b: 0 },
32+
{ r: 0, g: 0, b: 0 },
33+
{ r: 0, g: 0, b: 0 },
34+
{ r: 0, g: 0, b: 0 },
35+
{ r: 0, g: 0, b: 0 },
36+
{ r: 0, g: 0, b: 0 },
37+
{ r: 0, g: 0, b: 0 },
38+
{ r: 0, g: 0, b: 0 },
39+
],
1940
};
2041

2142
this.sensorValueSize = {
@@ -38,53 +59,55 @@ const NEOCANNON = {
3859
D9: 'd9',
3960
D10: 'd10',
4061
ANGLE_STATE: 'angleState',
62+
NEOPIXEL: 'neopixel',
4163
};
4264

43-
Module.prototype.init = function(handler, config) {};
65+
Module.prototype.init = function (handler, config) {};
4466

45-
Module.prototype.setSerialPort = function(sp) {
67+
Module.prototype.setSerialPort = function (sp) {
4668
this.sp = sp;
4769
};
4870

49-
Module.prototype.requestInitialData = function() {
71+
Module.prototype.requestInitialData = function () {
5072
const txData = this.tx_data;
73+
const dataLen = this.tx_max_len;
5174
txData[0] = 0xff;
52-
txData[1] = 0x0e;
75+
txData[1] = 0x44;
5376
txData[2] = 0x01;
5477
txData[3] = 0x03;
55-
for (let i = 4; i < this.tx_max_len - 2; i++) {
78+
for (let i = 4; i < dataLen - 2; i++) {
5679
txData[i] = 0;
5780
}
58-
txData[12] = 0x4;
59-
txData[13] = 0xa;
81+
txData[dataLen - 2] = 0x4;
82+
txData[dataLen - 1] = 0xa;
6083
return txData;
6184
};
6285

63-
Module.prototype.checkInitialData = function(data, config) {
86+
Module.prototype.checkInitialData = function (data, config) {
6487
return true;
6588
};
6689

67-
Module.prototype.afterConnect = function(that, cb) {
90+
Module.prototype.afterConnect = function (that, cb) {
6891
that.connected = true;
6992
if (cb) {
7093
cb('connected');
7194
}
7295
};
7396

74-
Module.prototype.validateLocalData = function(data) {
97+
Module.prototype.validateLocalData = function (data) {
7598
return true;
7699
};
77100

78101
/* 엔트리HW -> 엔트리JS */
79-
Module.prototype.requestRemoteData = function(handler) {
102+
Module.prototype.requestRemoteData = function (handler) {
80103
const sensorData = this.sensor_data;
81104
for (const key in sensorData) {
82105
handler.write(key, sensorData[key]);
83106
}
84107
};
85108

86109
/** 엔트리JS -> 엔트리HW */
87-
Module.prototype.handleRemoteData = function(handler) {
110+
Module.prototype.handleRemoteData = function (handler) {
88111
const workerData = this.worker_data;
89112
let newValue;
90113

@@ -136,18 +159,46 @@ Module.prototype.handleRemoteData = function(handler) {
136159
workerData.angle_state = newValue;
137160
}
138161

162+
if (handler.e(NEOCANNON.NEOPIXEL)) {
163+
newValue = handler.read(NEOCANNON.NEOPIXEL);
164+
if (newValue.data) {
165+
const red = newValue.data.red;
166+
const green = newValue.data.green;
167+
const blue = newValue.data.blue;
168+
169+
if (newValue.data.num !== undefined) {
170+
const num = newValue.data.num;
171+
workerData.neopixel[num].r = red;
172+
workerData.neopixel[num].g = green;
173+
workerData.neopixel[num].b = blue;
174+
} else {
175+
for (let i = 0; i < this.PIXEL_NUM; i++) {
176+
workerData.neopixel[i].r = red;
177+
workerData.neopixel[i].g = green;
178+
workerData.neopixel[i].b = blue;
179+
}
180+
}
181+
} else {
182+
for (let i = 0; i < this.PIXEL_NUM; i++) {
183+
workerData.neopixel[i].r = 0;
184+
workerData.neopixel[i].g = 0;
185+
workerData.neopixel[i].b = 0;
186+
}
187+
}
188+
}
189+
139190
this.worker_data = workerData;
140191
};
141192

142193
/* 엔트리HW -> 교구 */
143-
Module.prototype.requestLocalData = function() {
194+
Module.prototype.requestLocalData = function () {
144195
const workerData = this.worker_data;
145196
const txData = this.tx_data;
146197
let checkSum = 0;
147198
const dataLen = txData.length;
148199

149200
txData[0] = 0xff;
150-
txData[1] = 0x0e;
201+
txData[1] = 0x44;
151202
txData[2] = 0x01;
152203
txData[3] = 0x03;
153204
txData[4] = workerData.buz_octave;
@@ -158,7 +209,14 @@ Module.prototype.requestLocalData = function() {
158209
txData[9] = workerData.d9;
159210
txData[10] = workerData.d10;
160211
txData[11] = workerData.angle_state;
161-
txData[13] = 0xa;
212+
213+
for (let i = 0; i < this.PIXEL_NUM; i++) {
214+
txData[i * 3 + 12] = workerData.neopixel[i].r;
215+
txData[i * 3 + 13] = workerData.neopixel[i].g;
216+
txData[i * 3 + 14] = workerData.neopixel[i].b;
217+
}
218+
219+
txData[dataLen - 1] = 0xa;
162220

163221
for (let i = 2; i < dataLen - 2; i++) {
164222
checkSum += txData[i];
@@ -171,7 +229,7 @@ Module.prototype.requestLocalData = function() {
171229
};
172230

173231
/* 교구 -> 엔트리HW */
174-
Module.prototype.handleLocalData = function(data) {
232+
Module.prototype.handleLocalData = function (data) {
175233
const datas = this.getDataByBuffer(data);
176234
const sensorData = this.sensor_data;
177235

@@ -199,7 +257,7 @@ Module.prototype.handleLocalData = function(data) {
199257
this.sensor_data = sensorData;
200258
};
201259

202-
Module.prototype.getDataByBuffer = function(buffer) {
260+
Module.prototype.getDataByBuffer = function (buffer) {
203261
const datas = [];
204262
let lastIndex = 0;
205263
buffer.forEach((value, idx) => {
@@ -211,14 +269,14 @@ Module.prototype.getDataByBuffer = function(buffer) {
211269
return datas;
212270
};
213271

214-
Module.prototype.disconnect = function(connect) {
272+
Module.prototype.disconnect = function (connect) {
215273
connect.close();
216274
if (this.sp) {
217275
delete this.sp;
218276
}
219277
};
220278

221-
Module.prototype.reset = function() {
279+
Module.prototype.reset = function () {
222280
this.lastTime = 0;
223281
this.lastSendTime = 0;
224282
};

app/modules/robotis_RB100_practice.js

+52-40
Original file line numberDiff line numberDiff line change
@@ -569,29 +569,40 @@ Module.prototype.handleLocalData = function(data) { // data: Native Buffer
569569
}
570570
}
571571

572+
const dxlPositionStartAddr =
573+
addrMap[addrMap.length - 1][0] + addrMap[addrMap.length - 1][1];
574+
572575
// DXL Position
573576
for (let i = 0; i < 20; i++) {
574-
const currentId = rxPacket.data[2 + 83 + (3 * i)];
575-
const currentPos = rxPacket.data[2 + 83 + (3 * i) + 1] +
576-
(rxPacket.data[2 + 83 + (3 * i) + 2] << 8);
577-
if (currentId != 0xFF && currentPos != 0xFFFF) {
577+
const currentId =
578+
rxPacket.data[2 + dxlPositionStartAddr + 3 * i];
579+
const currentPos =
580+
rxPacket.data[2 + dxlPositionStartAddr + 3 * i + 1] +
581+
(rxPacket.data[2 + dxlPositionStartAddr + 3 * i + 2] << 8);
582+
if (currentId != 0xff && currentPos != 0xffff) {
578583
this.dxlPositions[currentId] = currentPos;
579584
}
580585
}
581586

587+
const lineCategoryStartAddr = dxlPositionStartAddr + 3 * 20;
588+
582589
// line category
583590
this.dataBuffer[5201] = rxPacket.data[2 + 143];
591+
592+
const sensorStartAddr = lineCategoryStartAddr + 1;
584593

585594
// 온습도+조도+동작감지센서값
586-
this.pirPir[0] = rxPacket.data[2 + 144];
587-
this.pirTemperature[0] = rxPacket.data[2 + 145];
588-
this.pirHumidity[0] = rxPacket.data[2 + 146];
589-
this.pirBrightness[0] = rxPacket.data[2 + 147];
595+
this.pirPir[0] = rxPacket.data[2 + sensorStartAddr];
596+
this.pirTemperature[0] = rxPacket.data[2 + sensorStartAddr + 1];
597+
this.pirHumidity[0] = rxPacket.data[2 + sensorStartAddr + 2];
598+
this.pirBrightness[0] = rxPacket.data[2 + sensorStartAddr + 3];
590599

591600
// 거리+버튼+조도센서값
592-
this.distanceDistance[0] = rxPacket.data[2 + 148] + (rxPacket.data[2 + 149] << 8);
593-
this.distanceButton[0] = rxPacket.data[2 + 150];
594-
this.distanceBrightness[0] = rxPacket.data[2 + 151];
601+
this.distanceDistance[0] =
602+
rxPacket.data[2 + sensorStartAddr + 4] +
603+
(rxPacket.data[2 + sensorStartAddr + 5] << 8);
604+
this.distanceButton[0] = rxPacket.data[2 + sensorStartAddr + 6];
605+
this.distanceBrightness[0] = rxPacket.data[2 + sensorStartAddr + 7];
595606

596607
for (let i = 0; i < addrMap2.length; i++) {
597608
switch (addrMap2[i][1]) {
@@ -842,39 +853,40 @@ const addrMap = [
842853
[69,8,502],
843854
[77,1,700],
844855
[78,1,810],
845-
[79,1,5015],
846-
[80,1,5030],
847-
[81,1,5031],
848-
[82,1,5040],
856+
[79,1,2134],
857+
[80,1,5015],
858+
[81,1,5030],
859+
[82,1,5031],
860+
[83,1,5040],
849861
];
850862

851863

852864
const addrMap2 = [
853-
[152,1,4000],
854-
[153,2,4003],
855-
[155,1,4005],
856-
[156,1,4006],
857-
[157,2,4009],
858-
[159,2,4011],
859-
[161,2,4013],
860-
[163,2,4015],
861-
[165,2,4017],
862-
[167,2,4019],
863-
[169,2,4021],
864-
[171,2,4023],
865-
[173,2,4025],
866-
[175,2,4027],
867-
[177,1,4031],
868-
[178,1,4032],
869-
[179,1,4033],
870-
[180,2,4036],
871-
[182,2,4038],
872-
[184,2,4040],
873-
[186,2,4042],
874-
[188,2,4044],
875-
[190,2,4046],
876-
[192,2,4048],
877-
[194,2,4050],
865+
[153,1,4000],
866+
[154,2,4003],
867+
[156,1,4005],
868+
[157,1,4006],
869+
[158,2,4009],
870+
[160,2,4011],
871+
[162,2,4013],
872+
[164,2,4015],
873+
[166,2,4017],
874+
[168,2,4019],
875+
[170,2,4021],
876+
[172,2,4023],
877+
[174,2,4025],
878+
[176,2,4027],
879+
[178,1,4031],
880+
[179,1,4032],
881+
[180,1,4033],
882+
[181,2,4036],
883+
[183,2,4038],
884+
[185,2,4040],
885+
[187,2,4042],
886+
[189,2,4044],
887+
[191,2,4046],
888+
[193,2,4048],
889+
[195,2,4050],
878890
];
879891

880892
//const rxPacket = Object.assign({}, packet);

app/server/mac/server.txt

104 Bytes
Binary file not shown.

app/server/win/server.exe

108 Bytes
Binary file not shown.

app/src/main/electron/serverProcessManager.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class ServerProcessManager {
5252
this._sendToChild('addRoomId', roomId);
5353
}
5454

55-
connectHardwareSuccess() {
56-
this._sendToChild('connectHardwareSuccess');
55+
connectHardwareSuccess(hardwareId: string) {
56+
this._sendToChild('connectHardwareSuccess', hardwareId);
5757
}
5858

5959
connectHardwareFailed() {

app/src/main/mainRouter.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface IEntryServer {
2222
setRouter: (router: MainRouter) => void;
2323
open: () => void;
2424
disconnectHardware: () => void;
25-
connectHardwareSuccess: () => void;
25+
connectHardwareSuccess: (hardwareId: String) => void;
2626
connectHardwareFailed: () => void;
2727
addRoomIdsOnSecondInstance: (roomId: string) => void;
2828
send: (data: any) => void;
@@ -320,7 +320,7 @@ class MainRouter {
320320
logger.verbose('entryServer, connector connection');
321321
this.handler = new DataHandler(this.config.id);
322322
this._connectToServer();
323-
this.server.connectHardwareSuccess();
323+
this.server.connectHardwareSuccess(this.config.id);
324324
this.connector.connect(); // router 설정 후 실제 기기와의 통신 시작
325325
}
326326
}

build/entry-hw.nsi

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
!define PRODUCT_NAME "Entry_HW"
1515
!define PROTOCOL_NAME "entryhw"
1616
!define APP_NAME "Entry_HW.exe"
17-
!define PRODUCT_VERSION "1.9.57"
17+
!define PRODUCT_VERSION "1.9.58"
1818
!define PRODUCT_PUBLISHER "EntryLabs"
1919
!define PRODUCT_WEB_SITE "https://www.playentry.org/"
2020

0 commit comments

Comments
 (0)