File tree 1 file changed +60
-0
lines changed
1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < Arduino.h>
2
+
3
+ #define INPUT_SIZE 32
4
+
5
+ char input[INPUT_SIZE + 1 ];
6
+
7
+ void modifyConfig (int asset, int value)
8
+ {
9
+ switch (asset)
10
+ {
11
+ case 1 :
12
+ // first setting
13
+ // config.blaa = value;
14
+ break ;
15
+ case 2 :
16
+ // second setting
17
+ // config.foo = value;
18
+ break ;
19
+ default :
20
+ break ;
21
+ }
22
+ }
23
+
24
+ void serialConfig ()
25
+ {
26
+ int key = 0 ;
27
+
28
+ // Start receiving command from Serial
29
+ while (Serial.available ())
30
+ {
31
+ delay (3 );
32
+
33
+ if (key < INPUT_SIZE && Serial.available ())
34
+ {
35
+ input[key] = Serial.read ();
36
+ key += 1 ;
37
+ }
38
+ }
39
+
40
+ if (key > 0 )
41
+ {
42
+ input[key] = 0 ;
43
+
44
+ char *command = strtok (input, " ;" );
45
+ while (command != 0 )
46
+ {
47
+ char *separator = strchr (command, ' :' );
48
+ if (separator != 0 )
49
+ {
50
+ *separator = 0 ;
51
+ int asset = atoi (command);
52
+ ++separator;
53
+ int value = atoi (separator);
54
+ modifyConfig (asset, value);
55
+ }
56
+
57
+ command = strtok (0 , " ;" );
58
+ }
59
+ }
60
+ }
You can’t perform that action at this time.
0 commit comments