Bläddra i källkod

tweak volcano conf and steps bar

Thomas Buck 11 månader sedan
förälder
incheckning
09e4ac3655
5 ändrade filer med 63 tillägg och 33 borttagningar
  1. 1
    1
      include/volcano.h
  2. 4
    2
      src/state_volcano_conf.c
  3. 1
    1
      src/state_volcano_run.c
  4. 56
    28
      src/volcano.c
  5. 1
    1
      src/workflow.c

+ 1
- 1
include/volcano.h Visa fil

@@ -32,7 +32,7 @@ enum volcano_state {
32 32
 };
33 33
 
34 34
 // returns < 0 on error
35
-int8_t volcano_discover_characteristics(void);
35
+int8_t volcano_discover_characteristics(bool wf, bool conf);
36 36
 
37 37
 // in 1/10th degrees C, or < 0 on error
38 38
 int16_t volcano_get_current_temp(void);

+ 4
- 2
src/state_volcano_conf.c Visa fil

@@ -80,13 +80,15 @@ static void enter_cb(int selection) {
80 80
 
81 81
 static void send_values(void) {
82 82
     volcano_set_unit(val_celsius ? UNIT_C : UNIT_F);
83
-    sleep_ms(100);
83
+    sleep_ms(150);
84 84
     volcano_set_vibration(val_vibrate);
85
-    sleep_ms(100);
85
+    sleep_ms(150);
86 86
     volcano_set_display_cooling(val_disp_cool);
87 87
 }
88 88
 
89 89
 static void fetch_values(void) {
90
+    volcano_discover_characteristics(false, true);
91
+
90 92
     enum unit unit = volcano_get_unit();
91 93
     val_celsius = (unit == UNIT_C);
92 94
 

+ 1
- 1
src/state_volcano_run.c Visa fil

@@ -121,7 +121,7 @@ static void draw(struct menu_state *menu) {
121 121
         return;
122 122
     }
123 123
 
124
-    bar_graph(50, menu->y_off, 0, state.index, state.count);
124
+    bar_graph(50, menu->y_off, 0, state.index + 1, state.count);
125 125
     bar_graph(50 + MENU_BOX_HEIGHT(3, 20, 2) + menu->y_off, menu->y_off,
126 126
               state.start_val, state.curr_val, state.step->val);
127 127
 

+ 56
- 28
src/volcano.c Visa fil

@@ -54,41 +54,69 @@ static uint8_t uuid_base2[16] = {
54 54
     0x5a, 0x26, 0x42, 0x49, 0x43, 0x4b, 0x45, 0x4c,
55 55
 };
56 56
 
57
-int8_t volcano_discover_characteristics(void) {
58
-    uuid_base[1] = UUID_SRVC_2;
59
-    uuid_base2[1] = UUID_SRVC_2;
57
+int8_t volcano_discover_characteristics(bool wf, bool conf) {
58
+    if (wf) {
59
+        uuid_base[1] = UUID_SRVC_2;
60
+        uuid_base2[1] = UUID_SRVC_2;
60 61
 
61
-    uuid_base[3] = UUID_WRITE_SRVC;
62
-    int8_t r;
62
+        uuid_base[3] = UUID_WRITE_SRVC;
63
+        int8_t r;
63 64
 
64
-    uuid_base2[3] = UUID_TARGET_TEMP;
65
-    r = ble_discover(uuid_base, uuid_base2);
66
-    if (r < 0) {
67
-        return r;
68
-    }
65
+        uuid_base2[3] = UUID_TARGET_TEMP;
66
+        r = ble_discover(uuid_base, uuid_base2);
67
+        if (r < 0) {
68
+            return r;
69
+        }
69 70
 
70
-    uuid_base2[3] = UUID_HEATER_ON;
71
-    r = ble_discover(uuid_base, uuid_base2);
72
-    if (r < 0) {
73
-        return r;
74
-    }
71
+        uuid_base2[3] = UUID_HEATER_ON;
72
+        r = ble_discover(uuid_base, uuid_base2);
73
+        if (r < 0) {
74
+            return r;
75
+        }
75 76
 
76
-    uuid_base2[3] = UUID_HEATER_OFF;
77
-    r = ble_discover(uuid_base, uuid_base2);
78
-    if (r < 0) {
79
-        return r;
80
-    }
77
+        uuid_base2[3] = UUID_HEATER_OFF;
78
+        r = ble_discover(uuid_base, uuid_base2);
79
+        if (r < 0) {
80
+            return r;
81
+        }
81 82
 
82
-    uuid_base2[3] = UUID_PUMP_ON;
83
-    r = ble_discover(uuid_base, uuid_base2);
84
-    if (r < 0) {
85
-        return r;
83
+        uuid_base2[3] = UUID_PUMP_ON;
84
+        r = ble_discover(uuid_base, uuid_base2);
85
+        if (r < 0) {
86
+            return r;
87
+        }
88
+
89
+        uuid_base2[3] = UUID_PUMP_OFF;
90
+        r = ble_discover(uuid_base, uuid_base2);
91
+        if (r < 0) {
92
+            return r;
93
+        }
86 94
     }
87 95
 
88
-    uuid_base2[3] = UUID_PUMP_OFF;
89
-    r = ble_discover(uuid_base, uuid_base2);
90
-    if (r < 0) {
91
-        return r;
96
+    if (conf) {
97
+        uuid_base[1] = UUID_SRVC_1;
98
+        uuid_base2[1] = UUID_SRVC_1;
99
+
100
+        uuid_base[3] = UUID_WRITE_SRVC;
101
+        int8_t r;
102
+
103
+        uuid_base2[3] = UUID_PRJSTAT1;
104
+        r = ble_discover(uuid_base, uuid_base2);
105
+        if (r < 0) {
106
+            return r;
107
+        }
108
+
109
+        uuid_base2[3] = UUID_PRJSTAT2;
110
+        r = ble_discover(uuid_base, uuid_base2);
111
+        if (r < 0) {
112
+            return r;
113
+        }
114
+
115
+        uuid_base2[3] = UUID_PRJSTAT3;
116
+        r = ble_discover(uuid_base, uuid_base2);
117
+        if (r < 0) {
118
+            return r;
119
+        }
92 120
     }
93 121
 
94 122
     return 0;

+ 1
- 1
src/workflow.c Visa fil

@@ -217,7 +217,7 @@ void wf_start(uint16_t index) {
217 217
      */
218 218
     DO_WHILE(volcano_set_heater_state(true),
219 219
              !(volcano_get_state() & VOLCANO_STATE_HEATER));
220
-    volcano_discover_characteristics();
220
+    volcano_discover_characteristics(true, false);
221 221
 
222 222
     do_step();
223 223
 }

Laddar…
Avbryt
Spara