Browse Source

upd upython

MX 8 tháng trước cách đây
mục cha
commit
2da8aacb77
10 tập tin đã thay đổi với 50 bổ sung25 xóa
  1. 8 1
      CHANGELOG.md
  2. 1 1
      application.fam
  3. 4 0
      docs/CHANGELOG.md
  4. 2 2
      docs/pages/conf.py
  5. 1 1
      pyproject.toml
  6. 2 3
      upython.h
  7. 8 5
      upython_cli.c
  8. 1 2
      upython_file.c
  9. 22 8
      upython_repl.c
  10. 1 2
      upython_splash.c

+ 8 - 1
CHANGELOG.md

@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
+## [1.8.0]
+
+### Fixed
+
+* [#9](https://github.com/ofabel/mp-flipper/issues/9): Update to latest SDK version.
+
 ## [1.7.0]
 
 ### Changed
@@ -172,7 +178,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 * Basic build setup
 * Minimal working example
 
-[Unreleased]: https://github.com/ofabel/mp-flipper/compare/v1.7.0...dev
+[Unreleased]: https://github.com/ofabel/mp-flipper/compare/v1.8.0...dev
+[1.8.0]: https://github.com/ofabel/mp-flipper/compare/v1.7.0...v1.8.0
 [1.7.0]: https://github.com/ofabel/mp-flipper/compare/v1.6.0...v1.7.0
 [1.6.0]: https://github.com/ofabel/mp-flipper/compare/v1.5.0...v1.6.0
 [1.5.0]: https://github.com/ofabel/mp-flipper/compare/v1.4.0...v1.5.0

+ 1 - 1
application.fam

@@ -5,7 +5,7 @@ App(
     entry_point="upython",
     stack_size=4 * 1024,
     fap_category="Tools",
-    fap_version="1.7",
+    fap_version="1.8",
     fap_description="Compile and execute MicroPython scripts",
     fap_icon="icon.png",
     fap_icon_assets="images",

+ 4 - 0
docs/CHANGELOG.md

@@ -1,3 +1,7 @@
+## 1.8
+
+* Update to latest SDK version.
+
 ## 1.7
 
 * Replaced speaker note constants with an attribute delegator function to save space.

+ 2 - 2
docs/pages/conf.py

@@ -35,8 +35,8 @@ now = datetime.datetime.now()
 project = 'uPython'
 copyright = str(now.year) + ', Oliver Fabel'
 author = 'Oliver Fabel'
-release = '1.7.0'
-version = '1.7'
+release = '1.8.0'
+version = '1.8'
 language = 'en'
 
 extensions = ["sphinx.ext.autodoc", "myst_parser"]

+ 1 - 1
pyproject.toml

@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
 
 [project]
 name = "flipperzero"
-version = "1.7.0"
+version = "1.8.0"
 authors = [
     { name = "Oliver Fabel" },
 ]

+ 2 - 3
upython.h

@@ -1,7 +1,6 @@
 #pragma once
 
-#include <toolbox/cli/cli_command.h>
-#include <cli/cli_main_commands.h>
+#include <cli/cli.h>
 #include <furi.h>
 
 #define TAG "uPython"
@@ -31,6 +30,6 @@ void upython_cli_unregister(void* args);
 
 void upython_cli(PipeSide* pipe, FuriString* args, void* ctx);
 
-void upython_repl_execute(PipeSide* pipe);
+void upython_repl_execute();
 
 void upython_file_execute(FuriString* file);

+ 8 - 5
upython_cli.c

@@ -1,5 +1,6 @@
 #include <furi.h>
 #include <storage/storage.h>
+#include <toolbox/pipe.h>
 
 #include "upython.h"
 
@@ -14,6 +15,8 @@ static void write_to_stdout_buffer(const char* data, size_t size, void* context)
 void upython_cli(PipeSide* pipe, FuriString* args, void* ctx) {
     UNUSED(ctx);
 
+    pipe_install_as_stdio(pipe);
+
     if(action != ActionNone) {
         printf("%s is busy!\n", TAG);
 
@@ -23,7 +26,7 @@ void upython_cli(PipeSide* pipe, FuriString* args, void* ctx) {
     if(furi_string_empty(args)) {
         action = ActionRepl;
 
-        upython_repl_execute(pipe);
+        upython_repl_execute();
 
         action = ActionNone;
     } else {
@@ -62,9 +65,9 @@ void upython_cli_register(void* args) {
         action = ActionNone;
     }
 
-    CliRegistry* registry = furi_record_open(RECORD_CLI);
+    CliRegistry* cli = furi_record_open(RECORD_CLI);
 
-    cli_registry_add_command(registry, CLI, CliCommandFlagParallelSafe, upython_cli, NULL);
+    cli_registry_add_command(cli, CLI, CliCommandFlagParallelSafe, upython_cli, NULL);
 
     furi_record_close(RECORD_CLI);
 }
@@ -76,9 +79,9 @@ void upython_cli_unregister(void* args) {
         return;
     }
 
-    CliRegistry* registry = furi_record_open(RECORD_CLI);
+    CliRegistry* cli = furi_record_open(RECORD_CLI);
 
-    cli_registry_delete_command(registry, CLI);
+    cli_registry_delete_command(cli, CLI);
 
     furi_record_close(RECORD_CLI);
 }

+ 1 - 2
upython_file.c

@@ -1,5 +1,4 @@
-#include <toolbox/cli/cli_command.h>
-#include <cli/cli_main_commands.h>
+#include <cli/cli.h>
 #include <furi.h>
 
 #include <genhdr/mpversion.h>

+ 22 - 8
upython_repl.c

@@ -1,7 +1,6 @@
 #include <stdio.h>
 
-#include <toolbox/cli/cli_command.h>
-#include <cli/cli_main_commands.h>
+#include <cli/cli.h>
 #include <cli/cli_ansi.h>
 #include <furi.h>
 
@@ -15,6 +14,21 @@
 #define AUTOCOMPLETE_MANY_MATCHES (size_t)(-1)
 #define HISTORY_SIZE              16
 
+typedef enum {
+    CliSymbolAsciiSOH = 0x01,
+    CliSymbolAsciiETX = 0x03,
+    CliSymbolAsciiEOT = 0x04,
+    CliSymbolAsciiBell = 0x07,
+    CliSymbolAsciiBackspace = 0x08,
+    CliSymbolAsciiTab = 0x09,
+    CliSymbolAsciiLF = 0x0A,
+    CliSymbolAsciiCR = 0x0D,
+    CliSymbolAsciiEsc = 0x1B,
+    CliSymbolAsciiUS = 0x1F,
+    CliSymbolAsciiSpace = 0x20,
+    CliSymbolAsciiDel = 0x7F,
+} CliSymbols;
+
 typedef struct {
     FuriString** stack;
     size_t pointer;
@@ -247,8 +261,7 @@ inline static bool continue_with_input(mp_flipper_repl_context_t* context) {
     return true;
 }
 
-void upython_repl_execute(PipeSide* pipe) {
-    UNUSED(pipe);
+void upython_repl_execute() {
     size_t stack;
 
     const size_t heap_size = memmgr_get_free_heap() * 0.1;
@@ -287,7 +300,7 @@ void upython_repl_execute(PipeSide* pipe) {
 
             // scan character loop
             do {
-                character = getchar();
+                character = getc(stdin);
 
                 // Ctrl + C
                 if(character == CliKeyETX) {
@@ -326,8 +339,8 @@ void upython_repl_execute(PipeSide* pipe) {
 
                 // handle arrow keys
                 if(character >= 0x18 && character <= 0x1B) {
-                    character = getchar();
-                    character = getchar();
+                    character = getc(stdin);
+                    character = getc(stdin);
 
                     handle_arrow_keys(character, context);
 
@@ -351,7 +364,8 @@ void upython_repl_execute(PipeSide* pipe) {
                 // append at end
                 if(context->cursor == furi_string_size(context->line)) {
                     buffer[0] = character;
-                    putchar(character);
+                    putc(buffer[0], stdout);
+                    fflush(stdout);
 
                     furi_string_push_back(context->line, character);
 

+ 1 - 2
upython_splash.c

@@ -4,8 +4,7 @@
 #include <gui/gui.h>
 #include <dialogs/dialogs.h>
 #include <storage/storage.h>
-#include <toolbox/cli/cli_command.h>
-#include <cli/cli_main_commands.h>
+#include <cli/cli.h>
 #include <cli/cli_vcp.h>
 
 #include <mp_flipper_runtime.h>