Sync work

This commit is contained in:
Jochen Friedrich 2025-01-13 08:50:18 +01:00
parent efa5673e71
commit cfff99eb68
7 changed files with 60 additions and 152 deletions

View file

@ -1,5 +1,5 @@
sdcc -mmcs51 -o lc.ihx lc.c -D FOSC_160000 -I../include
sdcc -mmcs51 --model-large -c MySensors.c -D FOSC_160000 -D MY_NODE_ID=201 -I../include
sdcc -mmcs51 --model-large -o chan8.ihx chan8.c MySensors.rel -D FOSC_160000 -I../include
sdcc -mmcs51 --model-large -c MySensors.c -D FOSC_160000 -D MY_NODE_ID=202 -I../include
sdcc -mmcs51 --model-large -o rs485relay.ihx rs485relay.c MySensors.rel -D FOSC_160000 -I../include
sdcc-sdcc -mmcs51 -o lc.ihx lc.c -D FOSC_160000 -I../include
sdcc-sdcc -mmcs51 --model-large -c MySensors.c -D FOSC_160000 -D MY_NODE_ID=201 -I../include
sdcc-sdcc -mmcs51 --model-large -o chan8.ihx chan8.c MySensors.rel -D FOSC_160000 -I../include
sdcc-sdcc -mmcs51 --model-large -c MySensors.c -D FOSC_160000 -D MY_NODE_ID=202 -I../include
sdcc-sdcc -mmcs51 --model-large -o rs485relay.ihx rs485relay.c MySensors.rel -D FOSC_160000 -I../include

View file

@ -73,24 +73,24 @@ void tuya_receive (unsigned int len, unsigned char *buffer) {
switch(dpid) {
case 1:
RELAY1 = buffer[4] ? 0 : 1;
RELAY1 = buffer[4] ? 1 : 0;
break;
case 2:
RELAY2 = buffer[4] ? 0 : 1;
RELAY2 = buffer[4] ? 1 : 0;
break;
case 3:
BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;SFRS|=0x01;
PWM_RED = buffer[4];
PWM_RED = buffer[7];
TA=0xAA;TA=0x55;SFRS&=0xFE;EA=BIT_TMP;
LOAD = 1;
break;
case 4:
PWM_GREEN = buffer[4];
PWM_GREEN = buffer[7];
LOAD = 1;
break;
case 5:
BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;SFRS|=0x01;
PWM_BLUE = buffer[4];
PWM_BLUE = buffer[7];
TA=0xAA;TA=0x55;SFRS&=0xFE;EA=BIT_TMP;
LOAD = 1;
break;
@ -113,6 +113,9 @@ void process(unsigned char cmd, unsigned int len, unsigned char *buffer) {
len = strlen(buffer);
sendpkt(1, len, buffer);
break;
case 2: /* Config */
sendpkt(2, 0, NULL); /* No GPIO Pins */
break;
case 3: /* WIFI State */
sendpkt(3, 0, NULL);
break;
@ -120,6 +123,45 @@ void process(unsigned char cmd, unsigned int len, unsigned char *buffer) {
tuya_receive(len, buffer);
break;
case 8: /* Query Command */
buffer[0] = 1;
buffer[1] = 1;
buffer[2] = 0;
buffer[3] = 1;
buffer[4] = 0;
buffer[5] = 2;
buffer[6] = 1;
buffer[7] = 0;
buffer[8] = 1;
buffer[9] = 0;
buffer[10] = 3;
buffer[11] = 2;
buffer[12] = 0;
buffer[13] = 4;
buffer[14] = 0;
buffer[15] = 0;
buffer[16] = 0;
buffer[17] = 0;
buffer[18] = 4;
buffer[19] = 2;
buffer[20] = 0;
buffer[21] = 4;
buffer[22] = 0;
buffer[23] = 0;
buffer[24] = 0;
buffer[25] = 0;
buffer[26] = 5;
buffer[27] = 2;
buffer[28] = 0;
buffer[29] = 4;
buffer[30] = 0;
buffer[31] = 0;
buffer[32] = 0;
buffer[33] = 0;
sendpkt(0x22, 34, buffer);
break;
}
}
@ -191,7 +233,7 @@ void uart_loop() {
buf[1] = 1;
buf[2] = 0;
buf[3] = 1;
buf[4] = (1 - RELAY1);
buf[4] = (RELAY1?1:0);
sendpkt(7, 5, buf);
}
}
@ -209,7 +251,7 @@ void uart_loop() {
buf[1] = 1;
buf[2] = 0;
buf[3] = 1;
buf[4] = (1 - RELAY2);
buf[4] = (RELAY2?1:0);
sendpkt(7, 5, buf);
}
}