优化电源控制

MQTTtest
Matthew 9 months ago
parent 1a0b940e65
commit 1ac95cada3

@ -36,6 +36,7 @@ add_definitions(-DUSING_NRSEC_VPN)
# OUTPUT_CAMERA_DBG_INFO: CARERA
# add_definitions(-DOUTPUT_CAMERA_DBG_INFO)
add_definitions(-DALIGN_HB_TIMER_TO_PHOTO)
add_definitions(-DENABLE_3V3_ALWAYS)
# add_definitions(-DUSING_N938)

@ -158,7 +158,7 @@ bool GpioControl::SetN938Cmd(int cmd, int val)
bool GpioControl::OpenSensors()
{
GpioControl::setInt(CMD_SET_CAM_3V3_EN_STATE, true ? 1 : 0);
GpioControl::setCam3V3Enable(true);
GpioControl::setInt(CMD_SET_485_EN_STATE, true ? 1 : 0);
int igpio;
GpioControl::setInt(CMD_SET_WTH_POWER, 1);

@ -6,6 +6,8 @@
#define MICROPHOTO_GPIOCONTROL_H
#include <string>
#include <chrono>
#include <thread>
#define CMD_GET_LIGHT_ADC 101
#define CMD_SET_LIGHT_ADC 102
@ -141,7 +143,11 @@ public:
static void setCam3V3Enable(bool enabled)
{
#ifdef ENABLE_3V3_ALWAYS
setInt(CMD_SET_CAM_3V3_EN_STATE, 1);
#else
setInt(CMD_SET_CAM_3V3_EN_STATE, enabled ? 1 : 0);
#endif
}
static void reboot()
@ -231,6 +237,10 @@ public:
static void setSpiPower(bool on) {
setInt(CMD_SET_SPI_POWER, on ? 1 : 0);
if (on)
{
std::this_thread::sleep_for(std::chrono::milliseconds(40));
}
}
static void setRS485Enable(bool z) {

@ -818,6 +818,7 @@ Java_com_xypower_mpapp_MicroPhotoService_importPublicKeyFile(
const char *md5Str = env->GetStringUTFChars(md5, 0);
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true);
@ -853,6 +854,7 @@ Java_com_xypower_mpapp_MicroPhotoService_importPublicKey(
return JNI_FALSE;
}
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true);
@ -889,7 +891,7 @@ Java_com_xypower_mpapp_MicroPhotoService_importPrivateKey(
return JNI_FALSE;
}
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true);
@ -927,6 +929,8 @@ Java_com_xypower_mpapp_MicroPhotoService_genKeys(
jclass cls, jint index) {
#ifdef USING_NRSEC
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true);
@ -956,6 +960,7 @@ Java_com_xypower_mpapp_MicroPhotoService_querySecVersion(
std::string version;
#ifdef USING_NRSEC
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true);
@ -986,6 +991,7 @@ Java_com_xypower_mpapp_MicroPhotoService_genCertRequest(
}
const char *path = NRSEC_PATH;
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true);
@ -1043,6 +1049,7 @@ Java_com_xypower_mpapp_MicroPhotoService_importPrivateKeyFile(
const char *path = NRSEC_PATH;
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true);
@ -1082,6 +1089,7 @@ Java_com_xypower_mpapp_MicroPhotoService_exportPublicKeyFile(
uint8_t len = 0;
std::vector<unsigned char> data(64, 0);
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true);
@ -1121,6 +1129,7 @@ Java_com_xypower_mpapp_MicroPhotoService_exportPrivateFile(
const char *path = NRSEC_PATH;
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true);

@ -1322,7 +1322,6 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
}
#endif
// GpioControl::EnableGpio(CMD_SET_CAM_3V3_EN_STATE, true);
bool res = false;
if (photoInfo.usbCamera)

@ -86,7 +86,11 @@ static void set12VEnable(bool z) {
static void setCam3V3Enable(bool enabled)
{
#ifdef ENABLE_3V3_ALWAYS
setInt(CMD_SET_CAM_3V3_EN_STATE, 1);
#else
setInt(CMD_SET_CAM_3V3_EN_STATE, enabled ? 1 : 0);
#endif
}
#if 0

@ -142,11 +142,6 @@ static void set12VEnable(bool z) {
setInt(CMD_SET_12V_EN_STATE, z ? 1 : 0);
}
static void setCam3V3Enable(bool enabled)
{
setInt(CMD_SET_CAM_3V3_EN_STATE, enabled ? 1 : 0);
}
/*********************************************************************************
* *

Loading…
Cancel
Save