From ceada3cc60d58e60b78694e290a9f07fef73c60b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Mahovli=C4=87?= Date: Sat, 19 Aug 2023 00:32:12 +0200 Subject: [PATCH] Removing eez adding eez-framework as submodule --- .gitmodules | 3 + Middlewares/eez-framework | 1 + Middlewares/eez/README.md | 0 Middlewares/eez/core/alloc.cpp | 202 - Middlewares/eez/core/alloc.h | 53 - Middlewares/eez/core/debug.cpp | 58 - Middlewares/eez/core/debug.h | 54 - Middlewares/eez/core/eeprom.cpp | 211 - Middlewares/eez/core/eeprom.h | 39 - Middlewares/eez/core/encoder.h | 32 - Middlewares/eez/core/hmi.cpp | 61 - Middlewares/eez/core/hmi.h | 33 - Middlewares/eez/core/keyboard.h | 285 - Middlewares/eez/core/memory.cpp | 99 - Middlewares/eez/core/memory.h | 84 - Middlewares/eez/core/mouse.h | 38 - Middlewares/eez/core/os.cpp | 37 - Middlewares/eez/core/os.h | 102 - Middlewares/eez/core/sound.h | 51 - Middlewares/eez/core/step_values.h | 30 - Middlewares/eez/core/unit.cpp | 309 - Middlewares/eez/core/unit.h | 94 - Middlewares/eez/core/utf8.h | 43 - Middlewares/eez/core/util.cpp | 921 -- Middlewares/eez/core/util.h | 209 - Middlewares/eez/core/value_types.h | 66 - Middlewares/eez/flow/components.cpp | 142 - Middlewares/eez/flow/components.h | 35 - Middlewares/eez/flow/components/animate.cpp | 110 - Middlewares/eez/flow/components/call_action.cpp | 77 - Middlewares/eez/flow/components/call_action.h | 41 - Middlewares/eez/flow/components/catch_error.cpp | 36 - Middlewares/eez/flow/components/compare.cpp | 57 - Middlewares/eez/flow/components/constant.cpp | 41 - Middlewares/eez/flow/components/counter.cpp | 57 - Middlewares/eez/flow/components/delay.cpp | 72 - Middlewares/eez/flow/components/end.cpp | 37 - Middlewares/eez/flow/components/error.cpp | 38 - Middlewares/eez/flow/components/expr_eval.cpp | 40 - Middlewares/eez/flow/components/input.cpp | 84 - Middlewares/eez/flow/components/input.h | 38 - Middlewares/eez/flow/components/is_true.cpp | 51 - .../eez/flow/components/layout_view_widget.cpp | 100 - Middlewares/eez/flow/components/log.cpp | 47 - Middlewares/eez/flow/components/loop.cpp | 102 - Middlewares/eez/flow/components/noop.cpp | 36 - Middlewares/eez/flow/components/on_event.cpp | 31 - Middlewares/eez/flow/components/output.cpp | 64 - Middlewares/eez/flow/components/roller_widget.cpp | 43 - Middlewares/eez/flow/components/roller_widget.h | 31 - .../eez/flow/components/select_language.cpp | 53 - .../eez/flow/components/set_page_direction.cpp | 49 - Middlewares/eez/flow/components/set_variable.cpp | 57 - Middlewares/eez/flow/components/set_variable.h | 36 - Middlewares/eez/flow/components/show_keyboard.cpp | 88 - Middlewares/eez/flow/components/show_keypad.cpp | 109 - .../eez/flow/components/show_message_box.cpp | 52 - Middlewares/eez/flow/components/show_page.cpp | 40 - Middlewares/eez/flow/components/start.cpp | 31 - Middlewares/eez/flow/components/switch.cpp | 61 - Middlewares/eez/flow/components/switch.h | 36 - Middlewares/eez/flow/components/watch_variable.cpp | 74 - Middlewares/eez/flow/dashboard_api.cpp | 378 - Middlewares/eez/flow/dashboard_api.h | 29 - Middlewares/eez/flow/debugger.cpp | 760 -- Middlewares/eez/flow/debugger.h | 62 - Middlewares/eez/flow/expression.cpp | 221 - Middlewares/eez/flow/expression.h | 66 - Middlewares/eez/flow/flow.cpp | 331 - Middlewares/eez/flow/flow.h | 58 - Middlewares/eez/flow/flow_defs_v3.h | 444 - Middlewares/eez/flow/hooks.cpp | 77 - Middlewares/eez/flow/hooks.h | 47 - Middlewares/eez/flow/operations.cpp | 1413 --- Middlewares/eez/flow/operations.h | 50 - Middlewares/eez/flow/private.cpp | 525 - Middlewares/eez/flow/private.h | 117 - Middlewares/eez/flow/queue.cpp | 126 - Middlewares/eez/flow/queue.h | 37 - Middlewares/eez/fs/fs.h | 162 - Middlewares/eez/fs/stm32/fs.cpp | 411 - Middlewares/eez/gui/action_impl.cpp | 71 - Middlewares/eez/gui/animation.cpp | 369 - Middlewares/eez/gui/animation.h | 78 - Middlewares/eez/gui/app_context.cpp | 543 - Middlewares/eez/gui/app_context.h | 146 - Middlewares/eez/gui/assets.cpp | 256 - Middlewares/eez/gui/assets.h | 493 - Middlewares/eez/gui/assets_fix_offsets.cpp | 275 - Middlewares/eez/gui/data.cpp | 1697 --- Middlewares/eez/gui/data.h | 761 -- Middlewares/eez/gui/display-private.h | 94 - Middlewares/eez/gui/display.cpp | 987 -- Middlewares/eez/gui/display.h | 180 - Middlewares/eez/gui/draw.cpp | 856 -- Middlewares/eez/gui/draw.h | 60 - Middlewares/eez/gui/event.cpp | 273 - Middlewares/eez/gui/event.h | 48 - Middlewares/eez/gui/font.cpp | 81 - Middlewares/eez/gui/font.h | 48 - Middlewares/eez/gui/geometry.cpp | 129 - Middlewares/eez/gui/geometry.h | 56 - Middlewares/eez/gui/gui.cpp | 142 - Middlewares/eez/gui/gui.h | 110 - Middlewares/eez/gui/hooks.cpp | 215 - Middlewares/eez/gui/hooks.h | 71 - Middlewares/eez/gui/image.h | 40 - Middlewares/eez/gui/keypad.cpp | 977 -- Middlewares/eez/gui/keypad.h | 230 - Middlewares/eez/gui/overlay.cpp | 109 - Middlewares/eez/gui/overlay.h | 72 - Middlewares/eez/gui/page.cpp | 909 -- Middlewares/eez/gui/page.h | 268 - Middlewares/eez/gui/thread.cpp | 158 - Middlewares/eez/gui/thread.h | 68 - Middlewares/eez/gui/touch.cpp | 112 - Middlewares/eez/gui/touch.h | 33 - Middlewares/eez/gui/touch_calibration.cpp | 168 - Middlewares/eez/gui/touch_calibration.h | 35 - Middlewares/eez/gui/touch_filter.cpp | 278 - Middlewares/eez/gui/touch_filter.h | 33 - Middlewares/eez/gui/update.cpp | 132 - Middlewares/eez/gui/update.h | 34 - Middlewares/eez/gui/widget.cpp | 647 -- Middlewares/eez/gui/widget.h | 306 - Middlewares/eez/gui/widgets/bar_graph.cpp | 382 - Middlewares/eez/gui/widgets/bar_graph.h | 50 - Middlewares/eez/gui/widgets/bitmap.cpp | 73 - Middlewares/eez/gui/widgets/bitmap.h | 37 - Middlewares/eez/gui/widgets/button.cpp | 65 - Middlewares/eez/gui/widgets/button.h | 39 - Middlewares/eez/gui/widgets/button_group.cpp | 146 - Middlewares/eez/gui/widgets/button_group.h | 40 - Middlewares/eez/gui/widgets/canvas.cpp | 47 - Middlewares/eez/gui/widgets/canvas.h | 35 - .../eez/gui/widgets/containers/app_view.cpp | 67 - Middlewares/eez/gui/widgets/containers/app_view.h | 35 - .../eez/gui/widgets/containers/container.cpp | 278 - Middlewares/eez/gui/widgets/containers/container.h | 53 - Middlewares/eez/gui/widgets/containers/grid.cpp | 105 - Middlewares/eez/gui/widgets/containers/grid.h | 38 - .../eez/gui/widgets/containers/layout_view.cpp | 152 - .../eez/gui/widgets/containers/layout_view.h | 49 - Middlewares/eez/gui/widgets/containers/list.cpp | 99 - Middlewares/eez/gui/widgets/containers/list.h | 39 - Middlewares/eez/gui/widgets/containers/select.cpp | 122 - Middlewares/eez/gui/widgets/containers/select.h | 38 - Middlewares/eez/gui/widgets/display_data.cpp | 260 - Middlewares/eez/gui/widgets/display_data.h | 49 - Middlewares/eez/gui/widgets/drop_down_list.cpp | 140 - Middlewares/eez/gui/widgets/drop_down_list.h | 41 - Middlewares/eez/gui/widgets/gauge.cpp | 334 - Middlewares/eez/gui/widgets/gauge.h | 48 - Middlewares/eez/gui/widgets/input.cpp | 206 - Middlewares/eez/gui/widgets/input.h | 62 - Middlewares/eez/gui/widgets/list_graph.cpp | 216 - Middlewares/eez/gui/widgets/list_graph.h | 46 - Middlewares/eez/gui/widgets/multiline_text.cpp | 70 - Middlewares/eez/gui/widgets/multiline_text.h | 39 - Middlewares/eez/gui/widgets/progress.cpp | 90 - Middlewares/eez/gui/widgets/progress.h | 41 - Middlewares/eez/gui/widgets/rectangle.cpp | 50 - Middlewares/eez/gui/widgets/rectangle.h | 41 - Middlewares/eez/gui/widgets/roller.cpp | 302 - Middlewares/eez/gui/widgets/roller.h | 68 - Middlewares/eez/gui/widgets/scroll_bar.cpp | 300 - Middlewares/eez/gui/widgets/scroll_bar.h | 59 - Middlewares/eez/gui/widgets/slider.cpp | 140 - Middlewares/eez/gui/widgets/slider.h | 46 - Middlewares/eez/gui/widgets/switch.cpp | 136 - Middlewares/eez/gui/widgets/switch.h | 40 - Middlewares/eez/gui/widgets/text.cpp | 158 - Middlewares/eez/gui/widgets/text.h | 40 - Middlewares/eez/gui/widgets/toggle_button.cpp | 55 - Middlewares/eez/gui/widgets/toggle_button.h | 37 - Middlewares/eez/gui/widgets/up_down.cpp | 153 - Middlewares/eez/gui/widgets/up_down.h | 56 - Middlewares/eez/gui/widgets/yt_graph.cpp | 615 -- Middlewares/eez/gui/widgets/yt_graph.h | 61 - Middlewares/eez/libs/agg/agg2d.cpp | 1224 --- Middlewares/eez/libs/agg/agg2d.h | 445 - Middlewares/eez/libs/agg/agg_alpha_mask_u8.h | 499 - Middlewares/eez/libs/agg/agg_arc.cpp | 106 - Middlewares/eez/libs/agg/agg_arc.h | 73 - Middlewares/eez/libs/agg/agg_array.h | 1119 -- Middlewares/eez/libs/agg/agg_arrowhead.cpp | 110 - Middlewares/eez/libs/agg/agg_arrowhead.h | 82 - Middlewares/eez/libs/agg/agg_basics.h | 590 -- Middlewares/eez/libs/agg/agg_bezier_arc.cpp | 258 - Middlewares/eez/libs/agg/agg_bezier_arc.h | 159 - Middlewares/eez/libs/agg/agg_bezier_ctrl.h | 196 - Middlewares/eez/libs/agg/agg_bitset_iterator.h | 54 - Middlewares/eez/libs/agg/agg_blur.h | 1505 --- Middlewares/eez/libs/agg/agg_bounding_rect.h | 116 - Middlewares/eez/libs/agg/agg_bspline.cpp | 284 - Middlewares/eez/libs/agg/agg_bspline.h | 76 - Middlewares/eez/libs/agg/agg_cbox_ctrl.h | 112 - Middlewares/eez/libs/agg/agg_clip_liang_barsky.h | 333 - Middlewares/eez/libs/agg/agg_color_gray.h | 1047 -- Middlewares/eez/libs/agg/agg_color_rgba.cpp | 17 - Middlewares/eez/libs/agg/agg_color_rgba.h | 1353 --- Middlewares/eez/libs/agg/agg_config.h | 44 - Middlewares/eez/libs/agg/agg_conv_adaptor_vcgen.h | 157 - Middlewares/eez/libs/agg/agg_conv_adaptor_vpgen.h | 159 - Middlewares/eez/libs/agg/agg_conv_bspline.h | 48 - Middlewares/eez/libs/agg/agg_conv_clip_polygon.h | 63 - Middlewares/eez/libs/agg/agg_conv_clip_polyline.h | 63 - Middlewares/eez/libs/agg/agg_conv_close_polygon.h | 125 - Middlewares/eez/libs/agg/agg_conv_concat.h | 73 - Middlewares/eez/libs/agg/agg_conv_contour.h | 65 - Middlewares/eez/libs/agg/agg_conv_curve.h | 201 - Middlewares/eez/libs/agg/agg_conv_dash.h | 68 - Middlewares/eez/libs/agg/agg_conv_gpc.h | 432 - Middlewares/eez/libs/agg/agg_conv_marker.h | 149 - Middlewares/eez/libs/agg/agg_conv_marker_adaptor.h | 51 - Middlewares/eez/libs/agg/agg_conv_segmentator.h | 48 - Middlewares/eez/libs/agg/agg_conv_shorten_path.h | 50 - Middlewares/eez/libs/agg/agg_conv_smooth_poly1.h | 80 - Middlewares/eez/libs/agg/agg_conv_stroke.h | 73 - Middlewares/eez/libs/agg/agg_conv_transform.h | 68 - .../eez/libs/agg/agg_conv_unclose_polygon.h | 52 - Middlewares/eez/libs/agg/agg_ctrl.h | 118 - Middlewares/eez/libs/agg/agg_curves.cpp | 613 -- Middlewares/eez/libs/agg/agg_curves.h | 693 -- Middlewares/eez/libs/agg/agg_dda_line.h | 290 - Middlewares/eez/libs/agg/agg_ellipse.h | 123 - Middlewares/eez/libs/agg/agg_ellipse_bresenham.h | 113 - .../eez/libs/agg/agg_embedded_raster_fonts.cpp | 10426 ------------------- .../eez/libs/agg/agg_embedded_raster_fonts.h | 59 - Middlewares/eez/libs/agg/agg_font_cache_manager.h | 409 - Middlewares/eez/libs/agg/agg_font_cache_manager2.h | 311 - Middlewares/eez/libs/agg/agg_gamma_ctrl.h | 170 - Middlewares/eez/libs/agg/agg_gamma_functions.h | 131 - Middlewares/eez/libs/agg/agg_gamma_lut.h | 307 - Middlewares/eez/libs/agg/agg_gamma_spline.h | 95 - Middlewares/eez/libs/agg/agg_glyph_raster_bin.h | 155 - Middlewares/eez/libs/agg/agg_gradient_lut.h | 244 - Middlewares/eez/libs/agg/agg_gsv_text.cpp | 677 -- Middlewares/eez/libs/agg/agg_gsv_text.h | 153 - Middlewares/eez/libs/agg/agg_image_accessors.h | 481 - Middlewares/eez/libs/agg/agg_image_filters.cpp | 103 - Middlewares/eez/libs/agg/agg_image_filters.h | 449 - Middlewares/eez/libs/agg/agg_line_aa_basics.cpp | 82 - Middlewares/eez/libs/agg/agg_line_aa_basics.h | 189 - Middlewares/eez/libs/agg/agg_line_profile_aa.cpp | 116 - Middlewares/eez/libs/agg/agg_math.h | 437 - Middlewares/eez/libs/agg/agg_math_stroke.h | 526 - Middlewares/eez/libs/agg/agg_path_length.h | 65 - Middlewares/eez/libs/agg/agg_path_storage.h | 1581 --- .../eez/libs/agg/agg_path_storage_integer.h | 295 - .../eez/libs/agg/agg_pattern_filters_rgba.h | 123 - .../eez/libs/agg/agg_pixfmt_amask_adaptor.h | 240 - Middlewares/eez/libs/agg/agg_pixfmt_base.h | 97 - Middlewares/eez/libs/agg/agg_pixfmt_gray.h | 738 -- Middlewares/eez/libs/agg/agg_pixfmt_rgb.h | 995 -- Middlewares/eez/libs/agg/agg_pixfmt_rgb_packed.h | 1312 --- Middlewares/eez/libs/agg/agg_pixfmt_rgba.h | 2803 ----- Middlewares/eez/libs/agg/agg_pixfmt_transposer.h | 157 - Middlewares/eez/libs/agg/agg_polygon_ctrl.h | 166 - Middlewares/eez/libs/agg/agg_rasterizer_cells_aa.h | 742 -- .../eez/libs/agg/agg_rasterizer_compound_aa.h | 665 -- Middlewares/eez/libs/agg/agg_rasterizer_outline.h | 147 - .../eez/libs/agg/agg_rasterizer_outline_aa.h | 600 -- .../eez/libs/agg/agg_rasterizer_scanline_aa.h | 481 - .../libs/agg/agg_rasterizer_scanline_aa_nogamma.h | 483 - Middlewares/eez/libs/agg/agg_rasterizer_sl_clip.h | 351 - Middlewares/eez/libs/agg/agg_rbox_ctrl.h | 141 - Middlewares/eez/libs/agg/agg_renderer_base.h | 731 -- Middlewares/eez/libs/agg/agg_renderer_markers.h | 711 -- Middlewares/eez/libs/agg/agg_renderer_mclip.h | 349 - Middlewares/eez/libs/agg/agg_renderer_outline_aa.h | 1838 ---- .../eez/libs/agg/agg_renderer_outline_image.h | 1037 -- Middlewares/eez/libs/agg/agg_renderer_primitives.h | 224 - .../eez/libs/agg/agg_renderer_raster_text.h | 264 - Middlewares/eez/libs/agg/agg_renderer_scanline.h | 855 -- Middlewares/eez/libs/agg/agg_rendering_buffer.h | 301 - .../eez/libs/agg/agg_rendering_buffer_dynarow.h | 138 - Middlewares/eez/libs/agg/agg_rounded_rect.cpp | 164 - Middlewares/eez/libs/agg/agg_rounded_rect.h | 72 - Middlewares/eez/libs/agg/agg_scale_ctrl.h | 146 - Middlewares/eez/libs/agg/agg_scanline_bin.h | 264 - .../eez/libs/agg/agg_scanline_boolean_algebra.h | 1566 --- Middlewares/eez/libs/agg/agg_scanline_p.h | 330 - Middlewares/eez/libs/agg/agg_scanline_storage_aa.h | 815 -- .../eez/libs/agg/agg_scanline_storage_bin.h | 585 -- Middlewares/eez/libs/agg/agg_scanline_u.h | 500 - Middlewares/eez/libs/agg/agg_shorten_path.h | 66 - Middlewares/eez/libs/agg/agg_simul_eq.h | 147 - Middlewares/eez/libs/agg/agg_slider_ctrl.h | 150 - Middlewares/eez/libs/agg/agg_span_allocator.h | 54 - Middlewares/eez/libs/agg/agg_span_converter.h | 56 - Middlewares/eez/libs/agg/agg_span_gouraud.h | 172 - Middlewares/eez/libs/agg/agg_span_gouraud_gray.h | 243 - Middlewares/eez/libs/agg/agg_span_gouraud_rgba.h | 278 - Middlewares/eez/libs/agg/agg_span_gradient.h | 376 - Middlewares/eez/libs/agg/agg_span_gradient_alpha.h | 126 - .../eez/libs/agg/agg_span_gradient_contour.h | 364 - Middlewares/eez/libs/agg/agg_span_gradient_image.h | 189 - Middlewares/eez/libs/agg/agg_span_image_filter.h | 247 - .../eez/libs/agg/agg_span_image_filter_gray.h | 723 -- .../eez/libs/agg/agg_span_image_filter_rgb.h | 861 -- .../eez/libs/agg/agg_span_image_filter_rgba.h | 890 -- .../eez/libs/agg/agg_span_interpolator_adaptor.h | 77 - .../eez/libs/agg/agg_span_interpolator_linear.h | 232 - .../eez/libs/agg/agg_span_interpolator_persp.h | 463 - .../eez/libs/agg/agg_span_interpolator_trans.h | 92 - Middlewares/eez/libs/agg/agg_span_pattern_gray.h | 93 - Middlewares/eez/libs/agg/agg_span_pattern_rgb.h | 96 - Middlewares/eez/libs/agg/agg_span_pattern_rgba.h | 94 - Middlewares/eez/libs/agg/agg_span_solid.h | 53 - Middlewares/eez/libs/agg/agg_span_subdiv_adaptor.h | 141 - Middlewares/eez/libs/agg/agg_spline_ctrl.h | 159 - Middlewares/eez/libs/agg/agg_sqrt_tables.cpp | 115 - Middlewares/eez/libs/agg/agg_trans_affine.cpp | 194 - Middlewares/eez/libs/agg/agg_trans_affine.h | 518 - Middlewares/eez/libs/agg/agg_trans_bilinear.h | 166 - Middlewares/eez/libs/agg/agg_trans_double_path.cpp | 273 - Middlewares/eez/libs/agg/agg_trans_double_path.h | 131 - Middlewares/eez/libs/agg/agg_trans_perspective.h | 732 -- Middlewares/eez/libs/agg/agg_trans_single_path.cpp | 202 - Middlewares/eez/libs/agg/agg_trans_single_path.h | 97 - Middlewares/eez/libs/agg/agg_trans_viewport.h | 304 - .../eez/libs/agg/agg_trans_warp_magnifier.cpp | 70 - .../eez/libs/agg/agg_trans_warp_magnifier.h | 56 - Middlewares/eez/libs/agg/agg_vcgen_bspline.cpp | 194 - Middlewares/eez/libs/agg/agg_vcgen_bspline.h | 74 - Middlewares/eez/libs/agg/agg_vcgen_contour.cpp | 164 - Middlewares/eez/libs/agg/agg_vcgen_contour.h | 94 - Middlewares/eez/libs/agg/agg_vcgen_dash.cpp | 235 - Middlewares/eez/libs/agg/agg_vcgen_dash.h | 93 - .../eez/libs/agg/agg_vcgen_markers_term.cpp | 103 - Middlewares/eez/libs/agg/agg_vcgen_markers_term.h | 66 - .../eez/libs/agg/agg_vcgen_smooth_poly1.cpp | 225 - Middlewares/eez/libs/agg/agg_vcgen_smooth_poly1.h | 87 - Middlewares/eez/libs/agg/agg_vcgen_stroke.cpp | 212 - Middlewares/eez/libs/agg/agg_vcgen_stroke.h | 102 - .../eez/libs/agg/agg_vcgen_vertex_sequence.h | 135 - Middlewares/eez/libs/agg/agg_vertex_sequence.h | 172 - .../eez/libs/agg/agg_vpgen_clip_polygon.cpp | 133 - Middlewares/eez/libs/agg/agg_vpgen_clip_polygon.h | 83 - .../eez/libs/agg/agg_vpgen_clip_polyline.cpp | 77 - Middlewares/eez/libs/agg/agg_vpgen_clip_polyline.h | 78 - Middlewares/eez/libs/agg/agg_vpgen_segmentator.cpp | 67 - Middlewares/eez/libs/agg/agg_vpgen_segmentator.h | 60 - Middlewares/eez/libs/date.h | 8200 --------------- Middlewares/eez/libs/libscpi/inc/scpi/cc.h | 205 - Middlewares/eez/libs/libscpi/inc/scpi/config.h | 287 - Middlewares/eez/libs/libscpi/inc/scpi/constants.h | 62 - Middlewares/eez/libs/libscpi/inc/scpi/error.h | 208 - Middlewares/eez/libs/libscpi/inc/scpi/expression.h | 62 - Middlewares/eez/libs/libscpi/inc/scpi/ieee488.h | 94 - Middlewares/eez/libs/libscpi/inc/scpi/minimal.h | 69 - Middlewares/eez/libs/libscpi/inc/scpi/parser.h | 151 - Middlewares/eez/libs/libscpi/inc/scpi/scpi.h | 51 - Middlewares/eez/libs/libscpi/inc/scpi/types.h | 401 - Middlewares/eez/libs/libscpi/inc/scpi/units.h | 60 - Middlewares/eez/libs/libscpi/inc/scpi/utils.h | 62 - Middlewares/eez/libs/libscpi/src/error.c | 234 - Middlewares/eez/libs/libscpi/src/expression.c | 316 - Middlewares/eez/libs/libscpi/src/fifo.c | 146 - Middlewares/eez/libs/libscpi/src/fifo_private.h | 61 - Middlewares/eez/libs/libscpi/src/ieee488.c | 371 - Middlewares/eez/libs/libscpi/src/lexer.c | 935 -- Middlewares/eez/libs/libscpi/src/lexer_private.h | 69 - Middlewares/eez/libs/libscpi/src/minimal.c | 215 - Middlewares/eez/libs/libscpi/src/parser.c | 1834 ---- Middlewares/eez/libs/libscpi/src/parser_private.h | 56 - Middlewares/eez/libs/libscpi/src/scpi.g | 141 - Middlewares/eez/libs/libscpi/src/units.c | 512 - Middlewares/eez/libs/libscpi/src/utils.c | 1142 -- Middlewares/eez/libs/libscpi/src/utils_private.h | 124 - Middlewares/eez/libs/lz4/lz4.c | 2122 ---- Middlewares/eez/libs/lz4/lz4.h | 607 -- Middlewares/eez/libs/utf8.h | 1682 --- Middlewares/eez/platform/stm32/display.cpp | 423 - Middlewares/eez/platform/stm32/touch.cpp | 259 - Middlewares/eez/platform/touch.h | 29 - 377 files changed, 4 insertions(+), 114470 deletions(-) create mode 100644 .gitmodules create mode 160000 Middlewares/eez-framework delete mode 100644 Middlewares/eez/README.md delete mode 100644 Middlewares/eez/core/alloc.cpp delete mode 100644 Middlewares/eez/core/alloc.h delete mode 100644 Middlewares/eez/core/debug.cpp delete mode 100644 Middlewares/eez/core/debug.h delete mode 100644 Middlewares/eez/core/eeprom.cpp delete mode 100644 Middlewares/eez/core/eeprom.h delete mode 100644 Middlewares/eez/core/encoder.h delete mode 100644 Middlewares/eez/core/hmi.cpp delete mode 100644 Middlewares/eez/core/hmi.h delete mode 100644 Middlewares/eez/core/keyboard.h delete mode 100644 Middlewares/eez/core/memory.cpp delete mode 100644 Middlewares/eez/core/memory.h delete mode 100644 Middlewares/eez/core/mouse.h delete mode 100644 Middlewares/eez/core/os.cpp delete mode 100644 Middlewares/eez/core/os.h delete mode 100644 Middlewares/eez/core/sound.h delete mode 100644 Middlewares/eez/core/step_values.h delete mode 100644 Middlewares/eez/core/unit.cpp delete mode 100644 Middlewares/eez/core/unit.h delete mode 100644 Middlewares/eez/core/utf8.h delete mode 100644 Middlewares/eez/core/util.cpp delete mode 100644 Middlewares/eez/core/util.h delete mode 100644 Middlewares/eez/core/value_types.h delete mode 100644 Middlewares/eez/flow/components.cpp delete mode 100644 Middlewares/eez/flow/components.h delete mode 100644 Middlewares/eez/flow/components/animate.cpp delete mode 100644 Middlewares/eez/flow/components/call_action.cpp delete mode 100644 Middlewares/eez/flow/components/call_action.h delete mode 100644 Middlewares/eez/flow/components/catch_error.cpp delete mode 100644 Middlewares/eez/flow/components/compare.cpp delete mode 100644 Middlewares/eez/flow/components/constant.cpp delete mode 100644 Middlewares/eez/flow/components/counter.cpp delete mode 100644 Middlewares/eez/flow/components/delay.cpp delete mode 100644 Middlewares/eez/flow/components/end.cpp delete mode 100644 Middlewares/eez/flow/components/error.cpp delete mode 100644 Middlewares/eez/flow/components/expr_eval.cpp delete mode 100644 Middlewares/eez/flow/components/input.cpp delete mode 100644 Middlewares/eez/flow/components/input.h delete mode 100644 Middlewares/eez/flow/components/is_true.cpp delete mode 100644 Middlewares/eez/flow/components/layout_view_widget.cpp delete mode 100644 Middlewares/eez/flow/components/log.cpp delete mode 100644 Middlewares/eez/flow/components/loop.cpp delete mode 100644 Middlewares/eez/flow/components/noop.cpp delete mode 100644 Middlewares/eez/flow/components/on_event.cpp delete mode 100644 Middlewares/eez/flow/components/output.cpp delete mode 100644 Middlewares/eez/flow/components/roller_widget.cpp delete mode 100644 Middlewares/eez/flow/components/roller_widget.h delete mode 100644 Middlewares/eez/flow/components/select_language.cpp delete mode 100644 Middlewares/eez/flow/components/set_page_direction.cpp delete mode 100644 Middlewares/eez/flow/components/set_variable.cpp delete mode 100644 Middlewares/eez/flow/components/set_variable.h delete mode 100644 Middlewares/eez/flow/components/show_keyboard.cpp delete mode 100644 Middlewares/eez/flow/components/show_keypad.cpp delete mode 100644 Middlewares/eez/flow/components/show_message_box.cpp delete mode 100644 Middlewares/eez/flow/components/show_page.cpp delete mode 100644 Middlewares/eez/flow/components/start.cpp delete mode 100644 Middlewares/eez/flow/components/switch.cpp delete mode 100644 Middlewares/eez/flow/components/switch.h delete mode 100644 Middlewares/eez/flow/components/watch_variable.cpp delete mode 100644 Middlewares/eez/flow/dashboard_api.cpp delete mode 100644 Middlewares/eez/flow/dashboard_api.h delete mode 100644 Middlewares/eez/flow/debugger.cpp delete mode 100644 Middlewares/eez/flow/debugger.h delete mode 100644 Middlewares/eez/flow/expression.cpp delete mode 100644 Middlewares/eez/flow/expression.h delete mode 100644 Middlewares/eez/flow/flow.cpp delete mode 100644 Middlewares/eez/flow/flow.h delete mode 100644 Middlewares/eez/flow/flow_defs_v3.h delete mode 100644 Middlewares/eez/flow/hooks.cpp delete mode 100644 Middlewares/eez/flow/hooks.h delete mode 100644 Middlewares/eez/flow/operations.cpp delete mode 100644 Middlewares/eez/flow/operations.h delete mode 100644 Middlewares/eez/flow/private.cpp delete mode 100644 Middlewares/eez/flow/private.h delete mode 100644 Middlewares/eez/flow/queue.cpp delete mode 100644 Middlewares/eez/flow/queue.h delete mode 100644 Middlewares/eez/fs/fs.h delete mode 100644 Middlewares/eez/fs/stm32/fs.cpp delete mode 100644 Middlewares/eez/gui/action_impl.cpp delete mode 100644 Middlewares/eez/gui/animation.cpp delete mode 100644 Middlewares/eez/gui/animation.h delete mode 100644 Middlewares/eez/gui/app_context.cpp delete mode 100644 Middlewares/eez/gui/app_context.h delete mode 100644 Middlewares/eez/gui/assets.cpp delete mode 100644 Middlewares/eez/gui/assets.h delete mode 100644 Middlewares/eez/gui/assets_fix_offsets.cpp delete mode 100644 Middlewares/eez/gui/data.cpp delete mode 100644 Middlewares/eez/gui/data.h delete mode 100644 Middlewares/eez/gui/display-private.h delete mode 100644 Middlewares/eez/gui/display.cpp delete mode 100644 Middlewares/eez/gui/display.h delete mode 100644 Middlewares/eez/gui/draw.cpp delete mode 100644 Middlewares/eez/gui/draw.h delete mode 100644 Middlewares/eez/gui/event.cpp delete mode 100644 Middlewares/eez/gui/event.h delete mode 100644 Middlewares/eez/gui/font.cpp delete mode 100644 Middlewares/eez/gui/font.h delete mode 100644 Middlewares/eez/gui/geometry.cpp delete mode 100644 Middlewares/eez/gui/geometry.h delete mode 100644 Middlewares/eez/gui/gui.cpp delete mode 100644 Middlewares/eez/gui/gui.h delete mode 100644 Middlewares/eez/gui/hooks.cpp delete mode 100644 Middlewares/eez/gui/hooks.h delete mode 100644 Middlewares/eez/gui/image.h delete mode 100644 Middlewares/eez/gui/keypad.cpp delete mode 100644 Middlewares/eez/gui/keypad.h delete mode 100644 Middlewares/eez/gui/overlay.cpp delete mode 100644 Middlewares/eez/gui/overlay.h delete mode 100644 Middlewares/eez/gui/page.cpp delete mode 100644 Middlewares/eez/gui/page.h delete mode 100644 Middlewares/eez/gui/thread.cpp delete mode 100644 Middlewares/eez/gui/thread.h delete mode 100644 Middlewares/eez/gui/touch.cpp delete mode 100644 Middlewares/eez/gui/touch.h delete mode 100644 Middlewares/eez/gui/touch_calibration.cpp delete mode 100644 Middlewares/eez/gui/touch_calibration.h delete mode 100644 Middlewares/eez/gui/touch_filter.cpp delete mode 100644 Middlewares/eez/gui/touch_filter.h delete mode 100644 Middlewares/eez/gui/update.cpp delete mode 100644 Middlewares/eez/gui/update.h delete mode 100644 Middlewares/eez/gui/widget.cpp delete mode 100644 Middlewares/eez/gui/widget.h delete mode 100644 Middlewares/eez/gui/widgets/bar_graph.cpp delete mode 100644 Middlewares/eez/gui/widgets/bar_graph.h delete mode 100644 Middlewares/eez/gui/widgets/bitmap.cpp delete mode 100644 Middlewares/eez/gui/widgets/bitmap.h delete mode 100644 Middlewares/eez/gui/widgets/button.cpp delete mode 100644 Middlewares/eez/gui/widgets/button.h delete mode 100644 Middlewares/eez/gui/widgets/button_group.cpp delete mode 100644 Middlewares/eez/gui/widgets/button_group.h delete mode 100644 Middlewares/eez/gui/widgets/canvas.cpp delete mode 100644 Middlewares/eez/gui/widgets/canvas.h delete mode 100644 Middlewares/eez/gui/widgets/containers/app_view.cpp delete mode 100644 Middlewares/eez/gui/widgets/containers/app_view.h delete mode 100644 Middlewares/eez/gui/widgets/containers/container.cpp delete mode 100644 Middlewares/eez/gui/widgets/containers/container.h delete mode 100644 Middlewares/eez/gui/widgets/containers/grid.cpp delete mode 100644 Middlewares/eez/gui/widgets/containers/grid.h delete mode 100644 Middlewares/eez/gui/widgets/containers/layout_view.cpp delete mode 100644 Middlewares/eez/gui/widgets/containers/layout_view.h delete mode 100644 Middlewares/eez/gui/widgets/containers/list.cpp delete mode 100644 Middlewares/eez/gui/widgets/containers/list.h delete mode 100644 Middlewares/eez/gui/widgets/containers/select.cpp delete mode 100644 Middlewares/eez/gui/widgets/containers/select.h delete mode 100644 Middlewares/eez/gui/widgets/display_data.cpp delete mode 100644 Middlewares/eez/gui/widgets/display_data.h delete mode 100644 Middlewares/eez/gui/widgets/drop_down_list.cpp delete mode 100644 Middlewares/eez/gui/widgets/drop_down_list.h delete mode 100644 Middlewares/eez/gui/widgets/gauge.cpp delete mode 100644 Middlewares/eez/gui/widgets/gauge.h delete mode 100644 Middlewares/eez/gui/widgets/input.cpp delete mode 100644 Middlewares/eez/gui/widgets/input.h delete mode 100644 Middlewares/eez/gui/widgets/list_graph.cpp delete mode 100644 Middlewares/eez/gui/widgets/list_graph.h delete mode 100644 Middlewares/eez/gui/widgets/multiline_text.cpp delete mode 100644 Middlewares/eez/gui/widgets/multiline_text.h delete mode 100644 Middlewares/eez/gui/widgets/progress.cpp delete mode 100644 Middlewares/eez/gui/widgets/progress.h delete mode 100644 Middlewares/eez/gui/widgets/rectangle.cpp delete mode 100644 Middlewares/eez/gui/widgets/rectangle.h delete mode 100644 Middlewares/eez/gui/widgets/roller.cpp delete mode 100644 Middlewares/eez/gui/widgets/roller.h delete mode 100644 Middlewares/eez/gui/widgets/scroll_bar.cpp delete mode 100644 Middlewares/eez/gui/widgets/scroll_bar.h delete mode 100644 Middlewares/eez/gui/widgets/slider.cpp delete mode 100644 Middlewares/eez/gui/widgets/slider.h delete mode 100644 Middlewares/eez/gui/widgets/switch.cpp delete mode 100644 Middlewares/eez/gui/widgets/switch.h delete mode 100644 Middlewares/eez/gui/widgets/text.cpp delete mode 100644 Middlewares/eez/gui/widgets/text.h delete mode 100644 Middlewares/eez/gui/widgets/toggle_button.cpp delete mode 100644 Middlewares/eez/gui/widgets/toggle_button.h delete mode 100644 Middlewares/eez/gui/widgets/up_down.cpp delete mode 100644 Middlewares/eez/gui/widgets/up_down.h delete mode 100644 Middlewares/eez/gui/widgets/yt_graph.cpp delete mode 100644 Middlewares/eez/gui/widgets/yt_graph.h delete mode 100644 Middlewares/eez/libs/agg/agg2d.cpp delete mode 100644 Middlewares/eez/libs/agg/agg2d.h delete mode 100644 Middlewares/eez/libs/agg/agg_alpha_mask_u8.h delete mode 100644 Middlewares/eez/libs/agg/agg_arc.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_arc.h delete mode 100644 Middlewares/eez/libs/agg/agg_array.h delete mode 100644 Middlewares/eez/libs/agg/agg_arrowhead.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_arrowhead.h delete mode 100644 Middlewares/eez/libs/agg/agg_basics.h delete mode 100644 Middlewares/eez/libs/agg/agg_bezier_arc.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_bezier_arc.h delete mode 100644 Middlewares/eez/libs/agg/agg_bezier_ctrl.h delete mode 100644 Middlewares/eez/libs/agg/agg_bitset_iterator.h delete mode 100644 Middlewares/eez/libs/agg/agg_blur.h delete mode 100644 Middlewares/eez/libs/agg/agg_bounding_rect.h delete mode 100644 Middlewares/eez/libs/agg/agg_bspline.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_bspline.h delete mode 100644 Middlewares/eez/libs/agg/agg_cbox_ctrl.h delete mode 100644 Middlewares/eez/libs/agg/agg_clip_liang_barsky.h delete mode 100644 Middlewares/eez/libs/agg/agg_color_gray.h delete mode 100644 Middlewares/eez/libs/agg/agg_color_rgba.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_color_rgba.h delete mode 100644 Middlewares/eez/libs/agg/agg_config.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_adaptor_vcgen.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_adaptor_vpgen.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_bspline.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_clip_polygon.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_clip_polyline.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_close_polygon.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_concat.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_contour.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_curve.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_dash.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_gpc.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_marker.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_marker_adaptor.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_segmentator.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_shorten_path.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_smooth_poly1.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_stroke.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_transform.h delete mode 100644 Middlewares/eez/libs/agg/agg_conv_unclose_polygon.h delete mode 100644 Middlewares/eez/libs/agg/agg_ctrl.h delete mode 100644 Middlewares/eez/libs/agg/agg_curves.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_curves.h delete mode 100644 Middlewares/eez/libs/agg/agg_dda_line.h delete mode 100644 Middlewares/eez/libs/agg/agg_ellipse.h delete mode 100644 Middlewares/eez/libs/agg/agg_ellipse_bresenham.h delete mode 100644 Middlewares/eez/libs/agg/agg_embedded_raster_fonts.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_embedded_raster_fonts.h delete mode 100644 Middlewares/eez/libs/agg/agg_font_cache_manager.h delete mode 100644 Middlewares/eez/libs/agg/agg_font_cache_manager2.h delete mode 100644 Middlewares/eez/libs/agg/agg_gamma_ctrl.h delete mode 100644 Middlewares/eez/libs/agg/agg_gamma_functions.h delete mode 100644 Middlewares/eez/libs/agg/agg_gamma_lut.h delete mode 100644 Middlewares/eez/libs/agg/agg_gamma_spline.h delete mode 100644 Middlewares/eez/libs/agg/agg_glyph_raster_bin.h delete mode 100644 Middlewares/eez/libs/agg/agg_gradient_lut.h delete mode 100644 Middlewares/eez/libs/agg/agg_gsv_text.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_gsv_text.h delete mode 100644 Middlewares/eez/libs/agg/agg_image_accessors.h delete mode 100644 Middlewares/eez/libs/agg/agg_image_filters.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_image_filters.h delete mode 100644 Middlewares/eez/libs/agg/agg_line_aa_basics.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_line_aa_basics.h delete mode 100644 Middlewares/eez/libs/agg/agg_line_profile_aa.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_math.h delete mode 100644 Middlewares/eez/libs/agg/agg_math_stroke.h delete mode 100644 Middlewares/eez/libs/agg/agg_path_length.h delete mode 100644 Middlewares/eez/libs/agg/agg_path_storage.h delete mode 100644 Middlewares/eez/libs/agg/agg_path_storage_integer.h delete mode 100644 Middlewares/eez/libs/agg/agg_pattern_filters_rgba.h delete mode 100644 Middlewares/eez/libs/agg/agg_pixfmt_amask_adaptor.h delete mode 100644 Middlewares/eez/libs/agg/agg_pixfmt_base.h delete mode 100644 Middlewares/eez/libs/agg/agg_pixfmt_gray.h delete mode 100644 Middlewares/eez/libs/agg/agg_pixfmt_rgb.h delete mode 100644 Middlewares/eez/libs/agg/agg_pixfmt_rgb_packed.h delete mode 100644 Middlewares/eez/libs/agg/agg_pixfmt_rgba.h delete mode 100644 Middlewares/eez/libs/agg/agg_pixfmt_transposer.h delete mode 100644 Middlewares/eez/libs/agg/agg_polygon_ctrl.h delete mode 100644 Middlewares/eez/libs/agg/agg_rasterizer_cells_aa.h delete mode 100644 Middlewares/eez/libs/agg/agg_rasterizer_compound_aa.h delete mode 100644 Middlewares/eez/libs/agg/agg_rasterizer_outline.h delete mode 100644 Middlewares/eez/libs/agg/agg_rasterizer_outline_aa.h delete mode 100644 Middlewares/eez/libs/agg/agg_rasterizer_scanline_aa.h delete mode 100644 Middlewares/eez/libs/agg/agg_rasterizer_scanline_aa_nogamma.h delete mode 100644 Middlewares/eez/libs/agg/agg_rasterizer_sl_clip.h delete mode 100644 Middlewares/eez/libs/agg/agg_rbox_ctrl.h delete mode 100644 Middlewares/eez/libs/agg/agg_renderer_base.h delete mode 100644 Middlewares/eez/libs/agg/agg_renderer_markers.h delete mode 100644 Middlewares/eez/libs/agg/agg_renderer_mclip.h delete mode 100644 Middlewares/eez/libs/agg/agg_renderer_outline_aa.h delete mode 100644 Middlewares/eez/libs/agg/agg_renderer_outline_image.h delete mode 100644 Middlewares/eez/libs/agg/agg_renderer_primitives.h delete mode 100644 Middlewares/eez/libs/agg/agg_renderer_raster_text.h delete mode 100644 Middlewares/eez/libs/agg/agg_renderer_scanline.h delete mode 100644 Middlewares/eez/libs/agg/agg_rendering_buffer.h delete mode 100644 Middlewares/eez/libs/agg/agg_rendering_buffer_dynarow.h delete mode 100644 Middlewares/eez/libs/agg/agg_rounded_rect.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_rounded_rect.h delete mode 100644 Middlewares/eez/libs/agg/agg_scale_ctrl.h delete mode 100644 Middlewares/eez/libs/agg/agg_scanline_bin.h delete mode 100644 Middlewares/eez/libs/agg/agg_scanline_boolean_algebra.h delete mode 100644 Middlewares/eez/libs/agg/agg_scanline_p.h delete mode 100644 Middlewares/eez/libs/agg/agg_scanline_storage_aa.h delete mode 100644 Middlewares/eez/libs/agg/agg_scanline_storage_bin.h delete mode 100644 Middlewares/eez/libs/agg/agg_scanline_u.h delete mode 100644 Middlewares/eez/libs/agg/agg_shorten_path.h delete mode 100644 Middlewares/eez/libs/agg/agg_simul_eq.h delete mode 100644 Middlewares/eez/libs/agg/agg_slider_ctrl.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_allocator.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_converter.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_gouraud.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_gouraud_gray.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_gouraud_rgba.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_gradient.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_gradient_alpha.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_gradient_contour.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_gradient_image.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_image_filter.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_image_filter_gray.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_image_filter_rgb.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_image_filter_rgba.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_interpolator_adaptor.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_interpolator_linear.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_interpolator_persp.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_interpolator_trans.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_pattern_gray.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_pattern_rgb.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_pattern_rgba.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_solid.h delete mode 100644 Middlewares/eez/libs/agg/agg_span_subdiv_adaptor.h delete mode 100644 Middlewares/eez/libs/agg/agg_spline_ctrl.h delete mode 100644 Middlewares/eez/libs/agg/agg_sqrt_tables.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_trans_affine.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_trans_affine.h delete mode 100644 Middlewares/eez/libs/agg/agg_trans_bilinear.h delete mode 100644 Middlewares/eez/libs/agg/agg_trans_double_path.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_trans_double_path.h delete mode 100644 Middlewares/eez/libs/agg/agg_trans_perspective.h delete mode 100644 Middlewares/eez/libs/agg/agg_trans_single_path.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_trans_single_path.h delete mode 100644 Middlewares/eez/libs/agg/agg_trans_viewport.h delete mode 100644 Middlewares/eez/libs/agg/agg_trans_warp_magnifier.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_trans_warp_magnifier.h delete mode 100644 Middlewares/eez/libs/agg/agg_vcgen_bspline.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_vcgen_bspline.h delete mode 100644 Middlewares/eez/libs/agg/agg_vcgen_contour.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_vcgen_contour.h delete mode 100644 Middlewares/eez/libs/agg/agg_vcgen_dash.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_vcgen_dash.h delete mode 100644 Middlewares/eez/libs/agg/agg_vcgen_markers_term.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_vcgen_markers_term.h delete mode 100644 Middlewares/eez/libs/agg/agg_vcgen_smooth_poly1.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_vcgen_smooth_poly1.h delete mode 100644 Middlewares/eez/libs/agg/agg_vcgen_stroke.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_vcgen_stroke.h delete mode 100644 Middlewares/eez/libs/agg/agg_vcgen_vertex_sequence.h delete mode 100644 Middlewares/eez/libs/agg/agg_vertex_sequence.h delete mode 100644 Middlewares/eez/libs/agg/agg_vpgen_clip_polygon.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_vpgen_clip_polygon.h delete mode 100644 Middlewares/eez/libs/agg/agg_vpgen_clip_polyline.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_vpgen_clip_polyline.h delete mode 100644 Middlewares/eez/libs/agg/agg_vpgen_segmentator.cpp delete mode 100644 Middlewares/eez/libs/agg/agg_vpgen_segmentator.h delete mode 100644 Middlewares/eez/libs/date.h delete mode 100644 Middlewares/eez/libs/libscpi/inc/scpi/cc.h delete mode 100644 Middlewares/eez/libs/libscpi/inc/scpi/config.h delete mode 100644 Middlewares/eez/libs/libscpi/inc/scpi/constants.h delete mode 100644 Middlewares/eez/libs/libscpi/inc/scpi/error.h delete mode 100644 Middlewares/eez/libs/libscpi/inc/scpi/expression.h delete mode 100644 Middlewares/eez/libs/libscpi/inc/scpi/ieee488.h delete mode 100644 Middlewares/eez/libs/libscpi/inc/scpi/minimal.h delete mode 100644 Middlewares/eez/libs/libscpi/inc/scpi/parser.h delete mode 100644 Middlewares/eez/libs/libscpi/inc/scpi/scpi.h delete mode 100644 Middlewares/eez/libs/libscpi/inc/scpi/types.h delete mode 100644 Middlewares/eez/libs/libscpi/inc/scpi/units.h delete mode 100644 Middlewares/eez/libs/libscpi/inc/scpi/utils.h delete mode 100644 Middlewares/eez/libs/libscpi/src/error.c delete mode 100644 Middlewares/eez/libs/libscpi/src/expression.c delete mode 100644 Middlewares/eez/libs/libscpi/src/fifo.c delete mode 100644 Middlewares/eez/libs/libscpi/src/fifo_private.h delete mode 100644 Middlewares/eez/libs/libscpi/src/ieee488.c delete mode 100644 Middlewares/eez/libs/libscpi/src/lexer.c delete mode 100644 Middlewares/eez/libs/libscpi/src/lexer_private.h delete mode 100644 Middlewares/eez/libs/libscpi/src/minimal.c delete mode 100644 Middlewares/eez/libs/libscpi/src/parser.c delete mode 100644 Middlewares/eez/libs/libscpi/src/parser_private.h delete mode 100644 Middlewares/eez/libs/libscpi/src/scpi.g delete mode 100644 Middlewares/eez/libs/libscpi/src/units.c delete mode 100644 Middlewares/eez/libs/libscpi/src/utils.c delete mode 100644 Middlewares/eez/libs/libscpi/src/utils_private.h delete mode 100644 Middlewares/eez/libs/lz4/lz4.c delete mode 100644 Middlewares/eez/libs/lz4/lz4.h delete mode 100644 Middlewares/eez/libs/utf8.h delete mode 100644 Middlewares/eez/platform/stm32/display.cpp delete mode 100644 Middlewares/eez/platform/stm32/touch.cpp delete mode 100644 Middlewares/eez/platform/touch.h diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a1e37cb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Middlewares/eez-framework"] + path = Middlewares/eez-framework + url = https://github.com/eez-open/eez-framework.git diff --git a/Middlewares/eez-framework b/Middlewares/eez-framework new file mode 160000 index 0000000..d317ba7 --- /dev/null +++ b/Middlewares/eez-framework @@ -0,0 +1 @@ +Subproject commit d317ba7f91a27ac03b20dedb4d2584c61d2f11ae diff --git a/Middlewares/eez/README.md b/Middlewares/eez/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/Middlewares/eez/core/alloc.cpp b/Middlewares/eez/core/alloc.cpp deleted file mode 100644 index 0bd3301..0000000 --- a/Middlewares/eez/core/alloc.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include - -#include -#include - -namespace eez { - -static const size_t ALIGNMENT = 8; -static const size_t MIN_BLOCK_SIZE = 8; - -struct AllocBlock { - AllocBlock *next; - int free; - size_t size; - uint32_t id; -}; - -static uint8_t *g_heap; - -#if defined(EEZ_PLATFORM_STM32) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wparentheses" -#endif - -EEZ_MUTEX_DECLARE(alloc); - -#if defined(EEZ_PLATFORM_STM32) -#pragma GCC diagnostic pop -#endif - -void initAllocHeap(uint8_t *heap, size_t heapSize) { - g_heap = heap; - - AllocBlock *first = (AllocBlock *)g_heap; - first->next = 0; - first->free = 1; - first->size = heapSize - sizeof(AllocBlock); - - EEZ_MUTEX_CREATE(alloc); -} - -void *alloc(size_t size, uint32_t id) { - if (size == 0) { - return nullptr; - } - - if (EEZ_MUTEX_WAIT(alloc, 0)) { - AllocBlock *firstBlock = (AllocBlock *)g_heap; - - AllocBlock *block = firstBlock; - size = ((size + ALIGNMENT - 1) / ALIGNMENT) * ALIGNMENT; - - // find free block with enough size - // TODO merge multiple free consecutive blocks into one that has enough size - while (block) { - if (block->free && block->size >= size) { - break; - } - block = block->next; - } - - if (!block) { - EEZ_MUTEX_RELEASE(alloc); - return nullptr; - } - - int remainingSize = block->size - size - sizeof(AllocBlock); - if (remainingSize >= (int)MIN_BLOCK_SIZE) { - // remainingSize is enough to create a new block - auto newBlock = (AllocBlock *)((uint8_t *)block + sizeof(AllocBlock) + size); - newBlock->next = block->next; - newBlock->free = 1; - newBlock->size = remainingSize; - - block->next = newBlock; - block->size = size; - } - - block->free = 0; - block->id = id; - - EEZ_MUTEX_RELEASE(alloc); - - return block + 1; - } - - return nullptr; -} - -void free(void *ptr) { - if (ptr == 0) { - return; - } - - if (EEZ_MUTEX_WAIT(alloc, 0)) { - AllocBlock *firstBlock = (AllocBlock *)g_heap; - - AllocBlock *prevBlock = nullptr; - AllocBlock *block = firstBlock; - - while (block && block + 1 < ptr) { - prevBlock = block; - block = block->next; - } - - if (!block || block + 1 != ptr || block->free) { - assert(false); - EEZ_MUTEX_RELEASE(alloc); - return; - } - - // reset memory to catch errors when memory is used after free is called - memset(ptr, 0xCC, block->size); - - auto nextBlock = block->next; - if (nextBlock && nextBlock->free) { - if (prevBlock && prevBlock->free) { - // both next and prev blocks are free, merge 3 blocks into one - prevBlock->next = nextBlock->next; - prevBlock->size += sizeof(AllocBlock) + block->size + sizeof(AllocBlock) + nextBlock->size; - } else { - // next block is free, merge 2 blocks into one - block->next = nextBlock->next; - block->size += sizeof(AllocBlock) + nextBlock->size; - block->free = 1; - } - } else if (prevBlock && prevBlock->free) { - // prev block is free, merge 2 blocks into one - prevBlock->next = nextBlock; - prevBlock->size += sizeof(AllocBlock) + block->size; - } else { - // just free - block->free = 1; - } - - EEZ_MUTEX_RELEASE(alloc); - } -} - -template void freeObject(T *ptr) { - ptr->~T(); - free(ptr); -} - -#if OPTION_SCPI -void dumpAlloc(scpi_t *context) { - AllocBlock *first = (AllocBlock *)g_heap; - AllocBlock *block = first; - while (block) { - char buffer[100]; - if (block->free) { - snprintf(buffer, sizeof(buffer), "FREE: %d", (int)block->size); - } else { - snprintf(buffer, sizeof(buffer), "ALOC (0x%08x): %d", (unsigned int)block->id, (int)block->size); - } - SCPI_ResultText(context, buffer); - block = block->next; - } -} -#endif - -void getAllocInfo(uint32_t &free, uint32_t &alloc) { - free = 0; - alloc = 0; - if (EEZ_MUTEX_WAIT(alloc, 0)) { - AllocBlock *first = (AllocBlock *)g_heap; - AllocBlock *block = first; - while (block) { - if (block->free) { - free += block->size; - } else { - alloc += block->size; - } - block = block->next; - } - EEZ_MUTEX_RELEASE(alloc); - } -} - -} // eez diff --git a/Middlewares/eez/core/alloc.h b/Middlewares/eez/core/alloc.h deleted file mode 100644 index bd36383..0000000 --- a/Middlewares/eez/core/alloc.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2021-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include -#include -#include - -#if OPTION_SCPI -#include -#endif - -namespace eez { - -void initAllocHeap(uint8_t *heap, size_t heapSize); - -void *alloc(size_t size, uint32_t id); -void free(void *ptr); - -template struct ObjectAllocator { - static T *allocate(uint32_t id) { - auto ptr = alloc(sizeof(T), id); - return new (ptr) T; - } - static void deallocate(T* ptr) { - ptr->~T(); - free(ptr); - } -}; - -#if OPTION_SCPI -void dumpAlloc(scpi_t *context); -#endif - -void getAllocInfo(uint32_t &free, uint32_t &alloc); - -} // eez \ No newline at end of file diff --git a/Middlewares/eez/core/debug.cpp b/Middlewares/eez/core/debug.cpp deleted file mode 100644 index 47cd0ee..0000000 --- a/Middlewares/eez/core/debug.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2018-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#ifdef DEBUG - -#include -#include -#include - -#include - -namespace eez { -namespace debug { - -void Trace(TraceType traceType, const char *format, ...) { - va_list args; - va_start(args, format); - - static const size_t BUFFER_SIZE = 256; - char buffer[BUFFER_SIZE + 1]; - - vsnprintf(buffer, BUFFER_SIZE, format, args); - buffer[BUFFER_SIZE] = 0; - - va_end(args); - - if (traceType == TRACE_TYPE_DEBUG) { - pushDebugTraceHook(buffer, strlen(buffer)); - } else if (traceType == TRACE_TYPE_INFO) { - pushInfoTraceHook(buffer, strlen(buffer)); - } else { - pushErrorTraceHook(buffer, strlen(buffer)); - } -} - -} // namespace debug -} // namespace eez - -extern "C" void debug_trace(const char *str, size_t len) { - eez::debug::pushDebugTraceHook(str, len); -} - -#endif // DEBUG diff --git a/Middlewares/eez/core/debug.h b/Middlewares/eez/core/debug.h deleted file mode 100644 index 3a8485d..0000000 --- a/Middlewares/eez/core/debug.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2018-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#ifdef DEBUG - -#include -#include - -namespace eez { -namespace debug { - -void pushDebugTraceHook(const char *message, size_t messageLength); -void pushInfoTraceHook(const char *message, size_t messageLength); -void pushErrorTraceHook(const char *message, size_t messageLength); - -enum TraceType { - TRACE_TYPE_DEBUG, - TRACE_TYPE_INFO, - TRACE_TYPE_ERROR -}; - -void Trace(TraceType traceType, const char *format, ...); - -} // namespace debug -} // namespace eez - -#define InfoTrace(...) ::eez::debug::Trace(::eez::debug::TRACE_TYPE_INFO, __VA_ARGS__) -#define ErrorTrace(...) ::eez::debug::Trace(::eez::debug::TRACE_TYPE_ERROR, __VA_ARGS__) -#define DebugTrace(...) ::eez::debug::Trace(::eez::debug::TRACE_TYPE_DEBUG, __VA_ARGS__) - -#else // NO DEBUG - -#define InfoTrace(...) 0 -#define ErrorTrace(...) 0 -#define DebugTrace(...) 0 - -#endif diff --git a/Middlewares/eez/core/eeprom.cpp b/Middlewares/eez/core/eeprom.cpp deleted file mode 100644 index 4212588..0000000 --- a/Middlewares/eez/core/eeprom.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2015-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include -#include -#include - -//#include -//#include - -#if defined(EEZ_PLATFORM_STM32) && !CONF_SURVIVE_MODE -#define USE_EEPROM 1 -#else -#define USE_EEPROM 0 -#endif - -#if defined(EEZ_PLATFORM_STM32) -#ifdef EEZ_PLATFORM_STM32F469I_DISCO -#else -#include -#endif -#endif - -#if !USE_EEPROM -#include -#endif - -#if OPTION_SCPI -#include -#endif - -namespace eez { -namespace eeprom { - -#if defined(EEZ_PLATFORM_STM32) -// opcodes -static const uint8_t WREN = 6; -static const uint8_t WRDI = 4; -static const uint8_t RDSR = 5; -static const uint8_t WRSR = 1; -static const uint8_t READ = 3; -static const uint8_t WRITE = 2; - -// EEPROM AT24C256C -// I2C-Compatible (2-Wire) Serial EEPROM -// 256-Kbit (32,768 x 8) -// http://ww1.microchip.com/downloads/en/devicedoc/atmel-8568-seeprom-at24c256c-datasheet.pdf -static const uint16_t EEPROM_ADDRESS = 0b10100000; -#endif - -TestResult g_testResult = TEST_FAILED; - -//////////////////////////////////////////////////////////////////////////////// - -#if defined(EEZ_PLATFORM_STM32) - -const int MAX_READ_CHUNK_SIZE = 16; -const int MAX_WRITE_CHUNK_SIZE = 16; - -bool readFromEEPROM(uint8_t *buffer, uint16_t bufferSize, uint16_t address) { -#ifdef EEZ_PLATFORM_STM32F469I_DISCO - return false; -#else - for (uint16_t i = 0; i < bufferSize; i += MAX_READ_CHUNK_SIZE) { - uint16_t chunkAddress = address + i; - - uint16_t chunkSize = MIN(MAX_READ_CHUNK_SIZE, bufferSize - i); - - uint8_t data[2] = { - I2C_MEM_ADD_MSB(chunkAddress), - I2C_MEM_ADD_LSB(chunkAddress) - }; - - HAL_StatusTypeDef returnValue; - - taskENTER_CRITICAL(); - returnValue = HAL_I2C_Master_Transmit(&hi2c1, EEPROM_ADDRESS, data, 2, HAL_MAX_DELAY); - if (returnValue != HAL_OK) { - taskEXIT_CRITICAL(); - return false; - } - returnValue = HAL_I2C_Master_Receive(&hi2c1, EEPROM_ADDRESS, buffer + i, chunkSize, HAL_MAX_DELAY); - taskEXIT_CRITICAL(); - if (returnValue != HAL_OK) { - return false; - } - } - - return true; -#endif -} - -bool writeToEEPROM(const uint8_t *buffer, uint16_t bufferSize, uint16_t address) { -#ifdef EEZ_PLATFORM_STM32F469I_DISCO - return false; -#else - for (uint16_t i = 0; i < bufferSize; i += MAX_WRITE_CHUNK_SIZE) { - uint16_t chunkAddress = address + i; - - uint16_t chunkSize = MIN(MAX_WRITE_CHUNK_SIZE, bufferSize - i); - - HAL_StatusTypeDef returnValue; - - taskENTER_CRITICAL(); - returnValue = HAL_I2C_Mem_Write(&hi2c1, EEPROM_ADDRESS, chunkAddress, I2C_MEMADD_SIZE_16BIT, (uint8_t *)buffer + i, chunkSize, HAL_MAX_DELAY); - taskEXIT_CRITICAL(); - - if (returnValue != HAL_OK) { - return false; - } - - osDelay(5); - - // verify - uint8_t verify[MAX_WRITE_CHUNK_SIZE]; - - uint8_t data[2] = { - I2C_MEM_ADD_MSB(chunkAddress), - I2C_MEM_ADD_LSB(chunkAddress) - }; - - taskENTER_CRITICAL(); - returnValue = HAL_I2C_Master_Transmit(&hi2c1, EEPROM_ADDRESS, data, 2, HAL_MAX_DELAY); - if (returnValue != HAL_OK) { - taskEXIT_CRITICAL(); - return false; - } - returnValue = HAL_I2C_Master_Receive(&hi2c1, EEPROM_ADDRESS, verify, chunkSize, HAL_MAX_DELAY); - taskEXIT_CRITICAL(); - if (returnValue != HAL_OK) { - return false; - } - - for (int j = 0; j < chunkSize; ++j) { - if (buffer[i+j] != verify[j]) { - return false; - } - } - } - - return true; -#endif -} - -#endif - -#if !USE_EEPROM -const char *EEPROM_FILE_PATH = "/EEPROM.state"; -#endif - -bool read(uint8_t *buffer, uint16_t bufferSize, uint16_t address) { -#if USE_EEPROM - return readFromEEPROM(buffer, bufferSize, address); -#else - File file; - if (!file.open(EEPROM_FILE_PATH, FILE_READ)) { - return false; - } - file.seek(address); - size_t readBytes = file.read(buffer, bufferSize); - if (readBytes < bufferSize) { - memset(buffer + readBytes, 0xFF, bufferSize - readBytes); - } - file.close(); - return true; -#endif -} - -bool write(const uint8_t *buffer, uint16_t bufferSize, uint16_t address) { -#if USE_EEPROM - return writeToEEPROM(buffer, bufferSize, address); -#else - File file; - if (!file.open(EEPROM_FILE_PATH, FILE_OPEN_ALWAYS | FILE_WRITE)) { - return false; - } - file.seek(address); - file.write(buffer, bufferSize); - file.close(); - return true; -#endif -} - -void init() { - g_testResult = TEST_OK; -} - -bool test() { - // TODO add test - return g_testResult == TEST_OK; -} - -} // namespace eeprom -} // namespace eez diff --git a/Middlewares/eez/core/eeprom.h b/Middlewares/eez/core/eeprom.h deleted file mode 100644 index 403ea84..0000000 --- a/Middlewares/eez/core/eeprom.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2015-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include - -#include - -namespace eez { -namespace eeprom { - -static const uint16_t EEPROM_SIZE = 32768; - -void init(); -bool test(); - -extern TestResult g_testResult; - -bool read(uint8_t *buffer, uint16_t buffer_size, uint16_t address); -bool write(const uint8_t *buffer, uint16_t buffer_size, uint16_t address); - -} // namespace eeprom -} // namespace eez diff --git a/Middlewares/eez/core/encoder.h b/Middlewares/eez/core/encoder.h deleted file mode 100644 index 7c3429d..0000000 --- a/Middlewares/eez/core/encoder.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -namespace eez { -namespace mcu { -namespace encoder { - -#if defined(EEZ_PLATFORM_SIMULATOR) -void write(int counter, bool clicked); -void setButtonState(bool pressed); -#endif - -} // namespace encoder -} // namespace mcu -} // namespace eez diff --git a/Middlewares/eez/core/hmi.cpp b/Middlewares/eez/core/hmi.cpp deleted file mode 100644 index acd817b..0000000 --- a/Middlewares/eez/core/hmi.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* -* EEZ PSU Firmware -* Copyright (C) 2015-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#include -#include - -namespace eez { -namespace hmi { - -#define MAX_GUI_OR_ENCODER_INACTIVITY_TIME_MS 60 * 1000 - -static uint32_t g_timeOfLastActivity; -static bool g_inactivityTimeMaxed = true; - -void tick() { - if (!g_inactivityTimeMaxed) { - uint32_t inactivityPeriod = getInactivityPeriodMs(); - if (inactivityPeriod >= MAX_GUI_OR_ENCODER_INACTIVITY_TIME_MS) { - g_inactivityTimeMaxed = true; - } - } -} - -void noteActivity() { - g_timeOfLastActivity = millis(); - g_inactivityTimeMaxed = false; -} - -uint32_t getInactivityPeriodMs() { - if (g_inactivityTimeMaxed) { - return MAX_GUI_OR_ENCODER_INACTIVITY_TIME_MS; - } else { - return millis() - g_timeOfLastActivity; - } -} - -uint32_t getTimeOfLastActivity() { - if (g_inactivityTimeMaxed) { - return millis() - MAX_GUI_OR_ENCODER_INACTIVITY_TIME_MS; - } else { - return g_timeOfLastActivity; - } -} - -} // namespace hmi -} // namespace eez \ No newline at end of file diff --git a/Middlewares/eez/core/hmi.h b/Middlewares/eez/core/hmi.h deleted file mode 100644 index 1b4e78a..0000000 --- a/Middlewares/eez/core/hmi.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -* EEZ PSU Firmware -* Copyright (C) 2017-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include - -namespace eez { -namespace hmi { - -void tick(); - -void noteActivity(); -uint32_t getInactivityPeriodMs(); -uint32_t getTimeOfLastActivity(); - -} -} // namespace eez::hmi diff --git a/Middlewares/eez/core/keyboard.h b/Middlewares/eez/core/keyboard.h deleted file mode 100644 index 59d3c98..0000000 --- a/Middlewares/eez/core/keyboard.h +++ /dev/null @@ -1,285 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2020-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include - -#include - -#if defined(EEZ_PLATFORM_STM32) -#if OPTION_KEYBOARD -#include -#endif -#endif - -#if defined(EEZ_PLATFORM_SIMULATOR) && !defined(__EMSCRIPTEN__) -#include -#endif - -namespace eez { -namespace keyboard { - -#if defined(EEZ_PLATFORM_STM32) -#if OPTION_KEYBOARD -void onKeyboardEvent(USBH_HandleTypeDef *phost); -#endif -#endif - -#if defined(EEZ_PLATFORM_SIMULATOR) && !defined(__EMSCRIPTEN__) -void onKeyboardEvent(SDL_KeyboardEvent *key); -#endif - -bool isDisplayDirty(); -void updateDisplay(); - -void onPageChanged(); - -static const uint8_t KEY_MOD_LCTRL = 1 << 0; -static const uint8_t KEY_MOD_LSHIFT = 1 << 1; -static const uint8_t KEY_MOD_LALT = 1 << 2; -static const uint8_t KEY_MOD_LGUI = 1 << 3; -static const uint8_t KEY_MOD_RCTRL = 1 << 4; -static const uint8_t KEY_MOD_RSHIFT = 1 << 5; -static const uint8_t KEY_MOD_RALT = 1 << 6; -static const uint8_t KEY_MOD_RGUI = 1 << 7; - -#if defined(EEZ_PLATFORM_SIMULATOR) -#define KEY_NONE 0x00 -#define KEY_ERRORROLLOVER 0x01 -#define KEY_POSTFAIL 0x02 -#define KEY_ERRORUNDEFINED 0x03 -#define KEY_A 0x04 -#define KEY_B 0x05 -#define KEY_C 0x06 -#define KEY_D 0x07 -#define KEY_E 0x08 -#define KEY_F 0x09 -#define KEY_G 0x0A -#define KEY_H 0x0B -#define KEY_I 0x0C -#define KEY_J 0x0D -#define KEY_K 0x0E -#define KEY_L 0x0F -#define KEY_M 0x10 -#define KEY_N 0x11 -#define KEY_O 0x12 -#define KEY_P 0x13 -#define KEY_Q 0x14 -#define KEY_R 0x15 -#define KEY_S 0x16 -#define KEY_T 0x17 -#define KEY_U 0x18 -#define KEY_V 0x19 -#define KEY_W 0x1A -#define KEY_X 0x1B -#define KEY_Y 0x1C -#define KEY_Z 0x1D -#define KEY_1_EXCLAMATION_MARK 0x1E -#define KEY_2_AT 0x1F -#define KEY_3_NUMBER_SIGN 0x20 -#define KEY_4_DOLLAR 0x21 -#define KEY_5_PERCENT 0x22 -#define KEY_6_CARET 0x23 -#define KEY_7_AMPERSAND 0x24 -#define KEY_8_ASTERISK 0x25 -#define KEY_9_OPARENTHESIS 0x26 -#define KEY_0_CPARENTHESIS 0x27 -#define KEY_ENTER 0x28 -#define KEY_ESCAPE 0x29 -#define KEY_BACKSPACE 0x2A -#define KEY_TAB 0x2B -#define KEY_SPACEBAR 0x2C -#define KEY_MINUS_UNDERSCORE 0x2D -#define KEY_EQUAL_PLUS 0x2E -#define KEY_OBRACKET_AND_OBRACE 0x2F -#define KEY_CBRACKET_AND_CBRACE 0x30 -#define KEY_BACKSLASH_VERTICAL_BAR 0x31 -#define KEY_NONUS_NUMBER_SIGN_TILDE 0x32 -#define KEY_SEMICOLON_COLON 0x33 -#define KEY_SINGLE_AND_DOUBLE_QUOTE 0x34 -#define KEY_GRAVE ACCENT AND TILDE 0x35 -#define KEY_COMMA_AND_LESS 0x36 -#define KEY_DOT_GREATER 0x37 -#define KEY_SLASH_QUESTION 0x38 -#define KEY_CAPS LOCK 0x39 -#define KEY_F1 0x3A -#define KEY_F2 0x3B -#define KEY_F3 0x3C -#define KEY_F4 0x3D -#define KEY_F5 0x3E -#define KEY_F6 0x3F -#define KEY_F7 0x40 -#define KEY_F8 0x41 -#define KEY_F9 0x42 -#define KEY_F10 0x43 -#define KEY_F11 0x44 -#define KEY_F12 0x45 -#define KEY_PRINTSCREEN 0x46 -#define KEY_SCROLL LOCK 0x47 -#define KEY_PAUSE 0x48 -#define KEY_INSERT 0x49 -#define KEY_HOME 0x4A -#define KEY_PAGEUP 0x4B -#define KEY_DELETE 0x4C -#define KEY_END1 0x4D -#define KEY_PAGEDOWN 0x4E -#define KEY_RIGHTARROW 0x4F -#define KEY_LEFTARROW 0x50 -#define KEY_DOWNARROW 0x51 -#define KEY_UPARROW 0x52 -#define KEY_KEYPAD_NUM_LOCK_AND_CLEAR 0x53 -#define KEY_KEYPAD_SLASH 0x54 -#define KEY_KEYPAD_ASTERIKS 0x55 -#define KEY_KEYPAD_MINUS 0x56 -#define KEY_KEYPAD_PLUS 0x57 -#define KEY_KEYPAD_ENTER 0x58 -#define KEY_KEYPAD_1_END 0x59 -#define KEY_KEYPAD_2_DOWN_ARROW 0x5A -#define KEY_KEYPAD_3_PAGEDN 0x5B -#define KEY_KEYPAD_4_LEFT_ARROW 0x5C -#define KEY_KEYPAD_5 0x5D -#define KEY_KEYPAD_6_RIGHT_ARROW 0x5E -#define KEY_KEYPAD_7_HOME 0x5F -#define KEY_KEYPAD_8_UP_ARROW 0x60 -#define KEY_KEYPAD_9_PAGEUP 0x61 -#define KEY_KEYPAD_0_INSERT 0x62 -#define KEY_KEYPAD_DECIMAL_SEPARATOR_DELETE 0x63 -#define KEY_NONUS_BACK_SLASH_VERTICAL_BAR 0x64 -#define KEY_APPLICATION 0x65 -#define KEY_POWER 0x66 -#define KEY_KEYPAD_EQUAL 0x67 -#define KEY_F13 0x68 -#define KEY_F14 0x69 -#define KEY_F15 0x6A -#define KEY_F16 0x6B -#define KEY_F17 0x6C -#define KEY_F18 0x6D -#define KEY_F19 0x6E -#define KEY_F20 0x6F -#define KEY_F21 0x70 -#define KEY_F22 0x71 -#define KEY_F23 0x72 -#define KEY_F24 0x73 -// #define KEY_EXECUTE 0x74 -#define KEY_HELP 0x75 -#define KEY_MENU 0x76 -#define KEY_SELECT 0x77 -#define KEY_STOP 0x78 -#define KEY_AGAIN 0x79 -#define KEY_UNDO 0x7A -#define KEY_CUT 0x7B -#define KEY_COPY 0x7C -#define KEY_PASTE 0x7D -#define KEY_FIND 0x7E -#define KEY_MUTE 0x7F -#define KEY_VOLUME_UP 0x80 -#define KEY_VOLUME_DOWN 0x81 -#define KEY_LOCKING_CAPS_LOCK 0x82 -#define KEY_LOCKING_NUM_LOCK 0x83 -#define KEY_LOCKING_SCROLL_LOCK 0x84 -#define KEY_KEYPAD_COMMA 0x85 -#define KEY_KEYPAD_EQUAL_SIGN 0x86 -#define KEY_INTERNATIONAL1 0x87 -#define KEY_INTERNATIONAL2 0x88 -#define KEY_INTERNATIONAL3 0x89 -#define KEY_INTERNATIONAL4 0x8A -#define KEY_INTERNATIONAL5 0x8B -#define KEY_INTERNATIONAL6 0x8C -#define KEY_INTERNATIONAL7 0x8D -#define KEY_INTERNATIONAL8 0x8E -#define KEY_INTERNATIONAL9 0x8F -#define KEY_LANG1 0x90 -#define KEY_LANG2 0x91 -#define KEY_LANG3 0x92 -#define KEY_LANG4 0x93 -#define KEY_LANG5 0x94 -#define KEY_LANG6 0x95 -#define KEY_LANG7 0x96 -#define KEY_LANG8 0x97 -#define KEY_LANG9 0x98 -#define KEY_ALTERNATE_ERASE 0x99 -#define KEY_SYSREQ 0x9A -#define KEY_CANCEL 0x9B -#define KEY_CLEAR 0x9C -#define KEY_PRIOR 0x9D -#define KEY_RETURN 0x9E -#define KEY_SEPARATOR 0x9F -#define KEY_OUT 0xA0 -#define KEY_OPER 0xA1 -#define KEY_CLEAR_AGAIN 0xA2 -#define KEY_CRSEL 0xA3 -#define KEY_EXSEL 0xA4 -#define KEY_KEYPAD_00 0xB0 -#define KEY_KEYPAD_000 0xB1 -#define KEY_THOUSANDS_SEPARATOR 0xB2 -#define KEY_DECIMAL_SEPARATOR 0xB3 -#define KEY_CURRENCY_UNIT 0xB4 -#define KEY_CURRENCY_SUB_UNIT 0xB5 -#define KEY_KEYPAD_OPARENTHESIS 0xB6 -#define KEY_KEYPAD_CPARENTHESIS 0xB7 -#define KEY_KEYPAD_OBRACE 0xB8 -#define KEY_KEYPAD_CBRACE 0xB9 -#define KEY_KEYPAD_TAB 0xBA -#define KEY_KEYPAD_BACKSPACE 0xBB -#define KEY_KEYPAD_A 0xBC -#define KEY_KEYPAD_B 0xBD -#define KEY_KEYPAD_C 0xBE -#define KEY_KEYPAD_D 0xBF -#define KEY_KEYPAD_E 0xC0 -#define KEY_KEYPAD_F 0xC1 -#define KEY_KEYPAD_XOR 0xC2 -#define KEY_KEYPAD_CARET 0xC3 -#define KEY_KEYPAD_PERCENT 0xC4 -#define KEY_KEYPAD_LESS 0xC5 -#define KEY_KEYPAD_GREATER 0xC6 -#define KEY_KEYPAD_AMPERSAND 0xC7 -#define KEY_KEYPAD_LOGICAL_AND 0xC8 -#define KEY_KEYPAD_VERTICAL_BAR 0xC9 -#define KEY_KEYPAD_LOGIACL_OR 0xCA -#define KEY_KEYPAD_COLON 0xCB -#define KEY_KEYPAD_NUMBER_SIGN 0xCC -#define KEY_KEYPAD_SPACE 0xCD -#define KEY_KEYPAD_AT 0xCE -#define KEY_KEYPAD_EXCLAMATION_MARK 0xCF -#define KEY_KEYPAD_MEMORY_STORE 0xD0 -#define KEY_KEYPAD_MEMORY_RECALL 0xD1 -#define KEY_KEYPAD_MEMORY_CLEAR 0xD2 -#define KEY_KEYPAD_MEMORY_ADD 0xD3 -#define KEY_KEYPAD_MEMORY_SUBTRACT 0xD4 -#define KEY_KEYPAD_MEMORY_MULTIPLY 0xD5 -#define KEY_KEYPAD_MEMORY_DIVIDE 0xD6 -#define KEY_KEYPAD_PLUSMINUS 0xD7 -#define KEY_KEYPAD_CLEAR 0xD8 -#define KEY_KEYPAD_CLEAR_ENTRY 0xD9 -#define KEY_KEYPAD_BINARY 0xDA -#define KEY_KEYPAD_OCTAL 0xDB -#define KEY_KEYPAD_DECIMAL 0xDC -#define KEY_KEYPAD_HEXADECIMAL 0xDD -#define KEY_LEFTCONTROL 0xE0 -#define KEY_LEFTSHIFT 0xE1 -#define KEY_LEFTALT 0xE2 -#define KEY_LEFT_GUI 0xE3 -#define KEY_RIGHTCONTROL 0xE4 -#define KEY_RIGHTSHIFT 0xE5 -#define KEY_RIGHTALT 0xE6 -#define KEY_RIGHT_GUI 0xE7 -#endif // EEZ_PLATFORM_STM32 - -} // keyboard -} // eez diff --git a/Middlewares/eez/core/memory.cpp b/Middlewares/eez/core/memory.cpp deleted file mode 100644 index 4175834..0000000 --- a/Middlewares/eez/core/memory.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2015-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include - -namespace eez { - -#if defined(EEZ_PLATFORM_SIMULATOR) -uint8_t g_memory[MEMORY_SIZE] = { 0 }; -#endif - -uint8_t *DECOMPRESSED_ASSETS_START_ADDRESS; -uint8_t *FLOW_TO_DEBUGGER_MESSAGE_BUFFER; - -uint8_t *VRAM_BUFFER1_START_ADDRESS; -uint8_t *VRAM_BUFFER2_START_ADDRESS; - -uint8_t *VRAM_ANIMATION_BUFFER1_START_ADDRESS; -uint8_t *VRAM_ANIMATION_BUFFER2_START_ADDRESS; - -uint8_t *VRAM_AUX_BUFFER1_START_ADDRESS; -uint8_t *VRAM_AUX_BUFFER2_START_ADDRESS; -uint8_t *VRAM_AUX_BUFFER3_START_ADDRESS; -uint8_t *VRAM_AUX_BUFFER4_START_ADDRESS; -uint8_t *VRAM_AUX_BUFFER5_START_ADDRESS; -uint8_t *VRAM_AUX_BUFFER6_START_ADDRESS; - -uint8_t *SCREENSHOOT_BUFFER_START_ADDRESS; - -uint8_t *GUI_STATE_BUFFER; - -uint8_t *ALLOC_BUFFER; -uint32_t ALLOC_BUFFER_SIZE; - -void initMemory() { - initAssetsMemory(); - initOtherMemory(); -} - -void initAssetsMemory() { - ALLOC_BUFFER = MEMORY_BEGIN; - ALLOC_BUFFER_SIZE = MEMORY_SIZE; - - DECOMPRESSED_ASSETS_START_ADDRESS = allocBuffer(MAX_DECOMPRESSED_ASSETS_SIZE); -} - -void initOtherMemory() { - FLOW_TO_DEBUGGER_MESSAGE_BUFFER = allocBuffer(FLOW_TO_DEBUGGER_MESSAGE_BUFFER_SIZE); - - uint32_t VRAM_BUFFER_SIZE = DISPLAY_WIDTH * DISPLAY_HEIGHT * DISPLAY_BPP / 8; - - VRAM_BUFFER1_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE); - VRAM_BUFFER2_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE); - - VRAM_ANIMATION_BUFFER1_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE); - VRAM_ANIMATION_BUFFER2_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE); - - VRAM_AUX_BUFFER1_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE); - VRAM_AUX_BUFFER2_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE); - VRAM_AUX_BUFFER3_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE); - VRAM_AUX_BUFFER4_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE); - VRAM_AUX_BUFFER5_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE); - VRAM_AUX_BUFFER6_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE); - - GUI_STATE_BUFFER = allocBuffer(GUI_STATE_BUFFER_SIZE); - - SCREENSHOOT_BUFFER_START_ADDRESS = VRAM_ANIMATION_BUFFER1_START_ADDRESS; -} - -uint8_t *allocBuffer(uint32_t size) { - size = ((size + 1023) / 1024) * 1024; - - auto buffer = ALLOC_BUFFER; - - assert(ALLOC_BUFFER_SIZE > size); - ALLOC_BUFFER += size; - ALLOC_BUFFER_SIZE -= size; - - return buffer; -} - -} // eez diff --git a/Middlewares/eez/core/memory.h b/Middlewares/eez/core/memory.h deleted file mode 100644 index 2cc7948..0000000 --- a/Middlewares/eez/core/memory.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2015-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include -#include - -namespace eez { - -#if defined(EEZ_PLATFORM_STM32) -static uint8_t * const MEMORY_BEGIN = (uint8_t *)0xc0000000u; -#if CONF_OPTION_FPGA -static const uint32_t MEMORY_SIZE = 32 * 1024 * 1024; -#elif defined(EEZ_PLATFORM_STM32F469I_DISCO) -static const uint32_t MEMORY_SIZE = 8 * 1024 * 1024; -#else -static const uint32_t MEMORY_SIZE = 8 * 1024 * 1024; -#endif -#endif - -#if defined(EEZ_PLATFORM_SIMULATOR) -extern uint8_t g_memory[]; -static uint8_t * const MEMORY_BEGIN = g_memory; -static const uint32_t MEMORY_SIZE = 64 * 1024 * 1024; -#endif - -extern uint8_t *ALLOC_BUFFER; -extern uint32_t ALLOC_BUFFER_SIZE; - -extern uint8_t *DECOMPRESSED_ASSETS_START_ADDRESS; -#if defined(EEZ_PLATFORM_STM32) -static const uint32_t MAX_DECOMPRESSED_ASSETS_SIZE = 2 * 1024 * 1024; -#endif -#if defined(EEZ_PLATFORM_SIMULATOR) -static const uint32_t MAX_DECOMPRESSED_ASSETS_SIZE = 8 * 1024 * 1024; -#endif - -extern uint8_t *FLOW_TO_DEBUGGER_MESSAGE_BUFFER; -#if defined(EEZ_PLATFORM_STM32) -static const uint32_t FLOW_TO_DEBUGGER_MESSAGE_BUFFER_SIZE = 32 * 1024; -#endif -#if defined(EEZ_PLATFORM_SIMULATOR) -static const uint32_t FLOW_TO_DEBUGGER_MESSAGE_BUFFER_SIZE = 1024 * 1024; -#endif - -extern uint8_t *VRAM_BUFFER1_START_ADDRESS; -extern uint8_t *VRAM_BUFFER2_START_ADDRESS; - -extern uint8_t *VRAM_ANIMATION_BUFFER1_START_ADDRESS; -extern uint8_t *VRAM_ANIMATION_BUFFER2_START_ADDRESS; - -extern uint8_t *VRAM_AUX_BUFFER1_START_ADDRESS; -extern uint8_t *VRAM_AUX_BUFFER2_START_ADDRESS; -extern uint8_t *VRAM_AUX_BUFFER3_START_ADDRESS; -extern uint8_t *VRAM_AUX_BUFFER4_START_ADDRESS; -extern uint8_t *VRAM_AUX_BUFFER5_START_ADDRESS; -extern uint8_t *VRAM_AUX_BUFFER6_START_ADDRESS; - -extern uint8_t* SCREENSHOOT_BUFFER_START_ADDRESS; - -extern uint8_t* GUI_STATE_BUFFER; - -void initMemory(); -void initAssetsMemory(); -void initOtherMemory(); -uint8_t *allocBuffer(uint32_t size); - -} // eez diff --git a/Middlewares/eez/core/mouse.h b/Middlewares/eez/core/mouse.h deleted file mode 100644 index 6c38e5e..0000000 --- a/Middlewares/eez/core/mouse.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2020-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include - -namespace eez { -namespace mouse { - -bool isMouseEnabled(); - -bool isDisplayDirty(); -void updateDisplay(); - -void onPageChanged(); - -#if defined(EEZ_PLATFORM_SIMULATOR) -void onMouseEvent(bool mouseButton1IsPressed, int mouseX, int mouseY); -#endif - -} // mouse -} // eez diff --git a/Middlewares/eez/core/os.cpp b/Middlewares/eez/core/os.cpp deleted file mode 100644 index 3ed285f..0000000 --- a/Middlewares/eez/core/os.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2018-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#if defined(EEZ_PLATFORM_STM32) -#include -#endif - -#include - -namespace eez { - -uint32_t millis() { -#if defined(EEZ_PLATFORM_STM32) - return HAL_GetTick(); -#endif - -#if defined(EEZ_PLATFORM_SIMULATOR) - return osKernelGetTickCount(); -#endif -} - -} // namespace eez diff --git a/Middlewares/eez/core/os.h b/Middlewares/eez/core/os.h deleted file mode 100644 index ae5a16e..0000000 --- a/Middlewares/eez/core/os.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include - -#include "cmsis_os2.h" - -#if defined(EEZ_PLATFORM_STM32) -#include "FreeRTOS.h" -#include "task.h" -#endif - -#define EEZ_THREAD_DECLARE(NAME, PRIORITY, STACK_SIZE) \ - osThreadId_t g_##NAME##TaskHandle; \ - const osThreadAttr_t g_##NAME##TaskAttributes = { \ - #NAME, \ - 0, \ - 0, \ - 0, \ - 0, \ - STACK_SIZE, \ - osPriority##PRIORITY, \ - 0, \ - 0, \ - } -#define EEZ_THREAD_CREATE(NAME, THREAD_FUNC) g_##NAME##TaskHandle = osThreadNew(THREAD_FUNC, nullptr, &g_##NAME##TaskAttributes); -#define EEZ_THREAD_TERMINATE(NAME) osThreadTerminate(g_##NAME##TaskHandle) - -#define EEZ_MESSAGE_QUEUE_DECLARE(NAME, OBJECT_DEF) \ - struct NAME##MessageQueueObject OBJECT_DEF; \ - osMessageQueueId_t g_##NAME##MessageQueueId -#define EEZ_MESSAGE_QUEUE_CREATE(NAME, QUEUE_SIZE) g_##NAME##MessageQueueId = osMessageQueueNew(QUEUE_SIZE, sizeof(NAME##MessageQueueObject), nullptr) -#define EEZ_MESSAGE_QUEUE_GET(NAME, OBJ, TIMEOUT) (osMessageQueueGet(g_##NAME##MessageQueueId, &OBJ, nullptr, TIMEOUT) == osOK) -#define EEZ_MESSAGE_QUEUE_PUT(NAME, OBJ, TIMEOUT) osMessageQueuePut(g_##NAME##MessageQueueId, &OBJ, 0, TIMEOUT) - -#define EEZ_MUTEX_DECLARE(NAME) \ - osMutexId_t g_##NAME##mutexId;\ - const osMutexAttr_t g_##NAME##mutexAttr = { \ - #NAME, \ - osMutexRecursive | osMutexPrioInherit, \ - NULL, \ - 0U \ - } -#define EEZ_MUTEX_CREATE(NAME) g_##NAME##mutexId = osMutexNew(&g_##NAME##mutexAttr) -#define EEZ_MUTEX_WAIT(NAME, TIMEOUT) osMutexAcquire(g_##NAME##mutexId, TIMEOUT) == osOK -#define EEZ_MUTEX_RELEASE(NAME) osMutexRelease(g_##NAME##mutexId) - -#if defined(__EMSCRIPTEN__) -#ifndef EM_PORT_API -# if defined(__EMSCRIPTEN__) -# include -# if defined(__cplusplus) -# define EM_PORT_API(rettype) extern "C" rettype EMSCRIPTEN_KEEPALIVE -# else -# define EM_PORT_API(rettype) rettype EMSCRIPTEN_KEEPALIVE -# endif -# else -# if defined(__cplusplus) -# define EM_PORT_API(rettype) extern "C" rettype -# else -# define EM_PORT_API(rettype) rettype -# endif -# endif -#endif -#else -# define EM_PORT_API(rettype) rettype -#endif - -namespace eez { - -enum TestResult { - TEST_NONE, - TEST_FAILED, - TEST_OK, - TEST_CONNECTING, - TEST_SKIPPED, - TEST_WARNING -}; - -uint32_t millis(); - -extern bool g_shutdown; -void shutdown(); - -} // namespace eez diff --git a/Middlewares/eez/core/sound.h b/Middlewares/eez/core/sound.h deleted file mode 100644 index 74ea996..0000000 --- a/Middlewares/eez/core/sound.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2015-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include - -namespace eez { -namespace sound { - -void init(); -void tick(); - -/// Play power up tune. -enum PlayPowerUpCondition { - PLAY_POWER_UP_CONDITION_NONE, - PLAY_POWER_UP_CONDITION_TEST_SUCCESSFUL, - PLAY_POWER_UP_CONDITION_WELCOME_PAGE_IS_ACTIVE -}; - -void playPowerUp(PlayPowerUpCondition condition); - -/// Play power down tune. -void playPowerDown(); - -/// Play beep sound. -void playBeep(bool force = false); - -/// Play click sound -void playClick(); - -/// Play shutter sound -void playShutter(); - -} // namespace sound -} // namespace eez diff --git a/Middlewares/eez/core/step_values.h b/Middlewares/eez/core/step_values.h deleted file mode 100644 index 780a303..0000000 --- a/Middlewares/eez/core/step_values.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include - -namespace eez { - -enum EncoderMode { - ENCODER_MODE_MIN, - ENCODER_MODE_AUTO = ENCODER_MODE_MIN, - ENCODER_MODE_STEP1, - ENCODER_MODE_STEP2, - ENCODER_MODE_STEP3, - ENCODER_MODE_STEP4, - ENCODER_MODE_STEP5, - ENCODER_MODE_MAX = ENCODER_MODE_STEP5 -}; - -struct StepValues { - int count; - const float *values; - Unit unit; - struct { - bool accelerationEnabled; - float range; - float step; - EncoderMode mode; - } encoderSettings; -}; - -} // namespace eez \ No newline at end of file diff --git a/Middlewares/eez/core/unit.cpp b/Middlewares/eez/core/unit.cpp deleted file mode 100644 index 3be5fc9..0000000 --- a/Middlewares/eez/core/unit.cpp +++ /dev/null @@ -1,309 +0,0 @@ - /* -* EEZ Generic Firmware -* Copyright (C) 2018-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#include - -#include - -#if OPTION_SCPI -#include -#endif - -namespace eez { - -const char *g_unitNames[] = { - "", // UNIT_NONE - "V", // UNIT_VOLT - "mV", // UNIT_MILLI_VOLT - "A", // UNIT_AMPER - "mA", // UNIT_MILLI_AMPER - "uA", // UNIT_MICRO_AMPER - "W", // UNIT_WATT - "mW", // UNIT_MILLI_WATT - "s", // UNIT_SECOND - "ms", // UNIT_MILLI_SECOND - DEGREE_SYMBOL"C", // UNIT_CELSIUS - "rpm", // UNIT_RPM - "\xb4", // UNIT_OHM - "K\xb4", // UNIT_KOHM - "M\xb4", // UNIT_MOHM - "%", // UNIT_PERCENT - "Hz", // UNIT_HERTZ - "mHz", // UNIT_MILLI_HERTZ - "KHz", // UNIT_KHERTZ - "MHz", // UNIT_MHERTZ - "J", // UNIT_JOULE - "F", // UNIT_FARAD - "mF", // UNIT_MILLI_FARAD - "uF", // UNIT_MICRO_FARAD - "nF", // UNIT_NANO_FARAD - "pF", // UNIT_PICO_FARAD - "minutes", // UNIT_MINUTE - "VA", // UNIT_VOLT_AMPERE - "VAR", // UNIT_VOLT_AMPERE_REACTIVE - DEGREE_SYMBOL, // UNIT_DEGREE - "Vpp", // UNIT_VOLT_PP - "mVpp", // UNIT_MILLI_VOLT_PP - "App", // UNIT_AMPER_PP - "mApp", // UNIT_MILLI_AMPER_PP - "uApp", // UNIT_MICRO_AMPER_PP -}; - -const Unit g_baseUnit[] = { - UNIT_NONE, // UNIT_NONE - UNIT_VOLT, // UNIT_VOLT - UNIT_VOLT, // UNIT_MILLI_VOLT - UNIT_AMPER, // UNIT_AMPER - UNIT_AMPER, // UNIT_MILLI_AMPER - UNIT_AMPER, // UNIT_MICRO_AMPER - UNIT_WATT, // UNIT_WATT - UNIT_WATT, // UNIT_MILLI_WATT - UNIT_SECOND, // UNIT_SECOND - UNIT_SECOND, // UNIT_MILLI_SECOND - UNIT_CELSIUS, // UNIT_CELSIUS - UNIT_RPM, // UNIT_RPM - UNIT_OHM, // UNIT_OHM - UNIT_OHM, // UNIT_KOHM - UNIT_OHM, // UNIT_MOHM - UNIT_PERCENT, // UNIT_PERCENT - UNIT_HERTZ, // UNIT_HERTZ - UNIT_HERTZ, // UNIT_MILLI_HERTZ - UNIT_HERTZ, // UNIT_KHERTZ - UNIT_HERTZ, // UNIT_MHERTZ - UNIT_JOULE, // UNIT_JOULE - UNIT_FARAD, // UNIT_FARAD - UNIT_FARAD, // UNIT_MILLI_FARAD - UNIT_FARAD, // UNIT_MICRO_FARAD - UNIT_FARAD, // UNIT_NANO_FARAD - UNIT_FARAD, // UNIT_PICO_FARAD - UNIT_SECOND, // UNIT_MINUTE - UNIT_VOLT_AMPERE, // UNIT_VOLT_AMPERE - UNIT_VOLT_AMPERE, //UNIT_VOLT_AMPERE_REACTIVE - UNIT_DEGREE, // UNIT_DEGREE - UNIT_VOLT_PP, // UNIT_VOLT_PP - UNIT_VOLT_PP, // UNIT_MILLI_VOLT_PP - UNIT_AMPER_PP, // UNIT_AMPER_PP - UNIT_AMPER_PP, // UNIT_MILLI_AMPER_PP - UNIT_AMPER_PP, // UNIT_MICRO_AMPER_PP -}; - -const float g_unitFactor[] = { - 1.0f, // UNIT_NONE - 1.0f, // UNIT_VOLT - 1E-3f, // UNIT_MILLI_VOLT - 1.0f, // UNIT_AMPER - 1E-3f, // UNIT_MILLI_AMPER - 1E-6f, // UNIT_MICRO_AMPER - 1.0f, // UNIT_WATT - 1E-3f, // UNIT_MILLI_WATT - 1.0f, // UNIT_SECOND - 1E-3f, // UNIT_MILLI_SECOND - 1.0f, // UNIT_CELSIUS - 1.0f, // UNIT_RPM - 1.0f, // UNIT_OHM - 1E3f, // UNIT_KOHM - 1E6f, // UNIT_MOHM - 1.0f, // UNIT_PERCENT - 1.0f, // UNIT_HERTZ - 1E-3f, // UNIT_MILLI_HERTZ - 1E3f, // UNIT_KHERTZ - 1E6f, // UNIT_MHERTZ - 1.0f, // UNIT_JOULE - 1.0f, // UNIT_FARAD - 1E-3f, // UNIT_MILLI_FARAD - 1E-6f, // UNIT_MICRO_FARAD - 1E-9f, // UNIT_NANO_FARAD - 1E-12f, // UNIT_PICO_FARAD - 60.0f, // UNIT_MINUTE - 1.0f, // UNIT_VOLT_AMPERE - 1.0f, //UNIT_VOLT_AMPERE_REACTIVE - 1.0f, // UNIT_DEGREE - 1.0f, // UNIT_VOLT_PP - 1E-3f, // UNIT_MILLI_VOLT_PP - 1.0f, // UNIT_AMPER_PP - 1E-3f, // UNIT_MILLI_AMPER_PP - 1E-6f, // UNIT_MICRO_AMPER_PP -}; - -#if OPTION_SCPI -static const int g_scpiUnits[] = { - SCPI_UNIT_NONE, // UNIT_NONE - SCPI_UNIT_VOLT, // UNIT_VOLT - SCPI_UNIT_VOLT, // UNIT_MILLI_VOLT - SCPI_UNIT_AMPER, // UNIT_AMPER - SCPI_UNIT_AMPER, // UNIT_MILLI_AMPER - SCPI_UNIT_AMPER, // UNIT_MICRO_AMPER - SCPI_UNIT_WATT, // UNIT_WATT - SCPI_UNIT_WATT, // UNIT_MILLI_WATT - SCPI_UNIT_SECOND, // UNIT_SECOND - SCPI_UNIT_SECOND, // UNIT_MILLI_SECOND - SCPI_UNIT_CELSIUS, // UNIT_CELSIUS - SCPI_UNIT_NONE, // UNIT_RPM - SCPI_UNIT_OHM, // UNIT_OHM - SCPI_UNIT_OHM, // UNIT_KOHM - SCPI_UNIT_OHM, // UNIT_MOHM - SCPI_UNIT_NONE, // UNIT_PERCENT - SCPI_UNIT_HERTZ, // UNIT_HERTZ - SCPI_UNIT_HERTZ, // UNIT_MILLI_HERTZ - SCPI_UNIT_HERTZ, // UNIT_KHERTZ - SCPI_UNIT_HERTZ, // UNIT_MHERTZ - SCPI_UNIT_JOULE, // UNIT_JOULE - SCPI_UNIT_FARAD, // UNIT_FARAD - SCPI_UNIT_FARAD, // UNIT_MILLI_FARAD - SCPI_UNIT_FARAD, // UNIT_MICRO_FARAD - SCPI_UNIT_FARAD, // UNIT_NANO_FARAD - SCPI_UNIT_FARAD, // UNIT_PICO_FARAD - SCPI_UNIT_SECOND, // UNIT_MINUTE - SCPI_UNIT_WATT, // UNIT_VOLT_AMPERE - SCPI_UNIT_WATT, // UNIT_VOLT_AMPERE_REACTIVE - SCPI_UNIT_DEGREE, // UNIT_DEGREE - SCPI_UNIT_VOLT, // UNIT_VOLT_PP - SCPI_UNIT_VOLT, // UNIT_MILLI_VOLT_PP - SCPI_UNIT_AMPER, // UNIT_AMPER_PP - SCPI_UNIT_AMPER, // UNIT_MILLI_AMPER_PP - SCPI_UNIT_AMPER, // UNIT_MICRO_AMPER_PP -}; -#endif - -Unit getUnitFromName(const char *unitName) { - if (unitName) { - for (unsigned i = 0; i < sizeof(g_unitNames) / sizeof(const char *); i++) { - if (strcmp(g_unitNames[i], unitName) == 0) { - return (Unit)i; - } - } - } - return UNIT_NONE; -} - -#if OPTION_SCPI -int getScpiUnit(Unit unit) { - if (unit == UNIT_UNKNOWN) { - return SCPI_UNIT_NONE; - } - return g_scpiUnits[unit]; -} -#endif - -Unit getBaseUnit(Unit unit) { - if (unit == UNIT_UNKNOWN) { - return UNIT_UNKNOWN; - } - return g_baseUnit[unit]; -} - -float getUnitFactor(Unit unit) { - if (unit == UNIT_UNKNOWN) { - return 1.0f; - } - return g_unitFactor[unit]; -} - -static Unit getDerivedUnit(Unit unit, float factor) { - if (unit == UNIT_UNKNOWN) { - return UNIT_UNKNOWN; - } - - for (size_t i = 0; i < sizeof(g_baseUnit); i++) { - if (g_baseUnit[i] == g_baseUnit[unit] && g_unitFactor[i] == factor) { - return (Unit)i; - } - } - - return UNIT_UNKNOWN; -} - -static const float FACTORS[] = { 1E-12F, 1E-9F, 1E-6F, 1E-3F, 1E0F, 1E3F, 1E6F, 1E9F, 1E12F }; - -Unit findDerivedUnit(float value, Unit unit) { - Unit result; - - for (int factorIndex = 1; ; factorIndex++) { - float factor = FACTORS[factorIndex]; - if (factor > 1.0F) { - break; - } - if (value < factor) { - result = getDerivedUnit(unit, FACTORS[factorIndex - 1]); - if (result != UNIT_UNKNOWN) { - return result; - } - } - } - - for (int factorIndex = sizeof(FACTORS) / sizeof(float) - 1; factorIndex >= 0; factorIndex--) { - float factor = FACTORS[factorIndex]; - if (factor == 1.0F) { - break; - } - if (value >= factor) { - result = getDerivedUnit(unit, factor); - if (result != UNIT_UNKNOWN) { - return result; - } - } - } - - return unit; -} - -float getSmallerFactor(float factor) { - for (int factorIndex = sizeof(FACTORS) / sizeof(float) - 1; factorIndex > 0; factorIndex--) { - float itFactor = FACTORS[factorIndex]; - if (itFactor < factor) { - return itFactor; - } - } - return FACTORS[0]; -} - -Unit getSmallerUnit(Unit unit, float min, float precision) { - float factor = getUnitFactor(unit); - if (precision <= factor || min <= factor) { - return getDerivedUnit(unit, getSmallerFactor(factor)); - } - return UNIT_UNKNOWN; -} - -Unit getBiggestUnit(Unit unit, float max) { - for (int factorIndex = sizeof(FACTORS) / sizeof(float) - 1; factorIndex >= 0; factorIndex--) { - float factor = FACTORS[factorIndex]; - if (max >= factor) { - auto result = getDerivedUnit(unit, factor); - if (result != UNIT_UNKNOWN) { - return result; - } - } - } - return UNIT_UNKNOWN; -} - -Unit getSmallestUnit(Unit unit, float min, float precision) { - for (int factorIndex = 0; factorIndex < int(sizeof(FACTORS) / sizeof(float)); factorIndex++) { - float factor = FACTORS[factorIndex]; - if (precision <= factor || min <= factor) { - auto result = getDerivedUnit(unit, factor); - if (result != UNIT_UNKNOWN) { - return result; - } - } - } - return UNIT_UNKNOWN; -} - -} // namespace eez diff --git a/Middlewares/eez/core/unit.h b/Middlewares/eez/core/unit.h deleted file mode 100644 index cb287fd..0000000 --- a/Middlewares/eez/core/unit.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2018-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#define INFINITY_SYMBOL "\x91" -#define DEGREE_SYMBOL "\x8a" - -namespace eez { - -// order of units should not be changed since it is used in DLOG files -enum Unit { - UNIT_UNKNOWN = 255, - UNIT_NONE = 0, - UNIT_VOLT, - UNIT_MILLI_VOLT, - UNIT_AMPER, - UNIT_MILLI_AMPER, - UNIT_MICRO_AMPER, - UNIT_WATT, - UNIT_MILLI_WATT, - UNIT_SECOND, - UNIT_MILLI_SECOND, - UNIT_CELSIUS, - UNIT_RPM, - UNIT_OHM, - UNIT_KOHM, - UNIT_MOHM, - UNIT_PERCENT, - UNIT_HERTZ, - UNIT_MILLI_HERTZ, - UNIT_KHERTZ, - UNIT_MHERTZ, - UNIT_JOULE, - UNIT_FARAD, - UNIT_MILLI_FARAD, - UNIT_MICRO_FARAD, - UNIT_NANO_FARAD, - UNIT_PICO_FARAD, - UNIT_MINUTE, - UNIT_VOLT_AMPERE, - UNIT_VOLT_AMPERE_REACTIVE, - UNIT_DEGREE, - UNIT_VOLT_PP, - UNIT_MILLI_VOLT_PP, - UNIT_AMPER_PP, - UNIT_MILLI_AMPER_PP, - UNIT_MICRO_AMPER_PP, -}; - -extern const char *g_unitNames[]; - -inline const char *getUnitName(Unit unit) { - if (unit == UNIT_UNKNOWN) { - return ""; - } - return g_unitNames[unit]; -} - -Unit getUnitFromName(const char *unitName); - -#if OPTION_SCPI -int getScpiUnit(Unit unit); -#endif - -// for UNIT_MILLI_VOLT returns UNIT_VOLT, etc... -Unit getBaseUnit(Unit unit); - -// returns 1.0 form UNIT_VOLT, returns 1E-3 for UNIT_MILLI_VOLT, 1E-6 for UNIT_MICRO_AMPER, 1E3 for UNIT_KOHM, etc -float getUnitFactor(Unit unit); - -// if value is 0.01 and unit is UNIT_VOLT returns UNIT_MILLI_VOLT, etc -Unit findDerivedUnit(float value, Unit unit); - -Unit getSmallerUnit(Unit unit, float min, float precision); -Unit getBiggestUnit(Unit unit, float max); -Unit getSmallestUnit(Unit unit, float min, float precision); - -} // namespace eez \ No newline at end of file diff --git a/Middlewares/eez/core/utf8.h b/Middlewares/eez/core/utf8.h deleted file mode 100644 index 114d7c2..0000000 --- a/Middlewares/eez/core/utf8.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2018-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include - -#ifndef UTF8_SUPPORT -#define UTF8_SUPPORT 1 -#endif - -#if UTF8_SUPPORT - -#include - -#else - -typedef char utf8_int8_t; -typedef int32_t utf8_int32_t; - -inline const utf8_int8_t* utf8codepoint(const utf8_int8_t *str, utf8_int32_t *out_codepoint) { - *out_codepoint = *((uint8_t *)str); - return str + 1; -} - -#define utf8len strlen - -#endif diff --git a/Middlewares/eez/core/util.cpp b/Middlewares/eez/core/util.cpp deleted file mode 100644 index 1699111..0000000 --- a/Middlewares/eez/core/util.cpp +++ /dev/null @@ -1,921 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2018-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#include - -#define _USE_MATH_DEFINES -#include -#include -#include -#include - -#if defined(EEZ_PLATFORM_STM32) -#include -#endif - -namespace eez { - -float remap(float x, float x1, float y1, float x2, float y2) { - return y1 + (x - x1) * (y2 - y1) / (x2 - x1); -} - -float remapQuad(float x, float x1, float y1, float x2, float y2) { - float t = remap(x, x1, 0, x2, 1); - t = t * t; - x = remap(t, 0, x1, 1, x2); - return remap(x, x1, y1, x2, y2); -} - -float remapOutQuad(float x, float x1, float y1, float x2, float y2) { - float t = remap(x, x1, 0, x2, 1); - t = t * (2 - t); - x = remap(t, 0, x1, 1, x2); - return remap(x, x1, y1, x2, y2); -} - -float remapInOutQuad(float x, float x1, float y1, float x2, float y2) { - float t = remap(x, x1, 0, x2, 1); - t = t < .5 ? 2 * t*t : -1 + (4 - 2 * t)*t; - x = remap(t, 0, x1, 1, x2); - return remap(x, x1, y1, x2, y2); -} - -float remapCubic(float x, float x1, float y1, float x2, float y2) { - float t = remap(x, x1, 0, x2, 1); - t = t * t * t; - x = remap(t, 0, x1, 1, x2); - return remap(x, x1, y1, x2, y2); -} - -float remapOutCubic(float x, float x1, float y1, float x2, float y2) { - float t = remap(x, x1, 0, x2, 1); - t = t - 1; - t = 1 + t * t * t; - x = remap(t, 0, x1, 1, x2); - return remap(x, x1, y1, x2, y2); -} - -float remapExp(float x, float x1, float y1, float x2, float y2) { - float t = remap(x, x1, 0, x2, 1); - t = t == 0 ? 0 : float(pow(2, 10 * (t - 1))); - x = remap(t, 0, x1, 1, x2); - return remap(x, x1, y1, x2, y2); -} - -float remapOutExp(float x, float x1, float y1, float x2, float y2) { - float t = remap(x, x1, 0, x2, 1); - t = t == 1 ? 1 : float(1 - pow(2, -10 * t)); - x = remap(t, 0, x1, 1, x2); - return remap(x, x1, y1, x2, y2); -} - -float clamp(float x, float min, float max) { - if (x < min) { - return min; - } - if (x > max) { - return max; - } - return x; -} - -void stringCopy(char *dst, size_t maxStrLength, const char *src) { - strncpy(dst, src, maxStrLength); - dst[maxStrLength - 1] = 0; -} - -void stringCopyLength(char *dst, size_t maxStrLength, const char *src, size_t length) { - size_t n = MIN(length, maxStrLength); - strncpy(dst, src, n); - dst[n] = 0; -} - -void stringAppendString(char *str, size_t maxStrLength, const char *value) { - int n = maxStrLength - strlen(str) - 1; - if (n >= 0) { - strncat(str, value, n); - } -} - -void stringAppendStringLength(char *str, size_t maxStrLength, const char *value, size_t length) { - int n = MIN(maxStrLength - strlen(str) - 1, length); - if (n >= 0) { - strncat(str, value, n); - } -} - -void stringAppendInt(char *str, size_t maxStrLength, int value) { - auto n = strlen(str); - snprintf(str + n, maxStrLength - n, "%d", value); -} - -void stringAppendUInt32(char *str, size_t maxStrLength, uint32_t value) { - auto n = strlen(str); - snprintf(str + n, maxStrLength - n, "%lu", (unsigned long)value); -} - -void stringAppendInt64(char *str, size_t maxStrLength, int64_t value) { - auto n = strlen(str); - snprintf(str + n, maxStrLength - n, "%jd", value); -} - -void stringAppendUInt64(char *str, size_t maxStrLength, uint64_t value) { - auto n = strlen(str); - snprintf(str + n, maxStrLength - n, "%ju", value); -} - -void stringAppendFloat(char *str, size_t maxStrLength, float value) { - auto n = strlen(str); - snprintf(str + n, maxStrLength - n, "%g", value); -} - -void stringAppendFloat(char *str, size_t maxStrLength, float value, int numDecimalPlaces) { - auto n = strlen(str); - snprintf(str + n, maxStrLength - n, "%.*f", numDecimalPlaces, value); -} - -void stringAppendDouble(char *str, size_t maxStrLength, double value) { - auto n = strlen(str); - snprintf(str + n, maxStrLength - n, "%g", value); -} - -void stringAppendDouble(char *str, size_t maxStrLength, double value, int numDecimalPlaces) { - auto n = strlen(str); - snprintf(str + n, maxStrLength - n, "%.*f", numDecimalPlaces, value); -} - -void stringAppendVoltage(char *str, size_t maxStrLength, float value) { - auto n = strlen(str); - snprintf(str + n, maxStrLength - n, "%g V", value); -} - -void stringAppendCurrent(char *str, size_t maxStrLength, float value) { - auto n = strlen(str); - snprintf(str + n, maxStrLength - n, "%g A", value); -} - -void stringAppendPower(char *str, size_t maxStrLength, float value) { - auto n = strlen(str); - snprintf(str + n, maxStrLength - n, "%g W", value); -} - -void stringAppendDuration(char *str, size_t maxStrLength, float value) { - auto n = strlen(str); - if (value > 0.1) { - snprintf(str + n, maxStrLength - n, "%g s", value); - } else { - snprintf(str + n, maxStrLength - n, "%g ms", value * 1000); - } -} - -void stringAppendLoad(char *str, size_t maxStrLength, float value) { - auto n = strlen(str); - if (value < 1000) { - snprintf(str + n, maxStrLength - n, "%g ohm", value); - } else if (value < 1000000) { - snprintf(str + n, maxStrLength - n, "%g Kohm", value / 1000); - } else { - snprintf(str + n, maxStrLength - n, "%g Mohm", value / 1000000); - } -} - -#if defined(EEZ_PLATFORM_STM32) -uint32_t crc32(const uint8_t *mem_block, size_t block_size) { - return HAL_CRC_Calculate(&hcrc, (uint32_t *)mem_block, block_size); -} -#else -/* -From http://www.hackersdelight.org/hdcodetxt/crc.c.txt: - -This is the basic CRC-32 calculation with some optimization but no -table lookup. The the byte reversal is avoided by shifting the crc reg -right instead of left and by using a reversed 32-bit word to represent -the polynomial. -When compiled to Cyclops with GCC, this function executes in 8 + 72n -instructions, where n is the number of bytes in the input message. It -should be doable in 4 + 61n instructions. -If the inner loop is strung out (approx. 5*8 = 40 instructions), -it would take about 6 + 46n instructions. -*/ - -uint32_t crc32(const uint8_t *mem_block, size_t block_size) { - uint32_t crc = 0xFFFFFFFF; - for (size_t i = 0; i < block_size; ++i) { - uint32_t byte = mem_block[i]; // Get next byte. - crc = crc ^ byte; - for (int j = 0; j < 8; ++j) { // Do eight times. - uint32_t mask = -((int32_t)crc & 1); - crc = (crc >> 1) ^ (0xEDB88320 & mask); - } - } - return ~crc; -} -#endif - -uint8_t toBCD(uint8_t bin) { - return ((bin / 10) << 4) | (bin % 10); -} - -uint8_t fromBCD(uint8_t bcd) { - return ((bcd >> 4) & 0xF) * 10 + (bcd & 0xF); -} - -float roundPrec(float a, float prec) { - float r = 1 / prec; - return roundf(a * r) / r; -} - -float floorPrec(float a, float prec) { - float r = 1 / prec; - return floorf(a * r) / r; -} - -float ceilPrec(float a, float prec) { - float r = 1 / prec; - return ceilf(a * r) / r; -} - -bool isNaN(float x) { - return x != x; -} - -bool isNaN(double x) { - return x != x; -} - -bool isDigit(char ch) { - return ch >= '0' && ch <= '9'; -} - -bool isHexDigit(char ch) { - return (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F'); -} - -bool isUperCaseLetter(char ch) { - return ch >= 'A' && ch <= 'Z'; -} - -char toHexDigit(int num) { - if (num >= 0 && num <= 9) { - return '0' + num; - } else { - return 'A' + (num - 10); - } -} - -int fromHexDigit(char ch) { - if (ch >= '0' && ch <= '9') { - return ch - '0'; - } - - if (ch >= 'a' && ch <= 'f') { - return 10 + (ch - 'a'); - } - - return 10 + (ch - 'A'); -} - -bool pointInsideRect(int xPoint, int yPoint, int xRect, int yRect, int wRect, int hRect) { - return xPoint >= xRect && xPoint < xRect + wRect && yPoint >= yRect && yPoint < yRect + hRect; -} - -void getParentDir(const char *path, char *parentDirPath) { - int lastPathSeparatorIndex; - - for (lastPathSeparatorIndex = strlen(path) - 1; - lastPathSeparatorIndex >= 0 && path[lastPathSeparatorIndex] != PATH_SEPARATOR[0]; - --lastPathSeparatorIndex) - ; - - int i; - for (i = 0; i < lastPathSeparatorIndex; ++i) { - parentDirPath[i] = path[i]; - } - parentDirPath[i] = 0; -} - -bool parseMacAddress(const char *macAddressStr, size_t macAddressStrLength, uint8_t *macAddress) { - int state = 0; - int a = 0; - int i = 0; - uint8_t resultMacAddress[6]; - - const char *end = macAddressStr + macAddressStrLength; - for (const char *p = macAddressStr; p < end; ++p) { - if (state == 0) { - if (*p == '-' || *p == ' ') { - continue; - } else if (isHexDigit(*p)) { - a = fromHexDigit(*p); - state = 1; - } else { - return false; - } - } else if (state == 1) { - if (isHexDigit(*p)) { - if (i < 6) { - resultMacAddress[i++] = (a << 4) | fromHexDigit(*p); - state = 0; - } else { - return false; - } - } else { - return false; - } - } - } - - if (state != 0 || i != 6) { - return false; - } - - memcpy(macAddress, resultMacAddress, 6); - - return true; -} - -bool parseIpAddress(const char *ipAddressStr, size_t ipAddressStrLength, uint32_t &ipAddress) { - const char *p = ipAddressStr; - const char *q = ipAddressStr + ipAddressStrLength; - - uint8_t ipAddressArray[4]; - - for (int i = 0; i < 4; ++i) { - if (p == q) { - return false; - } - - uint32_t part = 0; - for (int j = 0; j < 3; ++j) { - if (p == q) { - if (j > 0 && i == 3) { - break; - } else { - return false; - } - } else if (isDigit(*p)) { - part = part * 10 + (*p++ - '0'); - } else if (j > 0 && *p == '.') { - break; - } else { - return false; - } - } - - if (part > 255) { - return false; - } - - if ((i < 3 && *p++ != '.') || (i == 3 && p != q)) { - return false; - } - - ipAddressArray[i] = part; - } - - ipAddress = arrayToIpAddress(ipAddressArray); - - return true; -} - -int getIpAddressPartA(uint32_t ipAddress) { - return ((uint8_t *)&ipAddress)[0]; -} - -void setIpAddressPartA(uint32_t *ipAddress, uint8_t value) { - ((uint8_t *)ipAddress)[0] = value; -} - -int getIpAddressPartB(uint32_t ipAddress) { - return ((uint8_t *)&ipAddress)[1]; -} - -void setIpAddressPartB(uint32_t *ipAddress, uint8_t value) { - ((uint8_t *)ipAddress)[1] = value; -} - -int getIpAddressPartC(uint32_t ipAddress) { - return ((uint8_t *)&ipAddress)[2]; -} - -void setIpAddressPartC(uint32_t *ipAddress, uint8_t value) { - ((uint8_t *)ipAddress)[2] = value; -} - -int getIpAddressPartD(uint32_t ipAddress) { - return ((uint8_t *)&ipAddress)[3]; -} - -void setIpAddressPartD(uint32_t *ipAddress, uint8_t value) { - ((uint8_t *)ipAddress)[3] = value; -} - -void ipAddressToArray(uint32_t ipAddress, uint8_t *ipAddressArray) { - ipAddressArray[0] = getIpAddressPartA(ipAddress); - ipAddressArray[1] = getIpAddressPartB(ipAddress); - ipAddressArray[2] = getIpAddressPartC(ipAddress); - ipAddressArray[3] = getIpAddressPartD(ipAddress); -} - -uint32_t arrayToIpAddress(uint8_t *ipAddressArray) { - return getIpAddress(ipAddressArray[0], ipAddressArray[1], ipAddressArray[2], ipAddressArray[3]); -} - -uint32_t getIpAddress(uint8_t a, uint8_t b, uint8_t c, uint8_t d) { - uint32_t ipAddress; - - setIpAddressPartA(&ipAddress, a); - setIpAddressPartB(&ipAddress, b); - setIpAddressPartC(&ipAddress, c); - setIpAddressPartD(&ipAddress, d); - - return ipAddress; -} - -void ipAddressToString(uint32_t ipAddress, char *ipAddressStr, size_t maxIpAddressStrLength) { - snprintf(ipAddressStr, maxIpAddressStrLength, "%d.%d.%d.%d", - getIpAddressPartA(ipAddress), getIpAddressPartB(ipAddress), - getIpAddressPartC(ipAddress), getIpAddressPartD(ipAddress)); -} - -void macAddressToString(const uint8_t *macAddress, char *macAddressStr) { - for (int i = 0; i < 6; ++i) { - macAddressStr[3 * i] = toHexDigit((macAddress[i] & 0xF0) >> 4); - macAddressStr[3 * i + 1] = toHexDigit(macAddress[i] & 0xF); - macAddressStr[3 * i + 2] = i < 5 ? '-' : 0; - } -} - -void formatTimeZone(int16_t timeZone, char *text, int count) { - if (timeZone == 0) { - stringCopy(text, count, "GMT"); - } else { - char sign; - int16_t value; - if (timeZone > 0) { - sign = '+'; - value = timeZone; - } else { - sign = '-'; - value = -timeZone; - } - snprintf(text, count, "%c%02d:%02d GMT", sign, value / 100, value % 100); - } -} - -bool parseTimeZone(const char *timeZoneStr, size_t timeZoneLength, int16_t &timeZone) { - int state = 0; - - int sign = 1; - int integerPart = 0; - int fractionPart = 0; - - const char *end = timeZoneStr + timeZoneLength; - for (const char *p = timeZoneStr; p < end; ++p) { - if (*p == ' ') { - continue; - } - - if (state == 0) { - if (*p == '+') { - state = 1; - } else if (*p == '-') { - sign = -1; - state = 1; - } else if (isDigit(*p)) { - integerPart = *p - '0'; - state = 2; - } else { - return false; - } - } else if (state == 1) { - if (isDigit(*p)) { - integerPart = (*p - '0'); - state = 2; - } else { - return false; - } - } else if (state == 2) { - if (*p == ':') { - state = 4; - } else if (isDigit(*p)) { - integerPart = integerPart * 10 + (*p - '0'); - state = 3; - } else { - return false; - } - } else if (state == 3) { - if (*p == ':') { - state = 4; - } else { - return false; - } - } else if (state == 4) { - if (isDigit(*p)) { - fractionPart = (*p - '0'); - state = 5; - } else { - return false; - } - } else if (state == 5) { - if (isDigit(*p)) { - fractionPart = fractionPart * 10 + (*p - '0'); - state = 6; - } else { - return false; - } - } else { - return false; - } - } - - if (state != 2 && state != 3 && state != 6) { - return false; - } - - int value = sign * (integerPart * 100 + fractionPart); - - if (value < -1200 || value > 1400) { - return false; - } - - timeZone = (int16_t)value; - - return true; -} - -void replaceCharacter(char *str, char ch, char repl) { - while (*str) { - if (*str == ch) { - *str = repl; - } - ++str; - } -} - -int strcicmp(char const *a, char const *b) { - for (;; a++, b++) { - int d = tolower((unsigned char)*a) - tolower((unsigned char)*b); - if (d != 0 || !*a) - return d; - } -} - -int strncicmp(char const *a, char const *b, int n) { - for (; n--; a++, b++) { - int d = tolower((unsigned char)*a) - tolower((unsigned char)*b); - if (d != 0 || !*a) - return d; - } - return 0; -} - -bool isStringEmpty(char const *s) { - for (; *s; s++) { - if (!isspace(*s)) { - return false; - } - } - return true; -} - -bool startsWith(const char *str, const char *prefix) { - if (!str || !prefix) - return false; - size_t strLen = strlen(str); - size_t prefixLen = strlen(prefix); - if (prefixLen > strLen) - return false; - return strncmp(str, prefix, prefixLen) == 0; -} - -bool startsWithNoCase(const char *str, const char *prefix) { - if (!str || !prefix) - return false; - size_t strLen = strlen(str); - size_t prefixLen = strlen(prefix); - if (prefixLen > strLen) - return false; - return strncicmp(str, prefix, prefixLen) == 0; -} - -bool endsWith(const char *str, const char *suffix) { - if (!str || !suffix) - return false; - size_t strLen = strlen(str); - size_t suffixLen = strlen(suffix); - if (suffixLen > strLen) - return false; - return strncmp(str + strLen - suffixLen, suffix, suffixLen) == 0; -} - -bool endsWithNoCase(const char *str, const char *suffix) { - if (!str || !suffix) - return false; - size_t strLen = strlen(str); - size_t suffixLen = strlen(suffix); - if (suffixLen > strLen) - return false; - return strncicmp(str + strLen - suffixLen, suffix, suffixLen) == 0; -} - -void formatBytes(uint64_t bytes, char *text, int count) { - if (bytes == 0) { - stringCopy(text, count, "0 Bytes"); - } else { - double c = 1024.0; - const char *e[] = { "Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" }; - uint64_t f = (uint64_t)floor(log((double)bytes) / log(c)); - double g = round((bytes / pow(c, (double)f)) * 100) / 100; - snprintf(text, count, "%g %s", g, e[f]); - } -} - -void getFileName(const char *path, char *fileName, unsigned fileNameSize) { - const char *a = strrchr(path, '/'); - if (a) { - a++; - } else { - a = path; - } - - const char *b = path + strlen(path); - - unsigned n = b - a; - n = MIN(fileNameSize - 1, n); - if (n > 0) { - memcpy(fileName, a, n); - } - fileName[n] = 0; -} - -void getBaseFileName(const char *path, char *baseName, unsigned baseNameSize) { - const char *a = strrchr(path, '/'); - if (a) { - a++; - } else { - a = path; - } - - const char *b = strrchr(path, '.'); - if (!b || !(b >= a)) { - b = path + strlen(path); - } - - unsigned n = b - a; - n = MIN(baseNameSize - 1, n); - if (n > 0) { - memcpy(baseName, a, n); - } - baseName[n] = 0; -} - -//////////////////////////////////////////////////////////////////////////////// - -static const float PI = (float)M_PI; -static const float c1 = 1.70158f; -static const float c2 = c1 * 1.525f; -static const float c3 = c1 + 1.0f; -static const float c4 = (2 * PI) / 3; -static const float c5 = (2 * PI) / 4.5f; - -float linear(float x) { - return x; -} - -float easeInQuad(float x) { - return x * x; -} - -float easeOutQuad(float x) { - return 1 - (1 - x) * (1 - x); -} - -float easeInOutQuad(float x) { - return x < 0.5f ? 2 * x * x : 1 - powf(-2 * x + 2, 2) / 2; -} - -float easeInCubic(float x) { - return x * x * x; -} - -float easeOutCubic(float x) { - return 1 - pow(1 - x, 3); -} - -float easeInOutCubic(float x) { - return x < 0.5f ? 4 * x * x * x : 1 - powf(-2 * x + 2, 3) / 2; -} - -float easeInQuart(float x) { - return x * x * x * x; -} - -float easeOutQuart(float x) { - return 1 - powf(1 - x, 4); -} - -float easeInOutQuart(float x) { - return x < 0.5 ? 8 * x * x * x * x : 1 - powf(-2 * x + 2, 4) / 2; -} - -float easeInQuint(float x) { - return x * x * x * x * x; -} - -float easeOutQuint(float x) { - return 1 - powf(1 - x, 5); -} - -float easeInOutQuint(float x) { - return x < 0.5f ? 16 * x * x * x * x * x : 1 - powf(-2 * x + 2, 5) / 2; -} - -float easeInSine(float x) { - return 1 - cosf((x * PI) / 2); -} - -float easeOutSine(float x) { - return sinf((x * PI) / 2); -} - -float easeInOutSine(float x) { - return -(cosf(PI * x) - 1) / 2; -} - -float easeInExpo(float x) { - return x == 0 ? 0 : powf(2, 10 * x - 10); -} - -float easeOutExpo(float x) { - return x == 1 ? 1 : 1 - powf(2, -10 * x); -} - -float easeInOutExpo(float x) { - return x == 0 - ? 0 - : x == 1 - ? 1 - : x < 0.5 - ? powf(2, 20 * x - 10) / 2 - : (2 - powf(2, -20 * x + 10)) / 2; -} - -float easeInCirc(float x) { - return 1 - sqrtf(1 - powf(x, 2)); -} - -float easeOutCirc(float x) { - return sqrtf(1 - powf(x - 1, 2)); -} - -float easeInOutCirc(float x) { - return x < 0.5 - ? (1 - sqrtf(1 - pow(2 * x, 2))) / 2 - : (sqrtf(1 - powf(-2 * x + 2, 2)) + 1) / 2; -} - -float easeInBack(float x) { - return c3 * x * x * x - c1 * x * x; -} - -float easeOutBack(float x) { - return 1 + c3 * powf(x - 1, 3) + c1 * powf(x - 1, 2); -} - -float easeInOutBack(float x) { - return x < 0.5 - ? (powf(2 * x, 2) * ((c2 + 1) * 2 * x - c2)) / 2 - : (powf(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2; -} - -float easeInElastic(float x) { - return x == 0 - ? 0 - : x == 1 - ? 1 - : -powf(2, 10 * x - 10) * sinf((x * 10 - 10.75f) * c4); -} - -float easeOutElastic(float x) { - return x == 0 - ? 0 - : x == 1 - ? 1 - : powf(2, -10 * x) * sinf((x * 10 - 0.75f) * c4) + 1; -} - -float easeInOutElastic(float x) { - return x == 0 - ? 0 - : x == 1 - ? 1 - : x < 0.5 - ? -(powf(2, 20 * x - 10) * sinf((20 * x - 11.125f) * c5)) / 2 - : (powf(2, -20 * x + 10) * sinf((20 * x - 11.125f) * c5)) / 2 + 1; -} - -float easeOutBounce(float x); - -float easeInBounce(float x) { - return 1 -easeOutBounce(1 - x); -} - -float easeOutBounce(float x) { - static const float n1 = 7.5625f; - static const float d1 = 2.75f; - - if (x < 1 / d1) { - return n1 * x * x; - } else if (x < 2 / d1) { - x -= 1.5f / d1; - return n1 * x * x + 0.75f; - } else if (x < 2.5f / d1) { - x -= 2.25f / d1; - return n1 * x * x + 0.9375f; - } else { - x -= 2.625f / d1; - return n1 * x * x + 0.984375f; - } -}; - -float easeInOutBounce(float x) { - return x < 0.5 - ? (1 - easeOutBounce(1 - 2 * x)) / 2 - : (1 + easeOutBounce(2 * x - 1)) / 2; -} - -EasingFuncType g_easingFuncs[] = { - linear, - easeInQuad, - easeOutQuad, - easeInOutQuad, - easeInCubic, - easeOutCubic, - easeInOutCubic, - easeInQuart, - easeOutQuart, - easeInOutQuart, - easeInQuint, - easeOutQuint, - easeInOutQuint, - easeInSine, - easeOutSine, - easeInOutSine, - easeInExpo, - easeOutExpo, - easeInOutExpo, - easeInCirc, - easeOutCirc, - easeInOutCirc, - easeInBack, - easeOutBack, - easeInOutBack, - easeInElastic, - easeOutElastic, - easeInOutElastic, - easeInBounce, - easeOutBounce, - easeInOutBounce, -}; - -} // namespace eez - -#ifdef EEZ_PLATFORM_SIMULATOR_WIN32 -char *strnstr(const char *s1, const char *s2, size_t n) { - char c = *s2; - - if (c == '\0') - return (char *)s1; - - for (size_t len = strlen(s2); len <= n; n--, s1++) { - if (*s1 == c) { - for (size_t i = 1;; i++) { - if (i == len) { - return (char *)s1; - } - if (s1[i] != s2[i]) { - break; - } - } - } - } - - return NULL; -} -#endif diff --git a/Middlewares/eez/core/util.h b/Middlewares/eez/core/util.h deleted file mode 100644 index d561697..0000000 --- a/Middlewares/eez/core/util.h +++ /dev/null @@ -1,209 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2018-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include -#include - -#include -#include - -#define clear_bit(reg, bitmask) *reg &= ~bitmask -#define set_bit(reg, bitmask) *reg |= bitmask -#define util_swap(type, i, j) \ - { \ - type t = i; \ - i = j; \ - j = t; \ - } - -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif - -#ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif - -#define PATH_SEPARATOR "/" - -namespace eez { - -float remap(float x, float x1, float y1, float x2, float y2); -float remapQuad(float x, float x1, float y1, float x2, float y2); -float remapOutQuad(float x, float x1, float y1, float x2, float y2); -float remapInOutQuad(float x, float x1, float y1, float x2, float y2); -float remapCubic(float x, float x1, float y1, float x2, float y2); -float remapOutCubic(float x, float x1, float y1, float x2, float y2); -float remapExp(float x, float x1, float y1, float x2, float y2); -float remapOutExp(float x, float x1, float y1, float x2, float y2); -float clamp(float x, float min, float max); - -void stringCopy(char *dst, size_t maxStrLength, const char *src); -void stringCopyLength(char *dst, size_t maxStrLength, const char *src, size_t length); - -void stringAppendString(char *str, size_t maxStrLength, const char *value); -void stringAppendStringLength(char *str, size_t maxStrLength, const char *value, size_t length); - -void stringAppendInt(char *str, size_t maxStrLength, int value); -void stringAppendUInt32(char *str, size_t maxStrLength, uint32_t value); -void stringAppendInt64(char *str, size_t maxStrLength, int64_t value); -void stringAppendUInt64(char *str, size_t maxStrLength, uint64_t value); -void stringAppendFloat(char *str, size_t maxStrLength, float value); -void stringAppendFloat(char *str, size_t maxStrLength, float value, int numDecimalPlaces); -void stringAppendDouble(char *str, size_t maxStrLength, double value); -void stringAppendDouble(char *str, size_t maxStrLength, double value, int numDecimalPlaces); - -void stringAppendVoltage(char *str, size_t maxStrLength, float value); -void stringAppendCurrent(char *str, size_t maxStrLength, float value); -void stringAppendPower(char *str, size_t maxStrLength, float value); -void stringAppendDuration(char *str, size_t maxStrLength, float value); -void stringAppendLoad(char *str, size_t maxStrLength, float value); - -uint32_t crc32(const uint8_t *message, size_t size); - -uint8_t toBCD(uint8_t bin); -uint8_t fromBCD(uint8_t bcd); - -float roundPrec(float a, float prec); -float floorPrec(float a, float prec); -float ceilPrec(float a, float prec); - -bool isNaN(float x); -bool isNaN(double x); - -bool isDigit(char ch); -bool isHexDigit(char ch); -bool isUperCaseLetter(char ch); - -char toHexDigit(int num); -int fromHexDigit(char ch); - -bool pointInsideRect(int xPoint, int yPoint, int xRect, int yRect, int wRect, int hRect); - -void getParentDir(const char *path, char *parentDirPath); - -bool parseMacAddress(const char *macAddressStr, size_t macAddressStrLength, uint8_t *macAddress); - -int getIpAddressPartA(uint32_t ipAddress); -void setIpAddressPartA(uint32_t *ipAddress, uint8_t value); - -int getIpAddressPartB(uint32_t ipAddress); -void setIpAddressPartB(uint32_t *ipAddress, uint8_t value); - -int getIpAddressPartC(uint32_t ipAddress); -void setIpAddressPartC(uint32_t *ipAddress, uint8_t value); - -int getIpAddressPartD(uint32_t ipAddress); -void setIpAddressPartD(uint32_t *ipAddress, uint8_t value); - -void ipAddressToArray(uint32_t ipAddress, uint8_t *ipAddressArray); -uint32_t arrayToIpAddress(uint8_t *ipAddressArray); - -uint32_t getIpAddress(uint8_t a, uint8_t b, uint8_t c, uint8_t d); - -bool parseIpAddress(const char *ipAddressStr, size_t ipAddressStrLength, uint32_t &ipAddress); -void ipAddressToString(uint32_t ipAddress, char *ipAddressStr, size_t maxIpAddressStrLength); - -void macAddressToString(const uint8_t *macAddress, char *macAddressStr); - -void formatTimeZone(int16_t timeZone, char *text, int count); -bool parseTimeZone(const char *timeZoneStr, size_t timeZoneLength, int16_t &timeZone); - -void replaceCharacter(char *str, char ch, char repl); - -int strcicmp(char const *a, char const *b); -int strncicmp(char const *a, char const *b, int n); -bool isStringEmpty(char const *a); -bool startsWith(const char *str, const char *prefix); -bool startsWithNoCase(const char *str, const char *prefix); -bool endsWith(const char *str, const char *suffix); -bool endsWithNoCase(const char *str, const char *suffix); - -void formatBytes(uint64_t bytes, char *text, int count); - -void getFileName(const char *path, char *fileName, unsigned fileNameSize); -void getBaseFileName(const char *path, char *baseName, unsigned baseNameSize); - -typedef float (*EasingFuncType)(float x); -extern EasingFuncType g_easingFuncs[]; - -class Interval { -public: - // Returns true when called for the first time, - // and later returns true after interval, interval * 2, interval * 3, ... - // Interval is in milliseconds. - bool test(uint32_t interval) { - auto time = millis(); - - if (lastTime == 0) { - lastTime = time == 0 ? 1 : time; - return true; - } - - if (time >= lastTime + interval) { - lastTime += ((uint32_t)(time - lastTime) / interval) * interval; - return true; - } - - return false; - } - -private: - uint32_t lastTime = 0; -}; - -template -class MovingAverage { -public: - void operator()(T sample) { - if (m_numSamples < N) { - m_samples[m_numSamples++] = sample; - m_total += sample; - } else { - T& oldest = m_samples[m_numSamples++ % N]; - m_total += sample - oldest; - oldest = sample; - } - } - - operator T() const { - if (m_numSamples < N) { - return m_total / m_numSamples; - } else { - return m_total / N; - } - } - - void reset() { - m_numSamples = 0; - m_total = 0; - } - -private: - T m_samples[N]; - uint64_t m_numSamples{0}; - Total m_total{0}; -}; - -} // namespace eez - -#ifdef EEZ_PLATFORM_SIMULATOR_WIN32 -char *strnstr(const char *s1, const char *s2, size_t n); -#endif diff --git a/Middlewares/eez/core/value_types.h b/Middlewares/eez/core/value_types.h deleted file mode 100644 index c097440..0000000 --- a/Middlewares/eez/core/value_types.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2020-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include -#include - -#define VALUE_TYPES \ - VALUE_TYPE(UNDEFINED) /* 0 */ \ - VALUE_TYPE(NULL) /* 1 */ \ - VALUE_TYPE(BOOLEAN) /* 2 */ \ - VALUE_TYPE(INT8) /* 3 */ \ - VALUE_TYPE(UINT8) /* 4 */ \ - VALUE_TYPE(INT16) /* 5 */ \ - VALUE_TYPE(UINT16) /* 6 */ \ - VALUE_TYPE(INT32) /* 7 */ \ - VALUE_TYPE(UINT32) /* 8 */ \ - VALUE_TYPE(INT64) /* 9 */ \ - VALUE_TYPE(UINT64) /* 10 */ \ - VALUE_TYPE(FLOAT) /* 11 */ \ - VALUE_TYPE(DOUBLE) /* 12 */ \ - VALUE_TYPE(STRING) /* 13 */ \ - VALUE_TYPE(ARRAY) /* 14 */ \ - VALUE_TYPE(STRING_REF) /* 15 */ \ - VALUE_TYPE(ARRAY_REF) /* 16 */ \ - VALUE_TYPE(BLOB_REF) /* 17 */ \ - VALUE_TYPE(STREAM) /* 18 */ \ - VALUE_TYPE(DATE) /* 19 */ \ - VALUE_TYPE(VERSIONED_STRING) /* 20 */ \ - VALUE_TYPE(VALUE_PTR) /* 21 */ \ - VALUE_TYPE(ARRAY_ELEMENT_VALUE) /* 22 */ \ - VALUE_TYPE(FLOW_OUTPUT) /* 23 */ \ - VALUE_TYPE(NATIVE_VARIABLE) /* 24 */ \ - VALUE_TYPE(RANGE) /* 25 */ \ - VALUE_TYPE(POINTER) /* 26 */ \ - VALUE_TYPE(ENUM) /* 27 */ \ - VALUE_TYPE(IP_ADDRESS) /* 28 */ \ - VALUE_TYPE(TIME_ZONE) /* 29 */ \ - VALUE_TYPE(YT_DATA_GET_VALUE_FUNCTION_POINTER) /* 30 */ \ - CUSTOM_VALUE_TYPES - -namespace eez { - -#define VALUE_TYPE(NAME) VALUE_TYPE_##NAME, -enum ValueType { - VALUE_TYPES -}; -#undef VALUE_TYPE - -} diff --git a/Middlewares/eez/flow/components.cpp b/Middlewares/eez/flow/components.cpp deleted file mode 100644 index aa27e0c..0000000 --- a/Middlewares/eez/flow/components.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#if defined(__EMSCRIPTEN__) -#include -#endif - -using namespace eez::gui; - -namespace eez { -namespace flow { - -void executeStartComponent(FlowState *flowState, unsigned componentIndex); -void executeEndComponent(FlowState *flowState, unsigned componentIndex); -void executeInputComponent(FlowState *flowState, unsigned componentIndex); -void executeOutputComponent(FlowState *flowState, unsigned componentIndex); -void executeWatchVariableComponent(FlowState *flowState, unsigned componentIndex); -void executeEvalExprComponent(FlowState *flowState, unsigned componentIndex); -void executeSetVariableComponent(FlowState *flowState, unsigned componentIndex); -void executeSwitchComponent(FlowState *flowState, unsigned componentIndex); -void executeCompareComponent(FlowState *flowState, unsigned componentIndex); -void executeIsTrueComponent(FlowState *flowState, unsigned componentIndex); -void executeConstantComponent(FlowState *flowState, unsigned componentIndex); -void executeLogComponent(FlowState *flowState, unsigned componentIndex); -void executeCallActionComponent(FlowState *flowState, unsigned componentIndex); -void executeDelayComponent(FlowState *flowState, unsigned componentIndex); -void executeErrorComponent(FlowState *flowState, unsigned componentIndex); -void executeCatchErrorComponent(FlowState *flowState, unsigned componentIndex); -void executeCounterComponent(FlowState *flowState, unsigned componentIndex); -void executeLoopComponent(FlowState *flowState, unsigned componentIndex); -void executeShowPageComponent(FlowState *flowState, unsigned componentIndex); -void executeShowMessageBoxComponent(FlowState *flowState, unsigned componentIndex); -void executeShowKeyboardComponent(FlowState *flowState, unsigned componentIndex); -void executeShowKeypadComponent(FlowState *flowState, unsigned componentIndex); -void executeSelectLanguageComponent(FlowState *flowState, unsigned componentIndex); -void executeSetPageDirectionComponent(FlowState *flowState, unsigned componentIndex); -void executeAnimateComponent(FlowState *flowState, unsigned componentIndex); -void executeNoopComponent(FlowState *flowState, unsigned componentIndex); -void executeOnEventComponent(FlowState *flowState, unsigned componentIndex); - -void executeLayoutViewWidgetComponent(FlowState *flowState, unsigned componentIndex); -void executeRollerWidgetComponent(FlowState *flowState, unsigned componentIndex); - -typedef void (*ExecuteComponentFunctionType)(FlowState *flowState, unsigned componentIndex); - -static ExecuteComponentFunctionType g_executeComponentFunctions[] = { - executeStartComponent, - executeEndComponent, - executeInputComponent, - executeOutputComponent, - executeWatchVariableComponent, - executeEvalExprComponent, - executeSetVariableComponent, - executeSwitchComponent, - executeCompareComponent, - executeIsTrueComponent, - executeConstantComponent, - executeLogComponent, - executeCallActionComponent, - executeDelayComponent, - executeErrorComponent, - executeCatchErrorComponent, - executeCounterComponent, // COMPONENT_TYPE_COUNTER_ACTION - executeLoopComponent, - executeShowPageComponent, - nullptr, // COMPONENT_TYPE_SCPIACTION - executeShowMessageBoxComponent, - executeShowKeyboardComponent, - executeShowKeypadComponent, - executeNoopComponent, // COMPONENT_TYPE_NOOP_ACTION - nullptr, // COMPONENT_TYPE_COMMENT_ACTION - executeSelectLanguageComponent, // COMPONENT_TYPE_SELECT_LANGUAGE_ACTION - executeSetPageDirectionComponent, // COMPONENT_TYPE_SET_PAGE_DIRECTION_ACTION - executeAnimateComponent, // COMPONENT_TYPE_ANIMATE_ACTION - executeOnEventComponent, // COMPONENT_TYPE_ON_EVENT_ACTION -}; - -void registerComponent(ComponentTypes componentType, ExecuteComponentFunctionType executeComponentFunction) { - if (componentType >= defs_v3::COMPONENT_TYPE_START_ACTION) { - g_executeComponentFunctions[componentType - defs_v3::COMPONENT_TYPE_START_ACTION] = executeComponentFunction; - } -} - -void executeComponent(FlowState *flowState, unsigned componentIndex) { - auto component = flowState->flow->components[componentIndex]; - -#if defined(__EMSCRIPTEN__) - if (component->type >= defs_v3::FIRST_DASHBOARD_COMPONENT_TYPE) { - if (executeDashboardComponentHook) { - executeDashboardComponentHook(component->type, getFlowStateIndex(flowState), componentIndex); - return; - } - } else -#endif // __EMSCRIPTEN__ - if (component->type >= defs_v3::COMPONENT_TYPE_START_ACTION) { - auto executeComponentFunction = g_executeComponentFunctions[component->type - defs_v3::COMPONENT_TYPE_START_ACTION]; - if (executeComponentFunction != nullptr) { - executeComponentFunction(flowState, componentIndex); - return; - } - } else if (component->type < 1000) { - if (component->type == defs_v3::COMPONENT_TYPE_LAYOUT_VIEW_WIDGET) { - executeLayoutViewWidgetComponent(flowState, componentIndex); - } else if (component->type == defs_v3::COMPONENT_TYPE_ROLLER_WIDGET) { - executeRollerWidgetComponent(flowState, componentIndex); - } - return; - } - - char errorMessage[100]; - snprintf(errorMessage, sizeof(errorMessage), "Unknown component at index = %d, type = %d\n", componentIndex, component->type); - throwError(flowState, componentIndex, errorMessage); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components.h b/Middlewares/eez/flow/components.h deleted file mode 100644 index e7a18b1..0000000 --- a/Middlewares/eez/flow/components.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2021-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include -#include - -namespace eez { -namespace flow { - -using defs_v3::ComponentTypes; - -typedef void (*ExecuteComponentFunctionType)(FlowState *flowState, unsigned componentIndex); -void registerComponent(ComponentTypes componentType, ExecuteComponentFunctionType executeComponentFunction); - -void executeComponent(FlowState *flowState, unsigned componentIndex); - -} // flow -} // eez \ No newline at end of file diff --git a/Middlewares/eez/flow/components/animate.cpp b/Middlewares/eez/flow/components/animate.cpp deleted file mode 100644 index 41968a2..0000000 --- a/Middlewares/eez/flow/components/animate.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include - -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -struct AnimateComponenentExecutionState : public ComponenentExecutionState { - float startPosition; - float endPosition; - float speed; - uint32_t startTimestamp; -}; - -void executeAnimateComponent(FlowState *flowState, unsigned componentIndex) { - auto state = (AnimateComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex]; - if (!state) { - Value fromValue; - if (!evalProperty(flowState, componentIndex, defs_v3::ANIMATE_ACTION_COMPONENT_PROPERTY_FROM, fromValue, "Failed to evaluate From in Animate")) { - return; - } - - Value toValue; - if (!evalProperty(flowState, componentIndex, defs_v3::ANIMATE_ACTION_COMPONENT_PROPERTY_TO, toValue, "Failed to evaluate To in Animate")) { - return; - } - - Value speedValue; - if (!evalProperty(flowState, componentIndex, defs_v3::ANIMATE_ACTION_COMPONENT_PROPERTY_SPEED, speedValue, "Failed to evaluate Speed in Animate")) { - return; - } - - float from = fromValue.toFloat(); - float to = toValue.toFloat(); - float speed = speedValue.toFloat(); - - if (speed == 0) { - flowState->timelinePosition = to; - onFlowStateTimelineChanged(flowState); - - propagateValueThroughSeqout(flowState, componentIndex); - } else { - state = allocateComponentExecutionState(flowState, componentIndex); - - state->startPosition = from; - state->endPosition = to; - state->speed = speed; - state->startTimestamp = millis(); - - if (!addToQueue(flowState, componentIndex, -1, -1, -1, true)) { - throwError(flowState, componentIndex, "Execution queue is full\n"); - return; - } - } - } else { - float currentTime; - - if (state->startPosition < state->endPosition) { - currentTime = state->startPosition + state->speed * (millis() - state->startTimestamp) / 1000.0f; - if (currentTime >= state->endPosition) { - currentTime = state->endPosition; - } - } else { - currentTime = state->startPosition - state->speed * (millis() - state->startTimestamp) / 1000.0f; - if (currentTime <= state->endPosition) { - currentTime = state->endPosition; - } - } - - flowState->timelinePosition = currentTime; - onFlowStateTimelineChanged(flowState); - - if (currentTime == state->endPosition) { - deallocateComponentExecutionState(flowState, componentIndex); - propagateValueThroughSeqout(flowState, componentIndex); - } else { - if (!addToQueue(flowState, componentIndex, -1, -1, -1, true)) { - throwError(flowState, componentIndex, "Execution queue is full\n"); - return; - } - } - } -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/call_action.cpp b/Middlewares/eez/flow/components/call_action.cpp deleted file mode 100644 index c1cd127..0000000 --- a/Middlewares/eez/flow/components/call_action.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include - -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -CallActionComponenentExecutionState::~CallActionComponenentExecutionState() { - freeFlowState(flowState); -} - -void executeCallAction(FlowState *flowState, unsigned componentIndex, int flowIndex) { - if (flowIndex >= (int)flowState->flowDefinition->flows.count) { - executeActionFunction(flowIndex - flowState->flowDefinition->flows.count); - propagateValueThroughSeqout(flowState, componentIndex); - return; - } - - auto callActionComponenentExecutionState = (CallActionComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex]; - if (callActionComponenentExecutionState) { - if (canFreeFlowState(callActionComponenentExecutionState->flowState)) { - freeFlowState(callActionComponenentExecutionState->flowState); - } else { - throwError(flowState, componentIndex, "CallAction is already running\n"); - return; - } - } - - FlowState *actionFlowState = initActionFlowState(flowIndex, flowState, componentIndex); - - if (canFreeFlowState(actionFlowState)) { - freeFlowState(actionFlowState); - propagateValueThroughSeqout(flowState, componentIndex); - } else { - callActionComponenentExecutionState = allocateComponentExecutionState(flowState, componentIndex); - callActionComponenentExecutionState->flowState = actionFlowState; - } -} - -void executeCallActionComponent(FlowState *flowState, unsigned componentIndex) { - auto component = (CallActionActionComponent *)flowState->flow->components[componentIndex]; - - auto flowIndex = component->flowIndex; - if (flowIndex < 0) { - throwError(flowState, componentIndex, "Invalid action flow index in CallAction\n"); - return; - } - - executeCallAction(flowState, componentIndex, flowIndex); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/call_action.h b/Middlewares/eez/flow/components/call_action.h deleted file mode 100644 index 11c6cc6..0000000 --- a/Middlewares/eez/flow/components/call_action.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2021-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include - -namespace eez { -namespace flow { - -struct CallActionActionComponent : public Component { - int16_t flowIndex; - uint8_t inputsStartIndex; - uint8_t outputsStartIndex; -}; - -typedef CallActionActionComponent LayoutViewWidgetComponent; - -struct CallActionComponenentExecutionState : public ComponenentExecutionState { - FlowState *flowState; - - ~CallActionComponenentExecutionState(); -}; - -} // flow -} // eez diff --git a/Middlewares/eez/flow/components/catch_error.cpp b/Middlewares/eez/flow/components/catch_error.cpp deleted file mode 100644 index 2aacde3..0000000 --- a/Middlewares/eez/flow/components/catch_error.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -void executeCatchErrorComponent(FlowState *flowState, unsigned componentIndex) { - auto catchErrorComponentExecutionState = (CatchErrorComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex]; - propagateValue(flowState, componentIndex, 1, catchErrorComponentExecutionState->message); - deallocateComponentExecutionState(flowState, componentIndex); - propagateValueThroughSeqout(flowState, componentIndex); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/compare.cpp b/Middlewares/eez/flow/components/compare.cpp deleted file mode 100644 index a815d7b..0000000 --- a/Middlewares/eez/flow/components/compare.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -struct CompareActionComponent : public Component { - uint8_t conditionInstructions[1]; -}; - -void executeCompareComponent(FlowState *flowState, unsigned componentIndex) { - auto component = (CompareActionComponent *)flowState->flow->components[componentIndex]; - - Value conditionValue; - if (!evalExpression(flowState, componentIndex, component->conditionInstructions, conditionValue, "Failed to evaluate Condition in Compare")) { - return; - } - - int err; - bool result = conditionValue.toBool(&err); - if (err == 0) { - if (result) { - propagateValue(flowState, componentIndex, 1, Value(true, VALUE_TYPE_BOOLEAN)); - } else { - propagateValue(flowState, componentIndex, 2, Value(false, VALUE_TYPE_BOOLEAN)); - } - } else { - throwError(flowState, componentIndex, "Failed to convert Value to boolean in IsTrue\n"); - return; - } - - propagateValueThroughSeqout(flowState, componentIndex); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/constant.cpp b/Middlewares/eez/flow/components/constant.cpp deleted file mode 100644 index 58fbb8a..0000000 --- a/Middlewares/eez/flow/components/constant.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -struct ConstantActionComponent : public Component { - uint16_t valueIndex; -}; - -void executeConstantComponent(FlowState *flowState, unsigned componentIndex) { - auto component = (ConstantActionComponent *)flowState->flow->components[componentIndex]; - - auto &sourceValue = *flowState->flowDefinition->constants[component->valueIndex]; - - propagateValue(flowState, componentIndex, 1, sourceValue); - - propagateValueThroughSeqout(flowState, componentIndex); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/counter.cpp b/Middlewares/eez/flow/components/counter.cpp deleted file mode 100644 index 5b2e1fe..0000000 --- a/Middlewares/eez/flow/components/counter.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -struct CounterComponenentExecutionState : public ComponenentExecutionState { - int counter; -}; - -void executeCounterComponent(FlowState *flowState, unsigned componentIndex) { - auto counterComponenentExecutionState = (CounterComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex]; - - if (!counterComponenentExecutionState) { - Value counterValue; - if (!evalProperty(flowState, componentIndex, defs_v3::COUNTER_ACTION_COMPONENT_PROPERTY_COUNT_VALUE, counterValue, "Failed to evaluate countValue in Counter")) { - return; - } - - counterComponenentExecutionState = allocateComponentExecutionState(flowState, componentIndex); - counterComponenentExecutionState->counter = counterValue.getInt(); - } - - if (counterComponenentExecutionState->counter > 0) { - counterComponenentExecutionState->counter--; - propagateValueThroughSeqout(flowState, componentIndex); - } else { - // done - deallocateComponentExecutionState(flowState, componentIndex); - propagateValue(flowState, componentIndex, 1); - } -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/delay.cpp b/Middlewares/eez/flow/components/delay.cpp deleted file mode 100644 index f8b1b78..0000000 --- a/Middlewares/eez/flow/components/delay.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include - -#include -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -struct DelayComponenentExecutionState : public ComponenentExecutionState { - uint32_t waitUntil; -}; - -void executeDelayComponent(FlowState *flowState, unsigned componentIndex) { - auto delayComponentExecutionState = (DelayComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex]; - - if (!delayComponentExecutionState) { - Value value; - if (!evalProperty(flowState, componentIndex, defs_v3::DELAY_ACTION_COMPONENT_PROPERTY_MILLISECONDS, value, "Failed to evaluate Milliseconds in Delay")) { - return; - } - - double milliseconds = value.toDouble(); - if (!isNaN(milliseconds)) { - delayComponentExecutionState = allocateComponentExecutionState(flowState, componentIndex); - delayComponentExecutionState->waitUntil = millis() + (uint32_t)floor(milliseconds); - } else { - throwError(flowState, componentIndex, "Invalid Milliseconds value in Delay\n"); - return; - } - - if (!addToQueue(flowState, componentIndex, -1, -1, -1, true)) { - throwError(flowState, componentIndex, "Execution queue is full\n"); - return; - } - } else { - if (millis() >= delayComponentExecutionState->waitUntil) { - deallocateComponentExecutionState(flowState, componentIndex); - propagateValueThroughSeqout(flowState, componentIndex); - } else { - if (!addToQueue(flowState, componentIndex, -1, -1, -1, true)) { - throwError(flowState, componentIndex, "Execution queue is full\n"); - return; - } - } - } -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/end.cpp b/Middlewares/eez/flow/components/end.cpp deleted file mode 100644 index ccde926..0000000 --- a/Middlewares/eez/flow/components/end.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -void executeEndComponent(FlowState *flowState, unsigned componentIndex) { - if (flowState->parentFlowState && flowState->isAction) { - propagateValueThroughSeqout(flowState->parentFlowState, flowState->parentComponentIndex); - } else { - stopScriptHook(); - } -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/error.cpp b/Middlewares/eez/flow/components/error.cpp deleted file mode 100644 index 7f67e5f..0000000 --- a/Middlewares/eez/flow/components/error.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -void executeErrorComponent(FlowState *flowState, unsigned componentIndex) { - Value expressionValue; - if (!evalProperty(flowState, componentIndex, defs_v3::EVAL_EXPR_ACTION_COMPONENT_PROPERTY_EXPRESSION, expressionValue, "Failed to evaluate Message in Error")) { - return; - } - - throwError(flowState, componentIndex, expressionValue.getString()); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/expr_eval.cpp b/Middlewares/eez/flow/components/expr_eval.cpp deleted file mode 100644 index 523fc66..0000000 --- a/Middlewares/eez/flow/components/expr_eval.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -void executeEvalExprComponent(FlowState *flowState, unsigned componentIndex) { - Value expressionValue; - if (!evalProperty(flowState, componentIndex, defs_v3::EVAL_EXPR_ACTION_COMPONENT_PROPERTY_EXPRESSION, expressionValue, "Failed to evaluate Expression in EvalExpr")) { - return; - } - - propagateValue(flowState, componentIndex, 1, expressionValue); - - propagateValueThroughSeqout(flowState, componentIndex); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/input.cpp b/Middlewares/eez/flow/components/input.cpp deleted file mode 100644 index c1241e2..0000000 --- a/Middlewares/eez/flow/components/input.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -bool getCallActionValue(FlowState *flowState, unsigned componentIndex, Value &value) { - auto component = (InputActionComponent *)flowState->flow->components[componentIndex]; - - if (!flowState->parentFlowState) { - throwError(flowState, componentIndex, "No parentFlowState in Input\n"); - return false; - } - - if (!flowState->parentComponent) { - throwError(flowState, componentIndex, "No parentComponent in Input\n"); - return false; - } - - auto callActionComponent = (CallActionActionComponent *)flowState->parentComponent; - - uint8_t parentComponentInputIndex = callActionComponent->inputsStartIndex + component->inputIndex; - if (component->type == defs_v3::COMPONENT_TYPE_INPUT_ACTION) { - parentComponentInputIndex = callActionComponent->inputsStartIndex + component->inputIndex; - } else { - parentComponentInputIndex = 0; - } - - if (parentComponentInputIndex >= flowState->parentComponent->inputs.count) { - throwError(flowState, componentIndex, "Invalid input index in Input\n"); - return false; - } - - auto parentComponentInputs = flowState->parentComponent->inputs; - auto flowInputIndex = parentComponentInputs[parentComponentInputIndex]; - - auto parentFlow = flowState->flowDefinition->flows[flowState->parentFlowState->flowIndex]; - if (flowInputIndex >= parentFlow->componentInputs.count) { - throwError(flowState, componentIndex, "Invalid input index of parent component in Input\n"); - return false; - } - - value = flowState->parentFlowState->values[flowInputIndex]; - return true; -} - -void executeInputComponent(FlowState *flowState, unsigned componentIndex) { - Value value; - if (getCallActionValue(flowState, componentIndex, value)) { - auto inputActionComponentExecutionState = (InputActionComponentExecutionState *)flowState->componenentExecutionStates[componentIndex]; - if (!inputActionComponentExecutionState) { - inputActionComponentExecutionState = allocateComponentExecutionState(flowState, componentIndex); - } - - propagateValue(flowState, componentIndex, 0, value); - inputActionComponentExecutionState->value = value; - } -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/input.h b/Middlewares/eez/flow/components/input.h deleted file mode 100644 index deaa52e..0000000 --- a/Middlewares/eez/flow/components/input.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2021-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include - -namespace eez { -namespace flow { - -struct InputActionComponent : public Component { - uint8_t inputIndex; -}; - -struct InputActionComponentExecutionState : public ComponenentExecutionState { - Value value; -}; - - -bool getCallActionValue(FlowState *flowState, unsigned componentIndex, Value &value); - -} // flow -} // eez diff --git a/Middlewares/eez/flow/components/is_true.cpp b/Middlewares/eez/flow/components/is_true.cpp deleted file mode 100644 index eb26cc0..0000000 --- a/Middlewares/eez/flow/components/is_true.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -void executeIsTrueComponent(FlowState *flowState, unsigned componentIndex) { - Value srcValue; - if (!evalProperty(flowState, componentIndex, defs_v3::IS_TRUE_ACTION_COMPONENT_PROPERTY_VALUE, srcValue, "Failed to evaluate Value in IsTrue")) { - return; - } - - int err; - bool result = srcValue.toBool(&err); - if (err == 0) { - if (result) { - propagateValue(flowState, componentIndex, 1, Value(true, VALUE_TYPE_BOOLEAN)); - } else { - propagateValue(flowState, componentIndex, 2, Value(false, VALUE_TYPE_BOOLEAN)); - } - } else { - throwError(flowState, componentIndex, "Failed to convert Value to boolean in IsTrue\n"); - return; - } - - propagateValueThroughSeqout(flowState, componentIndex); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/layout_view_widget.cpp b/Middlewares/eez/flow/components/layout_view_widget.cpp deleted file mode 100644 index f7c800c..0000000 --- a/Middlewares/eez/flow/components/layout_view_widget.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include - -#include -#include -#include -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -struct LayoutViewWidgetExecutionState : public ComponenentExecutionState { - FlowState *flowState; - - ~LayoutViewWidgetExecutionState() { - freeFlowState(flowState); - } -}; - -static LayoutViewWidgetExecutionState *createLayoutViewFlowState(FlowState *flowState, uint16_t layoutViewWidgetComponentIndex, int16_t pageId) { - auto layoutViewFlowState = initPageFlowState(flowState->assets, pageId, flowState, layoutViewWidgetComponentIndex); - auto layoutViewWidgetExecutionState = allocateComponentExecutionState(flowState, layoutViewWidgetComponentIndex); - layoutViewWidgetExecutionState->flowState = layoutViewFlowState; - return layoutViewWidgetExecutionState; -} - -FlowState *getLayoutViewFlowState(FlowState *flowState, uint16_t layoutViewWidgetComponentIndex, int16_t pageId) { - auto layoutViewWidgetExecutionState = (LayoutViewWidgetExecutionState *)flowState->componenentExecutionStates[layoutViewWidgetComponentIndex]; - if (!layoutViewWidgetExecutionState) { - layoutViewWidgetExecutionState = createLayoutViewFlowState(flowState, layoutViewWidgetComponentIndex, pageId); - } - - return layoutViewWidgetExecutionState->flowState; -} - -void executeLayoutViewWidgetComponent(FlowState *flowState, unsigned componentIndex) { - auto component = (CallActionActionComponent *)flowState->flow->components[componentIndex]; - - auto layoutViewWidgetExecutionState = (LayoutViewWidgetExecutionState *)flowState->componenentExecutionStates[componentIndex]; - if (!layoutViewWidgetExecutionState) { - createLayoutViewFlowState(flowState, componentIndex, component->flowIndex); - } else { - auto layoutViewFlowState = layoutViewWidgetExecutionState->flowState; - for ( - unsigned layoutViewComponentIndex = 0; - layoutViewComponentIndex < layoutViewFlowState->flow->components.count; - layoutViewComponentIndex++ - ) { - auto layoutViewComponent = layoutViewFlowState->flow->components[layoutViewComponentIndex]; - if (layoutViewComponent->type == defs_v3::COMPONENT_TYPE_INPUT_ACTION) { - auto inputActionComponentExecutionState = (InputActionComponentExecutionState *)layoutViewFlowState->componenentExecutionStates[layoutViewComponentIndex]; - if (inputActionComponentExecutionState) { - Value value; - if (getCallActionValue(layoutViewFlowState, layoutViewComponentIndex, value)) { - if (inputActionComponentExecutionState->value != value) { - addToQueue(layoutViewWidgetExecutionState->flowState, layoutViewComponentIndex); - inputActionComponentExecutionState->value = value; - } - } else { - return; - } - } - } else if (layoutViewComponent->type == defs_v3::COMPONENT_TYPE_START_ACTION) { - Value value; - if (getCallActionValue(layoutViewFlowState, layoutViewComponentIndex, value)) { - if (value.getType() != VALUE_TYPE_UNDEFINED) { - addToQueue(layoutViewWidgetExecutionState->flowState, layoutViewComponentIndex); - } - } else { - return; - } - } - } - } -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/log.cpp b/Middlewares/eez/flow/components/log.cpp deleted file mode 100644 index cece2a0..0000000 --- a/Middlewares/eez/flow/components/log.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -void executeLogComponent(FlowState *flowState, unsigned componentIndex) { - Value value; - if (!evalProperty(flowState, componentIndex, defs_v3::LOG_ACTION_COMPONENT_PROPERTY_VALUE, value, "Failed to evaluate Message in Log")) { - return; - } - - Value strValue = value.toString(0x0f9812ee); - const char *valueStr = strValue.getString(); - if (valueStr && *valueStr) { - logInfo(flowState, componentIndex, valueStr); - } - - propagateValueThroughSeqout(flowState, componentIndex); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/loop.cpp b/Middlewares/eez/flow/components/loop.cpp deleted file mode 100644 index b7f941e..0000000 --- a/Middlewares/eez/flow/components/loop.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -struct LoopComponenentExecutionState : public ComponenentExecutionState { - Value dstValue; - Value toValue; - Value currentValue; -}; - -void executeLoopComponent(FlowState *flowState, unsigned componentIndex) { - auto component = flowState->flow->components[componentIndex]; - - auto loopComponentExecutionState = (LoopComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex]; - - // restart loop if entered through "start" input - static const unsigned START_INPUT_INDEX = 0; - auto startInputIndex = component->inputs[START_INPUT_INDEX]; - if (flowState->values[startInputIndex].type != VALUE_TYPE_UNDEFINED) { - if (loopComponentExecutionState) { - deallocateComponentExecutionState(flowState, componentIndex); - loopComponentExecutionState = nullptr; - } - } else { - if (!loopComponentExecutionState) { - return; - } - } - - Value stepValue; - if (!evalProperty(flowState, componentIndex, defs_v3::LOOP_ACTION_COMPONENT_PROPERTY_STEP, stepValue, "Failed to evaluate Step in Loop")) { - return; - } - - if (!loopComponentExecutionState) { - Value dstValue; - if (!evalAssignableProperty(flowState, componentIndex, defs_v3::LOOP_ACTION_COMPONENT_PROPERTY_VARIABLE, dstValue, "Failed to evaluate Variable in Loop")) { - return; - } - - Value fromValue; - if (!evalProperty(flowState, componentIndex, defs_v3::LOOP_ACTION_COMPONENT_PROPERTY_FROM, fromValue, "Failed to evaluate From in Loop")) { - return; - } - - Value toValue; - if (!evalProperty(flowState, componentIndex, defs_v3::LOOP_ACTION_COMPONENT_PROPERTY_TO, toValue, "Failed to evaluate To in Loop")) { - return; - } - - loopComponentExecutionState = allocateComponentExecutionState(flowState, componentIndex); - loopComponentExecutionState->dstValue = dstValue; - loopComponentExecutionState->toValue = toValue; - - loopComponentExecutionState->currentValue = fromValue; - } else { - loopComponentExecutionState->currentValue = op_add(loopComponentExecutionState->currentValue, stepValue); - } - - bool condition; - if (stepValue.getInt() > 0) { - condition = op_great(loopComponentExecutionState->currentValue, loopComponentExecutionState->toValue).toBool(); - } else { - condition = op_less(loopComponentExecutionState->currentValue, loopComponentExecutionState->toValue).toBool(); - } - - if (condition) { - // done - deallocateComponentExecutionState(flowState, componentIndex); - propagateValue(flowState, componentIndex, component->outputs.count - 1); - } else { - assignValue(flowState, componentIndex, loopComponentExecutionState->dstValue, loopComponentExecutionState->currentValue); - propagateValueThroughSeqout(flowState, componentIndex); - } -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/noop.cpp b/Middlewares/eez/flow/components/noop.cpp deleted file mode 100644 index a5bde41..0000000 --- a/Middlewares/eez/flow/components/noop.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -void executeNoopComponent(FlowState *flowState, unsigned componentIndex) { - propagateValueThroughSeqout(flowState, componentIndex); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/on_event.cpp b/Middlewares/eez/flow/components/on_event.cpp deleted file mode 100644 index 484453c..0000000 --- a/Middlewares/eez/flow/components/on_event.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -void executeOnEventComponent(FlowState *flowState, unsigned componentIndex) { - propagateValueThroughSeqout(flowState, componentIndex); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/output.cpp b/Middlewares/eez/flow/components/output.cpp deleted file mode 100644 index 1786de1..0000000 --- a/Middlewares/eez/flow/components/output.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -using namespace eez::gui; - -namespace eez { -namespace flow { - -struct OutputActionComponent : public Component { - uint8_t outputIndex; -}; - -void executeOutputComponent(FlowState *flowState, unsigned componentIndex) { - auto component = (OutputActionComponent *)flowState->flow->components[componentIndex]; - - if (!flowState->parentFlowState) { - throwError(flowState, componentIndex, "No parentFlowState in Output\n"); - return; - } - - if (!flowState->parentComponent) { - throwError(flowState, componentIndex, "No parentComponent in Output\n"); - return; - } - - auto inputIndex = component->inputs[0]; - if (inputIndex >= flowState->flow->componentInputs.count) { - throwError(flowState, componentIndex, "Invalid input index in Output\n"); - return; - } - - auto value = flowState->values[inputIndex]; - - auto callActionComponent = (CallActionActionComponent *)flowState->parentComponent; - - uint8_t parentComponentOutputIndex = callActionComponent->outputsStartIndex + component->outputIndex; - - if (parentComponentOutputIndex >= flowState->parentComponent->outputs.count) { - throwError(flowState, componentIndex, "Output action component, invalid output index\n"); - return; - } - - propagateValue(flowState->parentFlowState, flowState->parentComponentIndex, parentComponentOutputIndex, value); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/roller_widget.cpp b/Middlewares/eez/flow/components/roller_widget.cpp deleted file mode 100644 index afba520..0000000 --- a/Middlewares/eez/flow/components/roller_widget.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -void executeRollerWidgetComponent(FlowState *flowState, unsigned componentIndex) { - auto component = flowState->flow->components[componentIndex]; - - static const unsigned START_INPUT_INDEX = 0; - auto startInputIndex = component->inputs[START_INPUT_INDEX]; - if (flowState->values[startInputIndex].type != VALUE_TYPE_UNDEFINED) { - auto executionState = (RollerWidgetComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex]; - if (!executionState) { - executionState = allocateComponentExecutionState(flowState, componentIndex); - } - executionState->clear = true; - } -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/roller_widget.h b/Middlewares/eez/flow/components/roller_widget.h deleted file mode 100644 index 65ae3e2..0000000 --- a/Middlewares/eez/flow/components/roller_widget.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2021-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include - -namespace eez { -namespace flow { - -struct RollerWidgetComponenentExecutionState : public ComponenentExecutionState { - bool clear; -}; - -} // flow -} // eez \ No newline at end of file diff --git a/Middlewares/eez/flow/components/select_language.cpp b/Middlewares/eez/flow/components/select_language.cpp deleted file mode 100644 index 4132f6a..0000000 --- a/Middlewares/eez/flow/components/select_language.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -void executeSelectLanguageComponent(FlowState *flowState, unsigned componentIndex) { - Value languageValue; - if (!evalProperty(flowState, componentIndex, defs_v3::SELECT_LANGUAGE_ACTION_COMPONENT_PROPERTY_LANGUAGE, languageValue, "Failed to evaluate Language in SelectLanguage")) { - return; - } - - const char *language = languageValue.getString(); - - auto languages = flowState->assets->languages; - - for (uint32_t languageIndex = 0; languageIndex < languages.count; languageIndex++) { - if (strcmp(languages[languageIndex]->languageID, language) == 0) { - g_selectedLanguage = languageIndex; - propagateValueThroughSeqout(flowState, componentIndex); - return; - } - } - - char message[256]; - snprintf(message, sizeof(message), "Unknown language %s", language); - throwError(flowState, componentIndex, message); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/set_page_direction.cpp b/Middlewares/eez/flow/components/set_page_direction.cpp deleted file mode 100644 index f292072..0000000 --- a/Middlewares/eez/flow/components/set_page_direction.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include - -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -#define PAGE_DIRECTION_LTR 0 -#define PAGE_DIRECTION_RTL 1 - -struct SetPageDirectionComponent : public Component { - uint8_t direction; -}; - -void executeSetPageDirectionComponent(FlowState *flowState, unsigned componentIndex) { - auto component = (SetPageDirectionComponent *)flowState->flow->components[componentIndex]; - - gui::g_isRTL = component->direction == PAGE_DIRECTION_RTL; - - gui::refreshScreen(); - - propagateValueThroughSeqout(flowState, componentIndex); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/set_variable.cpp b/Middlewares/eez/flow/components/set_variable.cpp deleted file mode 100644 index 3dfaeef..0000000 --- a/Middlewares/eez/flow/components/set_variable.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -void executeSetVariableComponent(FlowState *flowState, unsigned componentIndex) { - auto component = (SetVariableActionComponent *)flowState->flow->components[componentIndex]; - - for (uint32_t entryIndex = 0; entryIndex < component->entries.count; entryIndex++) { - auto entry = component->entries[entryIndex]; - - char strErrorMessage[256]; - snprintf(strErrorMessage, sizeof(strErrorMessage), "Failed to evaluate Variable no. %d in SetVariable", (int)(entryIndex + 1)); - - Value dstValue; - if (!evalAssignableExpression(flowState, componentIndex, entry->variable, dstValue, strErrorMessage)) { - return; - } - - snprintf(strErrorMessage, sizeof(strErrorMessage), "Failed to evaluate Value no. %d in SetVariable", (int)(entryIndex + 1)); - - Value srcValue; - if (!evalExpression(flowState, componentIndex, entry->value, srcValue, strErrorMessage)) { - return; - } - - assignValue(flowState, componentIndex, dstValue, srcValue); - } - - propagateValueThroughSeqout(flowState, componentIndex); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/set_variable.h b/Middlewares/eez/flow/components/set_variable.h deleted file mode 100644 index 70f7deb..0000000 --- a/Middlewares/eez/flow/components/set_variable.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2022-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include - -namespace eez { -namespace flow { - -struct SetVariableEntry { - eez::gui::AssetsPtr variable; - eez::gui::AssetsPtr value; -}; - -struct SetVariableActionComponent : public Component { - eez::gui::ListOfAssetsPtr entries; -}; - -} // flow -} // eez diff --git a/Middlewares/eez/flow/components/show_keyboard.cpp b/Middlewares/eez/flow/components/show_keyboard.cpp deleted file mode 100644 index 85a8aa8..0000000 --- a/Middlewares/eez/flow/components/show_keyboard.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace eez { -namespace flow { - -struct ShowKeyboardActionComponent : public Component { - uint8_t password; -}; - -void executeShowKeyboardComponent(FlowState *flowState, unsigned componentIndex) { - auto component = (ShowKeyboardActionComponent *)flowState->flow->components[componentIndex]; - - Value labelValue; - if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYBOARD_ACTION_COMPONENT_PROPERTY_LABEL, labelValue, "Failed to evaluate Label in ShowKeyboard")) { - return; - } - - Value initialTextValue; - if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYBOARD_ACTION_COMPONENT_PROPERTY_INITAL_TEXT, initialTextValue, "Failed to evaluate InitialText in ShowKeyboard")) { - return; - } - - Value minCharsValue; - if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYBOARD_ACTION_COMPONENT_PROPERTY_MIN_CHARS, minCharsValue, "Failed to evaluate MinChars in ShowKeyboard")) { - return; - } - - Value maxCharsValue; - if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYBOARD_ACTION_COMPONENT_PROPERTY_MAX_CHARS, maxCharsValue, "Failed to evaluate MaxChars in ShowKeyboard")) { - return; - } - - static FlowState *g_showKeyboardFlowState; - static unsigned g_showKeyboardComponentIndex; - - g_showKeyboardFlowState = flowState; - g_showKeyboardComponentIndex = componentIndex; - - startAsyncExecution(flowState, componentIndex); - - auto onOk = [](char *value) { - propagateValue(g_showKeyboardFlowState, g_showKeyboardComponentIndex, 0, Value::makeStringRef(value, -1, 0x87d32fe2)); - getAppContextFromId(APP_CONTEXT_ID_DEVICE)->popPage(); - endAsyncExecution(g_showKeyboardFlowState, g_showKeyboardComponentIndex); - }; - - auto onCancel = []() { - propagateValue(g_showKeyboardFlowState, g_showKeyboardComponentIndex, 1, Value()); - getAppContextFromId(APP_CONTEXT_ID_DEVICE)->popPage(); - endAsyncExecution(g_showKeyboardFlowState, g_showKeyboardComponentIndex); - }; - - const char *label = labelValue.getString(); - if (label && *label) { - labelValue = op_add(labelValue, Value(": ")); - } - - showKeyboardHook(labelValue, initialTextValue, minCharsValue, maxCharsValue, component->password, onOk, onCancel); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/show_keypad.cpp b/Middlewares/eez/flow/components/show_keypad.cpp deleted file mode 100644 index 6224440..0000000 --- a/Middlewares/eez/flow/components/show_keypad.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace eez { -namespace flow { - -struct ShowKeyboardActionComponent : public Component { - uint8_t password; -}; - -void executeShowKeypadComponent(FlowState *flowState, unsigned componentIndex) { - Value labelValue; - if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYBOARD_ACTION_COMPONENT_PROPERTY_LABEL, labelValue, "Failed to evaluate Label in ShowKeypad")) { - return; - } - - Value initialValue; - if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_INITAL_VALUE, initialValue, "Failed to evaluate InitialValue in ShowKeypad")) { - return; - } - - Value minValue; - if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_MIN, minValue, "Failed to evaluate Min in ShowKeypad")) { - return; - } - - Value maxValue; - if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_MAX, maxValue, "Failed to evaluate Max in ShowKeypad")) { - return; - } - - Value unitValue; - if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_UNIT, unitValue, "Failed to evaluate Unit in ShowKeypad")) { - return; - } - - static FlowState *g_showKeyboardFlowState; - static unsigned g_showKeyboardComponentIndex; - - g_showKeyboardFlowState = flowState; - g_showKeyboardComponentIndex = componentIndex; - - startAsyncExecution(flowState, componentIndex); - - auto onOk = [](float value) { - Value precisionValue; - if (!evalProperty(g_showKeyboardFlowState, g_showKeyboardComponentIndex, defs_v3::SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_PRECISION, precisionValue, "Failed to evaluate Precision in ShowKeypad")) { - return; - } - - float precision = precisionValue.toFloat(); - - Value unitValue; - if (!evalProperty(g_showKeyboardFlowState, g_showKeyboardComponentIndex, defs_v3::SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_UNIT, unitValue, "Failed to evaluate Unit in ShowKeypad")) { - return; - } - - Unit unit = getUnitFromName(unitValue.getString()); - - value = roundPrec(value, precision) / getUnitFactor(unit); - - propagateValue(g_showKeyboardFlowState, g_showKeyboardComponentIndex, 0, Value(value, VALUE_TYPE_FLOAT)); - getAppContextFromId(APP_CONTEXT_ID_DEVICE)->popPage(); - endAsyncExecution(g_showKeyboardFlowState, g_showKeyboardComponentIndex); - }; - - auto onCancel = []() { - propagateValue(g_showKeyboardFlowState, g_showKeyboardComponentIndex, 1, Value()); - getAppContextFromId(APP_CONTEXT_ID_DEVICE)->popPage(); - endAsyncExecution(g_showKeyboardFlowState, g_showKeyboardComponentIndex); - }; - - const char *label = labelValue.getString(); - if (label && *label) { - labelValue = op_add(labelValue, Value(": ")); - } - - Unit unit = getUnitFromName(unitValue.getString()); - - showKeypadHook(labelValue, initialValue, minValue, maxValue, unit, onOk, onCancel); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/show_message_box.cpp b/Middlewares/eez/flow/components/show_message_box.cpp deleted file mode 100644 index dfc0446..0000000 --- a/Middlewares/eez/flow/components/show_message_box.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include - -#include - -namespace eez { -namespace flow { - -const uint8_t MESSAGE_BOX_TYPE_INFO = 1; -const uint8_t MESSAGE_BOX_TYPE_ERROR = 2; - -struct ShowMessagePageActionComponent : public Component { - uint8_t type; -}; - -void executeShowMessageBoxComponent(FlowState *flowState, unsigned componentIndex) { - auto component = (ShowMessagePageActionComponent *)flowState->flow->components[componentIndex]; - - Value messageValue; - if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_MESSAGE_BOX_ACTION_COMPONENT_PROPERTY_MESSAGE, messageValue, "Failed to evaluate Message in ShowMessageBox")) { - return; - } - - if (component->type == MESSAGE_BOX_TYPE_INFO) { - getAppContextFromId(APP_CONTEXT_ID_DEVICE)->infoMessage(messageValue); - } else if (component->type == MESSAGE_BOX_TYPE_ERROR) { - getAppContextFromId(APP_CONTEXT_ID_DEVICE)->errorMessage(messageValue); - } -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/show_page.cpp b/Middlewares/eez/flow/components/show_page.cpp deleted file mode 100644 index b291525..0000000 --- a/Middlewares/eez/flow/components/show_page.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include - -namespace eez { -namespace flow { - -struct ShowPageActionComponent : public Component { - int16_t page; -}; - -void executeShowPageComponent(FlowState *flowState, unsigned componentIndex) { - auto component = (ShowPageActionComponent *)flowState->flow->components[componentIndex]; - - replacePageHook(component->page); - - propagateValueThroughSeqout(flowState, componentIndex); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/start.cpp b/Middlewares/eez/flow/components/start.cpp deleted file mode 100644 index c31fb00..0000000 --- a/Middlewares/eez/flow/components/start.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -void executeStartComponent(FlowState *flowState, unsigned componentIndex) { - propagateValueThroughSeqout(flowState, componentIndex); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/switch.cpp b/Middlewares/eez/flow/components/switch.cpp deleted file mode 100644 index 5614dbd..0000000 --- a/Middlewares/eez/flow/components/switch.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include - -namespace eez { -namespace flow { - -void executeSwitchComponent(FlowState *flowState, unsigned componentIndex) { - auto component = (SwitchActionComponent *)flowState->flow->components[componentIndex]; - - for (uint32_t testIndex = 0; testIndex < component->tests.count; testIndex++) { - auto test = component->tests[testIndex]; - - char strMessage[256]; - snprintf(strMessage, sizeof(strMessage), "Failed to evaluate test condition no. %d in Switch", (int)(testIndex + 1)); - - Value conditionValue; - if (!evalExpression(flowState, componentIndex, test->conditionInstructions, conditionValue, strMessage)) { - return; - } - - int err; - bool result = conditionValue.toBool(&err); - if (err == 0) { - if (result) { - propagateValue(flowState, componentIndex, test->outputIndex); - break; - } - } else { - char strMessage[256]; - snprintf(strMessage, sizeof(strMessage), "Failed to convert Value no. %d to boolean in Switch\n", (int)(testIndex + 1)); - throwError(flowState, componentIndex, strMessage); - return; - } - } - - propagateValueThroughSeqout(flowState, componentIndex); -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/components/switch.h b/Middlewares/eez/flow/components/switch.h deleted file mode 100644 index 1a30767..0000000 --- a/Middlewares/eez/flow/components/switch.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2022-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include - -namespace eez { -namespace flow { - -struct SwitchTest { - uint8_t outputIndex; - uint8_t conditionInstructions[1]; -}; - -struct SwitchActionComponent : public Component { - eez::gui::ListOfAssetsPtr tests; -}; - -} // flow -} // eez \ No newline at end of file diff --git a/Middlewares/eez/flow/components/watch_variable.cpp b/Middlewares/eez/flow/components/watch_variable.cpp deleted file mode 100644 index d700c51..0000000 --- a/Middlewares/eez/flow/components/watch_variable.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include -#include - -#include -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -struct WatchVariableComponenentExecutionState : public ComponenentExecutionState { - Value value; -}; - -void executeWatchVariableComponent(FlowState *flowState, unsigned componentIndex) { - auto watchVariableComponentExecutionState = (WatchVariableComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex]; - - Value value; - if (!evalProperty(flowState, componentIndex, defs_v3::WATCH_VARIABLE_ACTION_COMPONENT_PROPERTY_VARIABLE, value, "Failed to evaluate Variable in WatchVariable")) { - return; - } - - if (!watchVariableComponentExecutionState) { - watchVariableComponentExecutionState = allocateComponentExecutionState(flowState, componentIndex); - watchVariableComponentExecutionState->value = value; - - propagateValue(flowState, componentIndex, 1, value); - - if (!addToQueue(flowState, componentIndex, -1, -1, -1, true)) { - throwError(flowState, componentIndex, "Execution queue is full\n"); - return; - } - } else { - if (value != watchVariableComponentExecutionState->value) { - watchVariableComponentExecutionState->value = value; - propagateValue(flowState, componentIndex, 1, value); - } - - if (canFreeFlowState(flowState, false)) { - deallocateComponentExecutionState(flowState, componentIndex); - } else { - if (!addToQueue(flowState, componentIndex, -1, -1, -1, true)) { - throwError(flowState, componentIndex, "Execution queue is full\n"); - return; - } - } - } -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/dashboard_api.cpp b/Middlewares/eez/flow/dashboard_api.cpp deleted file mode 100644 index d6d12a1..0000000 --- a/Middlewares/eez/flow/dashboard_api.cpp +++ /dev/null @@ -1,378 +0,0 @@ - -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#if defined(__EMSCRIPTEN__) - -#include - -#include -#include - -#include -#include -#include - -using namespace eez; -using namespace eez::gui; -using namespace eez::flow; - -namespace eez { -namespace flow { - -int getFlowStateIndex(FlowState *flowState) { - return (int)((uint8_t *)flowState - ALLOC_BUFFER); -} - -struct DashboardComponentExecutionState : public ComponenentExecutionState { - ~DashboardComponentExecutionState() { - EM_ASM({ - freeComponentExecutionState($0, $1); - }, g_wasmModuleId, state); - } - int32_t state; -}; - -} // flow -} // eez - -static inline FlowState *getFlowState(int flowStateIndex) { - return (FlowState *)(ALLOC_BUFFER + flowStateIndex); -} - -static void updateArrayValue(ArrayValue *arrayValue1, ArrayValue *arrayValue2) { - for (uint32_t i = 0; i < arrayValue1->arraySize; i++) { - if (arrayValue1->values[i].getType() == VALUE_TYPE_ARRAY || arrayValue1->values[i].getType() == VALUE_TYPE_ARRAY_REF) { - updateArrayValue(arrayValue1->values[i].getArray(), arrayValue2->values[i].getArray()); - } else { - arrayValue1->values[i] = arrayValue2->values[i]; - } - } -} - -EM_PORT_API(Value *) createUndefinedValue() { - auto pValue = ObjectAllocator::allocate(0x2e821285); - *pValue = Value(0, VALUE_TYPE_UNDEFINED); - return pValue; -} - -EM_PORT_API(Value *) createNullValue() { - auto pValue = ObjectAllocator::allocate(0x69debded); - *pValue = Value(0, VALUE_TYPE_NULL); - return pValue; -} - -EM_PORT_API(Value *) createIntValue(int value) { - auto pValue = ObjectAllocator::allocate(0x20ea356c); - *pValue = Value(value, VALUE_TYPE_INT32); - return pValue; -} - -EM_PORT_API(Value *) createDoubleValue(double value) { - auto pValue = ObjectAllocator::allocate(0xecfb69a9); - *pValue = Value(value, VALUE_TYPE_DOUBLE); - return pValue; -} - -EM_PORT_API(Value *) createBooleanValue(int value) { - auto pValue = ObjectAllocator::allocate(0x76071378); - *pValue = Value(value, VALUE_TYPE_BOOLEAN); - return pValue; -} - -EM_PORT_API(Value *) createStringValue(const char *value) { - auto pValue = ObjectAllocator::allocate(0x0a8a7ed1); - Value stringValue = Value::makeStringRef(value, strlen(value), 0x5b1e51d7); - *pValue = stringValue; - return pValue; -} - -EM_PORT_API(Value *) createArrayValue(int arraySize, int arrayType) { - Value value = Value::makeArrayRef(arraySize, arrayType, 0xeabb7edc); - auto pValue = ObjectAllocator::allocate(0xbab14c6a); - if (pValue) { - *pValue = value; - } - return pValue; -} - -EM_PORT_API(Value *) createStreamValue(double value) { - auto pValue = ObjectAllocator::allocate(0x53a2e660); - *pValue = Value(value, VALUE_TYPE_STREAM); - return pValue; -} - -EM_PORT_API(Value *) createDateValue(double value) { - auto pValue = ObjectAllocator::allocate(0x90b7ce70); - *pValue = Value(value, VALUE_TYPE_DATE); - return pValue; -} - -EM_PORT_API(void) arrayValueSetElementValue(Value *arrayValuePtr, int elementIndex, Value *valuePtr) { - auto array = arrayValuePtr->getArray(); - array->values[elementIndex] = *valuePtr; -} - -EM_PORT_API(void) valueFree(Value *valuePtr) { - ObjectAllocator::deallocate(valuePtr); -} - -EM_PORT_API(void) setGlobalVariable(int globalVariableIndex, Value *valuePtr) { - auto flowDefinition = static_cast(g_mainAssets->flowDefinition); - Value *globalVariableValuePtr = flowDefinition->globalVariables[globalVariableIndex]; - *globalVariableValuePtr = *valuePtr; -} - -EM_PORT_API(void) updateGlobalVariable(int globalVariableIndex, Value *valuePtr) { - auto flowDefinition = static_cast(g_mainAssets->flowDefinition); - Value *globalVariableValuePtr = flowDefinition->globalVariables[globalVariableIndex]; - updateArrayValue(globalVariableValuePtr->getArray(), valuePtr->getArray()); -} - -EM_PORT_API(int) getFlowIndex(int flowStateIndex) { - auto flowState = getFlowState(flowStateIndex); - return flowState->flowIndex; -} - -EM_PORT_API(int) getComponentExecutionState(int flowStateIndex, int componentIndex) { - auto flowState = getFlowState(flowStateIndex); - auto component = flowState->flow->components[componentIndex]; - auto executionState = (DashboardComponentExecutionState *)flowState->componenentExecutionStates[componentIndex]; - if (executionState) { - return executionState->state; - } - return -1; -} - -EM_PORT_API(void) setComponentExecutionState(int flowStateIndex, int componentIndex, int state) { - auto flowState = getFlowState(flowStateIndex); - auto component = flowState->flow->components[componentIndex]; - auto executionState = (DashboardComponentExecutionState *)flowState->componenentExecutionStates[componentIndex]; - if (executionState) { - if (state != -1) { - executionState->state = state; - } else { - deallocateComponentExecutionState(flowState, componentIndex); - } - } else { - if (state != -1) { - executionState = allocateComponentExecutionState(flowState, componentIndex); - executionState->state = state; - } - } -} - -EM_PORT_API(const char *) getStringParam(int flowStateIndex, int componentIndex, int offset) { - auto flowState = getFlowState(flowStateIndex); - auto component = flowState->flow->components[componentIndex]; - auto ptr = (const uint32_t *)((const uint8_t *)component + sizeof(Component) + offset); - return (const char *)(MEMORY_BEGIN + 4 + *ptr); -} - -struct ExpressionList { - uint32_t count; - Value values[1]; -}; - -EM_PORT_API(void *) getExpressionListParam(int flowStateIndex, int componentIndex, int offset) { - auto flowState = getFlowState(flowStateIndex); - auto component = flowState->flow->components[componentIndex]; - - struct List { - uint32_t count; - uint32_t items; - }; - auto list = (const List *)((const uint8_t *)component + sizeof(Component) + offset); - - auto expressionList = (ExpressionList *)::malloc((list->count + 1) * sizeof(Value)); - - expressionList->count = list->count; - - auto items = (const uint32_t *)(MEMORY_BEGIN + 4 + list->items); - - for (uint32_t i = 0; i < list->count; i++) { - // call Value constructor - new (expressionList->values + i) Value(); - - auto valueExpression = (const uint8_t *)(MEMORY_BEGIN + 4 + items[i]); - if (!evalExpression(flowState, componentIndex, valueExpression, expressionList->values[i], "Failed to evaluate expression")) { - return nullptr; - } - } - - return expressionList; -} - -EM_PORT_API(void) freeExpressionListParam(void *ptr) { - auto expressionList = (ExpressionList*)ptr; - - for (uint32_t i = 0; i < expressionList->count; i++) { - // call Value desctructor - (expressionList->values + i)->~Value(); - } - - ::free(ptr); -} - -EM_PORT_API(Value*) getInputValue(int flowStateIndex, int inputIndex) { - auto flowState = getFlowState(g_mainAssets, flowStateIndex); - return flowState->values + inputIndex; -} - -EM_PORT_API(void) clearInputValue(int flowStateIndex, int inputIndex) { - auto flowState = getFlowState(g_mainAssets, flowStateIndex); - flowState->values[inputIndex] = Value(); - onValueChanged(flowState->values + inputIndex); -} - -EM_PORT_API(Value *) evalProperty(int flowStateIndex, int componentIndex, int propertyIndex, int32_t *iterators) { - auto flowState = getFlowState(g_mainAssets, flowStateIndex); - - Value result; - if (!eez::flow::evalProperty(flowState, componentIndex, propertyIndex, result, "Failed to evaluate property", nullptr, iterators)) { - return nullptr; - } - - auto pValue = ObjectAllocator::allocate(0xb7e697b8); - if (!pValue) { - throwError(flowState, componentIndex, "Out of memory\n"); - return nullptr; - } - - *pValue = result; - - return pValue; -} - -EM_PORT_API(void) assignProperty(int flowStateIndex, int componentIndex, int propertyIndex, int32_t *iterators, Value *srcValuePtr) { - auto flowState = getFlowState(g_mainAssets, flowStateIndex); - - Value dstValue; - if (evalAssignableProperty(flowState, componentIndex, propertyIndex, dstValue, nullptr, nullptr, iterators)) { - assignValue(flowState, componentIndex, dstValue, *srcValuePtr); - } -} - -EM_PORT_API(void) setPropertyField(int flowStateIndex, int componentIndex, int propertyIndex, int fieldIndex, Value *valuePtr) { - auto flowState = getFlowState(g_mainAssets, flowStateIndex); - - Value result; - if (!eez::flow::evalProperty(flowState, componentIndex, propertyIndex, result, "Failed to evaluate property")) { - return; - } - - if (result.getType() == VALUE_TYPE_VALUE_PTR) { - result = *result.pValueValue; - } - - if (result.getType() != VALUE_TYPE_ARRAY && result.getType() != VALUE_TYPE_ARRAY_REF) { - throwError(flowState, componentIndex, "Property is not an array"); - return; - } - - auto array = result.getArray(); - - if (fieldIndex < 0 || fieldIndex >= array->arraySize) { - throwError(flowState, componentIndex, "Invalid field index"); - return; - } - - array->values[fieldIndex] = *valuePtr; - onValueChanged(array->values + fieldIndex); -} - -EM_PORT_API(void) propagateValue(int flowStateIndex, int componentIndex, int outputIndex, Value *valuePtr) { - auto flowState = getFlowState(g_mainAssets, flowStateIndex); - eez::flow::propagateValue(flowState, componentIndex, outputIndex, *valuePtr); -} - -EM_PORT_API(void) propagateValueThroughSeqout(int flowStateIndex, int componentIndex) { - auto flowState = getFlowState(flowStateIndex); - eez::flow::propagateValueThroughSeqout(flowState, componentIndex); -} - -EM_PORT_API(void) startAsyncExecution(int flowStateIndex, int componentIndex) { - auto flowState = getFlowState(flowStateIndex); - eez::flow::startAsyncExecution(flowState, componentIndex); -} - -EM_PORT_API(void) endAsyncExecution(int flowStateIndex, int componentIndex) { - auto flowState = getFlowState(flowStateIndex); - eez::flow::endAsyncExecution(flowState, componentIndex); -} - -EM_PORT_API(void) executeCallAction(int flowStateIndex, int componentIndex, int flowIndex) { - auto flowState = getFlowState(flowStateIndex); - eez::flow::executeCallAction(flowState, componentIndex, flowIndex); -} - -EM_PORT_API(void) logInfo(int flowStateIndex, int componentIndex, const char *infoMessage) { - auto flowState = getFlowState(flowStateIndex); - eez::flow::logInfo(flowState, componentIndex, infoMessage); -} - -EM_PORT_API(void) throwError(int flowStateIndex, int componentIndex, const char *errorMessage) { - auto flowState = getFlowState(flowStateIndex); - eez::flow::throwError(flowState, componentIndex, errorMessage); -} - -EM_PORT_API(int) getFirstRootFlowState() { - if (!g_firstFlowState) { - return -1; - } - return getFlowStateIndex(g_firstFlowState); -} - -EM_PORT_API(int) getFirstChildFlowState(int flowStateIndex) { - if (flowStateIndex == -1) { - return -1; - } - auto flowState = getFlowState(flowStateIndex); - auto firstChildFlowState = flowState->firstChild; - if (!firstChildFlowState) { - return -1; - } - return getFlowStateIndex(firstChildFlowState); -} - -EM_PORT_API(int) getNextSiblingFlowState(int flowStateIndex) { - if (flowStateIndex == -1) { - return -1; - } - auto flowState = getFlowState(flowStateIndex); - auto nextSiblingFlowState = flowState->nextSibling; - if (!nextSiblingFlowState) { - return -1; - } - return getFlowStateIndex(nextSiblingFlowState); -} - -EM_PORT_API(int) getFlowStateFlowIndex(int flowStateIndex) { - if (flowStateIndex == -1) { - return -1; - } - auto flowState = getFlowState(flowStateIndex); - return flowState->flowIndex; -} - -EM_PORT_API(bool) isRTL() { - return g_isRTL; -} - - -#endif // __EMSCRIPTEN__ diff --git a/Middlewares/eez/flow/dashboard_api.h b/Middlewares/eez/flow/dashboard_api.h deleted file mode 100644 index c92c655..0000000 --- a/Middlewares/eez/flow/dashboard_api.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -* EEZ Framework -* Copyright (C) 2022-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include - -namespace eez { -namespace flow { - -int getFlowStateIndex(FlowState *flowState); - -} // flow -} // eez diff --git a/Middlewares/eez/flow/debugger.cpp b/Middlewares/eez/flow/debugger.cpp deleted file mode 100644 index d0ef12b..0000000 --- a/Middlewares/eez/flow/debugger.cpp +++ /dev/null @@ -1,760 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include - -namespace eez { -namespace flow { - -enum MessagesToDebugger { - MESSAGE_TO_DEBUGGER_STATE_CHANGED, // STATE - - MESSAGE_TO_DEBUGGER_ADD_TO_QUEUE, // FLOW_STATE_INDEX, SOURCE_COMPONENT_INDEX, SOURCE_OUTPUT_INDEX, TARGET_COMPONENT_INDEX, TARGET_INPUT_INDEX, FREE_MEMORT, ALLOC_MEMORY - MESSAGE_TO_DEBUGGER_REMOVE_FROM_QUEUE, // no params - - MESSAGE_TO_DEBUGGER_GLOBAL_VARIABLE_INIT, // GLOBAL_VARIABLE_INDEX, VALUE_ADDR, VALUE - MESSAGE_TO_DEBUGGER_LOCAL_VARIABLE_INIT, // FLOW_STATE_INDEX, LOCAL_VARIABLE_INDEX, VALUE_ADDR, VALUE - MESSAGE_TO_DEBUGGER_COMPONENT_INPUT_INIT, // FLOW_STATE_INDEX, COMPONENT_INPUT_INDEX, VALUE_ADDR, VALUE - - MESSAGE_TO_DEBUGGER_VALUE_CHANGED, // VALUE_ADDR, VALUE - - MESSAGE_TO_DEBUGGER_FLOW_STATE_CREATED, // FLOW_STATE_INDEX, FLOW_INDEX, PARENT_FLOW_STATE_INDEX (-1 - NO PARENT), PARENT_COMPONENT_INDEX (-1 - NO PARENT COMPONENT) - MESSAGE_TO_DEBUGGER_FLOW_STATE_TIMELINE_CHANGED, // FLOW_STATE_INDEX, TIMELINE_POSITION - MESSAGE_TO_DEBUGGER_FLOW_STATE_DESTROYED, // FLOW_STATE_INDEX - - MESSAGE_TO_DEBUGGER_FLOW_STATE_ERROR, // FLOW_STATE_INDEX, COMPONENT_INDEX, ERROR_MESSAGE - - MESSAGE_TO_DEBUGGER_LOG, // LOG_ITEM_TYPE, FLOW_STATE_INDEX, COMPONENT_INDEX, MESSAGE - - MESSAGE_TO_DEBUGGER_PAGE_CHANGED, // PAGE_ID - - MESSAGE_TO_DEBUGGER_COMPONENT_EXECUTION_STATE_CHANGED, // FLOW_STATE_INDEX, COMPONENT_INDEX, STATE - MESSAGE_TO_DEBUGGER_COMPONENT_ASYNC_STATE_CHANGED // FLOW_STATE_INDEX, COMPONENT_INDEX, STATE -}; - -enum MessagesFromDebugger { - MESSAGE_FROM_DEBUGGER_RESUME, // no params - MESSAGE_FROM_DEBUGGER_PAUSE, // no params - MESSAGE_FROM_DEBUGGER_SINGLE_STEP, // no params - - MESSAGE_FROM_DEBUGGER_ADD_BREAKPOINT, // FLOW_INDEX, COMPONENT_INDEX - MESSAGE_FROM_DEBUGGER_REMOVE_BREAKPOINT, // FLOW_INDEX, COMPONENT_INDEX - MESSAGE_FROM_DEBUGGER_ENABLE_BREAKPOINT, // FLOW_INDEX, COMPONENT_INDEX - MESSAGE_FROM_DEBUGGER_DISABLE_BREAKPOINT, // FLOW_INDEX, COMPONENT_INDEX - - MESSAGE_FROM_DEBUGGER_MODE // MODE (0:RUN | 1:DEBUG) -}; - -enum LogItemType { - LOG_ITEM_TYPE_FATAL, - LOG_ITEM_TYPE_ERROR, - LOG_ITEM_TYPE_WARNING , - LOG_ITEM_TYPE_SCPI, - LOG_ITEM_TYPE_INFO, - LOG_ITEM_TYPE_DEBUG -}; - -enum DebuggerState { - DEBUGGER_STATE_RESUMED, - DEBUGGER_STATE_PAUSED, - DEBUGGER_STATE_SINGLE_STEP, - DEBUGGER_STATE_STOPPED, -}; - -bool g_debuggerIsConnected; -static DebuggerState g_debuggerState; -static bool g_skipNextBreakpoint; - -static char g_inputFromDebugger[64]; -static unsigned g_inputFromDebuggerPosition; - -int g_debuggerMode = DEBUGGER_MODE_RUN; - -//////////////////////////////////////////////////////////////////////////////// - -static void setDebuggerState(DebuggerState newState) { - if (newState != g_debuggerState) { - g_debuggerState = newState; - - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%d\n", - MESSAGE_TO_DEBUGGER_STATE_CHANGED, - g_debuggerState - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - } - } -} - -//////////////////////////////////////////////////////////////////////////////// - -void onDebuggerClientConnected() { - g_debuggerIsConnected = true; - - g_skipNextBreakpoint = false; - g_inputFromDebuggerPosition = 0; - - setDebuggerState(DEBUGGER_STATE_PAUSED); -} - -void onDebuggerClientDisconnected() { - g_debuggerIsConnected = false; - setDebuggerState(DEBUGGER_STATE_RESUMED); -} - -//////////////////////////////////////////////////////////////////////////////// - -void processDebuggerInput(char *buffer, uint32_t length) { - for (uint32_t i = 0; i < length; i++) { - if (buffer[i] == '\n') { - int messageFromDebugger = g_inputFromDebugger[0] - '0'; - - if (messageFromDebugger == MESSAGE_FROM_DEBUGGER_RESUME) { - setDebuggerState(DEBUGGER_STATE_RESUMED); - } else if (messageFromDebugger == MESSAGE_FROM_DEBUGGER_PAUSE) { - setDebuggerState(DEBUGGER_STATE_PAUSED); - } else if (messageFromDebugger == MESSAGE_FROM_DEBUGGER_SINGLE_STEP) { - setDebuggerState(DEBUGGER_STATE_SINGLE_STEP); - } else if ( - messageFromDebugger >= MESSAGE_FROM_DEBUGGER_ADD_BREAKPOINT && - messageFromDebugger <= MESSAGE_FROM_DEBUGGER_DISABLE_BREAKPOINT - ) { - char *p; - auto flowIndex = (uint32_t)strtol(g_inputFromDebugger + 2, &p, 10); - auto componentIndex = (uint32_t)strtol(p + 1, nullptr, 10); - - auto assets = g_firstFlowState->assets; - auto flowDefinition = static_cast(assets->flowDefinition); - if (flowIndex >= 0 && flowIndex < flowDefinition->flows.count) { - auto flow = flowDefinition->flows[flowIndex]; - if (componentIndex >= 0 && componentIndex < flow->components.count) { - auto component = flow->components[componentIndex]; - - component->breakpoint = messageFromDebugger == MESSAGE_FROM_DEBUGGER_ADD_BREAKPOINT || - messageFromDebugger == MESSAGE_FROM_DEBUGGER_ENABLE_BREAKPOINT ? 1 : 0; - } else { - ErrorTrace("Invalid breakpoint component index\n"); - } - } else { - ErrorTrace("Invalid breakpoint flow index\n"); - } - } else if (messageFromDebugger == MESSAGE_FROM_DEBUGGER_MODE) { - g_debuggerMode = strtol(g_inputFromDebugger + 2, nullptr, 10); - gui::refreshScreen(); - } - - g_inputFromDebuggerPosition = 0; - } else { - if (g_inputFromDebuggerPosition < sizeof(g_inputFromDebugger)) { - g_inputFromDebugger[g_inputFromDebuggerPosition++] = buffer[i]; - } else if (g_inputFromDebuggerPosition == sizeof(g_inputFromDebugger)) { - ErrorTrace("Input from debugger buffer overflow\n"); - } - } - } -} - -//////////////////////////////////////////////////////////////////////////////// - -bool canExecuteStep(FlowState *&flowState, unsigned &componentIndex) { - if (!g_debuggerIsConnected) { - return true; - } - - if (g_debuggerState == DEBUGGER_STATE_PAUSED) { - return false; - } - - if (g_debuggerState == DEBUGGER_STATE_SINGLE_STEP) { - g_skipNextBreakpoint = false; - setDebuggerState(DEBUGGER_STATE_PAUSED); - return true; - } - - // g_debuggerState == DEBUGGER_STATE_RESUMED - - if (g_skipNextBreakpoint) { - g_skipNextBreakpoint = false; - } else { - auto component = flowState->flow->components[componentIndex]; - if (component->breakpoint) { - g_skipNextBreakpoint = true; - setDebuggerState(DEBUGGER_STATE_PAUSED); - return false; - } - } - - return true; -} - -//////////////////////////////////////////////////////////////////////////////// - -#if defined(__EMSCRIPTEN__) -char outputBuffer[1024 * 1024]; -#else -char outputBuffer[64]; -#endif -int outputBufferPosition = 0; - -#define WRITE_TO_OUTPUT_BUFFER(ch) \ - outputBuffer[outputBufferPosition++] = ch; \ - if (outputBufferPosition == sizeof(outputBuffer)) { \ - writeDebuggerBufferHook(outputBuffer, outputBufferPosition); \ - outputBufferPosition = 0; \ - } - -#define FLUSH_OUTPUT_BUFFER() \ - if (outputBufferPosition > 0) { \ - writeDebuggerBufferHook(outputBuffer, outputBufferPosition); \ - outputBufferPosition = 0; \ - } - -void writeValueAddr(const void *pValue) { - char tmpStr[32]; - snprintf(tmpStr, sizeof(tmpStr), "%p", pValue); - auto len = strlen(tmpStr); - for (size_t i = 0; i < len; i++) { - WRITE_TO_OUTPUT_BUFFER(tmpStr[i]); - } -} - -void writeString(const char *str) { - WRITE_TO_OUTPUT_BUFFER('"'); - - for (const char *p = str; *p; p++) { - if (*p == '"') { - WRITE_TO_OUTPUT_BUFFER('\\'); - WRITE_TO_OUTPUT_BUFFER('"'); - } else if (*p == '\t') { - WRITE_TO_OUTPUT_BUFFER('\\'); - WRITE_TO_OUTPUT_BUFFER('t'); - } else if (*p == '\n') { - WRITE_TO_OUTPUT_BUFFER('\\'); - WRITE_TO_OUTPUT_BUFFER('n'); - } else { - WRITE_TO_OUTPUT_BUFFER(*p); - } - } - - WRITE_TO_OUTPUT_BUFFER('"'); - WRITE_TO_OUTPUT_BUFFER('\n'); - FLUSH_OUTPUT_BUFFER(); -} - -void writeArrayType(uint32_t arrayType) { - char tmpStr[32]; - snprintf(tmpStr, sizeof(tmpStr), "%x", (int)arrayType); - auto len = strlen(tmpStr); - for (size_t i = 0; i < len; i++) { - WRITE_TO_OUTPUT_BUFFER(tmpStr[i]); - } -} - -void writeArray(const ArrayValue *arrayValue) { - WRITE_TO_OUTPUT_BUFFER('{'); - - writeValueAddr(arrayValue); - - WRITE_TO_OUTPUT_BUFFER(','); - writeArrayType(arrayValue->arrayType); - - for (uint32_t i = 0; i < arrayValue->arraySize; i++) { - WRITE_TO_OUTPUT_BUFFER(','); - writeValueAddr(&arrayValue->values[i]); - } - - WRITE_TO_OUTPUT_BUFFER('}'); - WRITE_TO_OUTPUT_BUFFER('\n'); - FLUSH_OUTPUT_BUFFER(); - - for (uint32_t i = 0; i < arrayValue->arraySize; i++) { - onValueChanged(&arrayValue->values[i]); - } -} - -void writeHex(char *dst, uint8_t *src, size_t srcLength) { - *dst++ = 'H'; - for (size_t i = 0; i < srcLength; i++) { - *dst++ = toHexDigit(src[i] / 16); - *dst++ = toHexDigit(src[i] % 16); - } - *dst++ = 0; -} - -void writeValue(const Value &value) { - char tempStr[64]; - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4474) -#endif - - switch (value.getType()) { - case VALUE_TYPE_UNDEFINED: - stringCopy(tempStr, sizeof(tempStr) - 1, "undefined\n"); - break; - - case VALUE_TYPE_NULL: - stringCopy(tempStr, sizeof(tempStr) - 1, "null\n"); - break; - - case VALUE_TYPE_BOOLEAN: - stringCopy(tempStr, sizeof(tempStr) - 1, value.getBoolean() ? "true" : "false"); - break; - - case VALUE_TYPE_INT8: - snprintf(tempStr, sizeof(tempStr) - 1, "%" PRId8 "", value.int8Value); - break; - - case VALUE_TYPE_UINT8: - snprintf(tempStr, sizeof(tempStr) - 1, "%" PRIu8 "", value.uint8Value); - break; - - case VALUE_TYPE_INT16: - snprintf(tempStr, sizeof(tempStr) - 1, "%" PRId16 "", value.int16Value); - break; - - case VALUE_TYPE_UINT16: - snprintf(tempStr, sizeof(tempStr) - 1, "%" PRIu16 "", value.uint16Value); - break; - - case VALUE_TYPE_INT32: - snprintf(tempStr, sizeof(tempStr) - 1, "%" PRId32 "", value.int32Value); - break; - - case VALUE_TYPE_UINT32: - snprintf(tempStr, sizeof(tempStr) - 1, "%" PRIu32 "", value.uint32Value); - break; - - case VALUE_TYPE_INT64: - snprintf(tempStr, sizeof(tempStr) - 1, "%" PRId64 "", value.int64Value); - break; - - case VALUE_TYPE_UINT64: - snprintf(tempStr, sizeof(tempStr) - 1, "%" PRIu64 "", value.uint64Value); - break; - - case VALUE_TYPE_DOUBLE: - writeHex(tempStr, (uint8_t *)&value.doubleValue, sizeof(double)); - break; - - case VALUE_TYPE_FLOAT: - writeHex(tempStr, (uint8_t *)&value.floatValue, sizeof(float)); - break; - - case VALUE_TYPE_STRING: - case VALUE_TYPE_STRING_REF: - writeString(value.getString()); - return; - - case VALUE_TYPE_ARRAY: - case VALUE_TYPE_ARRAY_REF: - writeArray(value.getArray()); - return; - - case VALUE_TYPE_BLOB_REF: - snprintf(tempStr, sizeof(tempStr) - 1, "@%d", (int)((BlobRef *)value.refValue)->len); - break; - - case VALUE_TYPE_STREAM: - snprintf(tempStr, sizeof(tempStr) - 1, ">%d", (int)(value.int32Value)); - break; - - case VALUE_TYPE_DATE: - tempStr[0] = '!'; - writeHex(tempStr + 1, (uint8_t *)&value.doubleValue, sizeof(double)); - break; - - default: - tempStr[0] = 0; - break; - } - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - - stringAppendString(tempStr, sizeof(tempStr), "\n"); - - writeDebuggerBufferHook(tempStr, strlen(tempStr)); -} - -//////////////////////////////////////////////////////////////////////////////// - -void onStarted(Assets *assets) { - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - auto flowDefinition = static_cast(assets->flowDefinition); - - for (uint32_t i = 0; i < flowDefinition->globalVariables.count; i++) { - auto pValue = flowDefinition->globalVariables[i]; - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%d\t%p\t", - MESSAGE_TO_DEBUGGER_GLOBAL_VARIABLE_INIT, - (int)i, - (const void *)pValue - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - - writeValue(*pValue); - } - } -} - -void onStopped() { - setDebuggerState(DEBUGGER_STATE_STOPPED); -} - -void onAddToQueue(FlowState *flowState, int sourceComponentIndex, int sourceOutputIndex, unsigned targetComponentIndex, int targetInputIndex) { - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - uint32_t free; - uint32_t alloc; - getAllocInfo(free, alloc); - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", - MESSAGE_TO_DEBUGGER_ADD_TO_QUEUE, - (int)flowState->flowStateIndex, - sourceComponentIndex, - sourceOutputIndex, - targetComponentIndex, - targetInputIndex, - (int)free, - (int)ALLOC_BUFFER_SIZE - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - } -} - -void onRemoveFromQueue() { - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\n", - MESSAGE_TO_DEBUGGER_REMOVE_FROM_QUEUE - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - } -} - -void onValueChanged(const Value *pValue) { - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%p\t", - MESSAGE_TO_DEBUGGER_VALUE_CHANGED, - (const void *)pValue - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - - writeValue(*pValue); - } -} - -void onFlowStateCreated(FlowState *flowState) { - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\t%d\n", - MESSAGE_TO_DEBUGGER_FLOW_STATE_CREATED, - (int)flowState->flowStateIndex, - flowState->flowIndex, - (int)(flowState->parentFlowState ? flowState->parentFlowState->flowStateIndex : -1), - flowState->parentComponentIndex - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - - auto flow = flowState->flow; - - for (uint32_t i = 0; i < flow->localVariables.count; i++) { - auto pValue = &flowState->values[flow->componentInputs.count + i]; - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%p\t", - MESSAGE_TO_DEBUGGER_LOCAL_VARIABLE_INIT, - (int)flowState->flowStateIndex, - (int)i, - (const void *)pValue - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - - writeValue(*pValue); - } - - for (uint32_t i = 0; i < flow->componentInputs.count; i++) { - //auto &input = flow->componentInputs[i]; - //if (!(input & COMPONENT_INPUT_FLAG_IS_SEQ_INPUT)) { - auto pValue = &flowState->values[i]; - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%p\t", - MESSAGE_TO_DEBUGGER_COMPONENT_INPUT_INIT, - (int)flowState->flowStateIndex, - (int)i, - (const void *)pValue - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - - writeValue(*pValue); - //} - } - } -} - -void onFlowStateDestroyed(FlowState *flowState) { - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%d\n", - MESSAGE_TO_DEBUGGER_FLOW_STATE_DESTROYED, - (int)flowState->flowStateIndex - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - } -} - -void onFlowStateTimelineChanged(FlowState *flowState) { - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%d\t%g\n", - MESSAGE_TO_DEBUGGER_FLOW_STATE_TIMELINE_CHANGED, - (int)flowState->flowStateIndex, - flowState->timelinePosition - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - } -} - -void onFlowError(FlowState *flowState, int componentIndex, const char *errorMessage) { - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t", - MESSAGE_TO_DEBUGGER_FLOW_STATE_ERROR, - (int)flowState->flowStateIndex, - componentIndex - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - writeString(errorMessage); - } -} - -void onComponentExecutionStateChanged(FlowState *flowState, int componentIndex) { - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\n", - MESSAGE_TO_DEBUGGER_COMPONENT_EXECUTION_STATE_CHANGED, - (int)flowState->flowStateIndex, - componentIndex, - flowState->componenentExecutionStates[componentIndex] ? 1 : 0 - ); - - writeDebuggerBufferHook(buffer, strlen(buffer)); - } -} - -void onComponentAsyncStateChanged(FlowState *flowState, int componentIndex) { - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\n", - MESSAGE_TO_DEBUGGER_COMPONENT_ASYNC_STATE_CHANGED, - (int)flowState->flowStateIndex, - componentIndex, - flowState->componenentAsyncStates[componentIndex] ? 1 : 0 - ); - - writeDebuggerBufferHook(buffer, strlen(buffer)); - } -} - -void writeLogMessage(const char *str) { - for (const char *p = str; *p; p++) { - if (*p == '\t') { - WRITE_TO_OUTPUT_BUFFER('\\'); - WRITE_TO_OUTPUT_BUFFER('t'); - } if (*p == '\n') { - WRITE_TO_OUTPUT_BUFFER('\\'); - WRITE_TO_OUTPUT_BUFFER('n'); - } else { - WRITE_TO_OUTPUT_BUFFER(*p); - } - } - - WRITE_TO_OUTPUT_BUFFER('\n'); - FLUSH_OUTPUT_BUFFER(); -} - -void writeLogMessage(const char *str, size_t len) { - for (size_t i = 0; i < len; i++) { - if (str[i] == '\t') { - WRITE_TO_OUTPUT_BUFFER('\\'); - WRITE_TO_OUTPUT_BUFFER('t'); - } if (str[i] == '\n') { - WRITE_TO_OUTPUT_BUFFER('\\'); - WRITE_TO_OUTPUT_BUFFER('n'); - } else { - WRITE_TO_OUTPUT_BUFFER(str[i]); - } - } - - WRITE_TO_OUTPUT_BUFFER('\n'); - FLUSH_OUTPUT_BUFFER(); -} - -void logInfo(FlowState *flowState, unsigned componentIndex, const char *message) { - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\t", - MESSAGE_TO_DEBUGGER_LOG, - LOG_ITEM_TYPE_INFO, - (int)flowState->flowStateIndex, - componentIndex - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - writeLogMessage(message); - } -} - -void logScpiCommand(FlowState *flowState, unsigned componentIndex, const char *cmd) { - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\tSCPI COMMAND: ", - MESSAGE_TO_DEBUGGER_LOG, - LOG_ITEM_TYPE_SCPI, - (int)flowState->flowStateIndex, - componentIndex - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - writeLogMessage(cmd); - } -} - -void logScpiQuery(FlowState *flowState, unsigned componentIndex, const char *query) { - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\tSCPI QUERY: ", - MESSAGE_TO_DEBUGGER_LOG, - LOG_ITEM_TYPE_SCPI, - (int)flowState->flowStateIndex, - componentIndex - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - writeLogMessage(query); - } -} - -void logScpiQueryResult(FlowState *flowState, unsigned componentIndex, const char *resultText, size_t resultTextLen) { - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - char buffer[256]; - snprintf(buffer, sizeof(buffer) - 1, "%d\t%d\t%d\t%d\tSCPI QUERY RESULT: ", - MESSAGE_TO_DEBUGGER_LOG, - LOG_ITEM_TYPE_SCPI, - (int)flowState->flowStateIndex, - componentIndex - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - writeLogMessage(resultText, resultTextLen); - } -} - -void onPageChanged(int previousPageId, int activePageId) { - if (flow::isFlowStopped()) { - return; - } - - if (previousPageId == activePageId) { - return; - } - - if (previousPageId > 0 && previousPageId < FIRST_INTERNAL_PAGE_ID) { - auto flowState = getFlowState(g_mainAssets, previousPageId - 1, WidgetCursor()); - if (flowState) { - onEvent(flowState, FLOW_EVENT_CLOSE_PAGE); - } - } else if (previousPageId < 0) { - auto flowState = getFlowState(g_externalAssets, -previousPageId - 1, WidgetCursor()); - if (flowState) { - onEvent(flowState, FLOW_EVENT_CLOSE_PAGE); - } - } - - if (activePageId > 0 && activePageId < FIRST_INTERNAL_PAGE_ID) { - auto flowState = getFlowState(g_mainAssets, activePageId - 1, WidgetCursor()); - if (flowState) { - onEvent(flowState, FLOW_EVENT_OPEN_PAGE); - } - } else if (activePageId < 0) { - auto flowState = getFlowState(g_externalAssets, -activePageId - 1, WidgetCursor()); - if (flowState) { - onEvent(flowState, FLOW_EVENT_OPEN_PAGE); - } - } - - if (g_debuggerIsConnected) { - startToDebuggerMessageHook(); - - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%d\t%d\n", - MESSAGE_TO_DEBUGGER_PAGE_CHANGED, - activePageId - ); - writeDebuggerBufferHook(buffer, strlen(buffer)); - } -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/debugger.h b/Middlewares/eez/flow/debugger.h deleted file mode 100644 index f8a0c37..0000000 --- a/Middlewares/eez/flow/debugger.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2021-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -namespace eez { -namespace flow { - -extern bool g_debuggerIsConnected; - -enum { - DEBUGGER_MODE_RUN, - DEBUGGER_MODE_DEBUG, -}; -extern int g_debuggerMode; - -bool canExecuteStep(FlowState *&flowState, unsigned &componentIndex); - -void onStarted(gui::Assets *assets); -void onStopped(); - -void onAddToQueue(FlowState *flowState, int sourceComponentIndex, int sourceOutputIndex, unsigned targetComponentIndex, int targetInputIndex); -void onRemoveFromQueue(); - -void onValueChanged(const gui::Value *pValue); - -void onFlowStateCreated(FlowState *flowState); -void onFlowStateDestroyed(FlowState *flowState); -void onFlowStateTimelineChanged(FlowState *flowState); - -void onFlowError(FlowState *flowState, int componentIndex, const char *errorMessage); - -void onComponentExecutionStateChanged(FlowState *flowState, int componentIndex); -void onComponentAsyncStateChanged(FlowState *flowState, int componentIndex); - -void logInfo(FlowState *flowState, unsigned componentIndex, const char *message); - -void logScpiCommand(FlowState *flowState, unsigned componentIndex, const char *cmd); -void logScpiQuery(FlowState *flowState, unsigned componentIndex, const char *query); -void logScpiQueryResult(FlowState *flowState, unsigned componentIndex, const char *resultText, size_t resultTextLen); - -void onPageChanged(int previousPageId, int activePageId); - -void processDebuggerInput(char *buffer, uint32_t length); - -} // flow -} // eez diff --git a/Middlewares/eez/flow/expression.cpp b/Middlewares/eez/flow/expression.cpp deleted file mode 100644 index fed70a3..0000000 --- a/Middlewares/eez/flow/expression.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include -#include - -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -EvalStack g_stack; - -static bool evalExpression(FlowState *flowState, const uint8_t *instructions, int *numInstructionBytes, const char *errorMessage) { - auto flowDefinition = flowState->flowDefinition; - auto flow = flowState->flow; - - int i = 0; - while (true) { - uint16_t instruction = instructions[i] + (instructions[i + 1] << 8); - auto instructionType = instruction & EXPR_EVAL_INSTRUCTION_TYPE_MASK; - auto instructionArg = instruction & EXPR_EVAL_INSTRUCTION_PARAM_MASK; - if (instructionType == EXPR_EVAL_INSTRUCTION_TYPE_PUSH_CONSTANT) { - if (!g_stack.push(*flowDefinition->constants[instructionArg])) { - return false; - } - } else if (instructionType == EXPR_EVAL_INSTRUCTION_TYPE_PUSH_INPUT) { - if (!g_stack.push(flowState->values[instructionArg])) { - return false; - } - } else if (instructionType == EXPR_EVAL_INSTRUCTION_TYPE_PUSH_LOCAL_VAR) { - if (!g_stack.push(&flowState->values[flow->componentInputs.count + instructionArg])) { - return false; - } - } else if (instructionType == EXPR_EVAL_INSTRUCTION_TYPE_PUSH_GLOBAL_VAR) { - if ((uint32_t)instructionArg < flowDefinition->globalVariables.count) { - if (!g_stack.push(flowDefinition->globalVariables[instructionArg])) { - return false; - } - } else { - // native variable - if (!g_stack.push(Value((int)(instructionArg - flowDefinition->globalVariables.count + 1), VALUE_TYPE_NATIVE_VARIABLE))) { - return false; - } - } - } else if (instructionType == EXPR_EVAL_INSTRUCTION_TYPE_PUSH_OUTPUT) { - if (!g_stack.push(Value((uint16_t)instructionArg, VALUE_TYPE_FLOW_OUTPUT))) { - return false; - } - } else if (instructionType == EXPR_EVAL_INSTRUCTION_ARRAY_ELEMENT) { - auto elementIndexValue = g_stack.pop().getValue(); - auto arrayValue = g_stack.pop().getValue(); - - if (arrayValue.getType() == VALUE_TYPE_UNDEFINED || arrayValue.getType() == VALUE_TYPE_NULL) { - if (!g_stack.push(Value(0, VALUE_TYPE_UNDEFINED))) { - return false; - } - } else { - if (arrayValue.type != VALUE_TYPE_ARRAY && arrayValue.type != VALUE_TYPE_ARRAY_REF) { - throwError(flowState, g_stack.componentIndex, errorMessage, "Array value expected\n"); - return false; - } - - auto array = arrayValue.getArray(); - - int err; - auto elementIndex = elementIndexValue.toInt32(&err); - if (err) { - throwError(flowState, g_stack.componentIndex, errorMessage, "Integer value expected for array element index\n"); - return false; - } - - if (elementIndex < 0 || elementIndex >= (int)array->arraySize) { - throwError(flowState, g_stack.componentIndex, errorMessage, "Array element index out of bounds\n"); - return false; - } - - if (!g_stack.push(Value::makeArrayElementRef(arrayValue, elementIndex, 0x132e0e2f))) { - return false; - } - } - } else if (instructionType == EXPR_EVAL_INSTRUCTION_TYPE_OPERATION) { - if (!g_evalOperations[instructionArg](g_stack)) { - return false; - } - } else { - i += 2; - break; - } - - i += 2; - } - - if (numInstructionBytes) { - *numInstructionBytes = i; - } - - return true; -} - -bool evalExpression(FlowState *flowState, int componentIndex, const uint8_t *instructions, Value &result, const char *errorMessage, int *numInstructionBytes, const int32_t *iterators, DataOperationEnum operation) { - g_stack.sp = 0; - g_stack.flowState = flowState; - g_stack.componentIndex = componentIndex; - g_stack.iterators = iterators; - - if (evalExpression(flowState, instructions, numInstructionBytes, errorMessage)) { - if (g_stack.sp == 1) { - result = g_stack.pop().getValue(); - return true; - } - } - - result = Value(); - return false; -} - -bool evalAssignableExpression(FlowState *flowState, int componentIndex, const uint8_t *instructions, Value &result, const char *errorMessage, int *numInstructionBytes, const int32_t *iterators) { - g_stack.sp = 0; - g_stack.flowState = flowState; - g_stack.componentIndex = componentIndex; - g_stack.iterators = iterators; - - if (evalExpression(flowState, instructions, numInstructionBytes, errorMessage)) { - if (g_stack.sp == 1) { - auto finalResult = g_stack.pop(); - if (finalResult.getType() == VALUE_TYPE_VALUE_PTR || finalResult.getType() == VALUE_TYPE_NATIVE_VARIABLE || finalResult.getType() == VALUE_TYPE_FLOW_OUTPUT || finalResult.getType() == VALUE_TYPE_ARRAY_ELEMENT_VALUE) { - result = finalResult; - return true; - } - } - } - - return false; -} - -bool evalProperty(FlowState *flowState, int componentIndex, int propertyIndex, Value &result, const char *errorMessage, int *numInstructionBytes, const int32_t *iterators, DataOperationEnum operation) { - if (componentIndex < 0 || componentIndex >= (int)flowState->flow->components.count) { - char message[256]; - snprintf(message, sizeof(message), "invalid component index %d in flow at index %d", componentIndex, flowState->flowIndex); - throwError(flowState, componentIndex, errorMessage, message); - return false; - } - auto component = flowState->flow->components[componentIndex]; - if (propertyIndex < 0 || propertyIndex >= (int)component->properties.count) { - char message[256]; - snprintf(message, sizeof(message), "invalid property index %d at component index %d in flow at index %d", propertyIndex, componentIndex, flowState->flowIndex); - throwError(flowState, componentIndex, errorMessage, message); - return false; - } - return evalExpression(flowState, componentIndex, component->properties[propertyIndex]->evalInstructions, result, errorMessage, numInstructionBytes, iterators, operation); -} - -bool evalAssignableProperty(FlowState *flowState, int componentIndex, int propertyIndex, Value &result, const char *errorMessage, int *numInstructionBytes, const int32_t *iterators) { - if (componentIndex < 0 || componentIndex >= (int)flowState->flow->components.count) { - char message[256]; - snprintf(message, sizeof(message), "invalid component index %d in flow at index %d", componentIndex, flowState->flowIndex); - throwError(flowState, componentIndex, errorMessage, message); - return false; - } - auto component = flowState->flow->components[componentIndex]; - if (propertyIndex < 0 || propertyIndex >= (int)component->properties.count) { - char message[256]; - snprintf(message, sizeof(message), "invalid property index %d (max: %d) in component at index %d in flow at index %d", propertyIndex, (int)component->properties.count, componentIndex, flowState->flowIndex); - throwError(flowState, componentIndex, errorMessage, message); - return false; - } - return evalAssignableExpression(flowState, componentIndex, component->properties[propertyIndex]->evalInstructions, result, errorMessage, numInstructionBytes, iterators); -} - -int16_t getNativeVariableId(const WidgetCursor &widgetCursor) { - if (widgetCursor.flowState) { - FlowState *flowState = widgetCursor.flowState; - auto flow = flowState->flow; - - WidgetDataItem *widgetDataItem = flow->widgetDataItems[-(widgetCursor.widget->data + 1)]; - if (widgetDataItem && widgetDataItem->componentIndex != -1 && widgetDataItem->propertyValueIndex != -1) { - auto component = flow->components[widgetDataItem->componentIndex]; - auto property = component->properties[widgetDataItem->propertyValueIndex]; - - g_stack.sp = 0; - g_stack.flowState = flowState; - g_stack.componentIndex = widgetDataItem->componentIndex; - g_stack.iterators = widgetCursor.iterators; - - if (evalExpression(flowState, property->evalInstructions, nullptr, nullptr)) { - if (g_stack.sp == 1) { - auto finalResult = g_stack.pop(); - - if (finalResult.getType() == VALUE_TYPE_NATIVE_VARIABLE) { - return finalResult.getInt(); - } - } - } - } - } - - return DATA_ID_NONE; -} - -} // flow -} // eez diff --git a/Middlewares/eez/flow/expression.h b/Middlewares/eez/flow/expression.h deleted file mode 100644 index a8d87a6..0000000 --- a/Middlewares/eez/flow/expression.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2021-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include - -namespace eez { -namespace flow { - -static const size_t STACK_SIZE = 20; - -struct EvalStack { - FlowState *flowState; - int componentIndex; - const int32_t *iterators; - - Value stack[STACK_SIZE]; - size_t sp = 0; - - bool push(const Value &value) { - if (sp >= STACK_SIZE) { - throwError(flowState, componentIndex, "Evaluation stack is full\n"); - return false; - } - stack[sp++] = value; - return true; - } - - bool push(Value *pValue) { - if (sp >= STACK_SIZE) { - return false; - } - stack[sp++] = Value(pValue, VALUE_TYPE_VALUE_PTR); - return true; - } - - Value pop() { - return stack[--sp]; - } - -}; - -bool evalExpression(FlowState *flowState, int componentIndex, const uint8_t *instructions, Value &result, const char *errorMessage, int *numInstructionBytes = nullptr, const int32_t *iterators = nullptr, eez::gui::DataOperationEnum operation = eez::gui::DATA_OPERATION_GET); -bool evalAssignableExpression(FlowState *flowState, int componentIndex, const uint8_t *instructions, Value &result, const char *errorMessage, int *numInstructionBytes = nullptr, const int32_t *iterators = nullptr); - -bool evalProperty(FlowState *flowState, int componentIndex, int propertyIndex, Value &result, const char *errorMessage, int *numInstructionBytes = nullptr, const int32_t *iterators = nullptr, eez::gui::DataOperationEnum operation = eez::gui::DATA_OPERATION_GET); -bool evalAssignableProperty(FlowState *flowState, int componentIndex, int propertyIndex, Value &result, const char *errorMessage, int *numInstructionBytes = nullptr, const int32_t *iterators = nullptr); - -} // flow -} // eez diff --git a/Middlewares/eez/flow/flow.cpp b/Middlewares/eez/flow/flow.cpp deleted file mode 100644 index f60bcd1..0000000 --- a/Middlewares/eez/flow/flow.cpp +++ /dev/null @@ -1,331 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include - -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -#if defined(__EMSCRIPTEN__) -uint32_t g_wasmModuleId = 0; -#endif - -static const uint32_t FLOW_TICK_MAX_DURATION_MS = 5; - -int g_selectedLanguage = 0; -FlowState *g_firstFlowState; -FlowState *g_lastFlowState; - -static bool g_isStopped = true; - -//////////////////////////////////////////////////////////////////////////////// - -unsigned start(Assets *assets) { - auto flowDefinition = static_cast(assets->flowDefinition); - if (flowDefinition->flows.count == 0) { - return 0; - } - - g_isStopped = false; - - queueReset(); - - scpiComponentInitHook(); - - onStarted(assets); - - return 1; -} - -void tick() { - if (!isFlowRunningHook()) { - return; - } - - uint32_t startTickCount = millis(); - - while (true) { - FlowState *flowState; - unsigned componentIndex; - bool continuousTask; - if (!peekNextTaskFromQueue(flowState, componentIndex, continuousTask)) { - break; - } - - if (!continuousTask && !canExecuteStep(flowState, componentIndex)) { - break; - } - - removeNextTaskFromQueue(); - - executeComponent(flowState, componentIndex); - - if (isFlowStopped()) { - break; - } - - auto component = flowState->flow->components[componentIndex]; - - for (uint32_t i = 0; i < component->inputs.count; i++) { - auto inputIndex = component->inputs[i]; - if (flowState->flow->componentInputs[inputIndex] & COMPONENT_INPUT_FLAG_IS_SEQ_INPUT) { - auto pValue = &flowState->values[inputIndex]; - *pValue = Value(); - onValueChanged(pValue); - } - } - - if (canFreeFlowState(flowState)) { - freeFlowState(flowState); - } - - if (millis() - startTickCount >= FLOW_TICK_MAX_DURATION_MS) { - break; - } - } - - finishToDebuggerMessageHook(); -} - -void freeAllChildrenFlowStates(FlowState *firstChildFlowState) { - auto flowState = firstChildFlowState; - while (flowState != nullptr) { - auto nextFlowState = flowState->nextSibling; - freeAllChildrenFlowStates(flowState->firstChild); - freeFlowState(flowState); - flowState = nextFlowState; - } -} - -void stop() { - freeAllChildrenFlowStates(g_firstFlowState); - g_firstFlowState = nullptr; - g_lastFlowState = nullptr; - - g_isStopped = true; - - queueReset(); - onStopped(); -} - -bool isFlowStopped() { - return g_isStopped; -} - -FlowState *getFlowState(Assets *assets, int flowStateIndex) { - return (FlowState *)(ALLOC_BUFFER + flowStateIndex); -} - -FlowState *getFlowState(Assets *assets, int16_t pageIndex, const WidgetCursor &widgetCursor) { - if (!assets->flowDefinition) { - return nullptr; - } - - if (!isFlowRunningHook()) { - return nullptr; - } - - if (widgetCursor.widget && widgetCursor.widget->type == WIDGET_TYPE_LAYOUT_VIEW) { - if (widgetCursor.flowState) { - auto layoutViewWidget = (LayoutViewWidget *)widgetCursor.widget; - auto flowState = widgetCursor.flowState; - auto layoutViewWidgetComponentIndex = layoutViewWidget->componentIndex; - - return getLayoutViewFlowState(flowState, layoutViewWidgetComponentIndex, pageIndex); - } - } else { - auto page = assets->pages[pageIndex]; - if (!(page->flags & PAGE_IS_USED_AS_CUSTOM_WIDGET)) { - FlowState *flowState; - for (flowState = g_firstFlowState; flowState; flowState = flowState->nextSibling) { - if (flowState->flowIndex == pageIndex) { - break; - } - } - - if (!flowState) { - flowState = initPageFlowState(assets, pageIndex, nullptr, 0); - } - - return flowState; - } - } - - return nullptr; -} - -int getPageIndex(FlowState *flowState) { - return flowState->flowIndex; -} - -void executeFlowAction(const gui::WidgetCursor &widgetCursor, int16_t actionId, void *param) { - if (!isFlowRunningHook()) { - return; - } - - auto flowState = widgetCursor.flowState; - actionId = -actionId - 1; - - auto flow = flowState->flow; - - if (actionId >= 0 && actionId < (int16_t)flow->widgetActions.count) { - auto componentOutput = flow->widgetActions[actionId]; - if (componentOutput->componentIndex != -1 && componentOutput->componentOutputIndex != -1) { - if (widgetCursor.widget->type == WIDGET_TYPE_DROP_DOWN_LIST) { - auto params = Value::makeArrayRef(defs_v3::SYSTEM_STRUCTURE_DROP_DOWN_LIST_ACTION_PARAMS_NUM_FIELDS, defs_v3::SYSTEM_STRUCTURE_DROP_DOWN_LIST_ACTION_PARAMS, 0x53e3b30b); - - // index - ((ArrayValueRef *)params.refValue)->arrayValue.values[defs_v3::SYSTEM_STRUCTURE_DROP_DOWN_LIST_ACTION_PARAMS_FIELD_INDEX] = widgetCursor.iterators[0]; - - // indexes - auto indexes = Value::makeArrayRef(MAX_ITERATORS, defs_v3::ARRAY_TYPE_INTEGER, 0xb1f68ef8); - for (size_t i = 0; i < MAX_ITERATORS; i++) { - ((ArrayValueRef *)indexes.refValue)->arrayValue.values[i] = (int)widgetCursor.iterators[i]; - } - ((ArrayValueRef *)params.refValue)->arrayValue.values[defs_v3::SYSTEM_STRUCTURE_DROP_DOWN_LIST_ACTION_PARAMS_FIELD_INDEXES] = indexes; - - // selectedIndex - ((ArrayValueRef *)params.refValue)->arrayValue.values[defs_v3::SYSTEM_STRUCTURE_DROP_DOWN_LIST_ACTION_PARAMS_FIELD_SELECTED_INDEX] = *((int *)param); - - propagateValue(flowState, componentOutput->componentIndex, componentOutput->componentOutputIndex, params); - } else { - auto params = Value::makeArrayRef(defs_v3::SYSTEM_STRUCTURE_ACTION_PARAMS_NUM_FIELDS, defs_v3::SYSTEM_STRUCTURE_ACTION_PARAMS, 0x285940bb); - - // index - ((ArrayValueRef *)params.refValue)->arrayValue.values[defs_v3::SYSTEM_STRUCTURE_ACTION_PARAMS_FIELD_INDEX] = widgetCursor.iterators[0]; - - // indexes - auto indexes = Value::makeArrayRef(MAX_ITERATORS, defs_v3::ARRAY_TYPE_INTEGER, 0xb1f68ef8); - for (size_t i = 0; i < MAX_ITERATORS; i++) { - ((ArrayValueRef *)indexes.refValue)->arrayValue.values[i] = (int)widgetCursor.iterators[i]; - } - ((ArrayValueRef *)params.refValue)->arrayValue.values[defs_v3::SYSTEM_STRUCTURE_ACTION_PARAMS_FIELD_INDEXES] = indexes; - - propagateValue(flowState, componentOutput->componentIndex, componentOutput->componentOutputIndex, params); - } - } - } - - for (int i = 0; i < 3; i++) { - tick(); - } -} - -void dataOperation(int16_t dataId, DataOperationEnum operation, const gui::WidgetCursor &widgetCursor, Value &value) { - if (!isFlowRunningHook()) { - return; - } - - auto flowState = widgetCursor.flowState; - - auto flowDataId = -dataId - 1; - - auto flow = flowState->flow; - - if (flowDataId >= 0 && flowDataId < (int16_t)flow->widgetDataItems.count) { - WidgetDataItem *widgetDataItem = flow->widgetDataItems[flowDataId]; - auto component = flow->components[widgetDataItem->componentIndex]; - - if (operation == DATA_OPERATION_GET) { - getValue(flowDataId, operation, widgetCursor, value); - if (component->type == WIDGET_TYPE_INPUT && dataId == widgetCursor.widget->data) { - value = getInputWidgetData(widgetCursor, value); - } - } else if (operation == DATA_OPERATION_COUNT) { - Value arrayValue; - getValue(flowDataId, operation, widgetCursor, arrayValue); - if (arrayValue.getType() == VALUE_TYPE_ARRAY || arrayValue.getType() == VALUE_TYPE_ARRAY_REF) { - value = arrayValue.getArray()->arraySize; - } else { - value = 0; - } - } -#if OPTION_KEYPAD - else if (operation == DATA_OPERATION_GET_TEXT_CURSOR_POSITION) { - - Keypad *keypad = getActiveKeypad(); - if (keypad) { - value = keypad->getCursorPosition(); - } - } -#endif - else if (operation == DATA_OPERATION_GET_MIN) { - if (component->type == WIDGET_TYPE_INPUT) { - value = getInputWidgetMin(widgetCursor); - } - } else if (operation == DATA_OPERATION_GET_MAX) { - if (component->type == WIDGET_TYPE_INPUT) { - value = getInputWidgetMax(widgetCursor); - } - } else if (operation == DATA_OPERATION_GET_PRECISION) { - if (component->type == WIDGET_TYPE_INPUT) { - value = getInputWidgetPrecision(widgetCursor); - } - } else if (operation == DATA_OPERATION_GET_UNIT) { - if (component->type == WIDGET_TYPE_INPUT) { - value = getBaseUnit(getInputWidgetUnit(widgetCursor)); - } - } else if (operation == DATA_OPERATION_SET) { - if (component->type == WIDGET_TYPE_INPUT) { - auto inputWidget = (InputWidget *)widgetCursor.widget; - if (inputWidget->flags & INPUT_WIDGET_TYPE_NUMBER) { - if (value.isInt32()) { - setValue(flowDataId, widgetCursor, value); - } else { - Value precisionValue = getInputWidgetPrecision(widgetCursor); - float precision = precisionValue.toFloat(); - float valueFloat = value.toFloat(); - Unit unit = getInputWidgetUnit(widgetCursor); - setValue(flowDataId, widgetCursor, Value(roundPrec(valueFloat, precision) / getUnitFactor(unit), VALUE_TYPE_FLOAT)); - } - } else { - setValue(flowDataId, widgetCursor, value); - } - - executeFlowAction(widgetCursor, inputWidget->action, nullptr); - } else { - setValue(flowDataId, widgetCursor, value); - } - } - } else { - // TODO this shouldn't happen - value = Value(); - } -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/flow.h b/Middlewares/eez/flow/flow.h deleted file mode 100644 index f4be2fe..0000000 --- a/Middlewares/eez/flow/flow.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2021-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include - -namespace eez { -namespace flow { - -#if defined(__EMSCRIPTEN__) -extern uint32_t g_wasmModuleId; -#endif - -using namespace eez::gui; - -struct FlowState; - -unsigned start(eez::gui::Assets *assets); -void tick(); -void stop(); - -bool isFlowStopped(); - -FlowState *getFlowState(Assets *assets, int flowStateIndex); - -FlowState *getFlowState(Assets *assets, int16_t pageIndex, const WidgetCursor &widgetCursor); -int getPageIndex(FlowState *flowState); - -FlowState *getLayoutViewFlowState(FlowState *flowState, uint16_t layoutViewWidgetComponentIndex, int16_t pageId); - -void executeFlowAction(const WidgetCursor &widgetCursor, int16_t actionId, void *param); -void dataOperation(int16_t dataId, DataOperationEnum operation, const WidgetCursor &widgetCursor, Value &value); -int16_t getNativeVariableId(const WidgetCursor &widgetCursor); - -void onDebuggerClientConnected(); -void onDebuggerClientDisconnected(); - -void executeScpi(); -void flushToDebuggerMessage(); - -} // flow -} // eez diff --git a/Middlewares/eez/flow/flow_defs_v3.h b/Middlewares/eez/flow/flow_defs_v3.h deleted file mode 100644 index cc0612a..0000000 --- a/Middlewares/eez/flow/flow_defs_v3.h +++ /dev/null @@ -1,444 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2021-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -namespace eez { -namespace flow { -namespace defs_v3 { - -enum ComponentTypes { - COMPONENT_TYPE_NONE = 0, - COMPONENT_TYPE_CONTAINER_WIDGET = 1, - COMPONENT_TYPE_LIST_WIDGET = 2, - COMPONENT_TYPE_GRID_WIDGET = 3, - COMPONENT_TYPE_SELECT_WIDGET = 4, - COMPONENT_TYPE_DISPLAY_DATA_WIDGET = 5, - COMPONENT_TYPE_TEXT_WIDGET = 6, - COMPONENT_TYPE_MULTILINE_TEXT_WIDGET = 7, - COMPONENT_TYPE_RECTANGLE_WIDGET = 8, - COMPONENT_TYPE_BITMAP_WIDGET = 9, - COMPONENT_TYPE_BUTTON_WIDGET = 10, - COMPONENT_TYPE_TOGGLE_BUTTON_WIDGET = 11, - COMPONENT_TYPE_BUTTON_GROUP_WIDGET = 12, - COMPONENT_TYPE_BAR_GRAPH_WIDGET = 14, - COMPONENT_TYPE_LAYOUT_VIEW_WIDGET = 15, - COMPONENT_TYPE_YTGRAPH_WIDGET = 16, - COMPONENT_TYPE_UP_DOWN_WIDGET = 17, - COMPONENT_TYPE_LIST_GRAPH_WIDGET = 18, - COMPONENT_TYPE_APP_VIEW_WIDGET = 19, - COMPONENT_TYPE_SCROLL_BAR_WIDGET = 20, - COMPONENT_TYPE_PROGRESS_WIDGET = 21, - COMPONENT_TYPE_CANVAS_WIDGET = 22, - COMPONENT_TYPE_GAUGE_EMBEDDED_WIDGET = 23, - COMPONENT_TYPE_INPUT_EMBEDDED_WIDGET = 24, - COMPONENT_TYPE_ROLLER_WIDGET = 25, - COMPONENT_TYPE_SWITCH_WIDGET = 26, - COMPONENT_TYPE_SLIDER_WIDGET = 27, - COMPONENT_TYPE_DROP_DOWN_LIST_WIDGET = 28, - COMPONENT_TYPE_START_ACTION = 1001, - COMPONENT_TYPE_END_ACTION = 1002, - COMPONENT_TYPE_INPUT_ACTION = 1003, - COMPONENT_TYPE_OUTPUT_ACTION = 1004, - COMPONENT_TYPE_WATCH_VARIABLE_ACTION = 1005, - COMPONENT_TYPE_EVAL_EXPR_ACTION = 1006, - COMPONENT_TYPE_SET_VARIABLE_ACTION = 1007, - COMPONENT_TYPE_SWITCH_ACTION = 1008, - COMPONENT_TYPE_COMPARE_ACTION = 1009, - COMPONENT_TYPE_IS_TRUE_ACTION = 1010, - COMPONENT_TYPE_CONSTANT_ACTION = 1011, - COMPONENT_TYPE_LOG_ACTION = 1012, - COMPONENT_TYPE_CALL_ACTION_ACTION = 1013, - COMPONENT_TYPE_DELAY_ACTION = 1014, - COMPONENT_TYPE_ERROR_ACTION = 1015, - COMPONENT_TYPE_CATCH_ERROR_ACTION = 1016, - COMPONENT_TYPE_COUNTER_ACTION = 1017, - COMPONENT_TYPE_LOOP_ACTION = 1018, - COMPONENT_TYPE_SHOW_PAGE_ACTION = 1019, - COMPONENT_TYPE_SCPIACTION = 1020, - COMPONENT_TYPE_SHOW_MESSAGE_BOX_ACTION = 1021, - COMPONENT_TYPE_SHOW_KEYBOARD_ACTION = 1022, - COMPONENT_TYPE_SHOW_KEYPAD_ACTION = 1023, - COMPONENT_TYPE_NOOP_ACTION = 1024, - COMPONENT_TYPE_COMMENT_ACTION = 1025, - COMPONENT_TYPE_SELECT_LANGUAGE_ACTION = 1026, - COMPONENT_TYPE_SET_PAGE_DIRECTION_ACTION = 1027, - COMPONENT_TYPE_ANIMATE_ACTION = 1028, - COMPONENT_TYPE_ON_EVENT_ACTION = 1029, - FIRST_DASHBOARD_COMPONENT_TYPE = 10000 -}; - -enum Component_CONTAINER_WIDGET_Properties { - CONTAINER_WIDGET_PROPERTY_DATA = 0, - CONTAINER_WIDGET_PROPERTY_VISIBLE = 1, - CONTAINER_WIDGET_PROPERTY_OVERLAY = 2 -}; - -enum Component_LIST_WIDGET_Properties { - LIST_WIDGET_PROPERTY_DATA = 0, - LIST_WIDGET_PROPERTY_VISIBLE = 1 -}; - -enum Component_GRID_WIDGET_Properties { - GRID_WIDGET_PROPERTY_DATA = 0, - GRID_WIDGET_PROPERTY_VISIBLE = 1 -}; - -enum Component_SELECT_WIDGET_Properties { - SELECT_WIDGET_PROPERTY_DATA = 0, - SELECT_WIDGET_PROPERTY_VISIBLE = 1 -}; - -enum Component_DISPLAY_DATA_WIDGET_Properties { - DISPLAY_DATA_WIDGET_PROPERTY_DATA = 0, - DISPLAY_DATA_WIDGET_PROPERTY_VISIBLE = 1 -}; - -enum Component_TEXT_WIDGET_Properties { - TEXT_WIDGET_PROPERTY_DATA = 0, - TEXT_WIDGET_PROPERTY_VISIBLE = 1 -}; - -enum Component_MULTILINE_TEXT_WIDGET_Properties { - MULTILINE_TEXT_WIDGET_PROPERTY_DATA = 0, - MULTILINE_TEXT_WIDGET_PROPERTY_VISIBLE = 1 -}; - -enum Component_RECTANGLE_WIDGET_Properties { - RECTANGLE_WIDGET_PROPERTY_DATA = 0, - RECTANGLE_WIDGET_PROPERTY_VISIBLE = 1 -}; - -enum Component_BITMAP_WIDGET_Properties { - BITMAP_WIDGET_PROPERTY_DATA = 0, - BITMAP_WIDGET_PROPERTY_VISIBLE = 1 -}; - -enum Component_BUTTON_WIDGET_Properties { - BUTTON_WIDGET_PROPERTY_DATA = 0, - BUTTON_WIDGET_PROPERTY_VISIBLE = 1, - BUTTON_WIDGET_PROPERTY_ENABLED = 2 -}; - -enum Component_TOGGLE_BUTTON_WIDGET_Properties { - TOGGLE_BUTTON_WIDGET_PROPERTY_DATA = 0, - TOGGLE_BUTTON_WIDGET_PROPERTY_VISIBLE = 1 -}; - -enum Component_BUTTON_GROUP_WIDGET_Properties { - BUTTON_GROUP_WIDGET_PROPERTY_DATA = 0, - BUTTON_GROUP_WIDGET_PROPERTY_VISIBLE = 1 -}; - -enum Component_BAR_GRAPH_WIDGET_Properties { - BAR_GRAPH_WIDGET_PROPERTY_DATA = 0, - BAR_GRAPH_WIDGET_PROPERTY_VISIBLE = 1, - BAR_GRAPH_WIDGET_PROPERTY_LINE1_DATA = 2, - BAR_GRAPH_WIDGET_PROPERTY_LINE2_DATA = 3 -}; - -enum Component_LAYOUT_VIEW_WIDGET_Properties { - LAYOUT_VIEW_WIDGET_PROPERTY_DATA = 0, - LAYOUT_VIEW_WIDGET_PROPERTY_VISIBLE = 1, - LAYOUT_VIEW_WIDGET_PROPERTY_CONTEXT = 2 -}; - -enum Component_YTGRAPH_WIDGET_Properties { - YTGRAPH_WIDGET_PROPERTY_DATA = 0, - YTGRAPH_WIDGET_PROPERTY_VISIBLE = 1, - YTGRAPH_WIDGET_PROPERTY_Y2_DATA = 2 -}; - -enum Component_UP_DOWN_WIDGET_Properties { - UP_DOWN_WIDGET_PROPERTY_DATA = 0, - UP_DOWN_WIDGET_PROPERTY_VISIBLE = 1 -}; - -enum Component_LIST_GRAPH_WIDGET_Properties { - LIST_GRAPH_WIDGET_PROPERTY_DATA = 0, - LIST_GRAPH_WIDGET_PROPERTY_VISIBLE = 1, - LIST_GRAPH_WIDGET_PROPERTY_DWELL_DATA = 2, - LIST_GRAPH_WIDGET_PROPERTY_Y1_DATA = 3, - LIST_GRAPH_WIDGET_PROPERTY_Y2_DATA = 4, - LIST_GRAPH_WIDGET_PROPERTY_CURSOR_DATA = 5 -}; - -enum Component_APP_VIEW_WIDGET_Properties { - APP_VIEW_WIDGET_PROPERTY_DATA = 0, - APP_VIEW_WIDGET_PROPERTY_VISIBLE = 1 -}; - -enum Component_SCROLL_BAR_WIDGET_Properties { - SCROLL_BAR_WIDGET_PROPERTY_DATA = 0, - SCROLL_BAR_WIDGET_PROPERTY_VISIBLE = 1 -}; - -enum Component_PROGRESS_WIDGET_Properties { - PROGRESS_WIDGET_PROPERTY_DATA = 0, - PROGRESS_WIDGET_PROPERTY_VISIBLE = 1, - PROGRESS_WIDGET_PROPERTY_MIN = 2, - PROGRESS_WIDGET_PROPERTY_MAX = 3 -}; - -enum Component_CANVAS_WIDGET_Properties { - CANVAS_WIDGET_PROPERTY_DATA = 0, - CANVAS_WIDGET_PROPERTY_VISIBLE = 1 -}; - -enum Component_GAUGE_EMBEDDED_WIDGET_Properties { - GAUGE_EMBEDDED_WIDGET_PROPERTY_DATA = 0, - GAUGE_EMBEDDED_WIDGET_PROPERTY_VISIBLE = 1, - GAUGE_EMBEDDED_WIDGET_PROPERTY_MIN = 2, - GAUGE_EMBEDDED_WIDGET_PROPERTY_MAX = 3, - GAUGE_EMBEDDED_WIDGET_PROPERTY_THRESHOLD = 4, - GAUGE_EMBEDDED_WIDGET_PROPERTY_UNIT = 5 -}; - -enum Component_INPUT_EMBEDDED_WIDGET_Properties { - INPUT_EMBEDDED_WIDGET_PROPERTY_DATA = 0, - INPUT_EMBEDDED_WIDGET_PROPERTY_VISIBLE = 1, - INPUT_EMBEDDED_WIDGET_PROPERTY_MIN = 2, - INPUT_EMBEDDED_WIDGET_PROPERTY_MAX = 3, - INPUT_EMBEDDED_WIDGET_PROPERTY_PRECISION = 4, - INPUT_EMBEDDED_WIDGET_PROPERTY_UNIT = 5 -}; - -enum Component_ROLLER_WIDGET_Properties { - ROLLER_WIDGET_PROPERTY_DATA = 0, - ROLLER_WIDGET_PROPERTY_VISIBLE = 1, - ROLLER_WIDGET_PROPERTY_MIN = 2, - ROLLER_WIDGET_PROPERTY_MAX = 3, - ROLLER_WIDGET_PROPERTY_TEXT = 4 -}; - -enum Component_SWITCH_WIDGET_Properties { - SWITCH_WIDGET_PROPERTY_DATA = 0, - SWITCH_WIDGET_PROPERTY_VISIBLE = 1 -}; - -enum Component_SLIDER_WIDGET_Properties { - SLIDER_WIDGET_PROPERTY_DATA = 0, - SLIDER_WIDGET_PROPERTY_VISIBLE = 1, - SLIDER_WIDGET_PROPERTY_MIN = 2, - SLIDER_WIDGET_PROPERTY_MAX = 3 -}; - -enum Component_DROP_DOWN_LIST_WIDGET_Properties { - DROP_DOWN_LIST_WIDGET_PROPERTY_DATA = 0, - DROP_DOWN_LIST_WIDGET_PROPERTY_VISIBLE = 1, - DROP_DOWN_LIST_WIDGET_PROPERTY_OPTIONS = 2 -}; - -enum Component_WATCH_VARIABLE_ACTION_COMPONENT_Properties { - WATCH_VARIABLE_ACTION_COMPONENT_PROPERTY_VARIABLE = 0 -}; - -enum Component_EVAL_EXPR_ACTION_COMPONENT_Properties { - EVAL_EXPR_ACTION_COMPONENT_PROPERTY_EXPRESSION = 0 -}; - -enum Component_COMPARE_ACTION_COMPONENT_Properties { - COMPARE_ACTION_COMPONENT_PROPERTY_A = 0, - COMPARE_ACTION_COMPONENT_PROPERTY_B = 1, - COMPARE_ACTION_COMPONENT_PROPERTY_C = 2 -}; - -enum Component_IS_TRUE_ACTION_COMPONENT_Properties { - IS_TRUE_ACTION_COMPONENT_PROPERTY_VALUE = 0 -}; - -enum Component_CONSTANT_ACTION_COMPONENT_Properties { - CONSTANT_ACTION_COMPONENT_PROPERTY_VALUE = 0 -}; - -enum Component_LOG_ACTION_COMPONENT_Properties { - LOG_ACTION_COMPONENT_PROPERTY_VALUE = 0 -}; - -enum Component_DELAY_ACTION_COMPONENT_Properties { - DELAY_ACTION_COMPONENT_PROPERTY_MILLISECONDS = 0 -}; - -enum Component_ERROR_ACTION_COMPONENT_Properties { - ERROR_ACTION_COMPONENT_PROPERTY_MESSAGE = 0 -}; - -enum Component_COUNTER_ACTION_COMPONENT_Properties { - COUNTER_ACTION_COMPONENT_PROPERTY_COUNT_VALUE = 0 -}; - -enum Component_LOOP_ACTION_COMPONENT_Properties { - LOOP_ACTION_COMPONENT_PROPERTY_VARIABLE = 0, - LOOP_ACTION_COMPONENT_PROPERTY_FROM = 1, - LOOP_ACTION_COMPONENT_PROPERTY_TO = 2, - LOOP_ACTION_COMPONENT_PROPERTY_STEP = 3 -}; - -enum Component_SCPIACTION_COMPONENT_Properties { - SCPIACTION_COMPONENT_PROPERTY_INSTRUMENT = 0 -}; - -enum Component_SHOW_MESSAGE_BOX_ACTION_COMPONENT_Properties { - SHOW_MESSAGE_BOX_ACTION_COMPONENT_PROPERTY_MESSAGE = 0 -}; - -enum Component_SHOW_KEYBOARD_ACTION_COMPONENT_Properties { - SHOW_KEYBOARD_ACTION_COMPONENT_PROPERTY_LABEL = 0, - SHOW_KEYBOARD_ACTION_COMPONENT_PROPERTY_INITAL_TEXT = 1, - SHOW_KEYBOARD_ACTION_COMPONENT_PROPERTY_MIN_CHARS = 2, - SHOW_KEYBOARD_ACTION_COMPONENT_PROPERTY_MAX_CHARS = 3 -}; - -enum Component_SHOW_KEYPAD_ACTION_COMPONENT_Properties { - SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_LABEL = 0, - SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_INITAL_VALUE = 1, - SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_MIN = 2, - SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_MAX = 3, - SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_PRECISION = 4, - SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_UNIT = 5 -}; - -enum Component_SELECT_LANGUAGE_ACTION_COMPONENT_Properties { - SELECT_LANGUAGE_ACTION_COMPONENT_PROPERTY_LANGUAGE = 0 -}; - -enum Component_ANIMATE_ACTION_COMPONENT_Properties { - ANIMATE_ACTION_COMPONENT_PROPERTY_FROM = 0, - ANIMATE_ACTION_COMPONENT_PROPERTY_TO = 1, - ANIMATE_ACTION_COMPONENT_PROPERTY_SPEED = 2 -}; - -enum OperationTypes { - OPERATION_TYPE_ADD = 0, - OPERATION_TYPE_SUB = 1, - OPERATION_TYPE_MUL = 2, - OPERATION_TYPE_DIV = 3, - OPERATION_TYPE_MOD = 4, - OPERATION_TYPE_LEFT_SHIFT = 5, - OPERATION_TYPE_RIGHT_SHIFT = 6, - OPERATION_TYPE_BINARY_AND = 7, - OPERATION_TYPE_BINARY_OR = 8, - OPERATION_TYPE_BINARY_XOR = 9, - OPERATION_TYPE_EQUAL = 10, - OPERATION_TYPE_NOT_EQUAL = 11, - OPERATION_TYPE_LESS = 12, - OPERATION_TYPE_GREATER = 13, - OPERATION_TYPE_LESS_OR_EQUAL = 14, - OPERATION_TYPE_GREATER_OR_EQUAL = 15, - OPERATION_TYPE_LOGICAL_AND = 16, - OPERATION_TYPE_LOGICAL_OR = 17, - OPERATION_TYPE_UNARY_PLUS = 18, - OPERATION_TYPE_UNARY_MINUS = 19, - OPERATION_TYPE_BINARY_ONE_COMPLEMENT = 20, - OPERATION_TYPE_NOT = 21, - OPERATION_TYPE_CONDITIONAL = 22, - OPERATION_TYPE_SYSTEM_GET_TICK = 23, - OPERATION_TYPE_FLOW_INDEX = 24, - OPERATION_TYPE_FLOW_IS_PAGE_ACTIVE = 25, - OPERATION_TYPE_FLOW_PAGE_TIMELINE_POSITION = 26, - OPERATION_TYPE_FLOW_MAKE_VALUE = 27, - OPERATION_TYPE_FLOW_MAKE_ARRAY_VALUE = 28, - OPERATION_TYPE_FLOW_LANGUAGES = 29, - OPERATION_TYPE_FLOW_TRANSLATE = 30, - OPERATION_TYPE_FLOW_PARSE_INTEGER = 31, - OPERATION_TYPE_FLOW_PARSE_FLOAT = 32, - OPERATION_TYPE_FLOW_PARSE_DOUBLE = 33, - OPERATION_TYPE_DATE_NOW = 34, - OPERATION_TYPE_DATE_TO_STRING = 35, - OPERATION_TYPE_DATE_FROM_STRING = 36, - OPERATION_TYPE_MATH_SIN = 37, - OPERATION_TYPE_MATH_COS = 38, - OPERATION_TYPE_MATH_LOG = 39, - OPERATION_TYPE_MATH_LOG10 = 40, - OPERATION_TYPE_MATH_ABS = 41, - OPERATION_TYPE_MATH_FLOOR = 42, - OPERATION_TYPE_MATH_CEIL = 43, - OPERATION_TYPE_MATH_ROUND = 44, - OPERATION_TYPE_MATH_MIN = 45, - OPERATION_TYPE_MATH_MAX = 46, - OPERATION_TYPE_STRING_FIND = 47, - OPERATION_TYPE_STRING_PAD_START = 48, - OPERATION_TYPE_STRING_SPLIT = 49, - OPERATION_TYPE_ARRAY_LENGTH = 50, - OPERATION_TYPE_ARRAY_SLICE = 51 -}; - -enum SystemStructures { - SYSTEM_STRUCTURE_ACTION_PARAMS = 20, - SYSTEM_STRUCTURE_CHECKBOX_ACTION_PARAMS = 21, - SYSTEM_STRUCTURE_TEXT_INPUT_ACTION_PARAMS = 22, - SYSTEM_STRUCTURE_DROP_DOWN_LIST_ACTION_PARAMS = 23, - SYSTEM_STRUCTURE_SERIAL_PORT = 24, - SYSTEM_STRUCTURE_TERMINAL_WIDGET_ON_DATA_PARAMS = 25 -}; - -enum ActionParamsSystemStructureFields { - SYSTEM_STRUCTURE_ACTION_PARAMS_FIELD_INDEX = 0, - SYSTEM_STRUCTURE_ACTION_PARAMS_FIELD_INDEXES = 1, - SYSTEM_STRUCTURE_ACTION_PARAMS_NUM_FIELDS -}; - -enum CheckboxActionParamsSystemStructureFields { - SYSTEM_STRUCTURE_CHECKBOX_ACTION_PARAMS_FIELD_INDEX = 0, - SYSTEM_STRUCTURE_CHECKBOX_ACTION_PARAMS_FIELD_INDEXES = 1, - SYSTEM_STRUCTURE_CHECKBOX_ACTION_PARAMS_FIELD_VALUE = 2, - SYSTEM_STRUCTURE_CHECKBOX_ACTION_PARAMS_NUM_FIELDS -}; - -enum TextInputActionParamsSystemStructureFields { - SYSTEM_STRUCTURE_TEXT_INPUT_ACTION_PARAMS_FIELD_INDEX = 0, - SYSTEM_STRUCTURE_TEXT_INPUT_ACTION_PARAMS_FIELD_INDEXES = 1, - SYSTEM_STRUCTURE_TEXT_INPUT_ACTION_PARAMS_FIELD_VALUE = 2, - SYSTEM_STRUCTURE_TEXT_INPUT_ACTION_PARAMS_NUM_FIELDS -}; - -enum DropDownListActionParamsSystemStructureFields { - SYSTEM_STRUCTURE_DROP_DOWN_LIST_ACTION_PARAMS_FIELD_INDEX = 0, - SYSTEM_STRUCTURE_DROP_DOWN_LIST_ACTION_PARAMS_FIELD_INDEXES = 1, - SYSTEM_STRUCTURE_DROP_DOWN_LIST_ACTION_PARAMS_FIELD_SELECTED_INDEX = 2, - SYSTEM_STRUCTURE_DROP_DOWN_LIST_ACTION_PARAMS_NUM_FIELDS -}; - -enum SerialPortSystemStructureFields { - SYSTEM_STRUCTURE_SERIAL_PORT_FIELD_MANUFACTURER = 0, - SYSTEM_STRUCTURE_SERIAL_PORT_FIELD_SERIAL_NUMBER = 1, - SYSTEM_STRUCTURE_SERIAL_PORT_FIELD_PATH = 2, - SYSTEM_STRUCTURE_SERIAL_PORT_NUM_FIELDS -}; - -enum TerminalWidgetOnDataParamsSystemStructureFields { - SYSTEM_STRUCTURE_TERMINAL_WIDGET_ON_DATA_PARAMS_FIELD_INDEX = 0, - SYSTEM_STRUCTURE_TERMINAL_WIDGET_ON_DATA_PARAMS_FIELD_INDEXES = 1, - SYSTEM_STRUCTURE_TERMINAL_WIDGET_ON_DATA_PARAMS_FIELD_DATA = 2, - SYSTEM_STRUCTURE_TERMINAL_WIDGET_ON_DATA_PARAMS_NUM_FIELDS -}; - -enum ArrayTypes { - ARRAY_TYPE_INTEGER = 26, - ARRAY_TYPE_FLOAT = 27, - ARRAY_TYPE_DOUBLE = 28, - ARRAY_TYPE_BOOLEAN = 29, - ARRAY_TYPE_STRING = 30, - ARRAY_TYPE_DATE = 31, - ARRAY_TYPE_BLOB = 32, - ARRAY_TYPE_ANY = 14 -}; - -} // defs_v3 -} // flow -} // eez \ No newline at end of file diff --git a/Middlewares/eez/flow/hooks.cpp b/Middlewares/eez/flow/hooks.cpp deleted file mode 100644 index a41723e..0000000 --- a/Middlewares/eez/flow/hooks.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include -#include - -namespace eez { -namespace flow { - -static bool isFlowRunning() { - return true; -} - -static void replacePage(int16_t pageId) { - eez::gui::getAppContextFromId(APP_CONTEXT_ID_DEVICE)->replacePage(pageId); -} - -static void showKeyboard(Value label, Value initialText, Value minChars, Value maxChars, bool isPassword, void(*onOk)(char *), void(*onCancel)()) { -} - -static void showKeypad(Value label, Value initialValue, Value min, Value max, Unit unit, void(*onOk)(float), void(*onCancel)()) { -} - -static void stopScript() { - assert(false); -} - -static void scpiComponentInit() { -} - -static void startToDebuggerMessage() { -} - -static void writeDebuggerBuffer(const char *buffer, uint32_t length) { -} - -static void finishToDebuggerMessage() { -} - -static void onDebuggerInputAvailable() { -} - -bool (*isFlowRunningHook)() = isFlowRunning; -void (*replacePageHook)(int16_t pageId) = replacePage; -void (*showKeyboardHook)(Value label, Value initialText, Value minChars, Value maxChars, bool isPassword, void(*onOk)(char *), void(*onCancel)()) = showKeyboard; -void (*showKeypadHook)(Value label, Value initialValue, Value min, Value max, Unit unit, void(*onOk)(float), void(*onCancel)()) = showKeypad; -void (*stopScriptHook)() = stopScript; - -void (*scpiComponentInitHook)() = scpiComponentInit; - -void (*startToDebuggerMessageHook)() = startToDebuggerMessage; -void (*writeDebuggerBufferHook)(const char *buffer, uint32_t length) = writeDebuggerBuffer; -void (*finishToDebuggerMessageHook)() = finishToDebuggerMessage; -void (*onDebuggerInputAvailableHook)() = onDebuggerInputAvailable; - -void (*executeDashboardComponentHook)(uint16_t componentType, int flowStateIndex, int componentIndex) = nullptr; - -} // namespace flow -} // namespace eez - diff --git a/Middlewares/eez/flow/hooks.h b/Middlewares/eez/flow/hooks.h deleted file mode 100644 index a80afa4..0000000 --- a/Middlewares/eez/flow/hooks.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2022-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include - -#include -#include - -namespace eez { -namespace flow { - -using eez::gui::Value; - -extern bool (*isFlowRunningHook)(); -extern void (*replacePageHook)(int16_t pageId); -extern void (*showKeyboardHook)(Value label, Value initialText, Value minChars, Value maxChars, bool isPassword, void(*onOk)(char *), void(*onCancel)()); -extern void (*showKeypadHook)(Value label, Value initialValue, Value min, Value max, Unit unit, void(*onOk)(float), void(*onCancel)()); -extern void (*stopScriptHook)(); - -extern void (*scpiComponentInitHook)(); - -extern void (*startToDebuggerMessageHook)(); -extern void (*writeDebuggerBufferHook)(const char *buffer, uint32_t length); -extern void (*finishToDebuggerMessageHook)(); -extern void (*onDebuggerInputAvailableHook)(); - -extern void (*executeDashboardComponentHook)(uint16_t componentType, int flowStateIndex, int componentIndex); - -} // flow -} // eez diff --git a/Middlewares/eez/flow/operations.cpp b/Middlewares/eez/flow/operations.cpp deleted file mode 100644 index ae04687..0000000 --- a/Middlewares/eez/flow/operations.cpp +++ /dev/null @@ -1,1413 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include - -// https://howardhinnant.github.io/date/date.html -#include - -#include - -#include -#include - -namespace eez { -namespace flow { - -using namespace gui; - -Value op_add(const Value& a1, const Value& b1) { - auto a = a1.getValue(); - auto b = b1.getValue(); - - if (a.isAnyStringType() || b.isAnyStringType()) { - Value value1 = a.toString(0x84eafaa8); - Value value2 = b.toString(0xd273cab6); - auto res = Value::concatenateString(value1, value2); - - char str1[128]; - res.toText(str1, sizeof(str1)); - - return res; - } - - if (a.isDouble() || b.isDouble()) { - return Value(a.toDouble() + b.toDouble(), VALUE_TYPE_DOUBLE); - } - - if (a.isFloat() || b.isFloat()) { - return Value(a.toFloat() + b.toFloat(), VALUE_TYPE_FLOAT); - } - - if (a.isInt64() || b.isInt64()) { - return Value(a.toInt64() + b.toInt64(), VALUE_TYPE_INT64); - } - - if (a.isInt32OrLess() && b.isInt32OrLess()) { - return Value((int)(a.int32Value + b.int32Value), VALUE_TYPE_INT32); - } - - return Value(); -} - -Value op_sub(const Value& a1, const Value& b1) { - auto a = a1.getValue(); - auto b = b1.getValue(); - - if (a.isDouble() || b.isDouble()) { - return Value(a.toDouble() - b.toDouble(), VALUE_TYPE_DOUBLE); - } - - if (a.isFloat() || b.isFloat()) { - return Value(a.toFloat() - b.toFloat(), VALUE_TYPE_FLOAT); - } - - if (a.isInt64() || b.isInt64()) { - return Value(a.toInt64() - b.toInt64(), VALUE_TYPE_INT64); - } - - if (a.isInt32OrLess() && b.isInt32OrLess()) { - return Value((int)(a.int32Value - b.int32Value), VALUE_TYPE_INT32); - } - - return Value(); -} - -Value op_mul(const Value& a1, const Value& b1) { - auto a = a1.getValue(); - auto b = b1.getValue(); - - if (a.isDouble() || b.isDouble()) { - return Value(a.toDouble() * b.toDouble(), VALUE_TYPE_DOUBLE); - } - - if (a.isFloat() || b.isFloat()) { - return Value(a.toFloat() * b.toFloat(), VALUE_TYPE_FLOAT); - } - - if (a.isInt64() || b.isInt64()) { - return Value(a.toInt64() * b.toInt64(), VALUE_TYPE_INT64); - } - - if (a.isInt32OrLess() && b.isInt32OrLess()) { - return Value((int)(a.int32Value * b.int32Value), VALUE_TYPE_INT32); - } - - return Value(); -} - -Value op_div(const Value& a1, const Value& b1) { - auto a = a1.getValue(); - auto b = b1.getValue(); - - if (a.isDouble() || b.isDouble()) { - return Value(a.toDouble() / b.toDouble(), VALUE_TYPE_DOUBLE); - } - - if (a.isFloat() || b.isFloat()) { - return Value(a.toFloat() / b.toFloat(), VALUE_TYPE_FLOAT); - } - - if (a.isInt64() || b.isInt64()) { - return Value(1.0 * a.toInt64() / b.toInt64(), VALUE_TYPE_DOUBLE); - } - - if (a.isInt32OrLess() && b.isInt32OrLess()) { - return Value(1.0 * a.int32Value / b.int32Value, VALUE_TYPE_DOUBLE); - } - - return Value(); -} - -Value op_mod(const Value& a1, const Value& b1) { - auto a = a1.getValue(); - auto b = b1.getValue(); - - return Value(a.toDouble() - floor(a.toDouble() / b.toDouble()) * b.toDouble(), VALUE_TYPE_DOUBLE); -} - -Value op_left_shift(const Value& a1, const Value& b1) { - auto a = a1.getValue(); - auto b = b1.getValue(); - - return Value((int)(a.toInt32() << b.toInt32()), VALUE_TYPE_INT32); -} - -Value op_right_shift(const Value& a1, const Value& b1) { - auto a = a1.getValue(); - auto b = b1.getValue(); - - return Value((int)(a.toInt32() >> b.toInt32()), VALUE_TYPE_INT32); -} - -Value op_binary_and(const Value& a1, const Value& b1) { - auto a = a1.getValue(); - auto b = b1.getValue(); - - return Value((int)(a.toBool() & b.toBool()), VALUE_TYPE_INT32); -} - -Value op_binary_or(const Value& a1, const Value& b1) { - auto a = a1.getValue(); - auto b = b1.getValue(); - - return Value((int)(a.toBool() | b.toBool()), VALUE_TYPE_INT32); -} - -Value op_binary_xor(const Value& a1, const Value& b1) { - auto a = a1.getValue(); - auto b = b1.getValue(); - - return Value((int)(a.toBool() ^ b.toBool()), VALUE_TYPE_INT32); -} - -bool is_equal(const Value& a1, const Value& b1) { - auto a = a1.getValue(); - auto b = b1.getValue(); - - auto aIsUndefinedOrNull = a.getType() == VALUE_TYPE_UNDEFINED || a.getType() == VALUE_TYPE_NULL; - auto bIsUndefinedOrNull = b.getType() == VALUE_TYPE_UNDEFINED || b.getType() == VALUE_TYPE_NULL; - - if (aIsUndefinedOrNull) { - return bIsUndefinedOrNull; - } else if (bIsUndefinedOrNull) { - return false; - } - - if (a.isAnyStringType() && b.isAnyStringType()) { - const char *aStr = a.getString(); - const char *bStr = b.getString(); - if (!aStr && !aStr) { - return true; - } - if (!aStr || !bStr) { - return false; - } - return strcmp(aStr, bStr) == 0; - } - - return a.toDouble() == b.toDouble(); -} - -bool is_less(const Value& a1, const Value& b1) { - auto a = a1.getValue(); - auto b = b1.getValue(); - - if (a.isAnyStringType() && b.isAnyStringType()) { - const char *aStr = a.getString(); - const char *bStr = b.getString(); - if (!aStr || !bStr) { - return false; - } - return strcmp(aStr, bStr) < 0; - } - - return a.toDouble() < b.toDouble(); -} - -Value op_eq(const Value& a1, const Value& b1) { - return Value(is_equal(a1, b1), VALUE_TYPE_BOOLEAN); -} - -Value op_neq(const Value& a1, const Value& b1) { - return Value(!is_equal(a1, b1), VALUE_TYPE_BOOLEAN); -} - -Value op_less(const Value& a1, const Value& b1) { - return Value(is_less(a1, b1), VALUE_TYPE_BOOLEAN); -} - -Value op_great(const Value& a1, const Value& b1) { - return Value(!is_less(a1, b1) && !is_equal(a1, b1), VALUE_TYPE_BOOLEAN); -} - -Value op_less_eq(const Value& a1, const Value& b1) { - return Value(is_less(a1, b1) || is_equal(a1, b1), VALUE_TYPE_BOOLEAN); -} - -Value op_great_eq(const Value& a1, const Value& b1) { - return Value(!is_less(a1, b1), VALUE_TYPE_BOOLEAN); -} - -bool do_OPERATION_TYPE_ADD(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - - auto result = op_add(a, b); - - if (result.getType() == VALUE_TYPE_UNDEFINED) { - return false; - } - - if (!stack.push(result)) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_SUB(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - - auto result = op_sub(a, b); - - if (result.getType() == VALUE_TYPE_UNDEFINED) { - return false; - } - - if (!stack.push(result)) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_MUL(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - - auto result = op_mul(a, b); - - if (result.getType() == VALUE_TYPE_UNDEFINED) { - return false; - } - - if (!stack.push(result)) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_DIV(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - - auto result = op_div(a, b); - - if (result.getType() == VALUE_TYPE_UNDEFINED) { - return false; - } - - if (!stack.push(result)) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_MOD(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - - auto result = op_mod(a, b); - - if (result.getType() == VALUE_TYPE_UNDEFINED) { - return false; - } - - if (!stack.push(result)) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_LEFT_SHIFT(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - - auto result = op_left_shift(a, b); - - if (result.getType() == VALUE_TYPE_UNDEFINED) { - return false; - } - - if (!stack.push(result)) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_RIGHT_SHIFT(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - - auto result = op_right_shift(a, b); - - if (result.getType() == VALUE_TYPE_UNDEFINED) { - return false; - } - - if (!stack.push(result)) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_BINARY_AND(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - - auto result = op_binary_and(a, b); - - if (result.getType() == VALUE_TYPE_UNDEFINED) { - return false; - } - - if (!stack.push(result)) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_BINARY_OR(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - - auto result = op_binary_or(a, b); - - if (result.getType() == VALUE_TYPE_UNDEFINED) { - return false; - } - - if (!stack.push(result)) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_BINARY_XOR(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - - auto result = op_binary_xor(a, b); - - if (result.getType() == VALUE_TYPE_UNDEFINED) { - return false; - } - - if (!stack.push(result)) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_EQUAL(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - if (!stack.push(op_eq(a, b))) { - return false; - } - return true; -} - -bool do_OPERATION_TYPE_NOT_EQUAL(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - if (!stack.push(op_neq(a, b))) { - return false; - } - return true;} - -bool do_OPERATION_TYPE_LESS(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - if (!stack.push(op_less(a, b))) { - return false; - } - return true; -} - -bool do_OPERATION_TYPE_GREATER(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - if (!stack.push(op_great(a, b))) { - return false; - } - return true; -} - -bool do_OPERATION_TYPE_LESS_OR_EQUAL(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - if (!stack.push(op_less_eq(a, b))) { - return false; - } - return true; -} - -bool do_OPERATION_TYPE_GREATER_OR_EQUAL(EvalStack &stack) { - auto b = stack.pop(); - auto a = stack.pop(); - if (!stack.push(op_great_eq(a, b))) { - return false; - } - return true; -} - -bool do_OPERATION_TYPE_LOGICAL_AND(EvalStack &stack) { - auto b = stack.pop().getValue(); - auto a = stack.pop().getValue(); - - if (!stack.push(Value(a.toBool() && b.toBool(), VALUE_TYPE_BOOLEAN))) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_LOGICAL_OR(EvalStack &stack) { - auto b = stack.pop().getValue(); - auto a = stack.pop().getValue(); - - if (!stack.push(Value(a.toBool() || b.toBool(), VALUE_TYPE_BOOLEAN))) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_UNARY_PLUS(EvalStack &stack) { - auto a = stack.pop().getValue(); - - if (a.isDouble()) { - if (!stack.push(Value(a.getDouble(), VALUE_TYPE_DOUBLE))) { - return false; - } - return true; - } - - if (a.isFloat()) { - if (!stack.push(Value(a.toFloat(), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - if (a.isInt64()) { - if (!stack.push(Value((int64_t)a.getInt64(), VALUE_TYPE_INT64))) { - return false; - } - return true; - } - - if (a.isInt32()) { - if (!stack.push(Value((int)a.getInt32(), VALUE_TYPE_INT32))) { - return false; - } - return true; - } - - if (a.isInt16()) { - if (!stack.push(Value((int16_t)a.getInt16(), VALUE_TYPE_INT16))) { - return false; - } - return true; - } - - - if (a.isInt8()) { - if (!stack.push(Value((int8_t)a.getInt8(), VALUE_TYPE_INT8))) { - return false; - } - return true; - } - - return false; -} - -bool do_OPERATION_TYPE_UNARY_MINUS(EvalStack &stack) { - auto a = stack.pop().getValue(); - - if (a.isDouble()) { - if (!stack.push(Value(-a.getDouble(), VALUE_TYPE_DOUBLE))) { - return false; - } - return true; - } - - if (a.isFloat()) { - if (!stack.push(Value(-a.toFloat(), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - if (a.isInt64()) { - if (!stack.push(Value((int64_t)-a.getInt64(), VALUE_TYPE_INT64))) { - return false; - } - return true; - } - - if (a.isInt32()) { - if (!stack.push(Value((int)-a.getInt32(), VALUE_TYPE_INT32))) { - return false; - } - return true; - } - - if (a.isInt16()) { - if (!stack.push(Value((int16_t)-a.getInt16(), VALUE_TYPE_INT16))) { - return false; - } - return true; - } - - - if (a.isInt8()) { - if (!stack.push(Value((int8_t)-a.getInt8(), VALUE_TYPE_INT8))) { - return false; - } - return true; - } - - return false; -} - -bool do_OPERATION_TYPE_BINARY_ONE_COMPLEMENT(EvalStack &stack) { - auto a = stack.pop().getValue(); - - if (a.isInt64()) { - if (!stack.push(Value(~a.uint64Value, VALUE_TYPE_UINT64))) { - return false; - } - return true; - } - - if (a.isInt32()) { - if (!stack.push(Value(~a.uint32Value, VALUE_TYPE_UINT32))) { - return false; - } - return true; - } - - if (a.isInt16()) { - if (!stack.push(Value(~a.uint16Value, VALUE_TYPE_UINT16))) { - return false; - } - return true; - } - - - if (a.isInt8()) { - if (!stack.push(Value(~a.uint8Value, VALUE_TYPE_UINT8))) { - return false; - } - return true; - } - - return false; -} - -bool do_OPERATION_TYPE_NOT(EvalStack &stack) { - auto aValue = stack.pop(); - - int err; - auto a = aValue.toBool(&err); - if (err != 0) { - return false; - } - - if (!stack.push(Value(!a, VALUE_TYPE_BOOLEAN))) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_CONDITIONAL(EvalStack &stack) { - auto alternate = stack.pop(); - auto consequent = stack.pop(); - auto conditionValue = stack.pop(); - - int err; - auto condition = conditionValue.toBool(&err); - if (err != 0) { - return false; - } - - if (!stack.push(condition ? consequent : alternate)) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_SYSTEM_GET_TICK(EvalStack &stack) { - if (!stack.push(Value(millis(), VALUE_TYPE_UINT32))) { - return false; - } - return true; -} - -bool do_OPERATION_TYPE_FLOW_INDEX(EvalStack &stack) { - if (!stack.iterators) { - return false; - } - - auto a = stack.pop(); - - int err; - auto iteratorIndex = a.toInt32(&err); - if (err != 0) { - return false; - } - - using eez::gui::MAX_ITERATORS; - - iteratorIndex = iteratorIndex; - if (iteratorIndex < 0 || iteratorIndex >= (int)MAX_ITERATORS) { - return false; - } - - if (!stack.push(stack.iterators[iteratorIndex])) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_FLOW_IS_PAGE_ACTIVE(EvalStack &stack) { - bool isActive = false; - - auto pageIndex = getPageIndex(stack.flowState); - if (pageIndex >= 0) { - int16_t pageId = (int16_t)(pageIndex + 1); - if (stack.flowState->assets == g_externalAssets) { - pageId = -pageId; - } - - for (int16_t appContextId = 0; ; appContextId++) { - auto appContext = getAppContextFromId(appContextId); - if (!appContext) { - break; - } - - if (appContext->isPageOnStack(pageId)) { - isActive = true; - break; - } - } - } - - if (!stack.push(Value(isActive, VALUE_TYPE_BOOLEAN))) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_FLOW_PAGE_TIMELINE_POSITION(EvalStack &stack) { - if (!stack.push(Value(stack.flowState->timelinePosition, VALUE_TYPE_FLOAT))) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_FLOW_MAKE_ARRAY_VALUE(EvalStack &stack) { - auto arrayTypeValue = stack.pop(); - auto arraySizeValue = stack.pop(); - - int arrayType = arrayTypeValue.getInt(); - int arraySize = arraySizeValue.getInt(); - - auto arrayValue = Value::makeArrayRef(arraySize, arrayType, 0x837260d4); - - auto array = arrayValue.getArray(); - - for (int i = 0; i < arraySize; i++) { - array->values[i] = stack.pop().getValue(); - } - - if (!stack.push(arrayValue)) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_FLOW_LANGUAGES(EvalStack &stack) { - auto languages = stack.flowState->assets->languages; - - auto arrayValue = Value::makeArrayRef(languages.count, VALUE_TYPE_STRING, 0xff4787fc); - - auto array = arrayValue.getArray(); - - for (uint32_t i = 0; i < languages.count; i++) { - array->values[i] = Value((const char *)(languages[i]->languageID)); - } - - if (!stack.push(arrayValue)) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_FLOW_TRANSLATE(EvalStack &stack) { - auto textResourceIndexValue = stack.pop(); - - int textResourceIndex = textResourceIndexValue.getInt(); - - int languageIndex = g_selectedLanguage; - - auto languages = stack.flowState->assets->languages; - if (languageIndex >= 0 && languageIndex < (int)languages.count) { - auto translations = languages[languageIndex]->translations; - if (textResourceIndex >= 0 && textResourceIndex < (int)translations.count) { - if (!stack.push(translations[textResourceIndex])) { - return false; - } - return true; - } - } - - if (!stack.push("")) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_FLOW_PARSE_INTEGER(EvalStack &stack) { - auto str = stack.pop(); - - int err; - auto value = str.toInt32(&err); - if (err) { - return false; - } - - if (!stack.push(Value((int)value, VALUE_TYPE_INT32))) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_FLOW_PARSE_FLOAT(EvalStack &stack) { - auto str = stack.pop(); - - int err; - auto value = str.toFloat(&err); - if (err) { - return false; - } - - if (!stack.push(Value(value, VALUE_TYPE_FLOAT))) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_FLOW_PARSE_DOUBLE(EvalStack &stack) { - auto str = stack.pop(); - - int err; - auto value = str.toDouble(&err); - if (err) { - return false; - } - - if (!stack.push(Value(value, VALUE_TYPE_DOUBLE))) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_DATE_NOW(EvalStack &stack) { - using namespace std::chrono; - milliseconds ms = duration_cast(system_clock::now().time_since_epoch()); - - if (!stack.push(Value((double)ms.count(), VALUE_TYPE_DATE))) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_DATE_TO_STRING(EvalStack &stack) { - auto a = stack.pop().getValue(); - if (a.getType() != VALUE_TYPE_DATE) { - return false; - } - - using namespace std; - using namespace std::chrono; - using namespace date; - - auto tp = system_clock::time_point(milliseconds((long long)a.getDouble())); - - stringstream out; - out << tp << endl; - - if (!stack.push(Value::makeStringRef(out.str().c_str(), -1, 0xbe440ec8))) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_DATE_FROM_STRING(EvalStack &stack) { - auto a = stack.pop().getValue(); - - Value dateStrValue = a.toString(0x99cb1a93); - - using namespace std; - using namespace std::chrono; - using namespace date; - - istringstream in{dateStrValue.getString()}; - - system_clock::time_point tp; - in >> date::parse("%Y-%m-%d %T", tp); - - milliseconds ms = duration_cast(tp.time_since_epoch()); - if (!stack.push(Value((double)ms.count(), VALUE_TYPE_DATE))) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_MATH_SIN(EvalStack &stack) { - auto a = stack.pop().getValue(); - - if (a.isDouble()) { - if (!stack.push(Value(sin(a.getDouble()), VALUE_TYPE_DOUBLE))) { - return false; - } - return true; - } - - if (a.isFloat()) { - if (!stack.push(Value(sinf(a.toFloat()), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - if (a.isInt64()) { - if (!stack.push(Value(sin(a.toInt64()), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - if (a.isInt32OrLess()) { - if (!stack.push(Value(sinf(a.int32Value), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - return false; -} - -bool do_OPERATION_TYPE_MATH_COS(EvalStack &stack) { - auto a = stack.pop().getValue(); - - if (a.isDouble()) { - if (!stack.push(Value(cos(a.getDouble()), VALUE_TYPE_DOUBLE))) { - return false; - } - return true; - } - - if (a.isFloat()) { - if (!stack.push(Value(cosf(a.toFloat()), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - if (a.isInt64()) { - if (!stack.push(Value(cos(a.toInt64()), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - if (a.isInt32OrLess()) { - if (!stack.push(Value(cosf(a.int32Value), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - return false; -} - -bool do_OPERATION_TYPE_MATH_LOG(EvalStack &stack) { - auto a = stack.pop().getValue(); - - if (a.isDouble()) { - if (!stack.push(Value(log(a.getDouble()), VALUE_TYPE_DOUBLE))) { - return false; - } - return true; - } - - if (a.isFloat()) { - if (!stack.push(Value(logf(a.toFloat()), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - if (a.isInt64()) { - if (!stack.push(Value(log(a.toInt64()), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - if (a.isInt32OrLess()) { - if (!stack.push(Value(logf(a.int32Value), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - return false; -} - -bool do_OPERATION_TYPE_MATH_LOG10(EvalStack &stack) { - auto a = stack.pop().getValue(); - - if (a.isDouble()) { - if (!stack.push(Value(log10(a.getDouble()), VALUE_TYPE_DOUBLE))) { - return false; - } - return true; - } - - if (a.isFloat()) { - if (!stack.push(Value(log10f(a.toFloat()), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - if (a.isInt64()) { - if (!stack.push(Value(log10(a.toInt64()), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - if (a.isInt32OrLess()) { - if (!stack.push(Value(log10f(a.int32Value), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - return false; -} - -bool do_OPERATION_TYPE_MATH_ABS(EvalStack &stack) { - auto a = stack.pop().getValue(); - - if (a.isDouble()) { - if (!stack.push(Value(abs(a.getDouble()), VALUE_TYPE_DOUBLE))) { - return false; - } - return true; - } - - if (a.isFloat()) { - if (!stack.push(Value(abs(a.toFloat()), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - if (a.isInt64()) { - if (!stack.push(Value((int64_t)abs(a.getInt64()), VALUE_TYPE_INT64))) { - return false; - } - return true; - } - - if (a.isInt32()) { - if (!stack.push(Value((int)abs(a.getInt32()), VALUE_TYPE_INT32))) { - return false; - } - return true; - } - - if (a.isInt16()) { - if (!stack.push(Value(abs(a.getInt16()), VALUE_TYPE_INT16))) { - return false; - } - return true; - } - - - if (a.isInt8()) { - if (!stack.push(Value(abs(a.getInt8()), VALUE_TYPE_INT8))) { - return false; - } - return true; - } - - return false; -} - -bool do_OPERATION_TYPE_MATH_FLOOR(EvalStack &stack) { - auto a = stack.pop().getValue(); - - if (a.isDouble()) { - if (!stack.push(Value(floor(a.getDouble()), VALUE_TYPE_DOUBLE))) { - return false; - } - return true; - } - - if (a.isFloat()) { - if (!stack.push(Value(floorf(a.toFloat()), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - return false; -} - -bool do_OPERATION_TYPE_MATH_CEIL(EvalStack &stack) { - auto a = stack.pop().getValue(); - - if (a.isDouble()) { - if (!stack.push(Value(ceil(a.getDouble()), VALUE_TYPE_DOUBLE))) { - return false; - } - return true; - } - - if (a.isFloat()) { - if (!stack.push(Value(ceilf(a.toFloat()), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - return false; -} - -float roundN(float value, unsigned int numDigits) { - float pow_10 = pow(10.0f, numDigits); - return round(value * pow_10) / pow_10; -} - -double roundN(double value, unsigned int numDigits) { - float pow_10 = pow(10.0f, numDigits); - return round(value * pow_10) / pow_10; -} - -bool do_OPERATION_TYPE_MATH_ROUND(EvalStack &stack) { - auto numArgs = stack.pop().getInt(); - auto a = stack.pop().getValue(); - - unsigned int numDigits; - if (numArgs > 1) { - auto b = stack.pop().getValue(); - numDigits = b.toInt32(); - } else { - numDigits = 0; - } - - if (a.isDouble()) { - if (!stack.push(Value(roundN(a.getDouble(), numDigits), VALUE_TYPE_DOUBLE))) { - return false; - } - return true; - } - - if (a.isFloat()) { - if (!stack.push(Value(roundN(a.toFloat(), numDigits), VALUE_TYPE_FLOAT))) { - return false; - } - return true; - } - - if (a.isInt32OrLess()) { - if (!stack.push(a)) { - return false; - } - return true; - } - - return false; -} - -bool do_OPERATION_TYPE_MATH_MIN(EvalStack &stack) { - auto numArgs = stack.pop().getInt(); - - double minValue = INFINITY; - - for (int i = 0; i < numArgs; i++) { - auto value = stack.pop().getValue().toDouble(); - if (value < minValue) { - minValue = value; - } - } - - if (!stack.push(Value(minValue, VALUE_TYPE_DOUBLE))) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_MATH_MAX(EvalStack &stack) { - auto numArgs = stack.pop().getInt(); - - double maxValue = -INFINITY; - - for (int i = 0; i < numArgs; i++) { - auto value = stack.pop().getValue().toDouble(); - if (value > maxValue) { - maxValue = value; - } - } - - if (!stack.push(Value(maxValue, VALUE_TYPE_DOUBLE))) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_STRING_FIND(EvalStack &stack) { - auto b = stack.pop().getValue(); - auto a = stack.pop().getValue(); - - Value aStr = a.toString(0xf616bf4d); - Value bStr = b.toString(0x81229133); - if (!aStr.getString() || !bStr.getString()) { - if (!stack.push(Value(-1, VALUE_TYPE_INT32))) { - return false; - } - } else { - const char *pos = strstr(aStr.getString(), bStr.getString()); - if (!pos) { - if (!stack.push(Value((int)(pos - aStr.getString()), VALUE_TYPE_INT32))) { - return false; - } - } else { - if (!stack.push(Value(-1, VALUE_TYPE_INT32))) { - return false; - } - } - } - - return true; -} - -bool do_OPERATION_TYPE_STRING_PAD_START(EvalStack &stack) { - auto a = stack.pop().getValue(); - auto b = stack.pop().getValue(); - auto c = stack.pop().getValue(); - - auto str = a.toString(0xcf6aabe6); - if (!str.getString()) { - return false; - } - int strLen = strlen(str.getString()); - - int err; - int targetLength = b.toInt32(&err); - if (err) { - return false; - } - if (targetLength < strLen) { - targetLength = strLen; - } - - auto padStr = c.toString(0x81353bd7); - if (!padStr.getString()) { - return false; - } - int padStrLen = strlen(padStr.getString()); - - Value resultValue = eez::gui::Value::makeStringRef("", targetLength, 0xf43b14dd); - if (resultValue.type == VALUE_TYPE_NULL) { - return false; - } - char *resultStr = (char *)resultValue.getString(); - - auto n = targetLength - strLen; - stringCopy(resultStr + (targetLength - strLen), strLen + 1, str.getString()); - - for (int i = 0; i < n; i++) { - resultStr[i] = padStr.getString()[i % padStrLen]; - } - - if (!stack.push(resultValue)) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_STRING_SPLIT(EvalStack &stack) { - auto strValue = stack.pop().getValue(); - auto delimValue = stack.pop().getValue(); - - auto str = strValue.getString(); - if (!str) { - return false; - } - - auto delim = delimValue.getString(); - if (!delim) { - return false; - } - - auto strLen = strlen(str); - - char *strCopy = (char *)eez::alloc(strLen + 1, 0xea9d0bc0); - stringCopy(strCopy, strLen + 1, str); - - // get num parts - size_t arraySize = 0; - char *token = strtok(strCopy, delim); - while (token != NULL) { - arraySize++; - token = strtok(NULL, delim); - } - - eez::free(strCopy); - strCopy = (char *)eez::alloc(strLen + 1, 0xea9d0bc1); - stringCopy(strCopy, strLen + 1, str); - - // make array - auto arrayValue = Value::makeArrayRef(arraySize, VALUE_TYPE_STRING, 0xe82675d4); - auto array = arrayValue.getArray(); - int i = 0; - token = strtok(strCopy, delim); - while (token != NULL) { - array->values[i++] = Value::makeStringRef(token, -1, 0x45209ec0); - token = strtok(NULL, delim); - } - - eez::free(strCopy); - - if (!stack.push(arrayValue)) { - return false; - } - - return true; -} - -bool do_OPERATION_TYPE_ARRAY_LENGTH(EvalStack &stack) { - auto a = stack.pop().getValue(); - - if (a.getType() == VALUE_TYPE_ARRAY || a.getType() == VALUE_TYPE_ARRAY_REF) { - auto array = a.getArray(); - - if (!stack.push(Value(array->arraySize, VALUE_TYPE_UINT32))) { - return false; - } - - return true; - } - - return false; -} - -bool do_OPERATION_TYPE_ARRAY_SLICE(EvalStack &stack) { - // TODO - return false; -} - -EvalOperation g_evalOperations[] = { - do_OPERATION_TYPE_ADD, - do_OPERATION_TYPE_SUB, - do_OPERATION_TYPE_MUL, - do_OPERATION_TYPE_DIV, - do_OPERATION_TYPE_MOD, - do_OPERATION_TYPE_LEFT_SHIFT, - do_OPERATION_TYPE_RIGHT_SHIFT, - do_OPERATION_TYPE_BINARY_AND, - do_OPERATION_TYPE_BINARY_OR, - do_OPERATION_TYPE_BINARY_XOR, - do_OPERATION_TYPE_EQUAL, - do_OPERATION_TYPE_NOT_EQUAL, - do_OPERATION_TYPE_LESS, - do_OPERATION_TYPE_GREATER, - do_OPERATION_TYPE_LESS_OR_EQUAL, - do_OPERATION_TYPE_GREATER_OR_EQUAL, - do_OPERATION_TYPE_LOGICAL_AND, - do_OPERATION_TYPE_LOGICAL_OR, - do_OPERATION_TYPE_UNARY_PLUS, - do_OPERATION_TYPE_UNARY_MINUS, - do_OPERATION_TYPE_BINARY_ONE_COMPLEMENT, - do_OPERATION_TYPE_NOT, - do_OPERATION_TYPE_CONDITIONAL, - do_OPERATION_TYPE_SYSTEM_GET_TICK, - do_OPERATION_TYPE_FLOW_INDEX, - do_OPERATION_TYPE_FLOW_IS_PAGE_ACTIVE, - do_OPERATION_TYPE_FLOW_PAGE_TIMELINE_POSITION, - do_OPERATION_TYPE_FLOW_MAKE_ARRAY_VALUE, - do_OPERATION_TYPE_FLOW_MAKE_ARRAY_VALUE, - do_OPERATION_TYPE_FLOW_LANGUAGES, - do_OPERATION_TYPE_FLOW_TRANSLATE, - do_OPERATION_TYPE_FLOW_PARSE_INTEGER, - do_OPERATION_TYPE_FLOW_PARSE_FLOAT, - do_OPERATION_TYPE_FLOW_PARSE_DOUBLE, - do_OPERATION_TYPE_DATE_NOW, - do_OPERATION_TYPE_DATE_TO_STRING, - do_OPERATION_TYPE_DATE_FROM_STRING, - do_OPERATION_TYPE_MATH_SIN, - do_OPERATION_TYPE_MATH_COS, - do_OPERATION_TYPE_MATH_LOG, - do_OPERATION_TYPE_MATH_LOG10, - do_OPERATION_TYPE_MATH_ABS, - do_OPERATION_TYPE_MATH_FLOOR, - do_OPERATION_TYPE_MATH_CEIL, - do_OPERATION_TYPE_MATH_ROUND, - do_OPERATION_TYPE_MATH_MIN, - do_OPERATION_TYPE_MATH_MAX, - do_OPERATION_TYPE_STRING_FIND, - do_OPERATION_TYPE_STRING_PAD_START, - do_OPERATION_TYPE_STRING_SPLIT, - do_OPERATION_TYPE_ARRAY_LENGTH, - do_OPERATION_TYPE_ARRAY_SLICE -}; - -} // namespace flow -} // namespace eez - diff --git a/Middlewares/eez/flow/operations.h b/Middlewares/eez/flow/operations.h deleted file mode 100644 index 11c3492..0000000 --- a/Middlewares/eez/flow/operations.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2021-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include - -namespace eez { -namespace flow { - -typedef bool (*EvalOperation)(EvalStack &); - -extern EvalOperation g_evalOperations[]; - -Value op_add(const Value& a1, const Value& b1); -Value op_sub(const Value& a1, const Value& b1); -Value op_mul(const Value& a1, const Value& b1); -Value op_div(const Value& a1, const Value& b1); -Value op_mod(const Value& a1, const Value& b1); - -Value op_left_shift(const Value& a1, const Value& b1); -Value op_right_shift(const Value& a1, const Value& b1); -Value op_binary_and(const Value& a1, const Value& b1); -Value op_binary_or(const Value& a1, const Value& b1); -Value op_binary_xor(const Value& a1, const Value& b1); - -Value op_eq(const Value& a1, const Value& b1); -Value op_neq(const Value& a1, const Value& b1); -Value op_less(const Value& a1, const Value& b1); -Value op_great(const Value& a1, const Value& b1); -Value op_less_eq(const Value& a1, const Value& b1); -Value op_great_eq(const Value& a1, const Value& b1); - -} // flow -} // eez diff --git a/Middlewares/eez/flow/private.cpp b/Middlewares/eez/flow/private.cpp deleted file mode 100644 index 1667f1a..0000000 --- a/Middlewares/eez/flow/private.cpp +++ /dev/null @@ -1,525 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -using namespace eez::gui; - -namespace eez { -namespace flow { - -bool isComponentReadyToRun(FlowState *flowState, unsigned componentIndex) { - auto component = flowState->flow->components[componentIndex]; - - if (component->type == defs_v3::COMPONENT_TYPE_CATCH_ERROR_ACTION) { - return false; - } - - if (component->type == defs_v3::COMPONENT_TYPE_ON_EVENT_ACTION) { - return false; - } - - if (component->type < defs_v3::COMPONENT_TYPE_START_ACTION) { - // always execute widget - return true; - } - - if (component->type == defs_v3::COMPONENT_TYPE_START_ACTION) { - auto parentComponent = flowState->parentComponent; - if (parentComponent) { - auto flowInputIndex = parentComponent->inputs[0]; - auto value = flowState->parentFlowState->values[flowInputIndex]; - return value.getType() != VALUE_TYPE_UNDEFINED; - } else { - return true; - } - } - - // check if required inputs are defined: - // - at least 1 seq input must be defined - // - all non optional data inputs must be defined - int numSeqInputs = 0; - int numDefinedSeqInputs = 0; - for (unsigned inputIndex = 0; inputIndex < component->inputs.count; inputIndex++) { - auto inputValueIndex = component->inputs[inputIndex]; - - auto input = flowState->flow->componentInputs[inputValueIndex]; - - if (input & COMPONENT_INPUT_FLAG_IS_SEQ_INPUT) { - numSeqInputs++; - auto &value = flowState->values[inputValueIndex]; - if (value.type != VALUE_TYPE_UNDEFINED) { - numDefinedSeqInputs++; - } - } else { - if (!(input & COMPONENT_INPUT_FLAG_IS_OPTIONAL)) { - auto &value = flowState->values[inputValueIndex]; - if (value.type == VALUE_TYPE_UNDEFINED) { - // non optional data input is undefined - return false; - } - } - } - } - - if (numSeqInputs && !numDefinedSeqInputs) { - // no seq input is defined - return false; - } - - return true; -} - -static bool pingComponent(FlowState *flowState, unsigned componentIndex, int sourceComponentIndex = -1, int sourceOutputIndex = -1, int targetInputIndex = -1) { - if (isComponentReadyToRun(flowState, componentIndex)) { - if (!addToQueue(flowState, componentIndex, sourceComponentIndex, sourceOutputIndex, targetInputIndex)) { - throwError(flowState, componentIndex, "Execution queue is full\n"); - return false; - } - return true; - } - return false; -} - - -static FlowState *initFlowState(Assets *assets, int flowIndex, FlowState *parentFlowState, int parentComponentIndex) { - auto flowDefinition = static_cast(assets->flowDefinition); - auto flow = flowDefinition->flows[flowIndex]; - - auto nValues = flow->componentInputs.count + flow->localVariables.count; - - FlowState *flowState = (FlowState *)alloc( - sizeof(FlowState) + - nValues * sizeof(Value) + - flow->components.count * sizeof(ComponenentExecutionState *) + - flow->components.count * sizeof(bool), - 0x4c3b6ef5 - ); - - flowState->flowStateIndex = (int)((uint8_t *)flowState - ALLOC_BUFFER); - flowState->assets = assets; - flowState->flowDefinition = static_cast(assets->flowDefinition); - flowState->flow = flowDefinition->flows[flowIndex]; - flowState->flowIndex = flowIndex; - flowState->error = false; - flowState->numAsyncComponents = 0; - flowState->parentFlowState = parentFlowState; - - flowState->timelinePosition = 0; - - if (parentFlowState) { - if (parentFlowState->lastChild) { - parentFlowState->lastChild->nextSibling = flowState; - flowState->previousSibling = parentFlowState->lastChild; - parentFlowState->lastChild = flowState; - } else { - flowState->previousSibling = nullptr; - parentFlowState->firstChild = flowState; - parentFlowState->lastChild = flowState; - } - - flowState->parentComponentIndex = parentComponentIndex; - flowState->parentComponent = parentFlowState->flow->components[parentComponentIndex]; - } else { - if (g_lastFlowState) { - g_lastFlowState->nextSibling = flowState; - flowState->previousSibling = g_lastFlowState; - g_lastFlowState = flowState; - } else { - flowState->previousSibling = nullptr; - g_firstFlowState = flowState; - g_lastFlowState = flowState; - } - - flowState->parentComponentIndex = -1; - flowState->parentComponent = nullptr; - } - - flowState->firstChild = nullptr; - flowState->lastChild = nullptr; - flowState->nextSibling = nullptr; - - flowState->values = (Value *)(flowState + 1); - flowState->componenentExecutionStates = (ComponenentExecutionState **)(flowState->values + nValues); - flowState->componenentAsyncStates = (bool *)(flowState->componenentExecutionStates + flow->components.count); - - for (unsigned i = 0; i < nValues; i++) { - new (flowState->values + i) Value(); - } - - auto &undefinedValue = *flowDefinition->constants[UNDEFINED_VALUE_INDEX]; - for (unsigned i = 0; i < flow->componentInputs.count; i++) { - flowState->values[i] = undefinedValue; - } - - for (unsigned i = 0; i < flow->localVariables.count; i++) { - auto value = flow->localVariables[i]; - flowState->values[flow->componentInputs.count + i] = *value; - } - - for (unsigned i = 0; i < flow->components.count; i++) { - flowState->componenentExecutionStates[i] = nullptr; - flowState->componenentAsyncStates[i] = false; - } - - onFlowStateCreated(flowState); - - for (unsigned componentIndex = 0; componentIndex < flow->components.count; componentIndex++) { - pingComponent(flowState, componentIndex); - } - - return flowState; -} - -FlowState *initActionFlowState(int flowIndex, FlowState *parentFlowState, int parentComponentIndex) { - auto flowState = initFlowState(parentFlowState->assets, flowIndex, parentFlowState, parentComponentIndex); - if (flowState) { - flowState->isAction = true; - } - return flowState; -} - -FlowState *initPageFlowState(Assets *assets, int flowIndex, FlowState *parentFlowState, int parentComponentIndex) { - auto flowState = initFlowState(assets, flowIndex, parentFlowState, parentComponentIndex); - if (flowState) { - flowState->isAction = false; - } - return flowState; -} - -bool canFreeFlowState(FlowState *flowState, bool includingWatchVariable) { - if (!flowState->isAction) { - return false; - } - - if (flowState->numAsyncComponents > 0) { - return false; - } - - if (isThereAnyTaskInQueueForFlowState(flowState, includingWatchVariable)) { - return false; - } - - for (uint32_t componentIndex = 0; componentIndex < flowState->flow->components.count; componentIndex++) { - auto component = flowState->flow->components[componentIndex]; - if ( - component->type != defs_v3::COMPONENT_TYPE_INPUT_ACTION && - component->type != defs_v3::COMPONENT_TYPE_LOOP_ACTION && - component->type != defs_v3::COMPONENT_TYPE_COUNTER_ACTION && - (includingWatchVariable || component->type != defs_v3::COMPONENT_TYPE_WATCH_VARIABLE_ACTION) && - flowState->componenentExecutionStates[componentIndex] - ) { - return false; - } - } - - return true; -} - -void freeFlowState(FlowState *flowState) { - auto parentFlowState = flowState->parentFlowState; - if (flowState->parentFlowState) { - auto componentExecutionState = flowState->parentFlowState->componenentExecutionStates[flowState->parentComponentIndex]; - if (componentExecutionState) { - deallocateComponentExecutionState(flowState->parentFlowState, flowState->parentComponentIndex); - return; - } - - if (parentFlowState->firstChild == flowState) { - parentFlowState->firstChild = flowState->nextSibling; - } - if (parentFlowState->lastChild == flowState) { - parentFlowState->lastChild = flowState->previousSibling; - } - } else { - if (g_firstFlowState == flowState) { - g_firstFlowState = flowState->nextSibling; - } - if (g_lastFlowState == flowState) { - g_lastFlowState = flowState->previousSibling; - } - } - - if (flowState->previousSibling) { - flowState->previousSibling->nextSibling = flowState->nextSibling; - } - if (flowState->nextSibling) { - flowState->nextSibling->previousSibling = flowState->previousSibling; - } - - auto flow = flowState->flow; - - auto valuesCount = flow->componentInputs.count + flow->localVariables.count; - - for (unsigned int i = 0; i < valuesCount; i++) { - (flowState->values + i)->~Value(); - } - - for (unsigned i = 0; i < flow->components.count; i++) { - deallocateComponentExecutionState(flowState, i); - } - - onFlowStateDestroyed(flowState); - - free(flowState); - - if (parentFlowState) { - if (canFreeFlowState(parentFlowState)) { - freeFlowState(parentFlowState); - } - } -} - -void deallocateComponentExecutionState(FlowState *flowState, unsigned componentIndex) { - auto executionState = flowState->componenentExecutionStates[componentIndex]; - if (executionState) { - flowState->componenentExecutionStates[componentIndex] = nullptr; - onComponentExecutionStateChanged(flowState, componentIndex); - ObjectAllocator::deallocate(executionState); - } -} - -void propagateValue(FlowState *flowState, unsigned componentIndex, unsigned outputIndex, const gui::Value &value) { - auto component = flowState->flow->components[componentIndex]; - auto componentOutput = component->outputs[outputIndex]; - - auto value2 = value.getValue(); - - for (unsigned connectionIndex = 0; connectionIndex < componentOutput->connections.count; connectionIndex++) { - auto connection = componentOutput->connections[connectionIndex]; - - auto pValue = &flowState->values[connection->targetInputIndex]; - - if (*pValue != value2) { - *pValue = value2; - - //if (!(flowState->flow->componentInputs[connection->targetInputIndex] & COMPONENT_INPUT_FLAG_IS_SEQ_INPUT)) { - onValueChanged(pValue); - //} - } - - pingComponent(flowState, connection->targetComponentIndex, componentIndex, outputIndex, connection->targetInputIndex); - } -} - -void propagateValue(FlowState *flowState, unsigned componentIndex, unsigned outputIndex) { - auto &nullValue = *flowState->flowDefinition->constants[NULL_VALUE_INDEX]; - propagateValue(flowState, componentIndex, outputIndex, nullValue); -} - -void propagateValueThroughSeqout(FlowState *flowState, unsigned componentIndex) { - // find @seqout output - // TODO optimization hint: always place @seqout at 0-th index - auto component = flowState->flow->components[componentIndex]; - for (uint32_t i = 0; i < component->outputs.count; i++) { - if (component->outputs[i]->isSeqOut) { - propagateValue(flowState, componentIndex, i); - return; - } - } -} - -//////////////////////////////////////////////////////////////////////////////// - -void getValue(uint16_t dataId, DataOperationEnum operation, const WidgetCursor &widgetCursor, Value &value) { - if (isFlowRunningHook()) { - FlowState *flowState = widgetCursor.flowState; - auto flow = flowState->flow; - - WidgetDataItem *widgetDataItem = flow->widgetDataItems[dataId]; - if (widgetDataItem && widgetDataItem->componentIndex != -1 && widgetDataItem->propertyValueIndex != -1) { - evalProperty(flowState, widgetDataItem->componentIndex, widgetDataItem->propertyValueIndex, value, "doGetFlowValue failed", nullptr, widgetCursor.iterators, operation); - } - } -} - -void setValue(uint16_t dataId, const WidgetCursor &widgetCursor, const Value& value) { - if (isFlowRunningHook()) { - FlowState *flowState = widgetCursor.flowState; - auto flow = flowState->flow; - - WidgetDataItem *widgetDataItem = flow->widgetDataItems[dataId]; - if (widgetDataItem && widgetDataItem->componentIndex != -1 && widgetDataItem->propertyValueIndex != -1) { - auto component = flow->components[widgetDataItem->componentIndex]; - auto property = component->properties[widgetDataItem->propertyValueIndex]; - Value dstValue; - if (evalAssignableExpression(flowState, widgetDataItem->componentIndex, property->evalInstructions, dstValue, "doSetFlowValue failed", nullptr, widgetCursor.iterators)) { - assignValue(flowState, widgetDataItem->componentIndex, dstValue, value); - } - } - } -} - -//////////////////////////////////////////////////////////////////////////////// - -void assignValue(FlowState *flowState, int componentIndex, Value &dstValue, const Value &srcValue) { - if (dstValue.getType() == VALUE_TYPE_FLOW_OUTPUT) { - propagateValue(flowState, componentIndex, dstValue.getUInt16(), srcValue); - } else if (dstValue.getType() == VALUE_TYPE_NATIVE_VARIABLE) { - set(g_widgetCursor, dstValue.getInt(), srcValue); - } else { - Value *pDstValue; - if (dstValue.getType() == VALUE_TYPE_ARRAY_ELEMENT_VALUE) { - auto arrayElementValue = (ArrayElementValue *)dstValue.refValue; - auto array = arrayElementValue->arrayValue.getArray(); - pDstValue = &array->values[arrayElementValue->elementIndex]; - } else { - pDstValue = dstValue.pValueValue; - } - - if (assignValue(*pDstValue, srcValue)) { - onValueChanged(pDstValue); - } else { - char errorMessage[100]; - snprintf(errorMessage, sizeof(errorMessage), "Can not assign %s to %s\n", - g_valueTypeNames[pDstValue->type](srcValue), g_valueTypeNames[srcValue.type](*pDstValue) - ); - throwError(flowState, componentIndex, errorMessage); - } - } -} - -//////////////////////////////////////////////////////////////////////////////// - -void startAsyncExecution(FlowState *flowState, int componentIndex) { - if (!flowState->componenentAsyncStates[componentIndex]) { - flowState->componenentAsyncStates[componentIndex] = true; - onComponentAsyncStateChanged(flowState, componentIndex); - - flowState->numAsyncComponents++; - } -} - -void endAsyncExecution(FlowState *flowState, int componentIndex) { - if (!g_firstFlowState) { - return; - } - - if (flowState->componenentAsyncStates[componentIndex]) { - flowState->componenentAsyncStates[componentIndex] = false; - onComponentAsyncStateChanged(flowState, componentIndex); - - flowState->numAsyncComponents--; - - if (canFreeFlowState(flowState)) { - freeFlowState(flowState); - } - } -} - -void onEvent(FlowState *flowState, FlowEvent flowEvent) { - for (unsigned componentIndex = 0; componentIndex < flowState->flow->components.count; componentIndex++) { - auto component = flowState->flow->components[componentIndex]; - if (component->type == defs_v3::COMPONENT_TYPE_ON_EVENT_ACTION) { - struct OnEventComponent : public Component { - uint8_t event; - }; - auto onEventComponent = (OnEventComponent *)component; - if (onEventComponent->event == flowEvent) { - if (!addToQueue(flowState, componentIndex, -1, -1, -1, false)) { - throwError(flowState, componentIndex, "Execution queue is full\n"); - return; - } - } - } - } -} - -//////////////////////////////////////////////////////////////////////////////// - -bool findCatchErrorComponent(FlowState *flowState, FlowState *&catchErrorFlowState, int &catchErrorComponentIndex) { - if (!flowState) { - return false; - } - - for (unsigned componentIndex = 0; componentIndex < flowState->flow->components.count; componentIndex++) { - auto component = flowState->flow->components[componentIndex]; - if (component->type == defs_v3::COMPONENT_TYPE_CATCH_ERROR_ACTION) { - catchErrorFlowState = flowState; - catchErrorComponentIndex = componentIndex; - return true; - } - } - - return findCatchErrorComponent(flowState->parentFlowState, catchErrorFlowState, catchErrorComponentIndex); -} - -void throwError(FlowState *flowState, int componentIndex, const char *errorMessage) { - auto component = flowState->flow->components[componentIndex]; - -#if defined(__EMSCRIPTEN__) - printf("throwError: %s\n", errorMessage); -#endif - - if (component->errorCatchOutput != -1) { - propagateValue( - flowState, - componentIndex, - component->errorCatchOutput, - Value::makeStringRef(errorMessage, strlen(errorMessage), 0xef6f8414) - ); - } else { - FlowState *catchErrorFlowState; - int catchErrorComponentIndex; - if ( - findCatchErrorComponent( - component->type == defs_v3::COMPONENT_TYPE_ERROR_ACTION ? flowState->parentFlowState : flowState, - catchErrorFlowState, - catchErrorComponentIndex - ) - ) { - auto catchErrorComponentExecutionState = allocateComponentExecutionState(catchErrorFlowState, catchErrorComponentIndex); - catchErrorComponentExecutionState->message = Value::makeStringRef(errorMessage, strlen(errorMessage), 0x9473eef2); - - if (!addToQueue(catchErrorFlowState, catchErrorComponentIndex, -1, -1, -1)) { - catchErrorFlowState->error = true; - onFlowError(catchErrorFlowState, catchErrorComponentIndex, "Execution queue is full\n"); - stopScriptHook(); - } - } else { - flowState->error = true; - onFlowError(flowState, componentIndex, errorMessage); - stopScriptHook(); - } - } -} - -void throwError(FlowState *flowState, int componentIndex, const char *errorMessage, const char *errorMessageDescription) { - if (errorMessage) { - char throwErrorMessage[512]; - snprintf(throwErrorMessage, sizeof(throwErrorMessage), "%s: %s", errorMessage, errorMessageDescription); - throwError(flowState, componentIndex, throwErrorMessage); - } else { - throwError(flowState, componentIndex, errorMessageDescription); - } -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/private.h b/Middlewares/eez/flow/private.h deleted file mode 100644 index 709ea65..0000000 --- a/Middlewares/eez/flow/private.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2021-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include -#include - -namespace eez { -namespace flow { - -using eez::gui::Value; -using eez::gui::Assets; -using eez::gui::FlowDefinition; -using eez::gui::Flow; -using eez::gui::Component; -using eez::gui::ComponentOutput; -using eez::gui::WidgetCursor; - -static const int UNDEFINED_VALUE_INDEX = 0; -static const int NULL_VALUE_INDEX = 1; - -struct ComponenentExecutionState { - virtual ~ComponenentExecutionState() {} -}; - -struct CatchErrorComponenentExecutionState : public ComponenentExecutionState { - Value message; -}; - -struct FlowState { - uint32_t flowStateIndex; - Assets *assets; - FlowDefinition *flowDefinition; - Flow *flow; - uint16_t flowIndex; - bool isAction; - uint16_t error; - uint32_t numAsyncComponents; - FlowState *parentFlowState; - Component *parentComponent; - int parentComponentIndex; - Value *values; - ComponenentExecutionState **componenentExecutionStates; - bool *componenentAsyncStates; - float timelinePosition; - - FlowState *firstChild; - FlowState *lastChild; - FlowState *previousSibling; - FlowState *nextSibling; -}; - -extern int g_selectedLanguage; -extern FlowState *g_firstFlowState; -extern FlowState *g_lastFlowState; - -FlowState *initActionFlowState(int flowIndex, FlowState *parentFlowState, int parentComponentIndex); -FlowState *initPageFlowState(Assets *assets, int flowIndex, FlowState *parentFlowState, int parentComponentIndex); - -bool canFreeFlowState(FlowState *flowState, bool includingWatchVariable = true); -void freeFlowState(FlowState *flowState); - -void deallocateComponentExecutionState(FlowState *flowState, unsigned componentIndex); - -template -T *allocateComponentExecutionState(FlowState *flowState, unsigned componentIndex) { - if (flowState->componenentExecutionStates[componentIndex]) { - deallocateComponentExecutionState(flowState, componentIndex); - } - auto executionState = ObjectAllocator::allocate(0x72dc3bf4); - flowState->componenentExecutionStates[componentIndex] = executionState; - onComponentExecutionStateChanged(flowState, componentIndex); - return executionState; -} - -void propagateValue(FlowState *flowState, unsigned componentIndex, unsigned outputIndex, const gui::Value &value); -void propagateValue(FlowState *flowState, unsigned componentIndex, unsigned outputIndex); // propagates null value -void propagateValueThroughSeqout(FlowState *flowState, unsigned componentIndex); // propagates null value through @seqout (0-th output) - -void getValue(uint16_t dataId, eez::gui::DataOperationEnum operation, const WidgetCursor &widgetCursor, Value &value); -void setValue(uint16_t dataId, const WidgetCursor &widgetCursor, const Value& value); - -void assignValue(FlowState *flowState, int componentIndex, Value &dstValue, const Value &srcValue); - -void startAsyncExecution(FlowState *flowState, int componentIndex); -void endAsyncExecution(FlowState *flowState, int componentIndex); - -void executeCallAction(FlowState *flowState, unsigned componentIndex, int flowIndex); - -enum FlowEvent { - FLOW_EVENT_OPEN_PAGE, - FLOW_EVENT_CLOSE_PAGE -}; - -void onEvent(FlowState *flowState, FlowEvent flowEvent); - -void throwError(FlowState *flowState, int componentIndex, const char *errorMessage); -void throwError(FlowState *flowState, int componentIndex, const char *errorMessage, const char *errorMessageDescription); - -} // flow -} // eez diff --git a/Middlewares/eez/flow/queue.cpp b/Middlewares/eez/flow/queue.cpp deleted file mode 100644 index c4e43d2..0000000 --- a/Middlewares/eez/flow/queue.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2021-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -namespace eez { -namespace flow { - -static const unsigned QUEUE_SIZE = 1000; -static struct { - FlowState *flowState; - unsigned componentIndex; - bool continuousTask; -} g_queue[QUEUE_SIZE]; -static unsigned g_queueHead; -static unsigned g_queueTail; -static bool g_queueIsFull = false; - -void queueReset() { - g_queueHead = 0; - g_queueTail = 0; - g_queueIsFull = false; -} - -size_t getQueueSize() { - if (g_queueHead == g_queueTail) { - if (g_queueIsFull) { - return QUEUE_SIZE; - } - return 0; - } - - if (g_queueHead < g_queueTail) { - return g_queueTail - g_queueHead; - } - - return QUEUE_SIZE - g_queueHead + g_queueTail; -} - -bool addToQueue(FlowState *flowState, unsigned componentIndex, int sourceComponentIndex, int sourceOutputIndex, int targetInputIndex, bool continuousTask) { - if (g_queueIsFull) { - return false; - } - - g_queue[g_queueTail].flowState = flowState; - g_queue[g_queueTail].componentIndex = componentIndex; - g_queue[g_queueTail].continuousTask = continuousTask; - - g_queueTail = (g_queueTail + 1) % QUEUE_SIZE; - - if (g_queueHead == g_queueTail) { - g_queueIsFull = true; - } - - if (!continuousTask) { - onAddToQueue(flowState, sourceComponentIndex, sourceOutputIndex, componentIndex, targetInputIndex); - } - - return true; -} - -bool peekNextTaskFromQueue(FlowState *&flowState, unsigned &componentIndex, bool &continuousTask) { - if (g_queueHead == g_queueTail && !g_queueIsFull) { - return false; - } - - flowState = g_queue[g_queueHead].flowState; - componentIndex = g_queue[g_queueHead].componentIndex; - continuousTask = g_queue[g_queueHead].continuousTask; - - return true; -} - -void removeNextTaskFromQueue() { - auto continuousTask = g_queue[g_queueHead].continuousTask; - - g_queueHead = (g_queueHead + 1) % QUEUE_SIZE; - g_queueIsFull = false; - - if (!continuousTask) { - onRemoveFromQueue(); - } -} - -bool isThereAnyTaskInQueueForFlowState(FlowState *flowState, bool includingWatchVariable) { - if (g_queueHead == g_queueTail && !g_queueIsFull) { - return false; - } - - unsigned int it = g_queueHead; - while (true) { - if (g_queue[it].flowState == flowState) { - auto component = flowState->flow->components[g_queue[it].componentIndex]; - if (includingWatchVariable || component->type != defs_v3::COMPONENT_TYPE_WATCH_VARIABLE_ACTION) { - return true; - } - } - - it = (it + 1) % QUEUE_SIZE; - if (it == g_queueTail) { - break; - } - } - - return false; -} - -} // namespace flow -} // namespace eez diff --git a/Middlewares/eez/flow/queue.h b/Middlewares/eez/flow/queue.h deleted file mode 100644 index 43a6695..0000000 --- a/Middlewares/eez/flow/queue.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -* EEZ Generic Firmware -* Copyright (C) 2021-present, Envox d.o.o. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once - -#include - -namespace eez { -namespace flow { - -void queueReset(); -size_t getQueueSize(); -bool addToQueue(FlowState *flowState, unsigned componentIndex, - int sourceComponentIndex = -1, int sourceOutputIndex = -1, int targetInputIndex = -1, - bool continuousTask = false); -bool peekNextTaskFromQueue(FlowState *&flowState, unsigned &componentIndex, bool &continuousTask); -void removeNextTaskFromQueue(); - -bool isThereAnyTaskInQueueForFlowState(FlowState *flowState, bool includingWatchVariable); - -} // flow -} // eez diff --git a/Middlewares/eez/fs/fs.h b/Middlewares/eez/fs/fs.h deleted file mode 100644 index ad4b025..0000000 --- a/Middlewares/eez/fs/fs.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2015-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include -#include - -#ifdef EEZ_PLATFORM_STM32 -#include -#endif - -#ifdef EEZ_PLATFORM_SIMULATOR -#include -#endif - -#define FILE_READ 0x01 -#define FILE_WRITE 0x02 -#define FILE_OPEN_EXISTING 0x00 -#define FILE_CREATE_NEW 0x04 -#define FILE_CREATE_ALWAYS 0x08 -#define FILE_OPEN_ALWAYS 0x10 -#define FILE_OPEN_APPEND 0x30 - -namespace eez { - -// clang-format off -enum SdFatResult { - SD_FAT_RESULT_OK = 0, /* (0) Succeeded */ - SD_FAT_RESULT_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ - SD_FAT_RESULT_INT_ERR, /* (2) Assertion failed */ - SD_FAT_RESULT_NOT_READY, /* (3) The physical drive cannot work */ - SD_FAT_RESULT_NO_FILE, /* (4) Could not find the file */ - SD_FAT_RESULT_NO_PATH, /* (5) Could not find the path */ - SD_FAT_RESULT_INVALID_NAME, /* (6) The path name format is invalid */ - SD_FAT_RESULT_DENIED, /* (7) Access denied due to prohibited access or directory full */ - SD_FAT_RESULT_EXIST, /* (8) Access denied due to prohibited access */ - SD_FAT_RESULT_INVALID_OBJECT, /* (9) The file/directory object is invalid */ - SD_FAT_RESULT_WRITE_PROTECTED, /* (10) The physical drive is write protected */ - SD_FAT_RESULT_INVALID_DRIVE, /* (11) The logical drive number is invalid */ - SD_FAT_RESULT_NOT_ENABLED, /* (12) The volume has no work area */ - SD_FAT_RESULT_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ - SD_FAT_RESULT_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any problem */ - SD_FAT_RESULT_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ - SD_FAT_RESULT_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ - SD_FAT_RESULT_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ - SD_FAT_RESULT_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_LOCK */ - SD_FAT_RESULT_INVALID_PARAMETER, /* (19) Given parameter is invalid */ -}; -// clang-format on - -struct FileInfo { - FileInfo(); - - SdFatResult fstat(const char *filePath); - - operator bool(); // fname[0] - bool isDirectory(); - void getName(char *name, size_t size); - size_t getSize(); - bool isHiddenOrSystemFile(); - - int getModifiedYear(); - int getModifiedMonth(); - int getModifiedDay(); - - int getModifiedHour(); - int getModifiedMinute(); - int getModifiedSecond(); - -#if defined(EEZ_PLATFORM_STM32) - FILINFO m_fno; -#else - std::filesystem::directory_entry m_entry; -#endif -}; - -struct Directory { - Directory(); - ~Directory(); - - void close(); - - SdFatResult findFirst(const char *path, FileInfo &fileInfo); - SdFatResult findNext(FileInfo &fileInfo); - -#if defined(EEZ_PLATFORM_STM32) - DIR m_dj; -#else - std::filesystem::directory_iterator m_it; -#endif -}; - -class File { - File(const File &file); - const File &operator=(const File &file); - - public: - File(); - - bool open(const char *path, uint8_t mode = FILE_READ); - - ~File(); - bool close(); - - bool isOpen(); - - bool truncate(uint32_t length); - - bool available(); - size_t size(); - bool seek(uint32_t pos); - size_t tell(); - int peek(); - int read(); - size_t read(void *buf, uint32_t nbyte); - size_t write(const void *buf, size_t size); - bool sync(); - - void print(float value, int numDecimalDigits); - void print(char value); - - private: - bool m_isOpen{false}; -#ifdef EEZ_PLATFORM_SIMULATOR - FILE *m_fp{NULL}; -#else - FIL m_file; -#endif -}; - -class SdFat { - public: - bool mount(int *err); - void unmount(); - bool exists(const char *path); - bool rename(const char *sourcePath, const char *destinationPath); - bool remove(const char *path); - bool mkdir(const char *path); - bool rmdir(const char *path); - - bool getInfo(int diskDriveIndex, uint64_t &usedSpace, uint64_t &freeSpace); -}; - -char *getConfFilePath(const char *file_name); - -} // namespace eez diff --git a/Middlewares/eez/fs/stm32/fs.cpp b/Middlewares/eez/fs/stm32/fs.cpp deleted file mode 100644 index 210c7ba..0000000 --- a/Middlewares/eez/fs/stm32/fs.cpp +++ /dev/null @@ -1,411 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2015-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#if defined(EEZ_PLATFORM_STM32) - -#include -#include - -#if OPTION_SCPI -#include -#else -#define SCPI_ERROR_MASS_MEDIA_NO_FILESYSTEM 410 -#define SCPI_ERROR_MASS_STORAGE_ERROR -250 -#define SCPI_RES_OK 1 -#endif - -#include -#include -#include - -#define CHECK_ERROR(desc, err) (void)(desc); (void)(err); -//#define CHECK_ERROR(desc, err) if (err != FR_OK) DebugTrace("%s: %d\n", desc, (int)err) - -namespace eez { - -//////////////////////////////////////////////////////////////////////////////// - -FileInfo::FileInfo() { - memset(&m_fno, 0, sizeof(m_fno)); -} - -SdFatResult FileInfo::fstat(const char *filePath) { - auto result = f_stat(filePath, &m_fno); - CHECK_ERROR("FileInfo::fstat", result); - return (SdFatResult)result; -} - -FileInfo::operator bool() { - return m_fno.fname[0] ? true : false; -} - -bool FileInfo::isDirectory() { - return m_fno.fattrib & AM_DIR ? true : false; -} - -void FileInfo::getName(char *name, size_t size) { - const char *str1 = strrchr(m_fno.fname, '\\'); - if (!str1) { - str1 = m_fno.fname; - } - - const char *str2 = strrchr(str1, '/'); - if (!str2) { - str2 = str1; - } - - stringCopy(name, size, str2); -} - -size_t FileInfo::getSize() { - return m_fno.fsize; -} - -bool FileInfo::isHiddenOrSystemFile() { - return (m_fno.fattrib & (AM_HID | AM_SYS)) != 0; -} - -#define FAT_YEAR(date) (1980 + ((date) >> 9)) -#define FAT_MONTH(date) (((date) >> 5) & 0XF) -#define FAT_DAY(date) ((date)&0X1F) - -#define FAT_HOUR(time) ((time) >> 11) -#define FAT_MINUTE(time) (((time) >> 5) & 0X3F) -#define FAT_SECOND(time) (2 * ((time)&0X1F)) - -int FileInfo::getModifiedYear() { - return FAT_YEAR(m_fno.fdate); -} - -int FileInfo::getModifiedMonth() { - return FAT_MONTH(m_fno.fdate); -} - -int FileInfo::getModifiedDay() { - return FAT_DAY(m_fno.fdate); -} - -int FileInfo::getModifiedHour() { - return FAT_HOUR(m_fno.ftime); -} - -int FileInfo::getModifiedMinute() { - return FAT_MINUTE(m_fno.ftime); -} - -int FileInfo::getModifiedSecond() { - return FAT_SECOND(m_fno.ftime); -} - -//////////////////////////////////////////////////////////////////////////////// - -Directory::Directory() { - memset(&m_dj, 0, sizeof(m_dj)); -} - -Directory::~Directory() { - close(); -} - -void Directory::close() { - auto result = f_closedir(&m_dj); - CHECK_ERROR("Directory::close", result); -} - -SdFatResult Directory::findFirst(const char *path, FileInfo &fileInfo) { - auto result = f_findfirst(&m_dj, &fileInfo.m_fno, path, "*"); - CHECK_ERROR("Directory::findFirst", result); - return (SdFatResult)result; -} - -SdFatResult Directory::findNext(FileInfo &fileInfo) { - auto result = f_findnext(&m_dj, &fileInfo.m_fno); - CHECK_ERROR("Directory::findNext", result); - return (SdFatResult)result; -} - -//////////////////////////////////////////////////////////////////////////////// - -File::File() : m_isOpen(false) { -} - -bool File::open(const char *path, uint8_t mode) { - auto result = f_open(&m_file, path, mode); - CHECK_ERROR("File::open", result); - m_isOpen = result == FR_OK; - return m_isOpen; -} - -File::~File() { -} - -bool File::close() { - auto result = f_close(&m_file); - CHECK_ERROR("File::close", result); - m_isOpen = false; - return result == FR_OK; -} - -bool File::isOpen() { - return m_isOpen; -} - -bool File::truncate(uint32_t length) { - auto result1 = f_lseek(&m_file, length); - CHECK_ERROR("File::truncate 1", result1); - auto result2 = f_truncate(&m_file); - CHECK_ERROR("File::truncate 2", result2); - return result1 == FR_OK && result2 == FR_OK; -} - -size_t File::size() { - return f_size(&m_file); -} - -bool File::available() { - return peek() != EOF; -} - -bool File::seek(uint32_t pos) { - auto result = f_lseek(&m_file, pos); - CHECK_ERROR("File::seek", result); - return result == FR_OK; -} - -size_t File::tell() { - auto result = f_tell(&m_file); - CHECK_ERROR("File::tell", result); - return result; -} - -int File::peek() { - auto pos = f_tell(&m_file); - int ch = read(); - auto result = f_lseek(&m_file, pos); - CHECK_ERROR("File::peek", result); - return ch; -} - -int File::read() { - uint8_t value; - UINT br; - auto result = f_read(&m_file, &value, 1, &br); - CHECK_ERROR("File::read", result); - return result != FR_OK || br != 1 ? EOF : (int)value; -} - -size_t File::read(void *buf, uint32_t size) { - uint32_t CHUNK_SIZE = 512; // unfortunately, it doesn't work when CHUNK_SIZE is > 512 - - UINT brTotal = 0; - - size_t unalignedLength = ((uint32_t)buf) & 3; - if (unalignedLength > 0) { - CHUNK_SIZE = 512; - unalignedLength = MIN(4 - unalignedLength, size); - uint8_t unalignedBuffer[4] __attribute__((aligned)); - UINT br; - auto result = f_read(&m_file, unalignedBuffer, unalignedLength, &br); - CHECK_ERROR("File::read 1", result); - if (result != FR_OK) { - return 0; - } - - for (size_t i = 0; i < br; i++) { - ((uint8_t *)buf)[i] = unalignedBuffer[i]; - } - - brTotal += br; - - if (br < unalignedLength) { - return brTotal; - } - } - - while (brTotal < size) { - uint32_t btr = MIN(CHUNK_SIZE, size - brTotal); - - UINT br; - auto result = f_read(&m_file, (uint8_t *)buf + brTotal, btr, &br); - CHECK_ERROR("File::read 2", result); - if (result != FR_OK) { - return brTotal; - } - - brTotal += br; - - if (br < btr) { - break; - } - } - - return brTotal; -} - -size_t File::write(const void *buf, size_t size) { - uint32_t CHUNK_SIZE = 64 * 1024; - - UINT bwTotal = 0; - - size_t unalignedLength = ((uint32_t)buf) & 3; - if (unalignedLength > 0) { - CHUNK_SIZE = 512; - - unalignedLength = MIN(4 - unalignedLength, size); - uint8_t unalignedBuffer[4] __attribute__((aligned)); - for (size_t i = 0; i < unalignedLength; i++) { - unalignedBuffer[i] = ((uint8_t *)buf)[i]; - } - - UINT bw; - auto result = f_write(&m_file, unalignedBuffer, unalignedLength, &bw); - CHECK_ERROR("File::write 1", result); - if (result != FR_OK) { - return 0; - } - - bwTotal += bw; - - if (bw < unalignedLength) { - return bwTotal; - } - } - - while (bwTotal < size) { - auto btw = MIN(CHUNK_SIZE, size - bwTotal); - - UINT bw; - auto result = f_write(&m_file, (const uint8_t *)buf + bwTotal, btw, &bw); - CHECK_ERROR("File::write 2", result); - if (result != FR_OK) { - return bwTotal; - } - - bwTotal += bw; - - if (bw < btw) { - break; - } - } - - return bwTotal; -} - -bool File::sync() { - auto result = f_sync(&m_file); - CHECK_ERROR("File::sync", result); - return result == FR_OK; -} - -void File::print(float value, int numDecimalDigits) { - char buffer[32]; - snprintf(buffer, sizeof(buffer), "%.*f", numDecimalDigits, value); - write((uint8_t *)buffer, strlen(buffer)); -} - -void File::print(char value) { - auto result = f_printf(&m_file, "%c", value); - CHECK_ERROR("File:print", result); -} - -//////////////////////////////////////////////////////////////////////////////// - -bool SdFat::mount(int *err) { - auto result = f_mount(&SDFatFS, SDPath, 1); - CHECK_ERROR("SdFat::mount", result); - if (result != FR_OK) { - if (result == FR_NO_FILESYSTEM) { - *err = SCPI_ERROR_MASS_MEDIA_NO_FILESYSTEM; - } else { - *err = SCPI_ERROR_MASS_STORAGE_ERROR; - } - return false; - } - - *err = SCPI_RES_OK; - return true; -} - -void SdFat::unmount() { - auto result = f_mount(0, "", 0); - CHECK_ERROR("SdFat::unmount", result); - memset(&SDFatFS, 0, sizeof(SDFatFS)); -} - -bool SdFat::exists(const char *path) { - if (strcmp(path, "/") == 0) { - return true; - } - FILINFO fno; - auto result = f_stat(path, &fno); - CHECK_ERROR("SdFat::exists", result); - return result == FR_OK; -} - -bool SdFat::rename(const char *sourcePath, const char *destinationPath) { - auto result = f_rename(sourcePath, destinationPath); - CHECK_ERROR("SdFat::rename", result); - return result == FR_OK; -} - -bool SdFat::remove(const char *path) { - auto result = f_unlink(path); - CHECK_ERROR("SdFat::remove", result); - return result == FR_OK; -} - -bool SdFat::mkdir(const char *path) { - auto result = f_mkdir(path); - CHECK_ERROR("SdFat::mkdir", result); - return result == FR_OK; -} - -bool SdFat::rmdir(const char *path) { - auto result = f_unlink(path); - CHECK_ERROR("SdFat::rmdir", result); - return result == FR_OK; -} - -bool SdFat::getInfo(int diskDriveIndex, uint64_t &usedSpace, uint64_t &freeSpace) { - char path[3]; - - path[0] = '0' + diskDriveIndex; - path[1] = ':'; - path[2] = 0; - - DWORD freeClusters; - FATFS *fs; - auto result = f_getfree(path, &freeClusters, &fs); - CHECK_ERROR("SdFat::getInfo", result); - if (result != FR_OK) { - return false; - } - - DWORD totalSector = (fs->n_fatent - 2) * fs->csize; - DWORD freeSector = freeClusters * fs->csize; - - uint64_t totalSpace = totalSector * uint64_t(512); - freeSpace = freeSector * uint64_t(512); - usedSpace = totalSpace - freeSpace; - - return true; -} - -} // namespace eez - -#endif // EEZ_PLATFORM_STM32 diff --git a/Middlewares/eez/gui/action_impl.cpp b/Middlewares/eez/gui/action_impl.cpp deleted file mode 100644 index 83a7670..0000000 --- a/Middlewares/eez/gui/action_impl.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2020-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -namespace eez { -namespace gui { - -void action_yes() { - auto appContext = getAppContextFromId(APP_CONTEXT_ID_DEVICE); - auto callback = appContext->m_dialogYesCallback; - appContext->popPage(); - if (callback) { - callback(); - } -} - -void action_no() { - auto appContext = getAppContextFromId(APP_CONTEXT_ID_DEVICE); - auto callback = appContext->m_dialogNoCallback; - appContext->popPage(); - if (callback) { - callback(); - } -} - -void action_ok() { - action_yes(); -} - -void action_cancel() { - auto appContext = getAppContextFromId(APP_CONTEXT_ID_DEVICE); - auto callback = appContext->m_dialogCancelCallback; - appContext->popPage(); - if (callback) { - callback(); - } -} - -void action_later() { - auto appContext = getAppContextFromId(APP_CONTEXT_ID_DEVICE); - auto callback = appContext->m_dialogLaterCallback; - appContext->popPage(); - if (callback) { - callback(); - } -} - -void action_drag_overlay() { -} - -void action_scroll() { -} - -} // namespace gui -} // namespace eez \ No newline at end of file diff --git a/Middlewares/eez/gui/animation.cpp b/Middlewares/eez/gui/animation.cpp deleted file mode 100644 index f6898a6..0000000 --- a/Middlewares/eez/gui/animation.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2015-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -namespace eez { -namespace gui { - -using namespace display; - -AnimationState g_animationState; -static bool g_animationStateDirection; -static Rect g_animationStateSrcRect; -static Rect g_animationStateDstRect; - -void animateOpenCloseCallback(float t, VideoBuffer bufferOld, VideoBuffer bufferNew, VideoBuffer bufferDst) { - if (!g_animationStateDirection) { - auto bufferTemp = bufferOld; - bufferOld = bufferNew; - bufferNew = bufferTemp; - } - - auto remapX = g_animationStateDirection ? remapExp : remapOutExp; - auto remapY = g_animationStateDirection ? remapExp : remapOutExp; - - int srcX1; - int srcY1; - int srcX2; - int srcY2; - - int dstX1; - int dstY1; - int dstX2; - int dstY2; - - if (g_animationStateDirection) { - srcX1 = g_animationStateSrcRect.x; - srcY1 = g_animationStateSrcRect.y; - srcX2 = g_animationStateSrcRect.x + g_animationStateSrcRect.w; - srcY2 = g_animationStateSrcRect.y + g_animationStateSrcRect.h; - - int dx = MAX(g_animationStateSrcRect.x - g_animationStateDstRect.x, - g_animationStateDstRect.x + g_animationStateDstRect.w - - (g_animationStateSrcRect.x + g_animationStateSrcRect.w)); - - int dy = MAX(g_animationStateSrcRect.y - g_animationStateDstRect.y, - g_animationStateDstRect.y + g_animationStateDstRect.h - - (g_animationStateSrcRect.y + g_animationStateSrcRect.h)); - - dstX1 = g_animationStateSrcRect.x - dx; - dstY1 = g_animationStateSrcRect.y - dy; - dstX2 = g_animationStateSrcRect.x + g_animationStateSrcRect.w + dx; - dstY2 = g_animationStateSrcRect.y + g_animationStateSrcRect.h + dy; - } else { - int dx = MAX(g_animationStateDstRect.x - g_animationStateSrcRect.x, - g_animationStateSrcRect.x + g_animationStateSrcRect.w - - (g_animationStateDstRect.x + g_animationStateDstRect.w)); - - int dy = MAX(g_animationStateDstRect.y - g_animationStateSrcRect.y, - g_animationStateSrcRect.y + g_animationStateSrcRect.h - - g_animationStateDstRect.y + g_animationStateDstRect.h); - - srcX1 = g_animationStateDstRect.x - dx; - srcY1 = g_animationStateDstRect.y - dx; - srcX2 = g_animationStateDstRect.x + g_animationStateDstRect.w + dx; - srcY2 = g_animationStateDstRect.y + g_animationStateDstRect.h + dy; - - dstX1 = g_animationStateDstRect.x; - dstY1 = g_animationStateDstRect.y; - dstX2 = g_animationStateDstRect.x + g_animationStateDstRect.w; - dstY2 = g_animationStateDstRect.y + g_animationStateDstRect.h; - } - - int x1 = (int)round(remapX((float)t, 0, (float)srcX1, 1, (float)dstX1)); - if (g_animationStateDirection) { - if (x1 < g_animationStateDstRect.x) { - x1 = g_animationStateDstRect.x; - } - } else { - if (x1 < g_animationStateSrcRect.x) { - x1 = g_animationStateSrcRect.x; - } - } - - int y1 = (int)round(remapY((float)t, 0, (float)srcY1, 1, (float)dstY1)); - if (g_animationStateDirection) { - if (y1 < g_animationStateDstRect.y) { - y1 = g_animationStateDstRect.y; - } - } else { - if (y1 < g_animationStateSrcRect.y) { - y1 = g_animationStateSrcRect.y; - } - } - - int x2 = (int)round(remapX((float)t, 0, (float)srcX2, 1, (float)dstX2)); - if (g_animationStateDirection) { - if (x2 > g_animationStateDstRect.x + g_animationStateDstRect.w) { - x2 = g_animationStateDstRect.x + g_animationStateDstRect.w; - } - } else { - if (x2 > g_animationStateSrcRect.x + g_animationStateSrcRect.w) { - x2 = g_animationStateSrcRect.x + g_animationStateSrcRect.w; - } - } - - int y2 = (int)round(remapY((float)t, 0, (float)srcY2, 1, (float)dstY2)); - if (g_animationStateDirection) { - if (y2 > g_animationStateDstRect.y + g_animationStateDstRect.h) { - y2 = g_animationStateDstRect.y + g_animationStateDstRect.h; - } - } else { - if (y2 > g_animationStateSrcRect.y + g_animationStateSrcRect.h) { - y2 = g_animationStateSrcRect.y + g_animationStateSrcRect.h; - } - } - - bitBlt(bufferOld, bufferDst, 0, 0, getDisplayWidth() - 1, getDisplayHeight() - 1); - bitBlt(bufferNew, bufferDst, x1, y1, x2, y2); -} - -void animateOpenClose(const Rect &srcRect, const Rect &dstRect, bool direction) { - display::animate(BUFFER_OLD, animateOpenCloseCallback); - g_animationStateSrcRect = srcRect; - g_animationStateDstRect = dstRect; - g_animationStateDirection = direction; -} - -void animateOpen(const Rect &srcRect, const Rect &dstRect) { - animateOpenClose(srcRect, dstRect, true); -} - -void animateClose(const Rect &srcRect, const Rect &dstRect) { - animateOpenClose(srcRect, dstRect, false); -} - -static Rect g_clipRect; -static int g_numRects; -AnimRect g_animRects[MAX_ANIM_RECTS]; - -void animateRectsStep(float t, VideoBuffer bufferOld, VideoBuffer bufferNew, VideoBuffer bufferDst) { - bitBlt(g_animationState.startBuffer == BUFFER_OLD ? bufferOld : bufferNew, bufferDst, 0, 0, getDisplayWidth() - 1, getDisplayHeight() - 1); - - float t1 = g_animationState.easingRects(t, 0, 0, 1, 1); // rects - float t2 = g_animationState.easingOpacity(t, 0, 0, 1, 1); // opacity - - for (int i = 0; i < g_numRects; i++) { - AnimRect &animRect = g_animRects[i]; - - int x, y, w, h; - - if (animRect.srcRect == animRect.dstRect) { - x = animRect.srcRect.x; - y = animRect.srcRect.y; - w = animRect.srcRect.w; - h = animRect.srcRect.h; - } else { - if (animRect.dstRect.x > animRect.srcRect.x) - x = (int)roundf(animRect.srcRect.x + t1 * (animRect.dstRect.x - animRect.srcRect.x)); - else - x = (int)floorf(animRect.srcRect.x + t1 * (animRect.dstRect.x - animRect.srcRect.x)); - - if (animRect.dstRect.y > animRect.srcRect.y) - y = (int)roundf(animRect.srcRect.y + t1 * (animRect.dstRect.y - animRect.srcRect.y)); - else - y = (int)floorf(animRect.srcRect.y + t1 * (animRect.dstRect.y - animRect.srcRect.y)); - - if (animRect.dstRect.w > animRect.srcRect.w) - w = (int)ceilf(animRect.srcRect.w + t1 * (animRect.dstRect.w - animRect.srcRect.w)); - else - w = (int)floorf(animRect.srcRect.w + t1 * (animRect.dstRect.w - animRect.srcRect.w)); - - if (animRect.dstRect.h > animRect.srcRect.h) - h = (int)ceilf(animRect.srcRect.h + t1 * (animRect.dstRect.h - animRect.srcRect.h)); - else - h = (int)floorf(animRect.srcRect.h + t1 * (animRect.dstRect.h - animRect.srcRect.h)); - } - - uint8_t opacity; - if (animRect.opacity == OPACITY_FADE_IN) { - opacity = (uint8_t)roundf(clamp(roundf(t2 * 255), 0, 255)); - } else if (animRect.opacity == OPACITY_FADE_OUT) { - opacity = (uint8_t)roundf(clamp((1 - t2) * 255, 0, 255)); - } else { - opacity = 255; - } - - if (animRect.buffer == BUFFER_SOLID_COLOR) { - auto savedOpacity = setOpacity(opacity); - setColor(animRect.color); - - // clip - if (x < g_clipRect.x) { - w -= g_clipRect.x - x; - x = g_clipRect.x; - } - - if (x + w > g_clipRect.x + g_clipRect.w) { - w -= (x + w) - (g_clipRect.x + g_clipRect.w); - } - - if (y < g_clipRect.y) { - h -= g_clipRect.y - y; - y = g_clipRect.y; - } - - if (y + h > g_clipRect.y + g_clipRect.h) { - h -= (y + h) - (g_clipRect.y + g_clipRect.y); - } - - fillRect(bufferDst, x, y, x + w - 1, y + h - 1); - - setOpacity(savedOpacity); - } else { - void *buffer = animRect.buffer == BUFFER_OLD ? bufferOld : bufferNew; - Rect &srcRect = animRect.buffer == BUFFER_OLD ? animRect.srcRect : animRect.dstRect; - - int sx; - int sy; - int sw; - int sh; - - int dx; - int dy; - - if (animRect.position == POSITION_TOP_LEFT || animRect.position == POSITION_LEFT || animRect.position == POSITION_BOTTOM_LEFT) { - sx = srcRect.x; - sw = MIN(srcRect.w, w); - dx = x; - } else if (animRect.position == POSITION_TOP || animRect.position == POSITION_CENTER || animRect.position == POSITION_BOTTOM) { - if (srcRect.w < w) { - sx = srcRect.x; - sw = srcRect.w; - dx = x + (w - srcRect.w) / 2; - } else if (srcRect.w > w) { - sx = srcRect.x + (srcRect.w - w) / 2; - sw = w; - dx = x; - } else { - sx = srcRect.x; - sw = srcRect.w; - dx = x; - } - } else { - sw = MIN(srcRect.w, w); - sx = srcRect.x + srcRect.w - sw; - dx = x + w - sw; - } - - if (animRect.position == POSITION_TOP_LEFT || animRect.position == POSITION_TOP || animRect.position == POSITION_TOP_RIGHT) { - sy = srcRect.y; - sh = MIN(srcRect.h, h); - dy = y; - } else if (animRect.position == POSITION_LEFT || animRect.position == POSITION_CENTER || animRect.position == POSITION_RIGHT) { - if (srcRect.h < h) { - sy = srcRect.y; - sh = srcRect.h; - dy = y + (h - srcRect.h) / 2; - } else if (srcRect.h > h) { - sy = srcRect.y + (srcRect.h - h) / 2; - sh = h; - dy = y; - } else { - sy = srcRect.y; - sh = srcRect.h; - dy = y; - } - } else { - sh = MIN(srcRect.h, h); - sy = srcRect.y + srcRect.h - sh; - dy = y + h - sh; - } - - // clip - if (sx < g_clipRect.x) { - sw -= g_clipRect.x - sx; - dx += g_clipRect.x - sx; - sx = g_clipRect.x; - } - - if (dx < g_clipRect.x) { - sw -= g_clipRect.x - dx; - sx += g_clipRect.x - dx; - dx = g_clipRect.x; - } - - if (sx + sw > g_clipRect.x + g_clipRect.w) { - sw -= (sx + sw) - (g_clipRect.x + g_clipRect.w); - } - - if (dx + sw > g_clipRect.x + g_clipRect.w) { - sw -= (dx + sw) - (g_clipRect.x + g_clipRect.w); - } - - if (sy < g_clipRect.y) { - sh -= g_clipRect.y - sy; - dy += g_clipRect.y - sy; - sy = g_clipRect.y; - } - - if (dy < g_clipRect.y) { - sh -= g_clipRect.y - dy; - sy += g_clipRect.y - dy; - dy = g_clipRect.y; - } - - if (dy + sh > g_clipRect.y + g_clipRect.h) { - sh -= (dy + sh) - (g_clipRect.y + g_clipRect.h); - } - - if (sy + sh > g_clipRect.y + g_clipRect.h) { - sy -= (sy + sh) - (g_clipRect.y + g_clipRect.h); - } - - bitBlt(buffer, bufferDst, sx, sy, sw, sh, dx, dy, opacity); - } - } -} - -void prepareRect(AppContext *appContext, Rect &rect) { - if (appContext->rect.x > 0) { - rect.x += appContext->rect.x; - } - if (appContext->rect.y > 0) { - rect.y += appContext->rect.y; - } -} - -void animateRects(AppContext *appContext, Buffer startBuffer, int numRects, float duration, const Rect *clipRect) { - display::animate(startBuffer, animateRectsStep, duration); - - g_numRects = numRects; - - if (clipRect) { - g_clipRect.x = clipRect->x; - g_clipRect.y = clipRect->y; - g_clipRect.w = clipRect->w; - g_clipRect.h = clipRect->h; - prepareRect(appContext, g_clipRect); - } else { - g_clipRect.x = appContext->rect.x; - g_clipRect.y = appContext->rect.y; - g_clipRect.w = appContext->rect.w; - g_clipRect.h = appContext->rect.h; - } - - for (int i = 0; i < numRects; i++) { - prepareRect(appContext, g_animRects[i].srcRect); - prepareRect(appContext, g_animRects[i].dstRect); - } -} - -} // gui -} // eez diff --git a/Middlewares/eez/gui/animation.h b/Middlewares/eez/gui/animation.h deleted file mode 100644 index 79beca2..0000000 --- a/Middlewares/eez/gui/animation.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2015-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -namespace eez { -namespace gui { - -enum Buffer { - BUFFER_OLD, - BUFFER_NEW, - BUFFER_SOLID_COLOR -}; - -enum Opacity { - OPACITY_SOLID, - OPACITY_FADE_IN, - OPACITY_FADE_OUT -}; - -enum Position { - POSITION_TOP_LEFT, - POSITION_TOP, - POSITION_TOP_RIGHT, - POSITION_LEFT, - POSITION_CENTER, - POSITION_RIGHT, - POSITION_BOTTOM_LEFT, - POSITION_BOTTOM, - POSITION_BOTTOM_RIGHT -}; - -struct AnimationState { - bool enabled; - uint32_t startTime; - float duration; - Buffer startBuffer; - void (*callback)(float t, VideoBuffer bufferOld, VideoBuffer bufferNew, VideoBuffer bufferDst); - float (*easingRects)(float x, float x1, float y1, float x2, float y2); - float (*easingOpacity)(float x, float x1, float y1, float x2, float y2); -}; - -struct AnimRect { - Buffer buffer; - Rect srcRect; - Rect dstRect; - uint16_t color; - Opacity opacity; - Position position; -}; - -extern AnimationState g_animationState; - -#define MAX_ANIM_RECTS 10 - -extern AnimRect g_animRects[MAX_ANIM_RECTS]; - -void animateOpen(const Rect &srcRect, const Rect &dstRect); -void animateClose(const Rect &srcRect, const Rect &dstRect); -void animateRects(AppContext *appContext, Buffer startBuffer, int numRects, float duration = -1, const Rect *clipRect = nullptr); - -} // gui -} // eez \ No newline at end of file diff --git a/Middlewares/eez/gui/app_context.cpp b/Middlewares/eez/gui/app_context.cpp deleted file mode 100644 index a835278..0000000 --- a/Middlewares/eez/gui/app_context.cpp +++ /dev/null @@ -1,543 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2015-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include -#include -#include -#include - -#if OPTION_KEYBOARD -#include -#endif - -#if OPTION_MOUSE -#include -#endif - -#include -#include -#include -#include - -#include -#include - -#include - -#define CONF_GUI_TOAST_DURATION_MS 1000L - -namespace eez { -namespace gui { - -//////////////////////////////////////////////////////////////////////////////// - -AppContext::AppContext() { - m_updatePageIndex = -1; -} - -void AppContext::stateManagment() { - // remove alert message after period of time - if (getActivePageId() == INTERNAL_PAGE_ID_TOAST_MESSAGE) { - ToastMessagePage *page = (ToastMessagePage *)getActivePage(); - if (!page->hasAction() && eez::hmi::getInactivityPeriodMs() >= CONF_GUI_TOAST_DURATION_MS) { - popPage(); - } - } -} - -//////////////////////////////////////////////////////////////////////////////// - -bool AppContext::isActivePageInternal() { - return isPageInternal(getActivePageId()); -} - -bool AppContext::isWidgetActionEnabled(const WidgetCursor &widgetCursor) { - const Widget *widget = widgetCursor.widget; - auto action = getWidgetAction(widgetCursor); - if (action) { - if (widget->type == WIDGET_TYPE_BUTTON) { - auto buttonWidget = (const ButtonWidget *)widget; - auto enabled = get(widgetCursor, buttonWidget->enabled); - if (!(enabled.getType() == VALUE_TYPE_UNDEFINED || enabled.getInt() ? 1 : 0)) { - return false; - } - } - - return true; - } - - return false; -} - -bool AppContext::isAutoRepeatAction(int action) { - return false; -} - -bool AppContext::isFocusWidget(const WidgetCursor &widgetCursor) { - return false; -} - -//////////////////////////////////////////////////////////////////////////////// - -void AppContext::onPageChanged(int previousPageId, int activePageId) { - display::turnOn(); - hmi::noteActivity(); - -#if OPTION_MOUSE - mouse::onPageChanged(); -#endif - -#if OPTION_KEYBOARD - keyboard::onPageChanged(); -#endif - - flow::onPageChanged(previousPageId, activePageId); -} - -void AppContext::doShowPage(int pageId, Page *page, int previousPageId) { -#if CONF_OPTION_FPGA - pageId = PAGE_ID_WELCOME_800X480; - page = nullptr; -#endif - - page = page ? page : g_hooks.getPageFromId(pageId); - - m_pageNavigationStack[m_pageNavigationStackPointer].page = page; - m_pageNavigationStack[m_pageNavigationStackPointer].pageId = pageId; - m_pageNavigationStack[m_pageNavigationStackPointer].displayBufferIndex = -1; - m_pageNavigationStack[m_pageNavigationStackPointer].timelinePosition = 0; - - if (page) { - page->pageWillAppear(); - } - - m_showPageTime = millis(); - - onPageChanged(previousPageId, pageId); - - refreshScreen(); -} - -void AppContext::setPage(int pageId) { - int previousPageId = getActivePageId(); - - // delete stack - for (int i = 0; i <= m_pageNavigationStackPointer; ++i) { - if (m_pageNavigationStack[i].page) { - m_pageNavigationStack[i].page->pageFree(); - } - } - m_pageNavigationStackPointer = 0; - - // - doShowPage(pageId, nullptr, previousPageId); -} - -void AppContext::replacePage(int pageId, Page *page) { - int previousPageId = getActivePageId(); - - Page *activePage = getActivePage(); - if (activePage) { - activePage->pageFree(); - } - - doShowPage(pageId, page, previousPageId); -} - -void AppContext::pushPage(int pageId, Page *page) { - if (pushPageInGuiThread(this, pageId, page)) { - return; - } - - int previousPageId = getActivePageId(); - - // advance stack pointer - if (getActivePageId() != PAGE_ID_NONE && getActivePageId() != PAGE_ID_ASYNC_OPERATION_IN_PROGRESS && getActivePageId() != INTERNAL_PAGE_ID_TOAST_MESSAGE) { - m_pageNavigationStackPointer++; - assert (m_pageNavigationStackPointer < CONF_GUI_PAGE_NAVIGATION_STACK_SIZE); - } - - doShowPage(pageId, page, previousPageId); -} - -void AppContext::popPage() { - if (m_pageNavigationStackPointer > 0) { - int previousPageId = getActivePageId(); - - if (m_pageNavigationStack[m_pageNavigationStackPointer].page) { - m_pageNavigationStack[m_pageNavigationStackPointer].page->pageFree(); - m_pageNavigationStack[m_pageNavigationStackPointer].page = nullptr; - } - --m_pageNavigationStackPointer; - - doShowPage(m_pageNavigationStack[m_pageNavigationStackPointer].pageId, m_pageNavigationStack[m_pageNavigationStackPointer].page, previousPageId); - } -} - -void AppContext::removePageFromStack(int pageId) { - for (int i = m_pageNavigationStackPointer; i > 0; i--) { - if (m_pageNavigationStack[i].pageId == pageId) { - if (i == m_pageNavigationStackPointer) { - popPage(); - } else { - if (m_pageNavigationStack[i].page) { - m_pageNavigationStack[i].page->pageFree(); - } - - for (int j = i + 1; j <= m_pageNavigationStackPointer; j++) { - memcpy(m_pageNavigationStack + j - 1, m_pageNavigationStack + j, sizeof(PageOnStack)); - } - - m_pageNavigationStack[m_pageNavigationStackPointer].page = nullptr; - - --m_pageNavigationStackPointer; - } - refreshScreen(); - break; - } - } -} - -Page *AppContext::getPage(int pageId) { - for (int i = 0; i <= m_pageNavigationStackPointer; ++i) { - if (m_pageNavigationStack[i].pageId == pageId) { - return m_pageNavigationStack[i].page; - } - } - return nullptr; -} - -bool AppContext::isPageOnStack(int pageId) { - for (int i = 0; i <= m_pageNavigationStackPointer; ++i) { - if (m_pageNavigationStack[i].pageId == pageId) { - return true; - } - } - return false; -} - -bool AppContext::isExternalPageOnStack() { - for (int i = 0; i <= m_pageNavigationStackPointer; ++i) { - if (m_pageNavigationStack[i].pageId < 0) { - return true; - } - } - return false; -} - -void AppContext::removeExternalPagesFromTheStack() { - for (int i = 0; i <= m_pageNavigationStackPointer; ++i) { - if (m_pageNavigationStack[i].pageId < 0) { - removePageFromStack(m_pageNavigationStack[i].pageId); - i = 0; - } - } -} - -void AppContext::showPage(int pageId) { - if (showPageInGuiThread(this, pageId)) { - return; - } - - if (pageId != getActivePageId()) { - setPage(pageId); - } -} - -//////////////////////////////////////////////////////////////////////////////// - -bool AppContext::testExecuteActionOnTouchDown(int action) { - return false; -} - -bool AppContext::isBlinking(const WidgetCursor &widgetCursor, int16_t id) { - return false; -} - -bool AppContext::canExecuteActionWhenTouchedOutsideOfActivePage(int pageId, int action) { - return false; -} - -void AppContext::onPageTouch(const WidgetCursor &foundWidget, Event &touchEvent) { - int activePageId = getActivePageId(); -#if OPTION_TOUCH_CALIBRATION - if (activePageId == PAGE_ID_TOUCH_CALIBRATION) { - onTouchCalibrationPageTouch(foundWidget, touchEvent); - return; - } -#endif - - if (activePageId != PAGE_ID_NONE && !isPageInternal(activePageId)) { - auto page = getPageAsset(activePageId); - if ((page->flags & CLOSE_PAGE_IF_TOUCHED_OUTSIDE_FLAG) != 0) { - int xPage; - int yPage; - int wPage; - int hPage; - getPageRect(activePageId, getActivePage(), xPage, yPage, wPage, hPage); - - if (!pointInsideRect(touchEvent.x, touchEvent.y, xPage, yPage, wPage, hPage)) { - int activePageId = getActivePageId(); - - // clicked outside page, close page - popPage(); - - auto widgetCursor = findWidget(touchEvent.x, touchEvent.y); - - if (widgetCursor.widget) { - auto action = getWidgetAction(widgetCursor); - if (action != ACTION_ID_NONE && canExecuteActionWhenTouchedOutsideOfActivePage(activePageId, action)) { - processTouchEvent(touchEvent); - } - } - } - } - } -} - -//////////////////////////////////////////////////////////////////////////////// - -void AppContext::updatePage(int i, WidgetCursor &widgetCursor) { - if (g_findCallback == nullptr) { - m_pageNavigationStack[i].displayBufferIndex = display::beginBufferRendering(); - } - - m_updatePageIndex = i; - - int x; - int y; - int width; - int height; - bool withShadow; - - if (isPageInternal(m_pageNavigationStack[i].pageId)) { - auto internalPage = ((InternalPage *)m_pageNavigationStack[i].page); - - x = internalPage->x; - y = internalPage->y; - width = internalPage->width; - height = internalPage->height; - withShadow = true; - - widgetCursor.w = width; - widgetCursor.h = height; - - if (g_findCallback == nullptr) { - internalPage->updateInternalPage(); - } - - enumNoneWidget(); - } else { - auto page = getPageAsset(m_pageNavigationStack[i].pageId, widgetCursor); - - if (widgetCursor.flowState && widgetCursor.flowState->timelinePosition != m_pageNavigationStack[i].timelinePosition) { - widgetCursor.hasPreviousState = false; - m_pageNavigationStack[i].timelinePosition = widgetCursor.flowState->timelinePosition; - } - - auto savedWidget = widgetCursor.widget; - widgetCursor.widget = page; - - if ((page->flags & PAGE_SCALE_TO_FIT) && flow::g_debuggerMode == flow::DEBUGGER_MODE_RUN) { - x = rect.x; - y = rect.y; - width = rect.w; - height = rect.h; - } else { - x = widgetCursor.x + page->x; - y = widgetCursor.y + page->y; - width = page->width; - height = page->height; - } - - withShadow = page->x > 0; - - auto savedX = widgetCursor.x; - auto savedY = widgetCursor.y; - - widgetCursor.x = x; - widgetCursor.y = y; - - widgetCursor.w = width; - widgetCursor.h = height; - - enumWidget(); - - widgetCursor.x = savedX; - widgetCursor.y = savedY; - - widgetCursor.widget = savedWidget; - } - - if (g_findCallback == nullptr) { - pageRenderCustom(i, widgetCursor); - display::endBufferRendering(m_pageNavigationStack[i].displayBufferIndex, x, y, width, height, withShadow, 255, 0, 0, withShadow && g_hooks.activePageHasBackdrop() ? &rect : nullptr); - } - - m_updatePageIndex = -1; -} - -void AppContext::pageRenderCustom(int i, WidgetCursor &widgetCursor) { -} - -bool isRect1FullyCoveredByRect2(int xRect1, int yRect1, int wRect1, int hRect1, int xRect2, int yRect2, int wRect2, int hRect2) { - return xRect2 <= xRect1 && yRect2 <= yRect1 && xRect2 + wRect2 >= xRect1 + wRect1 && yRect2 + hRect2 >= yRect1 + hRect1; -} - -void AppContext::getPageRect(int pageId, const Page *page, int &x, int &y, int &w, int &h) { - if (isPageInternal(pageId)) { - x = rect.x + ((InternalPage *)page)->x; - y = rect.y + ((InternalPage *)page)->y; - w = ((InternalPage *)page)->width; - h = ((InternalPage *)page)->height; - } else { - auto page = getPageAsset(pageId); - if ((page->flags & PAGE_SCALE_TO_FIT) && flow::g_debuggerMode == flow::DEBUGGER_MODE_RUN) { - x = rect.x; - y = rect.y; - w = rect.w; - h = rect.h; - } else { - x = rect.x + page->x; - y = rect.y + page->y; - w = page->width; - h = page->height; - } - } -} - -bool AppContext::isPageFullyCovered(int pageNavigationStackIndex) { - int xPage, yPage, wPage, hPage; - getPageRect(m_pageNavigationStack[pageNavigationStackIndex].pageId, m_pageNavigationStack[pageNavigationStackIndex].page, xPage, yPage, wPage, hPage); - - for (int i = pageNavigationStackIndex + 1; i <= m_pageNavigationStackPointer; i++) { - int xPageAbove, yPageAbove, wPageAbove, hPageAbove; - getPageRect(m_pageNavigationStack[i].pageId, m_pageNavigationStack[i].page, xPageAbove, yPageAbove, wPageAbove, hPageAbove); - - if (isRect1FullyCoveredByRect2(xPage, yPage, wPage, hPage, xPageAbove, yPageAbove, wPageAbove, hPageAbove)) { - return true; - } - } - - return false; -} - -int AppContext::getLongTouchActionHook(const WidgetCursor &widgetCursor) { - return ACTION_ID_NONE; -} - -void AppContext::yesNoDialog(int yesNoPageId, const char *message, void (*yes_callback)(), void (*no_callback)(), void (*cancel_callback)()) { - set(WidgetCursor(), DATA_ID_ALERT_MESSAGE, Value(message)); - - m_dialogYesCallback = yes_callback; - m_dialogNoCallback = no_callback; - m_dialogCancelCallback = cancel_callback; - - pushPage(yesNoPageId); -} - -void AppContext::yesNoDialog(int yesNoPageId, Value value, void(*yes_callback)(), void(*no_callback)(), void(*cancel_callback)()) { - set(WidgetCursor(), DATA_ID_ALERT_MESSAGE, value); - - m_dialogYesCallback = yes_callback; - m_dialogNoCallback = no_callback; - m_dialogCancelCallback = cancel_callback; - - pushPage(yesNoPageId); -} - -void AppContext::infoMessage(const char *message) { - pushToastMessage(ToastMessagePage::create(this, INFO_TOAST, message)); -} - -void AppContext::infoMessage(Value value) { - pushToastMessage(ToastMessagePage::create(this, INFO_TOAST, value)); -} - -void AppContext::infoMessage(const char *message, void (*action)(), const char *actionLabel) { - pushToastMessage(ToastMessagePage::create(this, INFO_TOAST, message, action, actionLabel)); -} - -void AppContext::errorMessage(const char *message, bool autoDismiss) { - AppContext::pushToastMessage(ToastMessagePage::create(this, ERROR_TOAST, message, autoDismiss)); - sound::playBeep(); -} - -void AppContext::errorMessage(Value value) { - AppContext::pushToastMessage(ToastMessagePage::create(this, ERROR_TOAST, value)); - sound::playBeep(); -} - -void AppContext::errorMessageWithAction(Value value, void (*action)(int param), const char *actionLabel, int actionParam) { - AppContext::pushToastMessage(ToastMessagePage::create(this, ERROR_TOAST, value, action, actionLabel, actionParam)); - sound::playBeep(); -} - -void AppContext::errorMessageWithAction(const char *message, void (*action)(), const char *actionLabel) { - AppContext::pushToastMessage(ToastMessagePage::create(this, ERROR_TOAST, message, action, actionLabel)); - sound::playBeep(); -} - -void AppContext::pushToastMessage(ToastMessagePage *toastMessage) { - pushPage(INTERNAL_PAGE_ID_TOAST_MESSAGE, toastMessage); -} - -void AppContext::getBoundingRect(Rect &rectBounding) { - if (m_pageNavigationStackPointer >= 0) { - int x1 = rect.x + rect.w; - int y1 = rect.y + rect.h; - int x2 = rect.x; - int y2 = rect.y; - - for (int i = 0; i <= m_pageNavigationStackPointer; ++i) { - if (!isPageInternal(m_pageNavigationStack[i].pageId)) { - int xPage, yPage, wPage, hPage; - getPageRect(m_pageNavigationStack[i].pageId, m_pageNavigationStack[i].page, xPage, yPage, wPage, hPage); - if (xPage < x1) x1 = xPage; - if (xPage + wPage > x2) x2 = xPage + wPage; - if (yPage < y1) y1 = yPage; - if (yPage + hPage > y2) y2 = yPage + hPage; - } - } - - rectBounding.x = x1; - rectBounding.y = y1; - rectBounding.w = x2 - x1; - rectBounding.h = y2 - y1; - } else { - rectBounding.x = rect.x; - rectBounding.y = rect.y; - rectBounding.w = rect.w; - rectBounding.h = rect.h; - } -} - -AppContext *getRootAppContext() { -#ifdef EEZ_PLATFORM_SIMULATOR - return getAppContextFromId(APP_CONTEXT_ID_SIMULATOR_FRONT_PANEL); -#else - return getAppContextFromId(APP_CONTEXT_ID_DEVICE); -#endif -} - -} // namespace gui -} // namespace eez diff --git a/Middlewares/eez/gui/app_context.h b/Middlewares/eez/gui/app_context.h deleted file mode 100644 index 0ee1b6c..0000000 --- a/Middlewares/eez/gui/app_context.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2015-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#define CONF_GUI_PAGE_NAVIGATION_STACK_SIZE 10 - -#define APP_CONTEXT_ID_DEVICE 0 -#define APP_CONTEXT_ID_SIMULATOR_FRONT_PANEL 1 - -namespace eez { -namespace gui { - -class Page; - -struct PageOnStack { - int pageId = PAGE_ID_NONE; - Page *page = nullptr; - int displayBufferIndex = -1; - float timelinePosition; -}; - -class ToastMessagePage; - -class AppContext { - friend struct AppViewWidgetState; - -public: - Rect rect; - - AppContext(); - - virtual void stateManagment(); - - void showPage(int pageId); - void pushPage(int pageId, Page *page = nullptr); - void popPage(); - void removePageFromStack(int pageId); - - int getActivePageStackPointer() { - return m_updatePageIndex != -1 ? m_updatePageIndex : m_pageNavigationStackPointer; - } - - int getActivePageId() { - return m_pageNavigationStack[getActivePageStackPointer()].pageId; - } - - Page *getActivePage() { - return m_pageNavigationStack[getActivePageStackPointer()].page; - } - - bool isActivePageInternal(); - - int getPreviousPageId() { - int index = getActivePageStackPointer(); - return index == 0 ? PAGE_ID_NONE : m_pageNavigationStack[index - 1].pageId; - } - - void replacePage(int pageId, Page *page = nullptr); - - Page *getPage(int pageId); - bool isPageOnStack(int pageId); - bool isExternalPageOnStack(); - void removeExternalPagesFromTheStack(); - - int getNumPagesOnStack() { - return m_pageNavigationStackPointer + 1; - } - - virtual bool isFocusWidget(const WidgetCursor &widgetCursor); - - virtual bool isBlinking(const WidgetCursor &widgetCursor, int16_t id); - - virtual void onPageTouch(const WidgetCursor &foundWidget, Event &touchEvent); - - virtual bool testExecuteActionOnTouchDown(int action); - - virtual bool isAutoRepeatAction(int action); - - virtual bool isWidgetActionEnabled(const WidgetCursor &widgetCursor); - - virtual int getLongTouchActionHook(const WidgetCursor &widgetCursor); - - void infoMessage(const char *message); - void infoMessage(Value value); - void infoMessage(const char *message, void (*action)(), const char *actionLabel); - void errorMessage(const char *message, bool autoDismiss = false); - void errorMessage(Value value); - void errorMessageWithAction(Value value, void (*action)(int param), const char *actionLabel, int actionParam); - void errorMessageWithAction(const char *message, void (*action)(), const char *actionLabel); - - void yesNoDialog(int yesNoPageId, const char *message, void (*yes_callback)(), void (*no_callback)(), void (*cancel_callback)()); - void yesNoDialog(int yesNoPageId, Value value, void(*yes_callback)(), void(*no_callback)(), void(*cancel_callback)()); - - // TODO these should be private - void(*m_dialogYesCallback)(); - void(*m_dialogNoCallback)(); - void(*m_dialogCancelCallback)(); - void(*m_dialogLaterCallback)(); - - virtual int getMainPageId() = 0; - - void getBoundingRect(Rect &rect); - -protected: - PageOnStack m_pageNavigationStack[CONF_GUI_PAGE_NAVIGATION_STACK_SIZE]; - int m_pageNavigationStackPointer = 0; - int m_updatePageIndex; - - uint32_t m_showPageTime; - - virtual void onPageChanged(int previousPageId, int activePageId); - - void doShowPage(int index, Page *page, int previousPageId); - void setPage(int pageId); - - void updatePage(int i, WidgetCursor &widgetCursor); - virtual void pageRenderCustom(int i, WidgetCursor &widgetCursor); - - void getPageRect(int pageId, const Page *page, int &x, int &y, int &w, int &h); - bool isPageFullyCovered(int pageNavigationStackIndex); - - virtual bool canExecuteActionWhenTouchedOutsideOfActivePage(int pageId, int action); - - void pushToastMessage(ToastMessagePage *toastMessage); -}; - -AppContext *getRootAppContext(); - -} // namespace gui -} // namespace eez diff --git a/Middlewares/eez/gui/assets.cpp b/Middlewares/eez/gui/assets.cpp deleted file mode 100644 index 863437f..0000000 --- a/Middlewares/eez/gui/assets.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2015-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#if OPTION_SCPI -#include -#else -#define SCPI_ERROR_OUT_OF_DEVICE_MEMORY -321 -#define SCPI_ERROR_INVALID_BLOCK_DATA -161 -#endif - -namespace eez { -namespace gui { - -bool g_isMainAssetsLoaded; -Assets *g_mainAssets; -Assets *g_externalAssets; - -//////////////////////////////////////////////////////////////////////////////// - -void fixOffsets(Assets *assets); - -bool decompressAssetsData(const uint8_t *assetsData, uint32_t assetsDataSize, Assets *decompressedAssets, uint32_t maxDecompressedAssetsSize, int *err) { - uint32_t compressedDataOffset; - uint32_t decompressedSize; - - auto header = (Header *)assetsData; - - if (header->tag == HEADER_TAG) { - decompressedAssets->projectMajorVersion = header->projectMajorVersion; - decompressedAssets->projectMinorVersion = header->projectMinorVersion; - decompressedAssets->assetsType = header->assetsType; - - compressedDataOffset = sizeof(Header); - decompressedSize = header->decompressedSize; - } else { - decompressedAssets->projectMajorVersion = PROJECT_VERSION_V2; - decompressedAssets->projectMinorVersion = 0; - decompressedAssets->assetsType = ASSETS_TYPE_RESOURCE; - - compressedDataOffset = 4; - decompressedSize = header->tag; - } - -// disable warning: offsetof within non-standard-layout type ... is conditionally-supported [-Winvalid-offsetof] -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Winvalid-offsetof" -#endif - - auto decompressedDataOffset = offsetof(Assets, settings); - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif - - - if (decompressedDataOffset + decompressedSize > maxDecompressedAssetsSize) { - if (err) { - *err = SCPI_ERROR_OUT_OF_DEVICE_MEMORY; - } - return false; - } - - int compressedSize = assetsDataSize - compressedDataOffset; - - int decompressResult = LZ4_decompress_safe( - (const char *)(assetsData + compressedDataOffset), - (char *)decompressedAssets + decompressedDataOffset, - compressedSize, - decompressedSize - ); - - if (decompressResult != (int)decompressedSize) { - if (err) { - *err = SCPI_ERROR_INVALID_BLOCK_DATA; - } - return false; - } - - if (decompressedAssets->projectMajorVersion >= PROJECT_VERSION_V3) { - fixOffsets(decompressedAssets); - } - - return true; -} - -void loadMainAssets(const uint8_t *assets, uint32_t assetsSize) { - g_mainAssets = (Assets *)DECOMPRESSED_ASSETS_START_ADDRESS; - g_mainAssets->external = false; - auto decompressedSize = decompressAssetsData(assets, assetsSize, g_mainAssets, MAX_DECOMPRESSED_ASSETS_SIZE, nullptr); - assert(decompressedSize); - g_isMainAssetsLoaded = true; -} - -void unloadExternalAssets() { - if (g_externalAssets) { - removeExternalPagesFromTheStack(); - - free(g_externalAssets); - g_externalAssets = nullptr; - } -} - -//////////////////////////////////////////////////////////////////////////////// - -const PageAsset* getPageAsset(int pageId) { - if (pageId > 0) { - return g_mainAssets->pages[pageId - 1]; - } else if (pageId < 0) { - if (g_externalAssets == nullptr) { - return nullptr; - } - return g_externalAssets->pages[-pageId - 1]; - } - return nullptr; -} - -const PageAsset* getPageAsset(int pageId, WidgetCursor& widgetCursor) { - if (pageId < 0) { - widgetCursor.assets = g_externalAssets; - widgetCursor.flowState = flow::getFlowState(g_externalAssets, -pageId - 1, widgetCursor); - } else { - widgetCursor.assets = g_mainAssets; - if (g_mainAssets->flowDefinition) { - widgetCursor.flowState = flow::getFlowState(g_mainAssets, pageId - 1, widgetCursor); - } - } - return getPageAsset(pageId); -} - -const Style *getStyle(int styleID) { - if (styleID > 0) { - return g_mainAssets->styles[styleID - 1]; - } else if (styleID < 0) { - if (g_externalAssets == nullptr) { - return getStyle(STYLE_ID_DEFAULT); - } - return g_externalAssets->styles[-styleID - 1]; - } - return getStyle(STYLE_ID_DEFAULT); -} - -const FontData *getFontData(int fontID) { - if (fontID > 0) { - return g_mainAssets->fonts[fontID - 1]; - } else if (fontID < 0) { - if (g_externalAssets == nullptr) { - return nullptr; - } - return g_externalAssets->fonts[-fontID - 1]; - } - return nullptr; -} - -const Bitmap *getBitmap(int bitmapID) { - if (bitmapID > 0) { - return g_mainAssets->bitmaps[bitmapID - 1]; - } else if (bitmapID < 0) { - if (g_externalAssets == nullptr) { - return nullptr; - } - return g_externalAssets->bitmaps[-bitmapID - 1]; - } - return nullptr; -} - -int getThemesCount() { - return (int)g_mainAssets->colorsDefinition->themes.count; -} - -Theme *getTheme(int i) { - return g_mainAssets->colorsDefinition->themes[i]; -} - -const char *getThemeName(int i) { - return static_cast(getTheme(i)->name); -} - -const uint32_t getThemeColorsCount(int themeIndex) { - return getTheme(themeIndex)->colors.count; -} - -const uint16_t *getThemeColors(int themeIndex) { - return static_cast(getTheme(themeIndex)->colors.items); -} - -const uint16_t *getColors() { - return static_cast(g_mainAssets->colorsDefinition->colors.items); -} - -int getExternalAssetsMainPageId() { - return -1; -} - -const char *getActionName(const WidgetCursor &widgetCursor, int16_t actionId) { - if (actionId == 0) { - return nullptr; - } - - if (actionId < 0) { - actionId = -actionId; - } - actionId--; - - if (!widgetCursor.assets) { - return ""; - } - - return widgetCursor.assets->actionNames[actionId]; -} - -int16_t getDataIdFromName(const WidgetCursor &widgetCursor, const char *name) { - if (!widgetCursor.assets) { - return 0; - } - - for (uint32_t i = 0; i < widgetCursor.assets->variableNames.count; i++) { - if (strcmp(widgetCursor.assets->variableNames[i], name) == 0) { - return -((int16_t)i + 1); - } - } - return 0; -} - -} // namespace gui -} // namespace eez diff --git a/Middlewares/eez/gui/assets.h b/Middlewares/eez/gui/assets.h deleted file mode 100644 index fd64d32..0000000 --- a/Middlewares/eez/gui/assets.h +++ /dev/null @@ -1,493 +0,0 @@ -/* - * EEZ Modular Firmware - * Copyright (C) 2015-present, Envox d.o.o. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include -#include - -namespace eez { -namespace gui { - -static const uint32_t HEADER_TAG = 0x7A65657E; - -static const uint8_t PROJECT_VERSION_V2 = 2; -static const uint8_t PROJECT_VERSION_V3 = 3; - -static const uint8_t ASSETS_TYPE_FIRMWARE = 1; -static const uint8_t ASSETS_TYPE_FIRMWARE_MODULE = 2; -static const uint8_t ASSETS_TYPE_RESOURCE = 3; -static const uint8_t ASSETS_TYPE_APPLET = 4; -static const uint8_t ASSETS_TYPE_DASHBOARD = 5; - -struct Header { - uint32_t tag; // HEADER_TAG - uint8_t projectMajorVersion; - uint8_t projectMinorVersion; - uint8_t assetsType; - uint8_t reserved; - uint32_t decompressedSize; -}; - -extern bool g_isMainAssetsLoaded; -extern Assets *g_mainAssets; -extern Assets *g_externalAssets; - -//////////////////////////////////////////////////////////////////////////////// - -/* This template is used (on 64-bit systems) to pack asset pointers into 32-bit values. - * All pointers are relative to MEMORY_BEGIN. - * This way, the assets created by Studio can be used without having to fix all - * the sizes - Studio creates 32-bit pointers that are relative to the - * beginning of the assets, which the firmware rewrites to global pointers - * during initialization. On a 32-bit system this works just fine, but for a - * 64-bit system the pointers have different sizes and this breaks. By - * inserting a 'middleman' structure that stores the pointers as a 32-bit - * offset to MEMORY_BEGIN, we can keep the pointer sizes and initialization - * code the same. - */ -template -struct AssetsPtrImpl { - /* Conversion to a T pointer */ - operator T*() { return ptr(); } - operator const T*() const { return ptr(); } - /* Dereferencing operators */ - T* operator->() { return ptr(); } - const T* operator->() const { return ptr(); } - - void operator=(T* ptr) { - if (ptr != nullptr) { - offset = (uint8_t *)ptr - MEMORY_BEGIN; - } else { - offset = 0; - } - } - - uint32_t offset = 0; - -private: - T* ptr() { - return offset ? (T *)(MEMORY_BEGIN + offset) : nullptr; - } - - const T* ptr() const { - return offset ? (const T *)(MEMORY_BEGIN + offset) : nullptr; - } -}; - -/* This struct chooses the type used for AssetsPtr - by default it uses an AssetsPtrImpl<> */ -template -struct AssetsPtrChooser -{ - using type = AssetsPtrImpl; -}; - -/* On 32-bit systems, we can just use raw pointers */ -template -struct AssetsPtrChooser -{ - using type = T*; -}; - -/* Utility typedef that delegates to AssetsPtrChooser */ -template -using AssetsPtr = typename AssetsPtrChooser::type; - -//////////////////////////////////////////////////////////////////////////////// - -template -struct ListOfAssetsPtr { - /* Array access */ - T* operator[](uint32_t i) { return item(i); } - const T* operator[](uint32_t i) const { return item(i); } - - uint32_t count = 0; - AssetsPtr> items; - -private: - T* item(int i) { - return static_cast(static_cast *>(items)[i]); - } - - const T* item(int i) const { - return static_cast(static_cast *>(items)[i]); - } -}; - -template -struct ListOfFundamentalType { - /* Array access */ - T& operator[](uint32_t i) { return ptr()[i]; } - const T& operator[](uint32_t i) const { return ptr()[i]; } - - uint32_t count; - AssetsPtr items; - -private: - T *ptr() { - return static_cast(items); - } -}; - -//////////////////////////////////////////////////////////////////////////////// - -struct Settings { - uint16_t displayWidth; - uint16_t displayHeight; -}; - -//////////////////////////////////////////////////////////////////////////////// - -#define WIDGET_FLAG_PIN_TO_LEFT (1 << 0) -#define WIDGET_FLAG_PIN_TO_RIGHT (1 << 1) -#define WIDGET_FLAG_PIN_TO_TOP (1 << 2) -#define WIDGET_FLAG_PIN_TO_BOTTOM (1 << 3) - -#define WIDGET_FLAG_FIX_WIDTH (1 << 4) -#define WIDGET_FLAG_FIX_HEIGHT (1 << 5) - -#define WIDGET_TIMELINE_PROPERTY_X (1 << 0) -#define WIDGET_TIMELINE_PROPERTY_Y (1 << 1) -#define WIDGET_TIMELINE_PROPERTY_WIDTH (1 << 2) -#define WIDGET_TIMELINE_PROPERTY_HEIGHT (1 << 3) -#define WIDGET_TIMELINE_PROPERTY_OPACITY (1 << 4) - -#define EASING_FUNC_LINEAR 0 -#define EASING_FUNC_IN_QUAD 1 -#define EASING_FUNC_OUT_QUAD 2 -#define EASING_FUNC_IN_OUT_QUAD 3 -#define EASING_FUNC_IN_CUBIC 4 -#define EASING_FUNC_OUT_CUBIC 5 -#define EASING_FUNC_IN_OUT_CUBIC 6 -#define EASING_FUNC_IN__QUART 7 -#define EASING_FUNC_OUT_QUART 8 -#define EASING_FUNC_IN_OUT_QUART 9 -#define EASING_FUNC_IN_QUINT 10 -#define EASING_FUNC_OUT_QUINT 11 -#define EASING_FUNC_IN_OUT_QUINT 12 -#define EASING_FUNC_IN_SINE 13 -#define EASING_FUNC_OUT_SINE 14 -#define EASING_FUNC_IN_OUT_SINE 15 -#define EASING_FUNC_IN_EXPO 16 -#define EASING_FUNC_OUT_EXPO 17 -#define EASING_FUNC_IN_OUT_EXPO 18 -#define EASING_FUNC_IN_CIRC 19 -#define EASING_FUNC_OUT_CIRC 20 -#define EASING_FUNC_IN_OUT_CIRC 21 -#define EASING_FUNC_IN_BACK 22 -#define EASING_FUNC_OUT_BACK 23 -#define EASING_FUNC_IN_OUT_BACK 24 -#define EASING_FUNC_IN_ELASTIC 25 -#define EASING_FUNC_OUT_ELASTIC 26 -#define EASING_FUNC_IN_OUT_ELASTIC 27 -#define EASING_FUNC_IN_BOUNCE 28 -#define EASING_FUNC_OUT_BOUNCE 29 -#define EASING_FUNC_IN_OUT_BOUNCE 30 - -struct TimelineKeyframe { - float start; - float end; - - uint32_t enabledProperties; - - int16_t x; - int16_t y; - int16_t width; - int16_t height; - float opacity; - - uint8_t xEasingFunc; - uint8_t yEasingFunc; - uint8_t widthEasingFunc; - uint8_t heightEasingFunc; - uint8_t opacityEasingFunc; - - uint8_t reserved1; - uint8_t reserved2; - uint8_t reserved3; -}; - -struct Widget { - uint16_t type; - int16_t data; - int16_t visible; - int16_t action; - int16_t x; - int16_t y; - int16_t width; - int16_t height; - int16_t style; - uint16_t flags; - ListOfAssetsPtr timeline; -}; - -#define SHADOW_FLAG (1 << 0) -#define CLOSE_PAGE_IF_TOUCHED_OUTSIDE_FLAG (1 << 1) -#define PAGE_IS_USED_AS_CUSTOM_WIDGET (1 << 2) -#define PAGE_CONTAINER (1 << 3) -#define PAGE_SCALE_TO_FIT (1 << 4) - -struct PageAsset : public Widget { - ListOfAssetsPtr widgets; - uint16_t flags; - int16_t overlay; -}; - -//////////////////////////////////////////////////////////////////////////////// - -#define STYLE_FLAGS_HORZ_ALIGN_MASK 0x7 -#define STYLE_FLAGS_HORZ_ALIGN_LEFT 0 -#define STYLE_FLAGS_HORZ_ALIGN_RIGHT 1 -#define STYLE_FLAGS_HORZ_ALIGN_CENTER 2 - -#define STYLE_FLAGS_VERT_ALIGN_MASK (0x7 << 3) -#define STYLE_FLAGS_VERT_ALIGN_TOP (0 << 3) -#define STYLE_FLAGS_VERT_ALIGN_BOTTOM (1 << 3) -#define STYLE_FLAGS_VERT_ALIGN_CENTER (2 << 3) - -#define STYLE_FLAGS_BLINK (1 << 6) - -struct Style { - uint16_t flags; // STYLE_FLAGS_... - - uint16_t backgroundColor; - uint16_t color; - - uint16_t activeBackgroundColor; - uint16_t activeColor; - - uint16_t focusBackgroundColor; - uint16_t focusColor; - - uint8_t borderSizeTop; - uint8_t borderSizeRight; - uint8_t borderSizeBottom; - uint8_t borderSizeLeft; - - uint16_t borderColor; - - uint8_t borderRadiusTLX; - uint8_t borderRadiusTLY; - uint8_t borderRadiusTRX; - uint8_t borderRadiusTRY; - uint8_t borderRadiusBLX; - uint8_t borderRadiusBLY; - uint8_t borderRadiusBRX; - uint8_t borderRadiusBRY; - - uint8_t font; - uint8_t opacity; // 0 - 255 - - uint8_t paddingTop; - uint8_t paddingRight; - uint8_t paddingBottom; - uint8_t paddingLeft; - - int16_t backgroundImage; -}; - -//////////////////////////////////////////////////////////////////////////////// - -struct GlyphData { - int8_t dx; // DWIDTH (-128 indicated empty glyph) - uint8_t width; // BBX width - uint8_t height; // BBX height - int8_t x; // BBX xoffset - int8_t y; // BBX yoffset - uint8_t reserved1; - uint8_t reserved2; - uint8_t reserved3; - uint8_t pixels[1]; -}; - -struct GlyphsGroup { - uint32_t encoding; - uint32_t glyphIndex; - uint32_t length; -}; - -struct FontData { - uint8_t ascent; - uint8_t descent; - uint8_t reserved1; - uint8_t reserved2; - uint32_t encodingStart; - uint32_t encodingEnd; - ListOfAssetsPtr groups; - ListOfAssetsPtr glyphs; -}; - -//////////////////////////////////////////////////////////////////////////////// - -struct Bitmap { - int16_t w; - int16_t h; - int16_t bpp; - int16_t reserved; - const uint8_t pixels[1]; -}; - -//////////////////////////////////////////////////////////////////////////////// - -struct Theme { - AssetsPtr name; - ListOfFundamentalType colors; -}; - -struct Colors { - ListOfAssetsPtr themes; - ListOfFundamentalType colors; -}; - -//////////////////////////////////////////////////////////////////////////////// - -static const uint16_t EXPR_EVAL_INSTRUCTION_TYPE_MASK = 0x0007 << 13; -static const uint16_t EXPR_EVAL_INSTRUCTION_PARAM_MASK = 0xFFFF >> 3; - -static const uint16_t EXPR_EVAL_INSTRUCTION_TYPE_PUSH_CONSTANT = (0 << 13); -static const uint16_t EXPR_EVAL_INSTRUCTION_TYPE_PUSH_INPUT = (1 << 13); -static const uint16_t EXPR_EVAL_INSTRUCTION_TYPE_PUSH_LOCAL_VAR = (2 << 13); -static const uint16_t EXPR_EVAL_INSTRUCTION_TYPE_PUSH_GLOBAL_VAR = (3 << 13); -static const uint16_t EXPR_EVAL_INSTRUCTION_TYPE_PUSH_OUTPUT = (4 << 13); -static const uint16_t EXPR_EVAL_INSTRUCTION_ARRAY_ELEMENT = (5 << 13); -static const uint16_t EXPR_EVAL_INSTRUCTION_TYPE_OPERATION = (6 << 13); -static const uint16_t EXPR_EVAL_INSTRUCTION_TYPE_END = (7 << 13); - -struct Property { - uint8_t evalInstructions[1]; -}; - -struct Connection { - uint16_t targetComponentIndex; - uint16_t targetInputIndex; -}; - -struct ComponentOutput { - ListOfAssetsPtr connections; - uint32_t isSeqOut; -}; - -static const uint16_t BREAKPOINT_ENABLED = 1; -static const uint16_t BREAKPOINT_DISABLED = 2; - -struct Component { - uint16_t type; - uint16_t breakpoint; - - // These are indexes to Flow::componentInputs. - // We use this to check if component is ready to run (i.e. all mandatory inputs have a value). - ListOfFundamentalType inputs; - - ListOfAssetsPtr properties; - ListOfAssetsPtr outputs; - int16_t errorCatchOutput; - uint16_t reserved; -}; - -struct WidgetDataItem { - int16_t componentIndex; - int16_t propertyValueIndex; -}; - -struct WidgetActionItem { - int16_t componentIndex; - int16_t componentOutputIndex; -}; - -#define COMPONENT_INPUT_FLAG_IS_SEQ_INPUT (1 << 0) -#define COMPONENT_INPUT_FLAG_IS_OPTIONAL (1 << 1) -typedef uint8_t ComponentInput; - -struct Flow { - ListOfAssetsPtr components; - ListOfAssetsPtr localVariables; - - // List of all component inputs of all components in this flow - // When flow state is created we reserve this many Value's in memory - // to keep the latest value of component input. - ListOfFundamentalType componentInputs; - - ListOfAssetsPtr widgetDataItems; - ListOfAssetsPtr widgetActions; -}; - -struct FlowDefinition { - ListOfAssetsPtr flows; - ListOfAssetsPtr constants; - ListOfAssetsPtr globalVariables; -}; - -struct Language { - AssetsPtr languageID; - ListOfAssetsPtr translations; -}; - -//////////////////////////////////////////////////////////////////////////////// - -struct Assets { - uint8_t projectMajorVersion; - uint8_t projectMinorVersion; - uint8_t assetsType; - uint8_t external; - - AssetsPtr settings; - ListOfAssetsPtr pages; - ListOfAssetsPtr