Skip to content

Commit 961ab3f

Browse files
committed
fix bugs
1 parent 41fbbbf commit 961ab3f

File tree

3 files changed

+75
-54
lines changed

3 files changed

+75
-54
lines changed

Distr/nrf24batch/CO2_mini.txt

+23-8
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ DPL: 0
77
RETR: 0x0F
88
Resend: 3
99
Delay_ms: 30
10-
Read repeat: 10
10+
Listen repeat: 3
1111

1212
Payload struct: 2,1,1
13-
EEPROM=0; RAM=1; PROGMEM=2; ID=3; RESET=4
13+
EEPROM=0; RAM=1; PROGMEM=2; ID=3; RESET=4; WRAM=0x89
1414

1515
R default: ,EEPROM,0xC1
1616
W default: n,,0x81
@@ -19,9 +19,15 @@ Write start: 0,0,0x8F
1919
Listen: C8C8C1=CO2,Alarm,-
2020

2121
R: ID*=,ID
22-
R: OSCCAL=0x51,RAM
22+
23+
R: _CO2*2=0x6C,RAM,0xC2
24+
R: _PORTA=0x39,RAM
25+
W: _PORTA=,0x3B,WRAM
26+
R: _PORTB=0x36,RAM
27+
W: _PORTB=,0x38,WRAM
28+
R: _OSCCAL=0x51,RAM
29+
W: _OSCCAL=,0x51,WRAM
2330
R: OSCCAL_EMEM=0
24-
R: CO2*2=0x6B,RAM,0xC2
2531

2632
R: RxAddr=1#
2733
W: RxAddr=,1
@@ -44,25 +50,34 @@ W: CO2 correct=,7,0x82
4450
R: FanLSB[10]=i:9#
4551
W: FanLSB=,i:9
4652

47-
R: Send pause=19
48-
W: Send pause=,19
53+
R: Transmit pause=19
54+
W: Transmit pause=,19
4955

5056
R: Flags=20#
5157
W: Flags=,20
5258

5359
W: Reset=,RESET,0xC1
5460

61+
R: _LED Warning=0x74,RAM
62+
W: _LED Warning=,0x74,WRAM
63+
5564
S: LED=,0,0x40
5665

5766
SBatch: LED On: LED=1
5867
SBatch: LED Off: LED=0
5968

6069
RBatch: Settings: ID;RxAddr;Ch;Send period;CO2 threshold;CO2 correct;FanLSB;nRF RETR;Send pause;Flags
6170

62-
WBatch: Default: RxAddr=0xCF;Ch=122;Send period=30;CO2 threshold=1000;CO2 correct=0;FanLSB={0xC1,0,0,0,0,0,0,0};nRF RETR=0x3;Send pause=1;Flags=0;Reset
71+
WBatch: Default: RxAddr=0xCF;Ch=122;Send period=30;CO2 threshold=1000;CO2 correct=0;FanLSB={0xC1,0,0,0,0,0,0,0};nRF RETR=0x3;Transmit pause=1;Flags=0;Reset
6372
WBatch: CO2: CO2 threshold=1000;CO2 correct=0
6473
WBatch: Fan: FanLSB={0xC1,0,0,0,0,0,0,0,0,0};Reset
6574
WBatch: RETR: nRF RETR=0x2F;Reset
66-
WBatch: Send pause: Send pause=30
75+
WBatch: Transmit pause: Transmit pause=30
6776
WBatch: Flags: Flags=0x00
77+
78+
WBatch: LED Warning: _LED Warning=0x30
79+
WBatch: PORTA: _PORTA=0x0C
80+
WBatch: PORTB: _PORTB=0xC
81+
WBatch: OSCCAL: _OSCCAL=128
82+
6883
WBatch: Reset: Reset

Distr/nrf24batch/Kitchen Vent.txt

+34-29
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ Resend: 3
99
Delay_ms: 30
1010

