@@ -84,11 +84,13 @@ class hexaboard extends BaseModule {
84
84
DISPLAY_OLED : 0x10 , // OLED 값 정의
85
85
DISPLAY_INIT_OLED : 0x12 , // OLED 값 정의
86
86
UPDATE_ALL_NEOPIXEL : 0x11 , //모든 네오픽셀 켜기
87
+ CLEAR_DISPLAY_OLED : 0x25 , // OLED값 리셋
87
88
CONNECT_WIFI : 0x21 , //WIFI 연결
88
89
CONNECT_BLYNK : 0x21 , //BLYNK서버 연결
89
90
BLYNK_VIRTUAL_WRITE : 0x22 , //BLYNK 가상의 핀 데이터 전송
90
91
BLYNK_WRITE : 0x23 , //BLYNK 상태값 바뀌었을때
91
92
CONNECTED_BLYNK : 0x24 , //BLYNK 연결 상태 확인
93
+ HEXA_INIT : 0x30 ,
92
94
} ;
93
95
// 자이로 센서에 대한 추가적인 세부 명령 정의
94
96
this . gyro_sensor = {
@@ -160,7 +162,7 @@ class hexaboard extends BaseModule {
160
162
// 에러 처리 또는 데이터 분할 필요
161
163
throw new Error ( 'Data length exceeds buffer limit' ) ;
162
164
}
163
-
165
+ // console.log(`딜레이 : ${duration}`);
164
166
buffer = new Buffer ( [
165
167
255 ,
166
168
85 ,
@@ -374,6 +376,7 @@ class hexaboard extends BaseModule {
374
376
data : value ,
375
377
} ) ,
376
378
] ) ;
379
+ // console.log(`pin : ${port}, value : ${value}`);
377
380
if ( buffer . length ) {
378
381
//이곳에서 데이터를 SendBuffer에 저장하기
379
382
this . sendBuffers . push ( buffer ) ;
@@ -414,6 +417,7 @@ class hexaboard extends BaseModule {
414
417
] ) ;
415
418
if ( buffer . length ) {
416
419
//이곳에서 데이터를 SendBuffer에 저장하기
420
+ console . log ( `duration : ${ duration } ` ) ;
417
421
this . sendBuffers . push ( buffer ) ;
418
422
}
419
423
break ;
@@ -525,6 +529,19 @@ class hexaboard extends BaseModule {
525
529
this . sendBuffers . push ( buffer ) ;
526
530
}
527
531
break ;
532
+ case this . sensorTypes . CLEAR_DISPLAY_OLED :
533
+ // console.log('DISPLAY_INIT_OLED');
534
+ buffer = Buffer . concat (
535
+ [ buffer ,
536
+ this . makeOutputBuffer ( {
537
+ command : this . command . WRITE ,
538
+ sensorType : this . sensorTypes . CLEAR_DISPLAY_OLED ,
539
+ } ) ,
540
+ ] ) ;
541
+ if ( buffer . length ) {
542
+ this . sendBuffers . push ( buffer ) ;
543
+ }
544
+ break ;
528
545
case this . sensorTypes . CONNECT_WIFI :
529
546
// console.log('CONNECT_WIFI');
530
547
ssid = readData . data . ssid ;
@@ -595,6 +612,19 @@ class hexaboard extends BaseModule {
595
612
this . sendBuffers . push ( buffer ) ;
596
613
}
597
614
break ;
615
+ case this . sensorTypes . HEXA_INIT :
616
+ buffer = Buffer . concat (
617
+ [ buffer ,
618
+ this . makeOutputBuffer ( {
619
+ command : this . command . WRITE ,
620
+ sensorType : this . sensorTypes . HEXA_INIT ,
621
+ } ) ,
622
+ ] ) ;
623
+ if ( buffer . length ) {
624
+ //이곳에서 데이터를 SendBuffer에 저장하기
625
+ this . sendBuffers . push ( buffer ) ;
626
+ }
627
+ break ;
598
628
}
599
629
}
600
630
@@ -617,6 +647,7 @@ class hexaboard extends BaseModule {
617
647
} ) ,
618
648
] ) ;
619
649
if ( buffer . length ) {
650
+ // console.log(`pin : ${port}, value : ${value}`);
620
651
this . sendBuffers . push ( buffer ) ;
621
652
}
622
653
break ;
@@ -691,6 +722,7 @@ class hexaboard extends BaseModule {
691
722
// 디바이스로 데이터를 보내는 로직. control: slave 인 경우 duration 주기에 맞춰 디바이스에 데이터를 보낸다.
692
723
// return 값으로 버퍼를 반환하면 디바이스로 데이터를 보내나, 아두이노의 경우 레거시 코드를 따르고 있다.
693
724
if ( this . sendBuffers . length > 0 ) {
725
+ // console.log(this.sendBuffers);
694
726
this . sp . write ( this . sendBuffers . shift ( ) , ( ) => {
695
727
if ( this . sp ) {
696
728
this . sp . drain ( ( ) => {
@@ -703,7 +735,9 @@ class hexaboard extends BaseModule {
703
735
return null ;
704
736
}
705
737
706
- connect ( ) { }
738
+ connect ( ) {
739
+ // console.log("connected");
740
+ }
707
741
708
742
disconnect ( connect ) {
709
743
if ( this . isConnect ) {
@@ -720,7 +754,9 @@ class hexaboard extends BaseModule {
720
754
}
721
755
}
722
756
723
- reset ( ) { }
757
+ reset ( ) {
758
+ // console.log("reset");
759
+ }
724
760
}
725
761
726
762
module . exports = new hexaboard ( ) ;
0 commit comments