You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
run_desktop: backup and restore config file
This commit is contained in:
@@ -0,0 +1,167 @@
|
||||
diff --git a/src/manifest.py b/src/manifest.py
|
||||
index ff69f76..929ff84 100644
|
||||
--- a/src/manifest.py
|
||||
+++ b/src/manifest.py
|
||||
@@ -1,4 +1,5 @@
|
||||
# Include the board's default manifest.
|
||||
include("$(PORT_DIR)/boards/manifest.py")
|
||||
# Add custom driver
|
||||
-module("acamera.py")
|
||||
\ No newline at end of file
|
||||
+module("acamera.py")
|
||||
+include("/home/user/projects/MicroPythonOS/claude/MicroPythonOS/lvgl_micropython/build/manifest.py") # workaround to prevent micropython-camera-API from overriding the lvgl_micropython manifest...
|
||||
diff --git a/src/modcamera.c b/src/modcamera.c
|
||||
index 5a0bd05..c84f09d 100644
|
||||
--- a/src/modcamera.c
|
||||
+++ b/src/modcamera.c
|
||||
@@ -252,7 +252,7 @@ const mp_rom_map_elem_t mp_camera_hal_pixel_format_table[] = {
|
||||
const mp_rom_map_elem_t mp_camera_hal_frame_size_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_R96X96), MP_ROM_INT((mp_uint_t)FRAMESIZE_96X96) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_QQVGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_QQVGA) },
|
||||
- { MP_ROM_QSTR(MP_QSTR_R128x128), MP_ROM_INT((mp_uint_t)FRAMESIZE_128X128) },
|
||||
+ { MP_ROM_QSTR(MP_QSTR_R128X128), MP_ROM_INT((mp_uint_t)FRAMESIZE_128X128) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_QCIF), MP_ROM_INT((mp_uint_t)FRAMESIZE_QCIF) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_HQVGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_HQVGA) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_R240X240), MP_ROM_INT((mp_uint_t)FRAMESIZE_240X240) },
|
||||
@@ -260,10 +260,17 @@ const mp_rom_map_elem_t mp_camera_hal_frame_size_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_R320X320), MP_ROM_INT((mp_uint_t)FRAMESIZE_320X320) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_CIF), MP_ROM_INT((mp_uint_t)FRAMESIZE_CIF) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_HVGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_HVGA) },
|
||||
+ { MP_ROM_QSTR(MP_QSTR_R480X480), MP_ROM_INT((mp_uint_t)FRAMESIZE_480X480) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_VGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_VGA) },
|
||||
+ { MP_ROM_QSTR(MP_QSTR_R640X640), MP_ROM_INT((mp_uint_t)FRAMESIZE_640X640) },
|
||||
+ { MP_ROM_QSTR(MP_QSTR_R720X720), MP_ROM_INT((mp_uint_t)FRAMESIZE_720X720) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SVGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_SVGA) },
|
||||
+ { MP_ROM_QSTR(MP_QSTR_R800X800), MP_ROM_INT((mp_uint_t)FRAMESIZE_800X800) },
|
||||
+ { MP_ROM_QSTR(MP_QSTR_R960X960), MP_ROM_INT((mp_uint_t)FRAMESIZE_960X960) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_XGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_XGA) },
|
||||
+ { MP_ROM_QSTR(MP_QSTR_R1024X1024),MP_ROM_INT((mp_uint_t)FRAMESIZE_1024X1024) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_HD), MP_ROM_INT((mp_uint_t)FRAMESIZE_HD) },
|
||||
+ { MP_ROM_QSTR(MP_QSTR_R1280X1280),MP_ROM_INT((mp_uint_t)FRAMESIZE_1280X1280) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SXGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_SXGA) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_UXGA), MP_ROM_INT((mp_uint_t)FRAMESIZE_UXGA) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_FHD), MP_ROM_INT((mp_uint_t)FRAMESIZE_FHD) },
|
||||
@@ -435,3 +442,22 @@ int mp_camera_hal_get_pixel_height(mp_camera_obj_t *self) {
|
||||
framesize_t framesize = sensor->status.framesize;
|
||||
return resolution[framesize].height;
|
||||
}
|
||||
+
|
||||
+int mp_camera_hal_set_res_raw(mp_camera_obj_t *self, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning) {
|
||||
+ check_init(self);
|
||||
+ sensor_t *sensor = esp_camera_sensor_get();
|
||||
+ if (!sensor->set_res_raw) {
|
||||
+ mp_raise_ValueError(MP_ERROR_TEXT("Sensor does not support set_res_raw"));
|
||||
+ }
|
||||
+
|
||||
+ if (self->captured_buffer) {
|
||||
+ esp_camera_return_all();
|
||||
+ self->captured_buffer = NULL;
|
||||
+ }
|
||||
+
|
||||
+ int ret = sensor->set_res_raw(sensor, startX, startY, endX, endY, offsetX, offsetY, totalX, totalY, outputX, outputY, scale, binning);
|
||||
+ if (ret < 0) {
|
||||
+ mp_raise_ValueError(MP_ERROR_TEXT("Failed to set raw resolution"));
|
||||
+ }
|
||||
+ return ret;
|
||||
+}
|
||||
diff --git a/src/modcamera.h b/src/modcamera.h
|
||||
index a3ce749..a8771bd 100644
|
||||
--- a/src/modcamera.h
|
||||
+++ b/src/modcamera.h
|
||||
@@ -211,7 +211,7 @@ extern const mp_rom_map_elem_t mp_camera_hal_pixel_format_table[9];
|
||||
* @brief Table mapping frame sizes API to their corresponding values at HAL.
|
||||
* @details Needs to be defined in the port-specific implementation.
|
||||
*/
|
||||
-extern const mp_rom_map_elem_t mp_camera_hal_frame_size_table[24];
|
||||
+extern const mp_rom_map_elem_t mp_camera_hal_frame_size_table[31];
|
||||
|
||||
/**
|
||||
* @brief Table mapping gainceiling API to their corresponding values at HAL.
|
||||
@@ -278,4 +278,24 @@ DECLARE_CAMERA_HAL_GET(int, pixel_width)
|
||||
DECLARE_CAMERA_HAL_GET(const char *, sensor_name)
|
||||
DECLARE_CAMERA_HAL_GET(bool, supports_jpeg)
|
||||
|
||||
-#endif // MICROPY_INCLUDED_MODCAMERA_H
|
||||
\ No newline at end of file
|
||||
+/**
|
||||
+ * @brief Sets the raw resolution parameters including ROI (Region of Interest).
|
||||
+ *
|
||||
+ * @param self Pointer to the camera object.
|
||||
+ * @param startX X start position.
|
||||
+ * @param startY Y start position.
|
||||
+ * @param endX X end position.
|
||||
+ * @param endY Y end position.
|
||||
+ * @param offsetX X offset.
|
||||
+ * @param offsetY Y offset.
|
||||
+ * @param totalX Total X size.
|
||||
+ * @param totalY Total Y size.
|
||||
+ * @param outputX Output X size.
|
||||
+ * @param outputY Output Y size.
|
||||
+ * @param scale Enable scaling.
|
||||
+ * @param binning Enable binning.
|
||||
+ * @return 0 on success, negative value on error.
|
||||
+ */
|
||||
+extern int mp_camera_hal_set_res_raw(mp_camera_obj_t *self, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning);
|
||||
+
|
||||
+#endif // MICROPY_INCLUDED_MODCAMERA_H
|
||||
diff --git a/src/modcamera_api.c b/src/modcamera_api.c
|
||||
index 39afa71..8f888ca 100644
|
||||
--- a/src/modcamera_api.c
|
||||
+++ b/src/modcamera_api.c
|
||||
@@ -285,6 +285,48 @@ CREATE_GETSET_FUNCTIONS(wpc, mp_obj_new_bool, mp_obj_is_true);
|
||||
CREATE_GETSET_FUNCTIONS(raw_gma, mp_obj_new_bool, mp_obj_is_true);
|
||||
CREATE_GETSET_FUNCTIONS(lenc, mp_obj_new_bool, mp_obj_is_true);
|
||||
|
||||
+// set_res_raw function for ROI (Region of Interest) / digital zoom
|
||||
+static mp_obj_t camera_set_res_raw(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
+ mp_camera_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
+ enum { ARG_startX, ARG_startY, ARG_endX, ARG_endY, ARG_offsetX, ARG_offsetY, ARG_totalX, ARG_totalY, ARG_outputX, ARG_outputY, ARG_scale, ARG_binning };
|
||||
+ static const mp_arg_t allowed_args[] = {
|
||||
+ { MP_QSTR_startX, MP_ARG_INT | MP_ARG_REQUIRED },
|
||||
+ { MP_QSTR_startY, MP_ARG_INT | MP_ARG_REQUIRED },
|
||||
+ { MP_QSTR_endX, MP_ARG_INT | MP_ARG_REQUIRED },
|
||||
+ { MP_QSTR_endY, MP_ARG_INT | MP_ARG_REQUIRED },
|
||||
+ { MP_QSTR_offsetX, MP_ARG_INT | MP_ARG_REQUIRED },
|
||||
+ { MP_QSTR_offsetY, MP_ARG_INT | MP_ARG_REQUIRED },
|
||||
+ { MP_QSTR_totalX, MP_ARG_INT | MP_ARG_REQUIRED },
|
||||
+ { MP_QSTR_totalY, MP_ARG_INT | MP_ARG_REQUIRED },
|
||||
+ { MP_QSTR_outputX, MP_ARG_INT | MP_ARG_REQUIRED },
|
||||
+ { MP_QSTR_outputY, MP_ARG_INT | MP_ARG_REQUIRED },
|
||||
+ { MP_QSTR_scale, MP_ARG_BOOL, {.u_bool = false} },
|
||||
+ { MP_QSTR_binning, MP_ARG_BOOL, {.u_bool = false} },
|
||||
+ };
|
||||
+
|
||||
+ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
+ mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
+
|
||||
+ int ret = mp_camera_hal_set_res_raw(
|
||||
+ self,
|
||||
+ args[ARG_startX].u_int,
|
||||
+ args[ARG_startY].u_int,
|
||||
+ args[ARG_endX].u_int,
|
||||
+ args[ARG_endY].u_int,
|
||||
+ args[ARG_offsetX].u_int,
|
||||
+ args[ARG_offsetY].u_int,
|
||||
+ args[ARG_totalX].u_int,
|
||||
+ args[ARG_totalY].u_int,
|
||||
+ args[ARG_outputX].u_int,
|
||||
+ args[ARG_outputY].u_int,
|
||||
+ args[ARG_scale].u_bool,
|
||||
+ args[ARG_binning].u_bool
|
||||
+ );
|
||||
+
|
||||
+ return mp_obj_new_int(ret);
|
||||
+}
|
||||
+static MP_DEFINE_CONST_FUN_OBJ_KW(camera_set_res_raw_obj, 1, camera_set_res_raw);
|
||||
+
|
||||
//API-Tables
|
||||
static const mp_rom_map_elem_t camera_camera_locals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_reconfigure), MP_ROM_PTR(&camera_reconfigure_obj) },
|
||||
@@ -293,6 +335,7 @@ static const mp_rom_map_elem_t camera_camera_locals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_free_buffer), MP_ROM_PTR(&camera_free_buf_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&camera_init_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&mp_camera_deinit_obj) },
|
||||
+ { MP_ROM_QSTR(MP_QSTR_set_res_raw), MP_ROM_PTR(&camera_set_res_raw_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_camera_deinit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&mp_camera___exit___obj) },
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
find internal_filesystem -iname "*.pyc" -exec rm {} \;
|
||||
@@ -62,9 +62,11 @@ if [ -f "$script" ]; then
|
||||
"$binary" -v -i "$script"
|
||||
else
|
||||
echo "Running app $script"
|
||||
mv data/com.micropythonos.settings/config.json data/com.micropythonos.settings/config.json.backup
|
||||
# When $script is empty, it just doesn't find the app and stays at the launcher
|
||||
echo '{"auto_start_app": "'$script'"}' > data/com.micropythonos.settings/config.json
|
||||
"$binary" -X heapsize=$HEAPSIZE -v -i -c "$(cat main.py)"
|
||||
mv data/com.micropythonos.settings/config.json.backup data/com.micropythonos.settings/config.json
|
||||
fi
|
||||
|
||||
popd
|
||||
|
||||
Reference in New Issue
Block a user