1111
Payload struct: 2,1,1
12-
EEPROM=0; RAM=1; PROGMEM=2; ID=3; RESET=4, WRAM=0x89
12+
EEPROM=0; RAM=1; PROGMEM=2; ID=3; RESET=4; WRAM=0x89; R1=0xC1; R2=0xC2; W1=0x81; W2=0x82
1313

14-
R default: ,EEPROM,0xC1
15-
W default: n,,0x81
14+
R default: ,EEPROM,R1
15+
W default: n,,W1
1616
Write start: 0,0,0x8F
1717

1818
R: ID*=,ID
1919

20-
R: CO2 level*2[3]=i:4,,0xC2
21-
W: CO2 level*2=,i:4,0x82
20+
R: CO2 level*2[3]=i:4,,R2
21+
W: CO2 level*2=,i:4,W2
2222

2323
R: FanSpeed[3]=i:19
2424
W: FanSpeed=,i:19
@@ -52,8 +52,8 @@ W: SpeedKeyIdx=,17
5252
R: IRRemotes=32
5353
W: IRRemotes=,32
5454

55-
R: IRRemotesHash*2[80]=i:32#
56-
W: IRRemotesHash*2=,i:32
55+
R: IRRemotesHash*2[80]=i:32#,,R2
56+
W: IRRemotesHash*2=,i:32,W2
5757

5858
R: OutPeriod=18
5959
W: OutPeriod=,18
@@ -67,48 +67,53 @@ W: RxAddr=,2
6767
R: Ch=3
6868
W: Ch=,3
6969

70-
R: OSCCAL#=0x51,RAM
71-
W: OSCCAL#=,0x51,WRAM
70+
R: _OSCCAL=0x51,RAM
71+
W: _OSCCAL=,0x51,WRAM
7272
R: OSCCAL_EMEM=0
7373

74-
R: PORTA#=0x39,RAM
75-
W: PORTA#=,0x3B,WRAM
76-
R: PORTB#=0x36,RAM
77-
W: PORTB#=,0x38,WRAM
74+
R: _PORTA=0x39,RAM
75+
W: _PORTA=,0x3B,WRAM
76+
R: _PORTB=0x36,RAM
77+
W: _PORTB=,0x38,WRAM
7878

79-
R: LED Warning#=0x6C,RAM
80-
W: LED Warning#=,0x6C,WRAM
79+
R: _LED Warning=0x6B,RAM
80+
W: _LED Warning=,0x6B,WRAM
8181

82-
R: FanOn=0x76,RAM
83-
R: FanOnNext=0x74,RAM
84-
R: FanOnNextCnt=0x72,RAM
85-
R: FanOnLast=0x73,RAM
86-
R: Fanspeed=0x75,RAM
82+
R: _FanOn=0x75,RAM
83+
R: _FanOnNext=0x73,RAM
84+
R: _FanOnNextCnt=0x71,RAM
85+
R: _FanOnLast=0x72,RAM
86+
R: _Fanspeed=0x74,RAM
87+
R: _IRHashLast*2=0x79,RAM,R2
8788

8889
W: Reset=,RESET,0xC1
8990

9091
S: Lamp=,0,0x40
9192
S: Fan=,1,0x40
9293
S: FanSpdUp=,2,0x40
9394
S: FanSpdDn=,3,0x40
94-
S: SetupIR=,4,0x40
95+
S: FanSpdSave=,4,0x40
96+
S: SetupIR=,5,0x40
9597

96-
SBatch: Fan Off: Fan=0
97-
SBatch: Fan On: Fan=3
9898
SBatch: Fan Cooker On: Fan=6
99-
SBatch: Fan Up: FanSpdUp=0
100-
SBatch: Fan Down: FanSpdDn=0
99+
SBatch: Fan On: Fan=3
100+
SBatch: Fan Off: Fan=0
101101
SBatch: Lamp On: Lamp=1
102102
SBatch: Lamp Off: Lamp=0
103+
SBatch: Fan Up: FanSpdUp=0
104+
SBatch: Fan Down: FanSpdDn=0
105+
SBatch: Fan SAVE: FanSpdSave=0;
106+
SBatch: Add new IR: SetupIR=1
103107

