Skip to content

Commit fa738c5

Browse files
committed
Add some more things
1 parent 4f11b1c commit fa738c5

File tree

7 files changed

+54
-24
lines changed

7 files changed

+54
-24
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "platformio_version_increment"]
2+
path = platformio_version_increment
3+
url = https://github.com/sblantipodi/platformio_version_increment.git

.version_no_increment

Whitespace-only changes.

include/Version.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
// AUTO GENERATED FILE, DO NOT EDIT
3+
#ifndef VERSION
4+
#define VERSION "0.1.1"
5+
#endif
6+
#ifndef BUILD_TIMESTAMP
7+
#define BUILD_TIMESTAMP "2020-12-18 20:12:23.062972"
8+
#endif
9+

platformio.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ platform = ststm32
1313
board = genericSTM32F103C8
1414
framework = arduino
1515
lib_deps = adafruit/Adafruit NeoPixel@^1.6.0
16+
extra_scripts =
17+
pre:platformio_version_increment/version_increment_pre.py
18+
post:platformio_version_increment/version_increment_post.py

platformio_version_increment

src/main.cpp

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Main STM32 Firmware
1818
#include <Arduino.h>
1919
#include <Servo.h>
2020
#include <Adafruit_NeoPixel.h>
21+
#include <Version.h>
2122

2223
//**********************
2324
//Motor Control //*
@@ -81,10 +82,12 @@ void recvArgs(int argsRequired) {
8182

8283
void loop() {
8384
serialCmd = recv();
85+
8486
if(serialCmd == "INIT\r") { // INIT - Initialize board
8587
Serial3.print("OK\r\n"); // send response
8688
digitalWrite(PC13, HIGH);
87-
} else if (serialCmd == "SETM\r") { // SETM - Set motor
89+
}
90+
else if (serialCmd == "SETM\r") { // SETM - Set motor
8891
Serial3.print("OK\r\n");
8992
recvArgs(3);
9093
Serial3.print("Motor ID: " + args[0] + "\r\n");
@@ -115,8 +118,23 @@ void loop() {
115118
digitalWrite(mcSPins[2], HIGH);
116119
}
117120
analogWrite(mcSPins[3], args[2].toInt()); // Set speed through PWM
118-
119-
} else if (serialCmd == "LEDS\r") { // LEDS - LED Set
121+
}
122+
else if (serialCmd == "STPM\r") { // Stop Motor
123+
Serial3.print("OK\r\n");
124+
recvArgs(1);
125+
if(args[0].toInt() == 1) {
126+
analogWrite(D1_ENA, 0);
127+
} else if (args[0].toInt() == 2) {
128+
analogWrite(D1_ENB, 0);
129+
} else if (args[0].toInt() == 3) {
130+
analogWrite(D2_ENA, 0);
131+
} else if (args[0].toInt() == 4) {
132+
analogWrite(D2_ENB, 0);
133+
} else {
134+
Serial3.print("ERROR\r\n");
135+
}
136+
}
137+
else if (serialCmd == "LEDS\r") { // LEDS - LED Set
120138
Serial3.print("OK\r\n");
121139
recvArgs(4);
122140
Serial3.print("Number is: " + args[0] + "\r\n");
@@ -125,7 +143,8 @@ void loop() {
125143
Serial3.print("B: " + args[3] + "\r\n");
126144
pixels.setPixelColor(args[0].toInt(), pixels.Color(args[1].toInt(), args[2].toInt(), args[3].toInt()));
127145
pixels.show();
128-
} else if (serialCmd == "LEDA\r") { // LEDA - Set all LEDs
146+
}
147+
else if (serialCmd == "LEDA\r") { // LEDA - Set all LEDs
129148
Serial3.print("OK\r\n");
130149
recvArgs(3);
131150
Serial3.print("R: " + args[0] + "\r\n");
@@ -135,7 +154,8 @@ void loop() {
135154
pixels.setPixelColor(i, pixels.Color(args[0].toInt(), args[1].toInt(), args[2].toInt())); // set pixel
136155
pixels.show();
137156
}
138-
} else if (serialCmd == "SEXT\r") { // Set External
157+
}
158+
else if (serialCmd == "SEXT\r") { // Set External
139159
for(int i = 0; i < 6; i++) {
140160
recvArgs(1); // Recieve data
141161
if (args[0] == "SRVO\r" && i == (EXT_1 || EXT_2)) { // If the pin is connected to a servo + that configuration is supported
@@ -153,7 +173,8 @@ void loop() {
153173
break; // Crash loop
154174
}
155175
}
156-
} else if (serialCmd == "SRVO\r") {
176+
}
177+
else if (serialCmd == "SRVO\r") { // Set Servo
157178
recvArgs(2); // Recieve data
158179
if (args[0].toInt() == 1 && servo1.attached() == false) {
159180
Serial3.print("ERROR\r\n");
@@ -166,25 +187,17 @@ void loop() {
166187
servo2.write(args[1].toInt());
167188
}
168189
}
169-
170-
} else if (serialCmd == "RSTS\r") { // Software Reset
190+
}
191+
else if (serialCmd == "RSTS\r") { // Software Reset
171192
Serial3.print("OK\r\n");
172193
NVIC_SystemReset();
173-
}/* else if (serialCmd == "TEST\r") {
174-
digitalWrite(M1_A, HIGH);
175-
digitalWrite(M1_B, LOW);
176-
digitalWrite(M2_A, HIGH);
177-
digitalWrite(M2_B, LOW);
178-
digitalWrite(M3_A, HIGH);
179-
digitalWrite(M3_B, LOW);
180-
digitalWrite(M4_A, HIGH);
181-
digitalWrite(M4_B, LOW);
182-
183-
analogWrite(D1_ENA, 255);
184-
analogWrite(D1_ENB, 255);
185-
analogWrite(D2_ENA, 255);
186-
analogWrite(D2_ENB, 255);
187-
} */else {
188-
Serial3.print("ERROR\r\n"); // ERROR - Error if command not recognized
194+
}
195+
else if (serialCmd == "VERS\r") { // Version
196+
Serial3.print("OK\r\n");
197+
Serial3.print("Version ID: " + String(VERSION) + "\r\n");
198+
Serial3.print("Built at: " + String(BUILD_TIMESTAMP) + "\r\n");
199+
}
200+
else { // ERROR - Error if command not recognized
201+
Serial3.print("ERROR\r\n");
189202
}
190203
}

version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.1

0 commit comments

Comments
 (0)