删除不需要代码

This commit is contained in:
Dominocs 2024-01-17 06:32:22 +08:00
parent 7da7070e60
commit d5d795a625
14 changed files with 24039 additions and 24739 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
661ccc56ad1395cbe649f896715e8af99a7d2feb
c4fff1c05db4174745ad45bc9c522f506c91eed9

View File

@ -1,19 +0,0 @@
#include <Arduino.h>
#include "battery.h"
#include "../config.h"
batteryClass *pbattery = NULL;
void batteryClass::updateBattery()
{
unsigned long currentTime = millis();
if(currentTime - ulTimer > BATTERY_UPDATE_TIME){
int sensorValue = analogRead(BATTERY_PIN);
float battery = (float)sensorValue / BATEERY_ADC_MAX; //分压电压
battery = battery / BATTERY_DOT; //电源实际电压
battery = battery < BATTERY_MAX?battery:BATTERY_MAX;
battery = battery > BATTERY_MIN?battery:BATTERY_MIN;
ucBattery = ceil((battery - BATTERY_MIN) / (BATTERY_MAX - BATTERY_MIN) * 100);
ulTimer = currentTime;
}
}

View File

@ -1,15 +0,0 @@
#ifndef _BATTERY_H
#define _BATTERY_H
#include <Arduino.h>
class batteryClass{
private:
unsigned long ulTimer = 0;
uint8_t ucBattery = 0;
public:
void updateBattery();
uint8_t getBattery(){
return ucBattery;
}
};
extern batteryClass *pbattery;
#endif

View File

@ -28,7 +28,7 @@ constexpr camera_config_t camconfig{
.pixel_format = PIXFORMAT_JPEG, //YUV422,GRAYSCALE,RGB565,JPEG
.frame_size = FRAMESIZE_HVGA, //QQVGA-UXGA, For ESP32, do not use sizes above QVGA when not JPEG. The performance of the ESP32-S series has improved a lot, but JPEG mode always gives better frame rates.
.jpeg_quality = 3, //0-63, for OV series camera sensors, lower number means higher quality(图片过大可能会导致堆栈溢出)
.jpeg_quality = 5, //0-63, for OV series camera sensors, lower number means higher quality(图片过大可能会导致堆栈溢出)
.fb_count = 3, //When jpeg mode is used, if fb_count more than one, the driver will work in continuous mode.
.grab_mode = CAMERA_GRAB_LATEST,
};

View File

@ -1,17 +0,0 @@
#ifndef CONFIG_HPP
#define CONFIG_HPP
#include <Arduino.h>
enum board{
esp32cam,
cympleeye,
};
#define BOARD_DEF cympleeye
/* LED配置 */
#define LED_PIN 33 /* GPIO33 for espcam*/
#define BATTERY_UPDATE_TIME 10000//10S刷新一次
#define BATTERY_PIN A0 //A0
#define BATEERY_ADC_MAX 1024.0 //ADC读出值范围为0-1024
#define BATTERY_MAX 4.2 //电池满电电压
#define BATTERY_MIN 3.7 //电池零电电压
#define BATTERY_DOT (10.0/(47.0 + 10.0)) //分压
#endif /* CONFIG_HPP */

View File

@ -1,42 +0,0 @@
#include <Arduino.h>
#include "led.h"
ledClass *pledObj = NULL;
void ledClass::ledMode(LED_MODE mode, unsigned long Ondelay, unsigned long Offdelay){
if((uimode == mode) && (Ondelay == uiLEDOnTimer) && (uiLEDOffTimer == Offdelay)){
return;
}
switch(mode){
case LED_MODE_ALWAYS_ON:
digitalWrite(LED_PIN, LOW);
break;
case LED_MODE_ALWAYS_OFF:
digitalWrite(LED_PIN, HIGH);
break;
case LED_MODE_BLINK:
uiLEDTimer = millis();
uiLEDOnTimer = Ondelay;
uiLEDOffTimer = Offdelay;
digitalWrite(LED_PIN, HIGH);
break;
}
uimode = mode;
}
void ledClass::runFrame(unsigned long currentT){
if(LED_MODE_BLINK != uimode){
return;
}
if(currentT - uiLEDTimer < uiLEDOnTimer){
digitalWrite(LED_PIN, LOW);
}
else if(currentT - uiLEDTimer < (uiLEDOnTimer + uiLEDOffTimer)){
/* 超过一个周期 */
digitalWrite(LED_PIN, HIGH);
}else{
uiLEDTimer = currentT;
digitalWrite(LED_PIN, LOW);
}
}