104108
RBatch: Work: ID;CO2 level;FanCookSpeed;FanCookOnTime;FanCookOffTime;FanCookSleep;FanSpeed;FanOnTime;FanOffTime;FanSleep
105109
RBatch: Hardware: ID;RxAddr;Ch;SpeedInitIdx;Flags;OutPeriod;IRRemotes;OSCCAL_EMEM
106110
RBatch: All: ID;CO2 level;FanCookSpeed;FanCookOnTime;FanCookOffTime;FanCookSleep;FanSpeed;FanOnTime;FanOffTime;FanSleep;RxAddr;Ch;SpeedInitIdx;Flags;OutPeriod;IRRemotes;IRRemotesHash
107111

108112
WBatch: Init(Cook2spd,Lamp-F2.2): RxAddr=0xC1;Ch=122;CO2 level={700,850,1000};FanSpeed={3,5,6};FanCookSpeed={3,6,12};FanSleep=20;FanCookSleep=6;FanOnTime=150;FanCookOnTime=2;FanOffTime=100;FanCookOffTime=0;SpeedInitIdx=0;SpeedKeyIdx=6;Flags=0x49;OutPeriod=6;IRRemotes=0
109-
WBatch: LED Warning: LED Warning#=0x10
110-
WBatch: PORTA: PORTA#=0x0C
111-
WBatch: PORTB: PORTB#=0xC
112-
WBatch: OSCCAL: OSCCAL#=128
113+
WBatch: IRRemotes: IRRemotes=0
114+
WBatch: LED Warning: _LED Warning=0x10
115+
WBatch: PORTA: _PORTA=0x0C
116+
WBatch: PORTB: _PORTB=0xC
117+
WBatch: OSCCAL: _OSCCAL=128
113118
WBatch: CO2 Level+Fan speed: CO2 level={700,850,1000};FanSpeed={3,5,6}
114119
WBatch: Reset: Reset

nrf24batch.c

+18-17
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const char SettingsFld_ReadBatch[] = "RBatch:";
4444
const char SettingsFld_WriteBatch[] = "WBatch:";
4545
const char SettingsFld_SetBatch[] = "SBatch:";
4646
const char SettingsFld_Listen[] = "Listen:";
47-
const char SettingsFld_ReadRepeatPeriod[] = "Read repeat:";
47+
const char SettingsFld_ListenRepeatPeriod[] = "Listen repeat:";
4848
const char AskQuestion_Save[] = "SAVE BATCH?";
4949
#define Settings_i 'i'
5050
#define Settings_n 'n'
@@ -95,7 +95,7 @@ uint8_t NRF_last_packet_send_st = 0;
9595
uint8_t NRF_resend = 1; // number of transaction attempts
9696
int8_t NRF_repeat = 0; // count number of repeated requests (until < NRF_resend)
9797
uint32_t NRF_time;
98-
uint16_t ReadRepeatPeriod = 10; // s
98+
uint16_t ListenRepeatPeriod = 10; // s
9999
bool ReadRepeat = false;
100100
uint32_t delay_between_pkt = 10;// ms
101101

@@ -854,8 +854,8 @@ static uint8_t load_settings_file() {
854854
NRF_resend = str_to_int(p + sizeof(SettingsFld_Resend));
855855
} else if(strncmp(p, SettingsFld_Delay, sizeof(SettingsFld_Delay)-1) == 0) {
856856
delay_between_pkt = str_to_int(p + sizeof(SettingsFld_Delay));
857-
} else if(strncmp(p, SettingsFld_ReadRepeatPeriod, sizeof(SettingsFld_ReadRepeatPeriod)-1) == 0) {
858-
ReadRepeatPeriod = str_to_int(p + sizeof(SettingsFld_ReadRepeatPeriod));
857+
} else if(strncmp(p, SettingsFld_ListenRepeatPeriod, sizeof(SettingsFld_ListenRepeatPeriod)-1) == 0) {
858+
ListenRepeatPeriod = str_to_int(p + sizeof(SettingsFld_ListenRepeatPeriod));
859859
} else if(strncmp(p, SettingsFld_Payload, sizeof(SettingsFld_Payload)-1) == 0) {
860860
p += sizeof(SettingsFld_Payload);
861861
payload_fields = 0;
@@ -1000,6 +1000,18 @@ static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queu
10001000
furi_message_queue_put(event_queue, &event, FuriWaitForever);
10011001
}
10021002

