Oliver Fabel 1 год назад
Родитель
Сommit
e251b917bc

+ 2 - 2
Makefile.micropython

@@ -54,8 +54,8 @@ micropython-embed-package: $(GENHDR_OUTPUT)
 	$(Q)$(CP) $(TOP)/py/*.[ch] $(PACKAGE_DIR)/py
 	$(Q)$(CP) $(TOP)/py/*.[ch] $(PACKAGE_DIR)/py
 	$(ECHO) "- extmod"
 	$(ECHO) "- extmod"
 	$(Q)$(CP) $(TOP)/extmod/modplatform.h $(PACKAGE_DIR)/extmod
 	$(Q)$(CP) $(TOP)/extmod/modplatform.h $(PACKAGE_DIR)/extmod
-	$(Q)$(CP) $(TOP)/extmod/modtime.h $(PACKAGE_DIR)/extmod
-	$(Q)$(CP) $(TOP)/extmod/modtime.c $(PACKAGE_DIR)/extmod
+	$(Q)$(CP) $(TOP)/extmod/modtime.[ch] $(PACKAGE_DIR)/extmod
+	$(Q)$(CP) $(TOP)/extmod/modrandom.[ch] $(PACKAGE_DIR)/extmod
 	$(ECHO) "- shared"
 	$(ECHO) "- shared"
 	$(Q)$(CP) $(TOP)/shared/runtime/gchelper.h $(PACKAGE_DIR)/shared/runtime
 	$(Q)$(CP) $(TOP)/shared/runtime/gchelper.h $(PACKAGE_DIR)/shared/runtime
 	$(Q)$(CP) $(TOP)/shared/runtime/gchelper_generic.c $(PACKAGE_DIR)/shared/runtime
 	$(Q)$(CP) $(TOP)/shared/runtime/gchelper_generic.c $(PACKAGE_DIR)/shared/runtime

+ 0 - 0
examples/dict.py → examples/dict_test.py


+ 0 - 0
examples/gc.py → examples/gc_test.py


+ 0 - 0
examples/greeter.py → examples/greeter_test.py


+ 0 - 0
examples/hello.py → examples/hello_test.py


+ 1 - 1
examples/import.py → examples/import_test.py

@@ -1,4 +1,4 @@
-from greeter import Greeter
+from greeter_test import Greeter
 
 
 buddy = Greeter('buddy')
 buddy = Greeter('buddy')
 
 

+ 0 - 0
examples/overflow.py → examples/overflow_test.py


+ 7 - 0
examples/rand_test.py

@@ -0,0 +1,7 @@
+from random import randint, seed
+
+seed(None)
+
+for limit in range(2,100):
+  value = randint(2, limit)
+  print(value)

+ 0 - 0
examples/sleep.py → examples/sleep_test.py


+ 9 - 0
lib/micropython-port/modrandom.c

@@ -0,0 +1,9 @@
+#include <furi_hal.h>
+
+#include "modrandom.h"
+
+uint32_t mp_flipper_seed_init() {
+    furi_hal_random_init();
+
+    return furi_hal_random_get();
+}

+ 5 - 0
lib/micropython-port/modrandom.h

@@ -0,0 +1,5 @@
+#pragma once
+
+#include <stdint.h>
+
+uint32_t mp_flipper_seed_init();

+ 5 - 0
mpconfigport.h

@@ -31,3 +31,8 @@ typedef long mp_off_t;
 
 
 #define MICROPY_PY_TIME (1)
 #define MICROPY_PY_TIME (1)
 #define MICROPY_PY_TIME_TIME_TIME_NS (1)
 #define MICROPY_PY_TIME_TIME_TIME_NS (1)
+
+#define MICROPY_PY_RANDOM (1)
+#define MICROPY_PY_RANDOM_EXTRA_FUNCS (1)
+
+#define MICROPY_PY_RANDOM_SEED_INIT_FUNC (mp_flipper_seed_init())