-
Notifications
You must be signed in to change notification settings - Fork 1
/
diff.diff
299 lines (296 loc) · 7.17 KB
/
diff.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
diff --git a/main/lib/Menu/Menu.cpp b/main/lib/Menu/Menu.cpp
new file mode 100644
index 0000000..f61f6a9
--- /dev/null
+++ b/main/lib/Menu/Menu.cpp
@@ -0,0 +1,5 @@
+#include "Menu.h"
+
+Menu::Menu() {
+
+}
diff --git a/main/lib/Menu/Menu.h b/main/lib/Menu/Menu.h
new file mode 100644
index 0000000..3703b05
--- /dev/null
+++ b/main/lib/Menu/Menu.h
@@ -0,0 +1,17 @@
+#pragma once
+#include "MenuItem.h"
+#include <Arduino.h>
+
+/**
+ * The base menu class. Call Menu.run() to start the menu.
+ * The menu will contain a base MenuItem implementation
+ *
+ *
+ *
+ */
+
+class Menu {
+private:
+public:
+ Menu();
+};
diff --git a/main/lib/Menu/MenuItem.cpp b/main/lib/Menu/MenuItem.cpp
new file mode 100644
index 0000000..ef1ce4a
--- /dev/null
+++ b/main/lib/Menu/MenuItem.cpp
@@ -0,0 +1,18 @@
+#include "MenuItem.h"
+
+int16_t MenuItem::getVal()
+{
+ return val;
+}
+void MenuItem::setVal(int16_t _val)
+{
+ val = _val;
+}
+constexpr int16_t MenuItem::getMin()
+{
+ return myMin;
+}
+constexpr int16_t MenuItem::getMax()
+{
+ return myMax;
+}
diff --git a/main/lib/Menu/MenuItem.h b/main/lib/Menu/MenuItem.h
new file mode 100644
index 0000000..1799ec7
--- /dev/null
+++ b/main/lib/Menu/MenuItem.h
@@ -0,0 +1,28 @@
+#pragma once
+#include <Arduino.h>
+
+class MenuItem {
+private:
+ const char* name;
+ const int16_t myMin, myMax;
+ // TODO track menu items
+
+public:
+ //MenuItem();
+ int16_t val;
+
+ constexpr MenuItem(const char* _name, int16_t _myMin, int16_t _myMax)
+ : name(_name), myMin(_myMin), myMax(_myMax), val(0)
+ {}
+ constexpr MenuItem(const char* _name, int16_t _myMin, int16_t _myMax, int16_t _defaultValue)
+ : name(_name), myMin(_myMin), myMax(_myMax), val(_defaultValue)
+ {}
+ constexpr char* getName()
+ {
+ return const_cast<char*>(name);
+ }
+ int16_t getVal();
+ void setVal(int16_t _val);
+ constexpr int16_t getMin();
+ constexpr int16_t getMax();
+};
diff --git a/main/lib/Menu/MenuScreen.cpp b/main/lib/Menu/MenuScreen.cpp
new file mode 100644
index 0000000..fcb42ab
--- /dev/null
+++ b/main/lib/Menu/MenuScreen.cpp
@@ -0,0 +1 @@
+#include "MenuScreen.h"
diff --git a/main/lib/Menu/MenuScreen.h b/main/lib/Menu/MenuScreen.h
new file mode 100644
index 0000000..28a90ad
--- /dev/null
+++ b/main/lib/Menu/MenuScreen.h
@@ -0,0 +1,7 @@
+#pragma once
+#include <Arduino.h>
+
+class MenuScreen {
+private:
+public:
+};
diff --git a/main/lib/constants/Constants.cpp b/main/lib/constants/Constants.cpp
new file mode 100644
index 0000000..cd23762
--- /dev/null
+++ b/main/lib/constants/Constants.cpp
@@ -0,0 +1,26 @@
+#include "Constants.h"
+
+uint8_t Constants::lowPwmPins[2] = {PA0, PA2};
+uint8_t Constants::highPwmPins[2] = {PA1, PA3};
+
+void Constants::load(int16_t addr)
+{
+ // TODO: What happens if overflowing EEPROM?
+ for(int i=0;i<static_cast<int>(size());++i)
+ {
+ *((char*)this+i) = EEPROM.read(addr+i);
+ }
+}
+
+void Constants::dump(int16_t addr)
+{
+ // TODO: What happens if overflowing EEPROM?
+ for(int i=0;i<static_cast<int>(size());++i)
+ {
+ EEPROM.write(addr+i, *((char*)this+i));
+ }
+}
+
+constexpr size_t Constants::size() {
+ return sizeof(Constants);
+}
diff --git a/main/lib/constants/constants.h b/main/lib/constants/constants.h
new file mode 100644
index 0000000..d6cf93f
--- /dev/null
+++ b/main/lib/constants/constants.h
@@ -0,0 +1,26 @@
+#pragma once
+#include <Arduino.h>
+#include <EEPROM.h>
+#include <MenuItem.h>
+
+/**
+ * NOTE: you will likely
+ *
+ */
+
+class Constants {
+private:
+ int16_t vals[20];
+public:
+ static uint8_t lowPwmPins[2];
+ static uint8_t highPwmPins[2];
+ constexpr static MenuItem PROPORTIONAL = MenuItem("P", 0, 256, 40);
+ constexpr static MenuItem INTEGRAL = MenuItem("I", 0, 20, 0);
+ constexpr static MenuItem DERIVATIVE = MenuItem("D", 0, 40, 5);
+ constexpr static MenuItem BASE_SPEED = MenuItem("BS", 0, 256, 150);
+ constexpr static MenuItem LEFT_THRESHOLD = MenuItem("LT", 0, 4096, 1024);
+ constexpr static MenuItem RIGHT_THRESHOLD = MenuItem("RT", 0, 4096, 1024);
+ void load(int16_t addr);
+ void dump(int16_t addr);
+ constexpr static size_t size();
+};
diff --git a/main/lib/readme.txt b/main/lib/readme.txt
new file mode 100644
index 0000000..131f1bf
--- /dev/null
+++ b/main/lib/readme.txt
@@ -0,0 +1,41 @@
+
+This directory is intended for the project specific (private) libraries.
+PlatformIO will compile them to static libraries and link to executable file.
+
+The source code of each library should be placed in separate directory, like
+"lib/private_lib/[here are source files]".
+
+For example, see how can be organized `Foo` and `Bar` libraries:
+
+|--lib
+| |
+| |--Bar
+| | |--docs
+| | |--examples
+| | |--src
+| | |- Bar.c
+| | |- Bar.h
+| | |- library.json (optional, custom build options, etc) http://docs.platformio.org/page/librarymanager/config.html
+| |
+| |--Foo
+| | |- Foo.c
+| | |- Foo.h
+| |
+| |- readme.txt --> THIS FILE
+|
+|- platformio.ini
+|--src
+ |- main.c
+
+Then in `src/main.c` you should use:
+
+#include <Foo.h>
+#include <Bar.h>
+
+// rest H/C/CPP code
+
+PlatformIO will find your libraries automatically, configure preprocessor's
+include paths and build them.
+
+More information about PlatformIO Library Dependency Finder
+- http://docs.platformio.org/page/librarymanager/ldf.html
diff --git a/main/platformio.ini b/main/platformio.ini
new file mode 100644
index 0000000..851a7c3
--- /dev/null
+++ b/main/platformio.ini
@@ -0,0 +1,14 @@
+; PlatformIO Project Configuration File
+;
+; Build options: build flags, source filter
+; Upload options: custom upload port, speed and extra flags
+; Library options: dependencies, extra library storages
+; Advanced options: extra scripting
+;
+; Please visit documentation for the other options and examples
+; http://docs.platformio.org/page/projectconf.html
+
+[env:bluepill_f103c8]
+platform = ststm32
+board = bluepill_f103c8
+framework = arduino
diff --git a/main/src/main.cpp b/main/src/main.cpp
new file mode 100644
index 0000000..f24c162
--- /dev/null
+++ b/main/src/main.cpp
@@ -0,0 +1,10 @@
+#include <Arduino.h>
+#include <Constants.h>
+
+void setup() {
+ // put your setup code here, to run once:
+}
+
+void loop() {
+ // put your main code here, to run repeatedly:
+}
diff --git a/motors/src/main.cpp b/motors/src/main.cpp
index 7d07554..1bcc8b9 100644
--- a/motors/src/main.cpp
+++ b/motors/src/main.cpp
@@ -48,6 +48,7 @@ int last_g = 0;
float i = 0;
void setup() {
+<<<<<<< HEAD
motor.init();
// put your setup code here, to run once:
oled.begin();
@@ -67,6 +68,8 @@ void setup() {
THRESHOLD_LEFT = pidScreen.vals[4]<<4;
THRESHOLD_RIGHT= pidScreen.vals[5]<<4;
//base_speed = pidScreen.vals[0];
+=======
+>>>>>>> 63b8f3b... Menu system dev
}
void loop() {
@@ -84,6 +87,7 @@ void loop() {
delay(15); */
// put your main code here, to run repeatedly:
+<<<<<<< HEAD
/*
oled.clrScr();
oled.printNumI(pval, 0, 0);
@@ -162,4 +166,10 @@ void loop() {
previous_time = now;
loop_counter++;
delay(10);
+=======
+ for(int i=0;i<4;++i) {
+ motor.speed(0, min(255, max(-255, i*256-512)));
+ delay(500);
+ }
+>>>>>>> 63b8f3b... Menu system dev
}