From loopspace at mathforge.org Sat Apr 1 12:07:02 2017 From: loopspace at mathforge.org (Andrew Stacey) Date: Sat, 1 Apr 2017 17:07:02 +0100 Subject: [Microbit-Python] Microbit+Lego project Message-ID: Hi all, I just wanted to post a link to a video and some code relating to a project I've been working on using a micro:bit to control a Lego Mindstorms EV3 robot. It uses ev3dev on the Lego brick, meaning that the entire code can be written in python of one flavour or other. The project uses two micro:bits. One is portable and it sends information about its state (accelerometer and buttons) via radio to a second micro:bit. That second micro:bit is connected to the Lego brick via a USB cable and just relays the information received down that cable. Finally, the EV3 reads that information and interprets it into instructions to drive the robot. As part of this, I wrote a simple module for presenting the micro:bit information to the main script which can be used with other python programs - at my github repository (linked below) I have examples using PyGame and the python turtle library. I'm sure it could be improved, but the aim was to make it so that students, say, could focus on what they wanted the micro:bit to control rather than fiddling with settings for serial ports. I hope that this is of interest to some of you. I'd like to acknowledge the help of this list in understanding the various bits involved. There's still plenty that's a bit rough at the edges, I'm sure. Video: https://youtu.be/IQCpcFz_93M Code: https://github.com/loopspace/microbit Andrew From bunce.joe at gmail.com Sat Apr 8 17:31:20 2017 From: bunce.joe at gmail.com (Joseph Bunce) Date: Sat, 8 Apr 2017 22:31:20 +0100 Subject: [Microbit-Python] JSON on micro:bit Message-ID: Hello, In the micro python (not micro:bit) documentation, it seems you can get access to the ujson library which has the basic dumps() and loads() methods. Is it possable to access this on the micro:bit an it does not seem to ba a listed module? I am aware that you can sortof use eval() to achieve the same end but this is generally very much suggested against. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From damien.p.george at gmail.com Sat Apr 8 20:57:58 2017 From: damien.p.george at gmail.com (Damien George) Date: Sun, 9 Apr 2017 10:57:58 +1000 Subject: [Microbit-Python] JSON on micro:bit In-Reply-To: References: Message-ID: No, the ujson library is not enabled on the micro:bit, due to size constraints. On 9 April 2017 at 07:31, Joseph Bunce wrote: > Hello, > > In the micro python (not micro:bit) documentation, it seems you can get > access to the ujson library which has the basic dumps() and loads() > methods. Is it possable to access this on the micro:bit an it does not seem > to ba a listed module? I am aware that you can sortof use eval() to achieve > the same end but this is generally very much suggested against. > > Thanks. > > _______________________________________________ > Microbit mailing list > Microbit at python.org > https://mail.python.org/mailman/listinfo/microbit > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bunce.joe at gmail.com Sun Apr 9 05:36:00 2017 From: bunce.joe at gmail.com (Joseph Bunce) Date: Sun, 9 Apr 2017 10:36:00 +0100 Subject: [Microbit-Python] JSON on micro:bit In-Reply-To: References: Message-ID: Is there any other way to load and dump JSON then or not? On Sunday, 9 April 2017, Damien George wrote: > No, the ujson library is not enabled on the micro:bit, due to size > constraints. > > On 9 April 2017 at 07:31, Joseph Bunce > wrote: > >> Hello, >> >> In the micro python (not micro:bit) documentation, it seems you can get >> access to the ujson library which has the basic dumps() and loads() >> methods. Is it possable to access this on the micro:bit an it does not seem >> to ba a listed module? I am aware that you can sortof use eval() to achieve >> the same end but this is generally very much suggested against. >> >> Thanks. >> >> _______________________________________________ >> Microbit mailing list >> Microbit at python.org >> https://mail.python.org/mailman/listinfo/microbit >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From damien.p.george at gmail.com Sun Apr 9 06:11:03 2017 From: damien.p.george at gmail.com (Damien George) Date: Sun, 9 Apr 2017 20:11:03 +1000 Subject: [Microbit-Python] JSON on micro:bit In-Reply-To: References: Message-ID: Unfortunately there is no easy way to deal with JSON data. You could write your own parser/formatter in Python, or you could copy across the code from the main MicroPython repository for the ujson module and compile it into your own custom firmware. On 9 April 2017 at 19:36, Joseph Bunce wrote: > Is there any other way to load and dump JSON then or not? > > > On Sunday, 9 April 2017, Damien George wrote: > >> No, the ujson library is not enabled on the micro:bit, due to size >> constraints. >> >> On 9 April 2017 at 07:31, Joseph Bunce wrote: >> >>> Hello, >>> >>> In the micro python (not micro:bit) documentation, it seems you can get >>> access to the ujson library which has the basic dumps() and loads() >>> methods. Is it possable to access this on the micro:bit an it does not seem >>> to ba a listed module? I am aware that you can sortof use eval() to achieve >>> the same end but this is generally very much suggested against. >>> >>> Thanks. >>> >>> _______________________________________________ >>> Microbit mailing list >>> Microbit at python.org >>> https://mail.python.org/mailman/listinfo/microbit >>> >>> >> > _______________________________________________ > Microbit mailing list > Microbit at python.org > https://mail.python.org/mailman/listinfo/microbit > > -------------- next part -------------- An HTML attachment was scrubbed... URL: