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

TimerCAM needs an end/stop method #21

Open
2 tasks done
raduprv opened this issue Apr 2, 2024 · 4 comments
Open
2 tasks done

TimerCAM needs an end/stop method #21

raduprv opened this issue Apr 2, 2024 · 4 comments

Comments

@raduprv
Copy link

raduprv commented Apr 2, 2024

Describe the bug

So my usecase is simple:
I need to check on the battery voltage. If it's ok, I do camera stuff, then I put it to sleep.
However, the camera doesn't seem to work after using TimerCAM.begin(). I am getting i2c errors, and others have gotten them too.

So there should be an end method, so that people can do stuff like read the voltage, end the TimerCAM stuff, use the camera, end the camera, use TimerCAM.begin again, and so on.

Right now, I can't check the voltage at the beginning if I want to sue the camera after that.

To reproduce

Tested on Arduino, but it should be the same all over.

Expected behavior

Be able to terminate TimerCAM

Screenshots

No response

Environment

  • OS:
  • IDE &IDE Version:
  • Repository Version:

Additional context

No response

Issue checklist

  • I searched for previous reports in the issue tracker
  • My report contains all necessary details
@Gitshaoxiang
Copy link
Contributor

thanks for you feedback , now it updated. could you pull the lib update, then test again?

#include "M5TimerCAM.h"
#include <WiFi.h>

void led_breathe(int ms) {
    for (int16_t i = 0; i < 255; i++) {
        TimerCAM.Power.setLed(i);
        vTaskDelay(pdMS_TO_TICKS(ms));
    }

    for (int16_t i = 255; i >= 0; i--) {
        TimerCAM.Power.setLed(i);
        vTaskDelay(pdMS_TO_TICKS(ms));
    }
}

void setup() {
    TimerCAM.begin(true);

    if (!TimerCAM.Camera.begin()) {
        Serial.println("Camera Init Fail");
        return;
    }
    Serial.println("Camera Init Success");

    TimerCAM.Camera.sensor->set_pixformat(TimerCAM.Camera.sensor,
                                          PIXFORMAT_JPEG);
    TimerCAM.Camera.sensor->set_framesize(TimerCAM.Camera.sensor,
                                          FRAMESIZE_SVGA);
    TimerCAM.Camera.sensor->set_vflip(TimerCAM.Camera.sensor, 1);
    TimerCAM.Camera.sensor->set_hmirror(TimerCAM.Camera.sensor, 0);

    Serial.printf("Bat Voltage: %dmv\r\n", TimerCAM.Power.getBatteryVoltage());
    Serial.printf("Bat Level: %d%%\r\n", TimerCAM.Power.getBatteryLevel());

    if (TimerCAM.Camera.deinit()) {
        Serial.println("Camera Deinit.");
    }

    if (!TimerCAM.Camera.begin()) {
        Serial.println("Camera Init Fail");
        return;
    }
    Serial.println("Camera Init Success");

    Serial.printf("Bat Voltage: %dmv\r\n", TimerCAM.Power.getBatteryVoltage());
    Serial.printf("Bat Level: %d%%\r\n", TimerCAM.Power.getBatteryLevel());
    led_breathe(10);
    TimerCAM.Power.timerSleep(5);
}

void loop() {
}

@raduprv
Copy link
Author

raduprv commented Apr 7, 2024

Thank you for replying. I am not using the camera class provided by TimerCAM, I am using the 'standard' way, like the ESP32-Cam camera code, so that it can be compatible with all the boards, and keep the board specific stuff (like sleeping) to a minimum.

My code fails when calling esp_camera_init() if I do a TimerCAM.begin(true); (i2c conflicts I guess). I was looking for a way to stop/deinit the entire TimerCAM thing, not just TimerCAM.Camera.

@Gitshaoxiang
Copy link
Contributor

yes, actually the TimerCAM class is using the standard API. also in this commit, we update the I2C port. I think you could modify the same thing then try again.

@raduprv
Copy link
Author

raduprv commented Apr 9, 2024

Can you make a new release too, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants