Skip to content

Commit 99e89db

Browse files
authored
Merge pull request #46 from hpsaturn/fix_cli_freenove_tank
Fix cli freenove tank
2 parents b3018bc + 1cb8f5d commit 99e89db

File tree

18 files changed

+61
-49
lines changed

18 files changed

+61
-49
lines changed

examples/esp32cam-p2p-sender/esp32cam-p2p-sender.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void setup() {
4141
}
4242

4343
// M5Core2 receiver target (P2P or 1:1 mode)
44-
uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
44+
const uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
4545
radio.setTarget(macRecv);
4646
radio.init();
4747

examples/freenove-p2p-sender/freenove-p2p-sender.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void setup() {
4040
}
4141

4242
// M5Core2 receiver
43-
uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
43+
const uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
4444
radio.setTarget(macRecv);
4545
radio.init();
4646

examples/freenove-tank/freenove-tank.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,19 @@ void onDataReady(uint32_t lenght) {
139139
decodeMsg(lenght);
140140
}
141141

142-
void wcli_reboot(String opts){
142+
void wcli_reboot(char *args, Stream *response){
143143
ESP.restart();
144144
}
145145

146-
void wcli_kset(String opts) {
147-
maschinendeck::Pair<String, String> operands = maschinendeck::SerialTerminal::ParseCommand(opts);
146+
void wcli_kset(char *args, Stream *response) {
147+
Pair<String, String> operands = wcli.parseCommand(args);
148148
String key = operands.first();
149149
String v = operands.second();
150150
cfg.saveAuto(key,v);
151151
}
152152

153-
void wcli_klist(String opts) {
154-
maschinendeck::Pair<String, String> operands = maschinendeck::SerialTerminal::ParseCommand(opts);
153+
void wcli_klist(char *args, Stream *response) {
154+
Pair<String, String> operands = wcli.parseCommand(args);
155155
String opt = operands.first();
156156
Serial.printf("\n%11s \t%s \t%s \r\n", "KEYNAME", "DEFINED", "VALUE");
157157
Serial.printf("\n%11s \t%s \t%s \r\n", "=======", "=======", "=====");
@@ -166,34 +166,34 @@ void wcli_klist(String opts) {
166166
}
167167
}
168168

169-
void wcli_setup(String opts) {
169+
void wcli_setup(char *args, Stream *response) {
170170
setup_mode = true;
171171
Serial.println("\r\nSetup Mode Enable (fail-safe mode)\r\n");
172172
}
173173

174-
void wcli_exit(String opts) {
174+
void wcli_exit(char *args, Stream *response) {
175175
setup_time = 0;
176176
setup_mode = false;
177177
}
178178

179-
void wcli_debug(String opts) {
179+
void wcli_debug(char *args, Stream *response) {
180180
debug = !debug;
181181
cfg.saveBool(PKEYS::KDEBUG, debug);
182182
}
183183

184-
void wcli_servoL(String opts) {
185-
maschinendeck::Pair<String, String> operands = maschinendeck::SerialTerminal::ParseCommand(opts);
184+
void wcli_servoL(char *args, Stream *response) {
185+
Pair<String, String> operands = wcli.parseCommand(args);
186186
attachServoLeft();
187187
servoLeft.write(operands.first().toInt());
188188
}
189189

190-
void wcli_servoR(String opts) {
191-
maschinendeck::Pair<String, String> operands = maschinendeck::SerialTerminal::ParseCommand(opts);
190+
void wcli_servoR(char *args, Stream *response) {
191+
Pair<String, String> operands = wcli.parseCommand(args);
192192
attachServoRight();
193193
servoRight.write(operands.first().toInt());
194194
}
195195

196-
void wcli_pauseCam(String opts){
196+
void wcli_pauseCam(char *args, Stream *response){
197197
cam_stopped = !cam_stopped;
198198
Serial.printf("camera streaming %s\r\n", cam_stopped ? "stopped" : "resumed");
199199
}
@@ -218,7 +218,7 @@ void loadVariables() {
218218
degreesMaxR = degreesCenterR + spanRight + offsetRight;
219219
}
220220

221-
void wcli_print(String opts) {
221+
void wcli_print(char *args, Stream *response) {
222222
loadVariables();
223223
Serial.printf("LEFT => span: %i offset: %i center: %i\r\n", spanLeft, offsetLeft, degreesCenterL);
224224
Serial.printf("LEFT => degreesMinL: %i degreesMaxL: %i\r\n\n", degreesMinL, degreesMaxL);
@@ -237,20 +237,20 @@ void setup() {
237237

238238
cfg.init("espnowcam");
239239

240-
wcli.disableConnectInBoot();
241240
wcli.setSilentMode(true);
242-
wcli.begin();
243241

244-
wcli.term->add("reboot", &wcli_reboot, "\tperform a ESP32 reboot");
245-
wcli.term->add("setup", &wcli_setup,"\tTYPE THIS WORD to start to configure the device :D\n");
246-
wcli.term->add("exit", &wcli_exit, "\texit of the setup mode. AUTO EXIT in 10 seg! :)");
247-
wcli.term->add("klist", &wcli_klist, "\tlist valid preference keys");
248-
wcli.term->add("kset", &wcli_kset, "\tset preference key (e.g on/off or 1/0 or text)");
249-
wcli.term->add("print", &wcli_print, "\tprint current variables");
250-
wcli.term->add("servoL", &wcli_servoL, "\tset value on servo L");
251-
wcli.term->add("servoR", &wcli_servoR, "\tset value on servo R");
252-
wcli.term->add("pauseCam", &wcli_pauseCam, "\tstop/resume camera stream");
253-
wcli.term->add("debug", &wcli_debug, "\tdebugging flag toggle");
242+
wcli.add("reboot", &wcli_reboot, "\tperform a ESP32 reboot");
243+
wcli.add("setup", &wcli_setup,"\tTYPE THIS WORD to start to configure the device :D\n");
244+
wcli.add("exit", &wcli_exit, "\texit of the setup mode. AUTO EXIT in 10 seg! :)");
245+
wcli.add("klist", &wcli_klist, "\tlist valid preference keys");
246+
wcli.add("kset", &wcli_kset, "\tset preference key (e.g on/off or 1/0 or text)");
247+
wcli.add("print", &wcli_print, "\tprint current variables");
248+
wcli.add("servoL", &wcli_servoL, "\tset value on servo L");
249+
wcli.add("servoR", &wcli_servoR, "\tset value on servo R");
250+
wcli.add("pauseCam", &wcli_pauseCam, "\tstop/resume camera stream");
251+
wcli.add("debug", &wcli_debug, "\tdebugging flag toggle");
252+
253+
wcli.begin();
254254

255255
// Allow allocation of all timers
256256
ESP32PWM::allocateTimer(0);

examples/m5core2-basic-receiver/m5core2-basic-receiver.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void setup() {
3636
}
3737

3838
// BE CAREFUL WITH IT, IF JPG LEVEL CHANGES, INCREASE IT
39-
fb = (uint8_t*) ps_malloc(5000* sizeof( uint8_t ) ) ;
39+
fb = static_cast<uint8_t *>(ps_malloc(5000 * sizeof(uint8_t)));
4040

4141
radio.setRecvBuffer(fb);
4242
radio.setRecvCallback(onDataReady);

examples/m5core2-espnow-receiver/m5core2-espnow-receiver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void setup() {
3636
}
3737

3838
// BE CAREFUL WITH IT, IF JPG LEVEL CHANGES, INCREASE IT
39-
fb = (uint8_t *)ps_malloc(15000 * sizeof(uint8_t));
39+
fb = static_cast<uint8_t*>(ps_malloc(15000 * sizeof(uint8_t)));
4040

4141
radio.setRecvBuffer(fb);
4242
radio.setRecvCallback(onDataReady);

examples/m5cores3-espnow-receiver/m5cores3-espnow-receiver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static void print_FPS(int x, int y, const char *msg, uint32_t &frame, uint_fast6
2323
if (millis() - time_stamp > 1000) {
2424
time_stamp = millis();
2525
char output[40];
26-
sprintf(output, "%s %2d FPS JPG: %05d\r\n",msg, frame, len);
26+
sprintf(output, "%s %2d FPS JPG: %05d\r\n", msg, frame, len);
2727
// M5.Display.drawString(output, x, y);
2828
frame = 0;
2929
Serial.print(output);
@@ -53,7 +53,7 @@ void setup() {
5353
}
5454

5555
// BE CAREFUL WITH IT, IF JPG LEVEL CHANGES, INCREASE IT
56-
fb = (uint8_t *)ps_malloc(5000 * sizeof(uint8_t));
56+
fb = static_cast<uint8_t *>(ps_malloc(5000 * sizeof(uint8_t)));
5757

5858
radio.setRecvBuffer(fb);
5959
radio.setRecvCallback(onDataReady);

examples/multi-camera-one-receiver/m5core2-multi-receiver.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ void setup() {
4141
}
4242

4343
// BE CAREFUL WITH IT, IF JPG LEVEL CHANGES, INCREASE IT
44-
fb_camera1 = (uint8_t*) ps_malloc(5000* sizeof( uint8_t ) ) ;
45-
fb_camera2 = (uint8_t*) ps_malloc(5000* sizeof( uint8_t ) ) ;
44+
fb_camera1 = static_cast<uint8_t*>(ps_malloc(5000 * sizeof(uint8_t)));
45+
fb_camera2 = static_cast<uint8_t*>(ps_malloc(5000 * sizeof(uint8_t)));
4646

4747
// TJournal Camera 24:0a:c4:2f:8e:90
48-
uint8_t camera1[6] = {0x24, 0x0A, 0xC4, 0x2F, 0x8E, 0x90};
48+
const uint8_t camera1[6] = {0x24, 0x0A, 0xC4, 0x2F, 0x8E, 0x90};
4949
// XIAOSense Camera 74:4d:bd:81:4e:fc
50-
uint8_t camera2[6] = {0x74, 0x4D, 0xBD, 0x81, 0x4E, 0xFC};
50+
const uint8_t camera2[6] = {0x74, 0x4D, 0xBD, 0x81, 0x4E, 0xFC};
5151

5252
radio.setRecvFilter(fb_camera1, camera1, onCamera1DataReady);
5353
radio.setRecvFilter(fb_camera2, camera2, onCamera2DataReady);

examples/multi-camera-one-receiver/m5cores3-camera1.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
ESPNowCam radio;
1414
int32_t dw, dh;
1515

16-
static void drawFPS() {
16+
static inline void drawFPS() {
1717
static uint_least64_t timeStamp = 0;
1818
frame++;
1919
if (millis() - timeStamp > 1000) {
@@ -58,7 +58,7 @@ void setup() {
5858
// M5Core2 receiver MAC: B8:F0:09:C6:0E:CC
5959
// uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
6060
// Makerfabs receiver 7C:DF:A1:F3:73:3C
61-
uint8_t macRecv[6] = {0x7C,0xDF,0xA1,0xF3,0x73,0x3C};
61+
const uint8_t macRecv[6] = {0x7C,0xDF,0xA1,0xF3,0x73,0x3C};
6262

6363
radio.setTarget(macRecv);
6464
radio.init();

examples/multi-camera-one-receiver/makerfabs-multi-receiver.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ void setup() {
8585
}
8686

8787
// BE CAREFUL WITH IT, IF JPG LEVEL CHANGES, INCREASE IT
88-
fb_camera1 = (uint8_t *)ps_malloc(20000 * sizeof(uint8_t));
89-
fb_camera2 = (uint8_t *)ps_malloc(10000 * sizeof(uint8_t));
90-
fb_camera3 = (uint8_t *)ps_malloc(10000 * sizeof(uint8_t));
88+
fb_camera1 = static_cast<uint8_t*>(ps_malloc(20000 * sizeof(uint8_t)));
89+
fb_camera2 = static_cast<uint8_t*>(ps_malloc(10000 * sizeof(uint8_t)));
90+
fb_camera3 = static_cast<uint8_t*>(ps_malloc(10000 * sizeof(uint8_t)));
9191

9292
// M5CoreS3 Camera f4:12:fa:85:f4:9c
93-
uint8_t camera1[6] = {0xF4, 0x12, 0xFA, 0x85, 0xF4, 0x9C};
93+
const uint8_t camera1[6] = {0xF4, 0x12, 0xFA, 0x85, 0xF4, 0x9C};
9494
// TJournal Camera 24:0a:c4:2f:8e:90
95-
uint8_t camera2[6] = {0x24, 0x0A, 0xC4, 0x2F, 0x8E, 0x90};
95+
const uint8_t camera2[6] = {0x24, 0x0A, 0xC4, 0x2F, 0x8E, 0x90};
9696
// XIAOSense Camera 74:4d:bd:81:4e:fc
97-
uint8_t camera3[6] = {0x74, 0x4D, 0xBD, 0x81, 0x4E, 0xFC};
97+
const uint8_t camera3[6] = {0x74, 0x4D, 0xBD, 0x81, 0x4E, 0xFC};
9898

9999
radio.setRecvFilter(fb_camera1, camera1, onCamera1DataReady);
100100
radio.setRecvFilter(fb_camera2, camera2, onCamera2DataReady);

src/ESPNowCam.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ size_t encodeMsg(Frame msg);
2424
bool encode_uint8_array(pb_ostream_t *stream, const pb_field_t *field, void *const *arg) {
2525
if (!pb_encode_tag_for_field(stream, field))
2626
return false;
27-
return pb_encode_string(stream, (uint8_t *)(outdata + chunk_pos), chunk_size_left);
27+
return pb_encode_string(stream, static_cast<uint8_t*>(outdata + chunk_pos), chunk_size_left);
2828
}
2929

3030
void msgSentCb(const uint8_t *macAddr, esp_now_send_status_t status) {
@@ -97,7 +97,7 @@ bool sendMessage(uint32_t msglen, const uint8_t *mac) {
9797
return false;
9898
}
9999

100-
bool ESPNowCam::setTarget(uint8_t *macAddress) {
100+
bool ESPNowCam::setTarget(const uint8_t *macAddress) {
101101
memcpy(targetAddress, macAddress, 6);
102102
return false;
103103
}

0 commit comments

Comments
 (0)