🤖Have you ever tried Chat.M5Stack.com before asking??😎

Subcategories

  • 7 Topics
    19 Posts
    J
    @pabou try using uiflow to generate the code, then peek copy from there.
  • Can not get signal from GPIO 36

    2
    0 Votes
    2 Posts
    3k Views
    felmueF
    Hello @shliao GPIO36 does not support internal software pull-ups. So if your hardware setup requires a pull-up, you'll need to add an external pull-up resistor. Excerpt from this documentation: GPIO34-39 can only be set as input mode and do not have software pullup or pulldown functions. BTW: your Python code is ok and returns 1 when I connect GPIO36 to 3.3 V. Thanks Felix
  • when call TFT_eSprite drawString, crash down

    1
    0 Votes
    1 Posts
    3k Views
    No one has replied
  • Updated Micropython?

    5
    4 Votes
    5 Posts
    10k Views
    T
    @m5stack What is current fw build based on ? I mean version of mainstream micropy? Thanks
  • GPS (AT6558) at Thonny editor

    2
    0 Votes
    2 Posts
    5k Views
    S
    Hi, In GRAY M5STACK unfortunatelly PortA is used for I2C to some internal chip. Sometime GPS not work on Grove Cable. Just connect GPS to 16RX <<< TX White 17TX >>> Rx Yellow And all start working with no problem. Example code from Arduino works if You add #define RX1 16 #define TX1 17 ... void setup() { M5.begin(); M5.Power.begin(); GPSRaw.begin(9600, SERIAL_8N1,RX1,TX1); [image: 1620524778731-30c66d7b-be90-4ac1-80ac-0815ae8019a6-image-resized.png]
  • Available working! IDE for Micropython?

    1
    1 Votes
    1 Posts
    4k Views
    No one has replied
  • Core2 vs. Core

    3
    0 Votes
    3 Posts
    11k Views
    R
    If the M5 firmware is close to the upstream MicroPython, you can: import gc gc.mem_free() And it will print the available free memeory gc.collect() Will run the memory garbage collection to free up memory that is no longer being used. You can gc.collect() somewhere in your main loop to make sure memory is kept tidy. See the gc module page for more information https://docs.micropython.org/en/latest/library/gc.html?highlight=gc#module-gc
  • Avoid LCD Flicker When Updating Text on M5StickC?

    6
    0 Votes
    6 Posts
    15k Views
    A
    You can always use sprites to get rid of flicker. It happens because you write to LCD in runtime which is slow. Try sprites; First, create a sprite and set the size. Then fill it in black to avoid overwriting text. disp_buffer = new TFT_eSprite(&M5.Lcd); disp_buffer->setSwapBytes(false); disp_buffer->createSprite(240, 135); disp_buffer->fillRect(0, 0, 240, 135, BLACK); Then write desired text and push it to screen. disp_buffer->drawString("This is some text", 0, 0, 2); disp_buffer->pushSprite(0, 0);
  • UIFlow import asyncio

    5
    0 Votes
    5 Posts
    11k Views
    A
    Any update on asynchronous Json client communications please...
  • Special character handling - MQTT error

    5
    0 Votes
    5 Posts
    11k Views
    M
    So my last comment provided the solution.... The correct way of doing this is : 1/ Specify the Unicode character in the payload with chr(186) where 186 is the character number (in this case representing MASCULINE ORDINAL INDICATOR - Unicode: U+00BA, UTF-8: C2 BA. 2/ Ensure that your json.dumps applies utf-8 encoding before sending it to MQTT as follows: m5mqtt.publish(topic, json.dumps(payload).encode('utf-8')) Problem solved.
  • Newbie question - how to get started?

    19
    0 Votes
    19 Posts
    37k Views
    M
    Github repository of my MQTT Thermostat running on Core2 is here. It's pretty cool. The thermostat supports various modes: off/auto/manual/heat/cool/fan. You can specify minimum cycle duration as well as set swing mode parameters. It automatically gets discovered by Home Assistant. You can set thermostat mode and target temperature in Home Assistant and they will automatically get reflected on the Core2 display. It currently relies on the ENVII module for temperature reading, and requires a WIFI connection and an active MQTT broker. I haven't had time to implement error handling, so if something goes wrong, it might be non-obvious to figure out why. More work to be done. I couldn't figure out how to enable touch for a specific screen area without using visible buttons with M5stack_UI, so instead I used an lvgl button with invisible borders.
  • Preferred development flow

    5
    0 Votes
    5 Posts
    11k Views
    M
    @zontex nice .. finally smth I can debug with easily
  • Where is the WiFi config held?

    9
    1 Votes
    9 Posts
    21k Views
    D
    Rshell works pretty well, although the newer M5 releases are a lot harder to get into the correct mode, particularly on the atom. Uiflow is micropython: I have often written something in uiflow and then switched to the micropython side to see what the python is for a given uiflow thing. And then I can cut and paste into repl. For long-term debugging (fails once a day or week), I leave the device connected to putty. I have considered adding code that would catch Exception () in the main loop, do a stack trace, and save it into a file so that I don't need it to always be connected, but have never implemented it.
  • M5Stick-C-Plus LCD-Driver

    4
    0 Votes
    4 Posts
    9k Views
    B
    What they could possibly do is release a uiflow free firmware version where the modules would be frozen and you could access them directly. But in this case, anyone here could do it, by taking the micropython vanilla and freezing the C drivers in it. Like the Lobo version. But we are ignorant and lazy.
  • How to install MicroPython libraries? (HTTP GET with query parameters)

    4
    0 Votes
    4 Posts
    10k Views
    M
    Well, and there is always the option to just strip it down to the basics. # urlencode.py _ALWAYS_SAFE = frozenset(b'ABCDEFGHIJKLMNOPQRSTUVWXYZ' b'abcdefghijklmnopqrstuvwxyz' b'0123456789' b'_.-') _ALWAYS_SAFE_BYTES = bytes(_ALWAYS_SAFE) def quote(string, safe='/', encoding=None, errors=None): """quote('abc def') -> 'abc%20def' Each part of a URL, e.g. the path info, the query, etc., has a different set of reserved characters that must be quoted. RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists the following reserved characters. reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," Each of these characters is reserved in some component of a URL, but not necessarily in all of them. By default, the quote function is intended for quoting the path section of a URL. Thus, it will not encode '/'. This character is reserved, but in typical usage the quote function is being called on a path where the existing slash characters are used as reserved characters. string and safe may be either str or bytes objects. encoding must not be specified if string is a str. The optional encoding and errors parameters specify how to deal with non-ASCII characters, as accepted by the str.encode method. By default, encoding='utf-8' (characters are encoded with UTF-8), and errors='strict' (unsupported characters raise a UnicodeEncodeError). """ if isinstance(string, str): if not string: return string if encoding is None: encoding = 'utf-8' if errors is None: errors = 'strict' string = string.encode(encoding, errors) else: if encoding is not None: raise TypeError("quote() doesn't support 'encoding' for bytes") if errors is not None: raise TypeError("quote() doesn't support 'errors' for bytes") return quote_from_bytes(string, safe) def quote_plus(string, safe='', encoding=None, errors=None): """Like quote(), but also replace ' ' with '+', as required for quoting HTML form values. Plus signs in the original string are escaped unless they are included in safe. It also does not have safe default to '/'. """ # Check if ' ' in string, where string may either be a str or bytes. If # there are no spaces, the regular quote will produce the right answer. if ((isinstance(string, str) and ' ' not in string) or (isinstance(string, bytes) and b' ' not in string)): return quote(string, safe, encoding, errors) if isinstance(safe, str): space = ' ' else: space = b' ' string = quote(string, safe + space, encoding, errors) return string.replace(' ', '+') def quote_from_bytes(bs, safe='/'): """Like quote(), but accepts a bytes object rather than a str, and does not perform string-to-bytes encoding. It always returns an ASCII string. quote_from_bytes(b'abc def\x3f') -> 'abc%20def%3f' """ if not isinstance(bs, (bytes, bytearray)): raise TypeError("quote_from_bytes() expected bytes") if not bs: return '' if isinstance(safe, str): # Normalize 'safe' by converting to bytes and removing non-ASCII chars safe = safe.encode('ascii', 'ignore') else: safe = bytes([c for c in safe if c < 128]) if not bs.rstrip(_ALWAYS_SAFE_BYTES + safe): return bs.decode() try: quoter = _safe_quoters[safe] except KeyError: _safe_quoters[safe] = quoter = Quoter(safe).__getitem__ return ''.join([quoter(char) for char in bs]) def urlencode(query, doseq=False, safe='', encoding=None, errors=None): """Encode a dict or sequence of two-element tuples into a URL query string. If any values in the query arg are sequences and doseq is true, each sequence element is converted to a separate parameter. If the query arg is a sequence of two-element tuples, the order of the parameters in the output will match the order of parameters in the input. The components of a query arg may each be either a string or a bytes type. When a component is a string, the safe, encoding and error parameters are sent to the quote_plus function for encoding. """ if hasattr(query, "items"): query = query.items() else: # It's a bother at times that strings and string-like objects are # sequences. try: # non-sequence items should not work with len() # non-empty strings will fail this if len(query) and not isinstance(query[0], tuple): raise TypeError # Zero-length sequences of all types will get here and succeed, # but that's a minor nit. Since the original implementation # allowed empty dicts that type of behavior probably should be # preserved for consistency except TypeError: # ty, va, tb = sys.exc_info() raise TypeError("not a valid non-string sequence " "or mapping object")#.with_traceback(tb) l = [] if not doseq: for k, v in query: if isinstance(k, bytes): k = quote_plus(k, safe) else: k = quote_plus(str(k), safe, encoding, errors) if isinstance(v, bytes): v = quote_plus(v, safe) else: v = quote_plus(str(v), safe, encoding, errors) l.append(k + '=' + v) else: for k, v in query: if isinstance(k, bytes): k = quote_plus(k, safe) else: k = quote_plus(str(k), safe, encoding, errors) if isinstance(v, bytes): v = quote_plus(v, safe) l.append(k + '=' + v) elif isinstance(v, str): v = quote_plus(v, safe, encoding, errors) l.append(k + '=' + v) else: try: # Is this a sufficient test for sequence-ness? x = len(v) except TypeError: # not a sequence v = quote_plus(str(v), safe, encoding, errors) l.append(k + '=' + v) else: # loop over the sequence for elt in v: if isinstance(elt, bytes): elt = quote_plus(elt, safe) else: elt = quote_plus(str(elt), safe, encoding, errors) l.append(k + '=' + elt) return '&'.join(l) Then we can finally do a nicer GET with parameters: import urequests from urlencode import urlencode url = 'http://server.tld/path/to' params = {'key1': 'value1', 'key2': 'value2'} if params: url = url.rstrip('?') + '?' + urlencode(params, doseq=True) print(url) response = urequests.get(url)
  • [Bug] Core2 loads JPG from flash but crashes with image from micro SD card

    10
    0 Votes
    10 Posts
    18k Views
    M
    Here we go, easy work-around for the faulty lcd.image(): from m5stack import * buffer = open("/sd/images/test.jpg").read() lcd.image_buff(lcd.CENTER, lcd.CENTER, buffer)
  • M5.Lcd.drawJpg in python

    5
    0 Votes
    5 Posts
    9k Views
    M
    Now I found working code for UIFlow 1.7.2, but this only supports PNGs: from m5stack import * from m5stack_ui import * screen = M5Screen() screen.clean_screen() screen.set_screen_bg_color(0xFFFFFF) image0 = M5Img("/sd/images/sled150.png", x=0, y=0, parent=None)
  • adding lvgl to the m5stack micropython build?

    2
    0 Votes
    2 Posts
    5k Views
    C
    Ok! So after connecting to the serial REPL on the Core2, it seems like the lvgl module is already setup on the UIFlow firmware, which is great. I just wish that was made more apparent in the documentation somewhere.
  • Getting started with M5Core2

    1
    0 Votes
    1 Posts
    4k Views
    No one has replied
  • micropython flowlib missing sources

    15
    2 Votes
    15 Posts
    30k Views
    U
    @m5stack said in micropython flowlib missing sources: @tialm we has plan to open source all Unit code. but maybe it need wait the UIFlow2.0 version finish 10 months later... So has there been any updates on this? If i knew this would end up in proprietary BS again i would have bought something else. Wasn't the whole point about learning to program Microcontrollers to NOT be some random companies b*tch? The device is great. But like this its just a blockly-toy.
  • Using the textwrap micropython module?

    2
    0 Votes
    2 Posts
    4k Views
    greenleafG
    I'd be open to any other methods you have for wrapping text. Or even generic instructions for importing external micropython modules... This works fine in my local python interpreter: from textwrap import * joke = "This is a really long joke. This is a really long joke.This is a really long joke.This is a really long joke.This is a really long joke." wrapper = textwrap.TextWrapper(width=30) print(wrapper.fill(joke)) But when I try to run it on the m5stack device I get: 'module' object has no attribute 'TextWrapper'