2022-10-25 09:23:44 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "sensor_mode.h"
|
|
|
|
|
2023-02-13 11:12:04 +00:00
|
|
|
bool sensor_mode_load(const char *encoded, sensor_mode_t *mode) {
|
2022-10-25 09:23:44 +00:00
|
|
|
char p;
|
2023-02-13 11:12:04 +00:00
|
|
|
int n = sscanf(encoded, "%u:%u:%u:%c", &(mode->width), &(mode->height), &(mode->bit_depth), &p);
|
2022-10-25 09:23:44 +00:00
|
|
|
if (n < 2) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n < 4) {
|
2023-02-13 11:12:04 +00:00
|
|
|
mode->packed = true;
|
2022-10-25 09:23:44 +00:00
|
|
|
} else if (toupper(p) == 'P') {
|
2023-02-13 11:12:04 +00:00
|
|
|
mode->packed = true;
|
2022-10-25 09:23:44 +00:00
|
|
|
} else if (toupper(p) == 'U') {
|
2023-02-13 11:12:04 +00:00
|
|
|
mode->packed = false;
|
2022-10-25 09:23:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (n < 3) {
|
2023-02-13 11:12:04 +00:00
|
|
|
mode->bit_depth = 12;
|
2022-10-25 09:23:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|