1003+
void display_remove_asterisk(char *fsp, uint8_t vx)
1004+
{
1005+
char *p2 = strchr(fsp, '*');
1006+
if(p2) { // remove '*' or '*n'
1007+
int pos = p2 - fsp;
1008+
if((pos -= vx) < 0) pos = 0;
1009+
char c = *(p2 + 1);
1010+
if(*(screen_buf + pos))
1011+
memmove(screen_buf + pos, screen_buf + pos + (c == ':' || c == '=' ? 1 : 2), FONT_5x7_SCREEN_WIDTH + 1 + 2 - pos);
1012+
}
1013+
}
1014+
10031015
void render_display_list(Canvas* const canvas, FuriString ***fsa, char delim, uint16_t view_pos, uint16_t max_i)
10041016
{
10051017
uint16_t page = view_pos & ~7;
@@ -1010,12 +1022,11 @@ void render_display_list(Canvas* const canvas, FuriString ***fsa, char delim, ui
10101022
p = (char*) furi_string_get_cstr((*fsa)[page + i]);
10111023
end = strchr(p, delim);
10121024
if(end) {
1013-
if(*(end - 1) == '*') end--; // skip *
1014-
else if(*(end - 2) == '*') end -= 2; // skip *?
10151025
len = MIN(end - p, view_x);
10161026
len = MIN(end - p - len, FONT_5x7_SCREEN_WIDTH);
10171027
strncpy(screen_buf, p + view_x, len);
10181028
screen_buf[len] = '\0';
1029+
display_remove_asterisk(p, MIN(end - p, view_x));
10191030
canvas_draw_str(canvas, 5, y, screen_buf);
10201031
}
10211032
if((view_pos & 7) == i) {
@@ -1025,16 +1036,6 @@ void render_display_list(Canvas* const canvas, FuriString ***fsa, char delim, ui
10251036
}
10261037
}
10271038

1028-
void display_remove_asterisk(char *fsp, uint8_t vx)
1029-
{
1030-
char *p2 = strchr(fsp, '*');
1031-
if(p2) { // remove '*' or '*n'
1032-
int pos = p2 - fsp;
1033-
if((pos -= vx) < 0) pos = 0;
1034-
memmove(screen_buf + pos, screen_buf + pos + (*(p2 + 1) == ':' ? 1 : 2), FONT_5x7_SCREEN_WIDTH + 1 + 2);
1035-
}
1036-
}
1037-
10381039
void display_edit_ttf_font(Canvas* const canvas, uint8_t start_x, uint8_t start_y)
10391040
{
10401041
screen_buf[0] = *Edit_pos; screen_buf[1] = '\0';
@@ -1392,7 +1393,7 @@ int32_t nrf24batch_app(void* p) {
13921393
FuriLogLevel = furi_log_get_level();
13931394
if(FuriLogLevel == FuriLogLevelDebug) furi_hal_uart_set_br(FuriHalUartIdUSART1, 1843200);
13941395
}
1395-
if(what_doing == 2 && rw_type == rwt_read_cmd && ReadRepeat && furi_get_tick() - NRF_time > (uint32_t)(ReadRepeatPeriod * 1000)) {
1396+
if(what_doing == 2 && rw_type == rwt_read_cmd && ReadRepeat && furi_get_tick() - NRF_time > (uint32_t)(ListenRepeatPeriod * 1000)) {
13961397
ERR = 0;
13971398
free_Log();
13981399
Run_Read_cmd(Read_cmd[view_cmd[rwt_read_cmd]]);

0 commit comments

Comments
 (0)