Thomas Buck před 4 měsíci
rodič
revize
689a3189d7
4 změnil soubory, kde provedl 56 přidání a 54 odebrání
  1. 2
    0
      CMakeLists.txt
  2. 24
    24
      src/console.c
  3. 10
    10
      src/log.c
  4. 20
    20
      src/workflow.c

+ 2
- 0
CMakeLists.txt Zobrazit soubor

157
     -Wall
157
     -Wall
158
     -Wextra
158
     -Wextra
159
     -Werror
159
     -Werror
160
+    -Wshadow
160
 )
161
 )
161
 
162
 
162
 # suppress some warnings for borked 3rd party files in Pico SDK
163
 # suppress some warnings for borked 3rd party files in Pico SDK
166
 set_source_files_properties(pico-sdk/lib/btstack/src/classic/avdtp_util.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
167
 set_source_files_properties(pico-sdk/lib/btstack/src/classic/avdtp_util.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
167
 set_source_files_properties(pico-sdk/lib/btstack/src/classic/goep_client.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
168
 set_source_files_properties(pico-sdk/lib/btstack/src/classic/goep_client.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
168
 set_source_files_properties(pico-sdk/lib/btstack/src/classic/goep_server.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
169
 set_source_files_properties(pico-sdk/lib/btstack/src/classic/goep_server.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
170
+set_source_files_properties(pico-sdk/src/rp2_common/hardware_flash/flash.c PROPERTIES COMPILE_FLAGS -Wno-shadow)
169
 
171
 
170
 # pull in common dependencies
172
 # pull in common dependencies
171
 target_link_libraries(gadget
173
 target_link_libraries(gadget

+ 24
- 24
src/console.c Zobrazit soubor

319
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
319
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
320
 #endif // TEST_VOLCANO_AUTO_CONNECT
320
 #endif // TEST_VOLCANO_AUTO_CONNECT
321
 
321
 
322
-            int8_t r = volcano_set_target_temp(v);
322
+            int8_t t = volcano_set_target_temp(v);
323
 
323
 
324
 #ifdef TEST_VOLCANO_AUTO_CONNECT
324
 #ifdef TEST_VOLCANO_AUTO_CONNECT
325
             ble_disconnect();
325
             ble_disconnect();
326
 #endif // TEST_VOLCANO_AUTO_CONNECT
326
 #endif // TEST_VOLCANO_AUTO_CONNECT
327
 
327
 
328
-            if (r < 0) {
329
-                println("error writing target temp %d", r);
328
+            if (t < 0) {
329
+                println("error writing target temp %d", t);
330
             } else {
330
             } else {
331
                 println("success");
331
                 println("success");
332
             }
332
             }
341
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
341
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
342
 #endif // TEST_VOLCANO_AUTO_CONNECT
342
 #endif // TEST_VOLCANO_AUTO_CONNECT
343
 
343
 
344
-            int8_t r = volcano_set_heater_state(val == 1);
344
+            int8_t t = volcano_set_heater_state(val == 1);
345
 
345
 
346
 #ifdef TEST_VOLCANO_AUTO_CONNECT
346
 #ifdef TEST_VOLCANO_AUTO_CONNECT
347
             ble_disconnect();
347
             ble_disconnect();
348
 #endif // TEST_VOLCANO_AUTO_CONNECT
348
 #endif // TEST_VOLCANO_AUTO_CONNECT
349
 
349
 
350
-            if (r < 0) {
351
-                println("error writing heater state %d", r);
350
+            if (t < 0) {
351
+                println("error writing heater state %d", t);
352
             } else {
352
             } else {
353
                 println("success");
353
                 println("success");
354
             }
354
             }
363
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
363
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
364
 #endif // TEST_VOLCANO_AUTO_CONNECT
364
 #endif // TEST_VOLCANO_AUTO_CONNECT
365
 
365
 
366
-            int8_t r = volcano_set_pump_state(val == 1);
366
+            int8_t s = volcano_set_pump_state(val == 1);
367
 
367
 
368
 #ifdef TEST_VOLCANO_AUTO_CONNECT
368
 #ifdef TEST_VOLCANO_AUTO_CONNECT
369
             ble_disconnect();
369
             ble_disconnect();
370
 #endif // TEST_VOLCANO_AUTO_CONNECT
370
 #endif // TEST_VOLCANO_AUTO_CONNECT
371
 
371
 
372
-            if (r < 0) {
373
-                println("error writing pump state %d", r);
372
+            if (s < 0) {
373
+                println("error writing pump state %d", s);
374
             } else {
374
             } else {
375
                 println("success");
375
                 println("success");
376
             }
376
             }
385
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
385
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
386
 #endif // TEST_VOLCANO_AUTO_CONNECT
386
 #endif // TEST_VOLCANO_AUTO_CONNECT
387
 
387
 
388
-            int8_t r = volcano_set_unit((val == 'C') ? UNIT_C : UNIT_F);
388
+            int8_t u = volcano_set_unit((val == 'C') ? UNIT_C : UNIT_F);
389
 
389
 
390
 #ifdef TEST_VOLCANO_AUTO_CONNECT
390
 #ifdef TEST_VOLCANO_AUTO_CONNECT
391
             ble_disconnect();
391
             ble_disconnect();
392
 #endif // TEST_VOLCANO_AUTO_CONNECT
392
 #endif // TEST_VOLCANO_AUTO_CONNECT
393
 
393
 
394
-            if (r < 0) {
395
-                println("error writing value %d", r);
394
+            if (u < 0) {
395
+                println("error writing value %d", u);
396
             } else {
396
             } else {
397
                 println("success");
397
                 println("success");
398
             }
398
             }
407
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
407
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
408
 #endif // TEST_VOLCANO_AUTO_CONNECT
408
 #endif // TEST_VOLCANO_AUTO_CONNECT
409
 
409
 
410
-            int8_t r = volcano_set_vibration(val == 1);
410
+            int8_t v = volcano_set_vibration(val == 1);
411
 
411
 
412
 #ifdef TEST_VOLCANO_AUTO_CONNECT
412
 #ifdef TEST_VOLCANO_AUTO_CONNECT
413
             ble_disconnect();
413
             ble_disconnect();
414
 #endif // TEST_VOLCANO_AUTO_CONNECT
414
 #endif // TEST_VOLCANO_AUTO_CONNECT
415
 
415
 
416
-            if (r < 0) {
417
-                println("error writing value %d", r);
416
+            if (v < 0) {
417
+                println("error writing value %d", v);
418
             } else {
418
             } else {
419
                 println("success");
419
                 println("success");
420
             }
420
             }
429
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
429
             DEV_AUTO_CONNECT(TEST_VOLCANO_AUTO_CONNECT);
430
 #endif // TEST_VOLCANO_AUTO_CONNECT
430
 #endif // TEST_VOLCANO_AUTO_CONNECT
431
 
431
 
432
-            int8_t r = volcano_set_display_cooling(val == 1);
432
+            int8_t c = volcano_set_display_cooling(val == 1);
433
 
433
 
434
 #ifdef TEST_VOLCANO_AUTO_CONNECT
434
 #ifdef TEST_VOLCANO_AUTO_CONNECT
435
             ble_disconnect();
435
             ble_disconnect();
436
 #endif // TEST_VOLCANO_AUTO_CONNECT
436
 #endif // TEST_VOLCANO_AUTO_CONNECT
437
 
437
 
438
-            if (r < 0) {
439
-                println("error writing value %d", r);
438
+            if (c < 0) {
439
+                println("error writing value %d", c);
440
             } else {
440
             } else {
441
                 println("success");
441
                 println("success");
442
             }
442
             }
517
             DEV_AUTO_CONNECT(TEST_CRAFTY_AUTO_CONNECT);
517
             DEV_AUTO_CONNECT(TEST_CRAFTY_AUTO_CONNECT);
518
 #endif // TEST_CRAFTY_AUTO_CONNECT
518
 #endif // TEST_CRAFTY_AUTO_CONNECT
519
 
519
 
520
-            int8_t r = crafty_set_target_temp(v);
520
+            int8_t t = crafty_set_target_temp(v);
521
 
521
 
522
 #ifdef TEST_CRAFTY_AUTO_CONNECT
522
 #ifdef TEST_CRAFTY_AUTO_CONNECT
523
             ble_disconnect();
523
             ble_disconnect();
524
 #endif // TEST_CRAFTY_AUTO_CONNECT
524
 #endif // TEST_CRAFTY_AUTO_CONNECT
525
 
525
 
526
-            if (r < 0) {
527
-                println("error writing target temp %d", r);
526
+            if (t < 0) {
527
+                println("error writing target temp %d", t);
528
             } else {
528
             } else {
529
                 println("success");
529
                 println("success");
530
             }
530
             }
539
             DEV_AUTO_CONNECT(TEST_CRAFTY_AUTO_CONNECT);
539
             DEV_AUTO_CONNECT(TEST_CRAFTY_AUTO_CONNECT);
540
 #endif // TEST_CRAFTY_AUTO_CONNECT
540
 #endif // TEST_CRAFTY_AUTO_CONNECT
541
 
541
 
542
-            int8_t r = crafty_set_heater_state(val == 1);
542
+            int8_t s = crafty_set_heater_state(val == 1);
543
 
543
 
544
 #ifdef TEST_CRAFTY_AUTO_CONNECT
544
 #ifdef TEST_CRAFTY_AUTO_CONNECT
545
             ble_disconnect();
545
             ble_disconnect();
546
 #endif // TEST_CRAFTY_AUTO_CONNECT
546
 #endif // TEST_CRAFTY_AUTO_CONNECT
547
 
547
 
548
-            if (r < 0) {
549
-                println("error writing heater state %d", r);
548
+            if (s < 0) {
549
+                println("error writing heater state %d", s);
550
             } else {
550
             } else {
551
                 println("success");
551
                 println("success");
552
             }
552
             }

+ 10
- 10
src/log.c Zobrazit soubor

30
 #include "log.h"
30
 #include "log.h"
31
 
31
 
32
 static uint8_t log_buff[4096] = {0};
32
 static uint8_t log_buff[4096] = {0};
33
-static struct ring_buffer log = RB_INIT(log_buff, sizeof(log_buff), 1);
33
+static struct ring_buffer log_rb = RB_INIT(log_buff, sizeof(log_buff), 1);
34
 
34
 
35
 static uint8_t line_buff[256] = {0};
35
 static uint8_t line_buff[256] = {0};
36
 static volatile bool got_input = false;
36
 static volatile bool got_input = false;
40
 #endif // PICOWOTA
40
 #endif // PICOWOTA
41
 
41
 
42
 static void add_to_log(const void *buff, size_t len) {
42
 static void add_to_log(const void *buff, size_t len) {
43
-    rb_add(&log, buff, len);
43
+    rb_add(&log_rb, buff, len);
44
 }
44
 }
45
 
45
 
46
 struct ring_buffer *log_get(void) {
46
 struct ring_buffer *log_get(void) {
47
-    return &log;
47
+    return &log_rb;
48
 }
48
 }
49
 
49
 
50
 #ifndef PICOWOTA
50
 #ifndef PICOWOTA
51
 static void log_dump_to_x(void (*write)(const void *, size_t)) {
51
 static void log_dump_to_x(void (*write)(const void *, size_t)) {
52
-    if (rb_len(&log) == 0) {
52
+    if (rb_len(&log_rb) == 0) {
53
         return;
53
         return;
54
     }
54
     }
55
 
55
 
58
         write(line_buff, l);
58
         write(line_buff, l);
59
     }
59
     }
60
 
60
 
61
-    rb_dump(&log, write, 0);
61
+    rb_dump(&log_rb, write, 0);
62
 
62
 
63
     l = snprintf((char *)line_buff, sizeof(line_buff), "\r\n\r\nlive log:\r\n");
63
     l = snprintf((char *)line_buff, sizeof(line_buff), "\r\n\r\nlive log:\r\n");
64
     if ((l > 0) && (l <= (int)sizeof(line_buff))) {
64
     if ((l > 0) && (l <= (int)sizeof(line_buff))) {
91
         return;
91
         return;
92
     }
92
     }
93
 
93
 
94
-    rb_dump(&log, log_file_write_callback, 0);
94
+    rb_dump(&log_rb, log_file_write_callback, 0);
95
 
95
 
96
     res = f_close(&log_file_fat);
96
     res = f_close(&log_file_fat);
97
     if (res != FR_OK) {
97
     if (res != FR_OK) {
101
 
101
 
102
 #endif // PICOWOTA
102
 #endif // PICOWOTA
103
 
103
 
104
-void debug_log_va(bool log, const char *format, va_list args) {
104
+void debug_log_va(bool do_log, const char *format, va_list args) {
105
     int l = vsnprintf((char *)line_buff, sizeof(line_buff), format, args);
105
     int l = vsnprintf((char *)line_buff, sizeof(line_buff), format, args);
106
 
106
 
107
     if (l < 0) {
107
     if (l < 0) {
120
 #endif // NDEBUG
120
 #endif // NDEBUG
121
 #endif // PICOWOTA
121
 #endif // PICOWOTA
122
 
122
 
123
-        if (log) {
123
+        if (do_log) {
124
             add_to_log(line_buff, l);
124
             add_to_log(line_buff, l);
125
         }
125
         }
126
     }
126
     }
127
 }
127
 }
128
 
128
 
129
-void debug_log(bool log, const char* format, ...) {
129
+void debug_log(bool do_log, const char* format, ...) {
130
     va_list args;
130
     va_list args;
131
     va_start(args, format);
131
     va_start(args, format);
132
-    debug_log_va(log, format, args);
132
+    debug_log_va(do_log, format, args);
133
     va_end(args);
133
     va_end(args);
134
 }
134
 }
135
 
135
 

+ 20
- 20
src/workflow.c Zobrazit soubor

104
     return mem_data()->wf[index].count;
104
     return mem_data()->wf[index].count;
105
 }
105
 }
106
 
106
 
107
-void wf_move_step_down(uint16_t index, uint16_t step) {
107
+void wf_move_step_down(uint16_t index, uint16_t step_i) {
108
     if (index >= mem_data()->wf_count) {
108
     if (index >= mem_data()->wf_count) {
109
         debug("invalid index %d", index);
109
         debug("invalid index %d", index);
110
         return;
110
         return;
111
     }
111
     }
112
-    if ((step < 1) || (step >= mem_data()->wf[index].count)) {
113
-        debug("invalid step %d", step);
112
+    if ((step_i < 1) || (step_i >= mem_data()->wf[index].count)) {
113
+        debug("invalid step %d", step_i);
114
         return;
114
         return;
115
     }
115
     }
116
 
116
 
117
-    struct wf_step tmp = mem_data()->wf[index].steps[step - 1];
118
-    mem_data()->wf[index].steps[step - 1] = mem_data()->wf[index].steps[step];
119
-    mem_data()->wf[index].steps[step] = tmp;
117
+    struct wf_step tmp = mem_data()->wf[index].steps[step_i - 1];
118
+    mem_data()->wf[index].steps[step_i - 1] = mem_data()->wf[index].steps[step_i];
119
+    mem_data()->wf[index].steps[step_i] = tmp;
120
 }
120
 }
121
 
121
 
122
-void wf_move_step_up(uint16_t index, uint16_t step) {
122
+void wf_move_step_up(uint16_t index, uint16_t step_i) {
123
     if (index >= mem_data()->wf_count) {
123
     if (index >= mem_data()->wf_count) {
124
         debug("invalid index %d", index);
124
         debug("invalid index %d", index);
125
         return;
125
         return;
126
     }
126
     }
127
-    if (step >= (mem_data()->wf[index].count - 1)) {
128
-        debug("invalid step %d", step);
127
+    if (step_i >= (mem_data()->wf[index].count - 1)) {
128
+        debug("invalid step %d", step_i);
129
         return;
129
         return;
130
     }
130
     }
131
 
131
 
132
-    struct wf_step tmp = mem_data()->wf[index].steps[step + 1];
133
-    mem_data()->wf[index].steps[step + 1] = mem_data()->wf[index].steps[step];
134
-    mem_data()->wf[index].steps[step] = tmp;
132
+    struct wf_step tmp = mem_data()->wf[index].steps[step_i + 1];
133
+    mem_data()->wf[index].steps[step_i + 1] = mem_data()->wf[index].steps[step_i];
134
+    mem_data()->wf[index].steps[step_i] = tmp;
135
 }
135
 }
136
 
136
 
137
-struct wf_step *wf_get_step(uint16_t index, uint16_t step) {
137
+struct wf_step *wf_get_step(uint16_t index, uint16_t step_i) {
138
     if (index >= mem_data()->wf_count) {
138
     if (index >= mem_data()->wf_count) {
139
         debug("invalid index %d", index);
139
         debug("invalid index %d", index);
140
         return NULL;
140
         return NULL;
141
     }
141
     }
142
-    return &mem_data()->wf[index].steps[step];
142
+    return &mem_data()->wf[index].steps[step_i];
143
 }
143
 }
144
 
144
 
145
-const char *wf_step_str(struct wf_step *step) {
145
+const char *wf_step_str(struct wf_step *step_p) {
146
     static char buff[20];
146
     static char buff[20];
147
 
147
 
148
-    switch (step->op) {
148
+    switch (step_p->op) {
149
     case OP_SET_TEMPERATURE:
149
     case OP_SET_TEMPERATURE:
150
         snprintf(buff, sizeof(buff),
150
         snprintf(buff, sizeof(buff),
151
-                 "set temp %.1f C", step->val / 10.0f);
151
+                 "set temp %.1f C", step_p->val / 10.0f);
152
         break;
152
         break;
153
 
153
 
154
     case OP_WAIT_TEMPERATURE:
154
     case OP_WAIT_TEMPERATURE:
155
         snprintf(buff, sizeof(buff),
155
         snprintf(buff, sizeof(buff),
156
-                 "wait temp %.1f C", step->val / 10.0f);
156
+                 "wait temp %.1f C", step_p->val / 10.0f);
157
         break;
157
         break;
158
 
158
 
159
     case OP_WAIT_TIME:
159
     case OP_WAIT_TIME:
160
     case OP_PUMP_TIME:
160
     case OP_PUMP_TIME:
161
         snprintf(buff, sizeof(buff),
161
         snprintf(buff, sizeof(buff),
162
                  "%s time %.1f s",
162
                  "%s time %.1f s",
163
-                 (step->op == OP_WAIT_TIME) ? "wait" : "pump",
164
-                 step->val / 1000.0f);
163
+                 (step_p->op == OP_WAIT_TIME) ? "wait" : "pump",
164
+                 step_p->val / 1000.0f);
165
         break;
165
         break;
166
     }
166
     }
167
 
167
 

Loading…
Zrušit
Uložit