Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cli freenove tank #46

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/esp32cam-p2p-sender/esp32cam-p2p-sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void setup() {
}

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

Expand Down
2 changes: 1 addition & 1 deletion examples/freenove-p2p-sender/freenove-p2p-sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void setup() {
}

// M5Core2 receiver
uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
const uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
radio.setTarget(macRecv);
radio.init();

Expand Down
52 changes: 26 additions & 26 deletions examples/freenove-tank/freenove-tank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,19 @@ void onDataReady(uint32_t lenght) {
decodeMsg(lenght);
}

void wcli_reboot(String opts){
void wcli_reboot(char *args, Stream *response){
ESP.restart();
}

void wcli_kset(String opts) {
maschinendeck::Pair<String, String> operands = maschinendeck::SerialTerminal::ParseCommand(opts);
void wcli_kset(char *args, Stream *response) {
Pair<String, String> operands = wcli.parseCommand(args);
String key = operands.first();
String v = operands.second();
cfg.saveAuto(key,v);
}

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

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

void wcli_exit(String opts) {
void wcli_exit(char *args, Stream *response) {
setup_time = 0;
setup_mode = false;
}

void wcli_debug(String opts) {
void wcli_debug(char *args, Stream *response) {
debug = !debug;
cfg.saveBool(PKEYS::KDEBUG, debug);
}

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

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

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

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

cfg.init("espnowcam");

wcli.disableConnectInBoot();
wcli.setSilentMode(true);
wcli.begin();

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

wcli.begin();

// Allow allocation of all timers
ESP32PWM::allocateTimer(0);
Expand Down
2 changes: 1 addition & 1 deletion examples/m5core2-basic-receiver/m5core2-basic-receiver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void setup() {
}

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

radio.setRecvBuffer(fb);
radio.setRecvCallback(onDataReady);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void setup() {
}

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

radio.setRecvBuffer(fb);
radio.setRecvCallback(onDataReady);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static void print_FPS(int x, int y, const char *msg, uint32_t &frame, uint_fast6
if (millis() - time_stamp > 1000) {
time_stamp = millis();
char output[40];
sprintf(output, "%s %2d FPS JPG: %05d\r\n",msg, frame, len);
sprintf(output, "%s %2d FPS JPG: %05d\r\n", msg, frame, len);
// M5.Display.drawString(output, x, y);
frame = 0;
Serial.print(output);
Expand Down Expand Up @@ -53,7 +53,7 @@ void setup() {
}

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

radio.setRecvBuffer(fb);
radio.setRecvCallback(onDataReady);
Expand Down
8 changes: 4 additions & 4 deletions examples/multi-camera-one-receiver/m5core2-multi-receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ void setup() {
}

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

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

radio.setRecvFilter(fb_camera1, camera1, onCamera1DataReady);
radio.setRecvFilter(fb_camera2, camera2, onCamera2DataReady);
Expand Down
4 changes: 2 additions & 2 deletions examples/multi-camera-one-receiver/m5cores3-camera1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ESPNowCam radio;
int32_t dw, dh;

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

radio.setTarget(macRecv);
radio.init();
Expand Down
12 changes: 6 additions & 6 deletions examples/multi-camera-one-receiver/makerfabs-multi-receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ void setup() {
}

// BE CAREFUL WITH IT, IF JPG LEVEL CHANGES, INCREASE IT
fb_camera1 = (uint8_t *)ps_malloc(20000 * sizeof(uint8_t));
fb_camera2 = (uint8_t *)ps_malloc(10000 * sizeof(uint8_t));
fb_camera3 = (uint8_t *)ps_malloc(10000 * sizeof(uint8_t));
fb_camera1 = static_cast<uint8_t*>(ps_malloc(20000 * sizeof(uint8_t)));
fb_camera2 = static_cast<uint8_t*>(ps_malloc(10000 * sizeof(uint8_t)));
fb_camera3 = static_cast<uint8_t*>(ps_malloc(10000 * sizeof(uint8_t)));

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

radio.setRecvFilter(fb_camera1, camera1, onCamera1DataReady);
radio.setRecvFilter(fb_camera2, camera2, onCamera2DataReady);
Expand Down
4 changes: 2 additions & 2 deletions src/ESPNowCam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ size_t encodeMsg(Frame msg);
bool encode_uint8_array(pb_ostream_t *stream, const pb_field_t *field, void *const *arg) {
if (!pb_encode_tag_for_field(stream, field))
return false;
return pb_encode_string(stream, (uint8_t *)(outdata + chunk_pos), chunk_size_left);
return pb_encode_string(stream, static_cast<uint8_t*>(outdata + chunk_pos), chunk_size_left);
}

void msgSentCb(const uint8_t *macAddr, esp_now_send_status_t status) {
Expand Down Expand Up @@ -97,7 +97,7 @@ bool sendMessage(uint32_t msglen, const uint8_t *mac) {
return false;
}

bool ESPNowCam::setTarget(uint8_t *macAddress) {
bool ESPNowCam::setTarget(const uint8_t *macAddress) {
memcpy(targetAddress, macAddress, 6);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ESPNowCam.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ESPNowCam {
void setRecvBuffer(uint8_t *fb);
void setRecvFilter(uint8_t *fb, const uint8_t *macAddr, RecvCb cb);
bool sendData(uint8_t* data, uint32_t lenght);
bool setTarget(uint8_t* macAddress);
bool setTarget(const uint8_t* macAddress);
bool init(uint8_t chunksize = 244);
};

Expand Down
4 changes: 2 additions & 2 deletions src/Utils.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


static void printDataChksum(uint8_t * jpg_data, uint32_t jpg_len){
static inline void printDataChksum(uint8_t * jpg_data, uint32_t jpg_len){
uint32_t checksum = 0;
Serial.println("JPG Frame:");
for (int i = 0; i < jpg_len; i++) {
Expand All @@ -12,7 +12,7 @@ static void printDataChksum(uint8_t * jpg_data, uint32_t jpg_len){

static uint16_t frame = 0;

static void printFPS(const char *msg) {
static inline void printFPS(const char *msg) {
static uint_least64_t timeStamp = 0;
frame++;
if (millis() - timeStamp > 1000) {
Expand Down
2 changes: 2 additions & 0 deletions src/drivers/CamAIThinker.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class CamAIThinker : public CameraBase {
config.fb_count = 2;
config.fb_location = CAMERA_FB_IN_PSRAM;
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
fb = nullptr;
sensor = nullptr;
}
};

Expand Down
2 changes: 2 additions & 0 deletions src/drivers/CamFreenove.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class CamFreenove : public CameraBase {
config.fb_count = 2;
config.fb_location = CAMERA_FB_IN_PSRAM;
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
fb = nullptr;
sensor = nullptr;
}
};

Expand Down
2 changes: 2 additions & 0 deletions src/drivers/CamFreenoveWR.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class CamFreenoveWR : public CameraBase {
config.fb_count = 2;
config.fb_location = CAMERA_FB_IN_PSRAM;
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
fb = nullptr;
sensor = nullptr;
}
};

Expand Down
2 changes: 2 additions & 0 deletions src/drivers/CamTJournal.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class CamTJournal : public CameraBase {
config.fb_count = 1;
config.fb_location = CAMERA_FB_IN_DRAM;
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
fb = nullptr;
sensor = nullptr;
}
};

Expand Down
2 changes: 2 additions & 0 deletions src/drivers/CamXiao.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class CamXiao : public CameraBase {
config.fb_count = 2;
config.fb_location = CAMERA_FB_IN_PSRAM;
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
fb = nullptr;
sensor = nullptr;
}
};

Expand Down
2 changes: 2 additions & 0 deletions src/drivers/UnitCamS3.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class UnitCamS3 : public CameraBase {
config.fb_count = 2;
config.fb_location = CAMERA_FB_IN_PSRAM;
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
fb = nullptr;
sensor = nullptr;
}
};

Expand Down
Loading