View File

@ -1,26 +0,0 @@
#ifndef LED_HPP
#define LED_HPP
#include<Arduino.h>
#include "../config.h"
enum LED_MODE{
LED_MODE_ALWAYS_OFF,
LED_MODE_ALWAYS_ON,
LED_MODE_BLINK,
};
class ledClass{
private:
uint16_t uimode = LED_MODE_ALWAYS_OFF;
unsigned long uiLEDTimer = 0;
unsigned long uiLEDOnTimer = 0;
unsigned long uiLEDOffTimer = 0;
public:
ledClass(){
pinMode(LED_PIN, OUTPUT);
ledMode(LED_MODE_ALWAYS_ON, 0, 0);
}
void ledMode(LED_MODE mode, unsigned long Ondelay, unsigned long Offdelay);
void runFrame(unsigned long currentT);
};
extern ledClass *pledObj;
#endif

View File

@ -2,7 +2,6 @@
#include <WiFi.h>
#include <EEPROM.h>
#include "drv/eeprom.h"
#include "drv/led.h"
#include "wlanMsg.h"
#include "serialMsg.h"
#include "esp32cam.h"
@ -11,8 +10,6 @@ void setup() {
delay(1000);
EEPROM.begin(sizeof(EEPROM_DATA_S));
pserialObj = new serialClass();
pledObj = new ledClass();
Serial.println("CympleEye LED Init!");
pwlanMsgObj = new wlanMsgClass();
Serial.println("CympleEye WLAN Init!");
pCamera = new cameraClass();
@ -22,7 +19,6 @@ void setup() {
void loop() {
currentT = millis();
pledObj->runFrame(currentT);
pserialObj->runFrame(currentT);
if(pwlanMsgObj->runFrame(currentT)){
return;
@ -31,5 +27,6 @@ void loop() {
delay(1000);
return;
}
delay(1);
currentT = millis() - currentT;
delay(currentT > 40?0:40 - currentT);
}

View File

@ -1,6 +1,5 @@
#include <AsyncUDP.h>
#include "common.h"
#include "drv/led.h"
#include "drv/eeprom.h"
#include "drv/network.h"
#include "esp32cam.h"
@ -23,7 +22,6 @@ static void onPacketCallBack(AsyncUDPPacket packet){
heartBeatTimer = millis();
bHeartbeatTimeout = false;
peerAddr = packet.remoteIP();
pledObj->ledMode(LED_MODE_BLINK, 1000, 2000);
break;
case MSG_POSITION_CFG_E:{
if(msgLen == sizeof(MSG_WLAN_POSIOTN_CONFIG_S)){
@ -51,9 +49,9 @@ wlanMsgClass::wlanMsgClass(){
peerAddr = INADDR_NONE;
WiFi.mode(WIFI_STA);
WiFi.persistent(false);
if(ESP_OK != esp_wifi_set_max_tx_power(WIFI_MAX_TX_POWER)){
Serial.println("Failed to config wifi max tx power.");
}
// if(ESP_OK != esp_wifi_set_max_tx_power(WIFI_MAX_TX_POWER)){
// Serial.println("Failed to config wifi max tx power.");
// }
while (!udpClient.listen(CYMPLEFACE_CAM_PORT)) //等待udp监听设置成功
{
}
@ -104,7 +102,6 @@ int wlanMsgClass::runFrame(unsigned long currentT){
deltaT = abs(deltaT);
if((!bHeartbeatTimeout) && (deltaT > WLAN_HEARTBEAT_TIMEOUT)){
bHeartbeatTimeout = true;
pledObj->ledMode(LED_MODE_ALWAYS_ON, 0, 0);
}
if(bHeartbeatTimeout){
if(!WiFi.isConnected()){