Skip to content

Commit

Permalink
Use better name for framerate limit variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
15498th committed Dec 18, 2021
1 parent 69888bd commit 721e825
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Call `/control?var=<key>&val=<val>` with a settings key and value to set camera
```
lamp - Lamp value in percent; integer, 0 - 100 (-1 = disabled)
framesize - See below
framerate_limit - Minimal frame duration in ms, used to limit max FPS. Must be positive integer
min_frame_time - Minimal frame duration in ms, used to limit max FPS. Must be positive integer
quality - 10 to 63 (ov3660: 4 to 10)
contrast - -2 to 2 (ov3660: -3 to 3)
brightness - -2 to 2 (ov3660: -3 to 3)
Expand Down
8 changes: 4 additions & 4 deletions app_httpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extern int8_t streamCount;
extern unsigned long streamsServed;
extern unsigned long imagesServed;
extern int myRotation;
extern int framerateLimit;
extern int minFrameTime;
extern int lampVal;
extern bool autoLamp;
extern bool filesystem;
Expand Down Expand Up @@ -276,7 +276,7 @@ static esp_err_t stream_handler(httpd_req_t *req){
}
int64_t frame_time = esp_timer_get_time() - last_frame;
frame_time /= 1000;
int32_t frame_delay = (framerateLimit > frame_time) ? framerateLimit - frame_time : 0;
int32_t frame_delay = (minFrameTime > frame_time) ? minFrameTime - frame_time : 0;
delay(frame_delay);

if (debugData) {
Expand Down Expand Up @@ -359,7 +359,7 @@ static esp_err_t cmd_handler(httpd_req_t *req){
else if(!strcmp(variable, "wb_mode")) res = s->set_wb_mode(s, val);
else if(!strcmp(variable, "ae_level")) res = s->set_ae_level(s, val);
else if(!strcmp(variable, "rotate")) myRotation = val;
else if(!strcmp(variable, "framerate_limit")) framerateLimit = val;
else if(!strcmp(variable, "min_frame_time")) minFrameTime = val;
else if(!strcmp(variable, "autolamp") && (lampVal != -1)) {
autoLamp = val;
if (autoLamp) {
Expand Down Expand Up @@ -415,7 +415,7 @@ static esp_err_t status_handler(httpd_req_t *req){
*p++ = '{';
p+=sprintf(p, "\"lamp\":%d,", lampVal);
p+=sprintf(p, "\"autolamp\":%d,", autoLamp);
p+=sprintf(p, "\"framerate_limit\":%d,", framerateLimit);
p+=sprintf(p, "\"min_frame_time\":%d,", minFrameTime);
p+=sprintf(p, "\"framesize\":%u,", s->status.framesize);
p+=sprintf(p, "\"quality\":%u,", s->status.quality);
p+=sprintf(p, "\"brightness\":%d,", s->status.brightness);
Expand Down
6 changes: 3 additions & 3 deletions esp32-cam-webserver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ char myVer[] PROGMEM = __DATE__ " @ " __TIME__;
int myRotation = CAM_ROTATION;

// minimal frame duration in ms, effectively 1/maxFPS
#if !defined(FRAMERATE_LIMIT)
#define FRAMERATE_LIMIT 0
#if !defined(MIN_FRAME_TIME)
#define MIN_FRAME_TIME 0
#endif
int framerateLimit = FRAMERATE_LIMIT;
int minFrameTime = MIN_FRAME_TIME;

// Illumination LAMP and status LED
#if defined(LAMP_DISABLE)
Expand Down
16 changes: 8 additions & 8 deletions index_ov2640.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ const uint8_t index_ov2640_html[] = R"=====(<!doctype html>
<label class="slider" for="colorbar"></label>
</div>
</div>
<div class="input-group" id="framerate_limit-group">
<label for="framerate_limit">FPS Limit</label>
<select id="framerate_limit" class="default-action">
<div class="input-group" id="min_frame_time-group">
<label for="min_frame_time">FPS Limit</label>
<select id="min_frame_time" class="default-action">
<option value="3333">0.3</option>
<option value="2000">0.5</option>
<option value="1000">1</option>
Expand Down Expand Up @@ -310,7 +310,7 @@ const uint8_t index_ov2640_html[] = R"=====(<!doctype html>
const savePrefsButton = document.getElementById('save_prefs')
const clearPrefsButton = document.getElementById('clear_prefs')
const rebootButton = document.getElementById('reboot')
const framerateLimit = document.getElementById('framerate_limit')
const minFrameTime = document.getElementById('min_frame_time')

const hide = el => {
el.classList.add('hidden')
Expand Down Expand Up @@ -374,8 +374,8 @@ const uint8_t index_ov2640_html[] = R"=====(<!doctype html>
} else if(el.id === "rotate"){
rotate.value = value;
applyRotation();
} else if(el.id === "framerate_limit"){
framerate_limit.value = value;
} else if(el.id === "min_frame_time"){
min_frame_time.value = value;
} else if(el.id === "stream_url"){
streamURL = value;
viewerURL = value + 'view';
Expand Down Expand Up @@ -579,8 +579,8 @@ const uint8_t index_ov2640_html[] = R"=====(<!doctype html>
updateConfig(framesize)
}

framerateLimit.onchange = () => {
updateConfig(framerateLimit)
minFrameTime.onchange = () => {
updateConfig(minFrameTime)
}

swapButton.onclick = () => {
Expand Down
16 changes: 8 additions & 8 deletions index_ov3660.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ const uint8_t index_ov3660_html[] = R"=====(<!doctype html>
<label class="slider" for="colorbar"></label>
</div>
</div>
<div class="input-group" id="framerate_limit-group">
<label for="framerate_limit">FPS Limit</label>
<select id="framerate_limit" class="default-action">
<div class="input-group" id="min_frame_time-group">
<label for="min_frame_time">FPS Limit</label>
<select id="min_frame_time" class="default-action">
<option value="3333">0.3</option>
<option value="2000">0.5</option>
<option value="1000">1</option>
Expand Down Expand Up @@ -324,7 +324,7 @@ const uint8_t index_ov3660_html[] = R"=====(<!doctype html>
const savePrefsButton = document.getElementById('save_prefs')
const clearPrefsButton = document.getElementById('clear_prefs')
const rebootButton = document.getElementById('reboot')
const framerateLimit = document.getElementById('framerate_limit')
const minFrameTime = document.getElementById('min_frame_time')

const hide = el => {
el.classList.add('hidden')
Expand Down Expand Up @@ -386,8 +386,8 @@ const uint8_t index_ov3660_html[] = R"=====(<!doctype html>
} else if(el.id === "rotate"){
rotate.value = value;
applyRotation();
} else if(el.id === "framerate_limit"){
framerate_limit.value = value;
} else if(el.id === "min_frame_time"){
min_frame_time.value = value;
} else if(el.id === "stream_url"){
streamURL = value;
viewerURL = value + 'view';
Expand Down Expand Up @@ -588,8 +588,8 @@ const uint8_t index_ov3660_html[] = R"=====(<!doctype html>
updateConfig(framesize)
}

framerateLimit.onchange = () => {
updateConfig(framerateLimit)
minFrameTime.onchange = () => {
updateConfig(minFrameTime)
}

swapButton.onclick = () => {
Expand Down
4 changes: 2 additions & 2 deletions myconfig.sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ struct station stationList[] = {{"ssid1", "pass1", true},
// #define CAM_ROTATION 0

// Minimal frame duration in ms, used to limit max FPS
// max_fps = 1000/framerate_limit
// #define FRAMERATE_LIMIT 500
// max_fps = 1000/min_frame_time
// #define MIN_FRAME_TIME 500

/*
* Additional Features
Expand Down
6 changes: 3 additions & 3 deletions storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extern void flashLED(int flashtime);
extern int myRotation; // Rotation
extern int lampVal; // The current Lamp value
extern int autoLamp; // Automatic lamp mode
extern int framerateLimit; // Minimal frame duration
extern int minFrameTime; // Minimal frame duration

/*
* Useful utility when debugging...
Expand Down Expand Up @@ -91,7 +91,7 @@ void loadPrefs(fs::FS &fs){
// process all the settings
lampVal = jsonExtract(prefs, "lamp").toInt();
autoLamp = jsonExtract(prefs, "autolamp").toInt();
framerateLimit = jsonExtract(prefs, "framerate_limit").toInt();
minFrameTime = jsonExtract(prefs, "min_frame_time").toInt();
s->set_framesize(s, (framesize_t)jsonExtract(prefs, "framesize").toInt());
s->set_quality(s, jsonExtract(prefs, "quality").toInt());
s->set_brightness(s, jsonExtract(prefs, "brightness").toInt());
Expand Down Expand Up @@ -138,7 +138,7 @@ void savePrefs(fs::FS &fs){
*p++ = '{';
p+=sprintf(p, "\"lamp\":%i,", lampVal);
p+=sprintf(p, "\"autolamp\":%u,", autoLamp);
p+=sprintf(p, "\"framerate_limit\":%d,", framerateLimit);
p+=sprintf(p, "\"min_frame_time\":%d,", minFrameTime);
p+=sprintf(p, "\"framesize\":%u,", s->status.framesize);
p+=sprintf(p, "\"quality\":%u,", s->status.quality);
p+=sprintf(p, "\"brightness\":%d,", s->status.brightness);
Expand Down

0 comments on commit 721e825

Please sign in to comment.