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

Subcategories

  • Lessons and Guides for Uiflow

    125 Topics
    434 Posts
    A
    Hi, I'm a new user of M5stack products, having got an M5StickC Plus2 recently. It's a nice device, but the documentation isn't always accurate which makes learning how to use it a slow process. I tried to use the example for drawing a raw buffer to the screen here But it resulted in different garbled output each time and not a green rectangle. It seems that the len parameter is expecting 16-bit entries in the buffer so needs to be halved. Here's the code that works on my device (note the //2 for len parameter): width, height = 40, 30 green565 = 0x07E0 raw_buf = bytearray(width * height * 2) for i in range(width * height): raw_buf[2*i] = (green565 >> 8) & 0xFF raw_buf[2*i+1] = green565 & 0xFF Display.drawRawBuf(raw_buf, 100, 100, width, height, len(raw_buf)//2, swap=False) Hopefully this will help others and eventually get changed in the docs - assuming it's the same for all UIFlow2 supported devices? If anybody knows a fix to make it work properly for lower than 16bit depth screens so I can draw a raw buffer to a 1-bit canvas properly, please let me know!
  • 211 Topics
    789 Posts
    robskiR
    @GiovanniCaenazzo disconnect M5Dial press and hold boot button at the back ofM5Dial - in the middle of Stamp Controller - it is very gentle switch connect M5Dial to USB M5Burner should detect com port in boot mode
  • 11 Topics
    33 Posts
    A
    @jeanfabre On web, just choice block type. [image: 1729260517944-86b7a25c93207d9a32e5b33471bb1f0.png] For code, add return description like this: def func(self) -> int: return 0
  • Emoji with M5 Fire

    5
    0 Votes
    5 Posts
    7k Views
    F
    Thanx I used the old M5burner, as the new one is for Windows10. Apparently it is ok with windows 7 too
  • Atom Stepmotor minimum code

    1
    0 Votes
    1 Posts
    3k Views
    No one has replied
  • HTTP Block Gives Error

    5
    1
    0 Votes
    5 Posts
    13k Views
    G
    @world101 sorry for delay on answering. Many thanks it works as expected! In the meanwhile i tried with upython language also to manage more complex json structures.
  • GPS and LoRaWAN Modules together

    1
    1 Votes
    1 Posts
    4k Views
    No one has replied
  • [Mac OS] UIFlow IDE copy paste don't works

    1
    1 Votes
    1 Posts
    4k Views
    No one has replied
  • Quick average demo

    2
    1
    0 Votes
    2 Posts
    3k Views
    world101W
    👍🏻 thanks
  • How to get the position on X and Y of an object?

    3
    0 Votes
    3 Posts
    6k Views
    M
    Wow, thank you, sure this works.
  • Guidance on operatinal mode

    1
    0 Votes
    1 Posts
    4k Views
    No one has replied
  • Esp now m5stickC problem

    5
    0 Votes
    5 Posts
    10k Views
    P
    Hi all, Very curious to give something similar a go. Driving a 5V motor over ESP now using the Joystick Unit at the transmit end. 2 x M5 Stack. Anybody have a UI Flow file I can modify? Kind regards, Paul
  • PYP SIM800L

    4
    0 Votes
    4 Posts
    8k Views
    E
    Nothing spectacular either trials via module or the example do not work what is the order to initiate GPRS transmition - upload to a server? This second attempt throws name 'pyb' isn't defined from m5stack import * from m5ui import * from uiflow import * import module setScreenColor(0x222222) Driver for SIM800L module (using AT commands) MIT License; Copyright (c) 2017 Jeffrey N. Magee https://github.com/jeffmer/micropython-upyphone import math kludge required because "ignore" parameter to decode not implemented def convert_to_string(buf): try: tt = buf.decode('utf-8').strip() return tt except UnicodeError: tmp = bytearray(buf) for i in range(len(tmp)): if tmp[i]>127: tmp[i] = ord('#') return bytes(tmp).decode('utf-8').strip() class SIM800LError(Exception): pass def check_result(errmsg,expected,res): if not res: res = 'None' #print(errmsg+res) if not expected == res and not res == 'None': raise SIM800LError('SIM800L Error {} {}'.format(errmsg,res)) class SIM800L: def __init__(self,uartno): # pos =1 or 2 depending on skin position self._uart = pyb.UART(uartno, 9600, read_buf_len=2048) self.incoming_action = None self.no_carrier_action = None self.clip_action = None self._clip = None self.msg_action = None self._msgid = 0 self.savbuf = None self.credit = '' self.credit_action = None def callback_incoming(self,action): self.incoming_action = action def callback_no_carrier(self,action): self.no_carrier_action = action def callback_clip(self,action): self.clip_action = action def callback_credit_action(self,action): self.credit_action = action def get_clip(self): return self._clip def callback_msg(self,action): self.msg_action = action def get_msgid(self): return self._msgid def command(self, cmdstr, lines=1, waitfor=500, msgtext=None): #flush input #print(cmdstr) while self._uart.any(): self._uart.readchar() self._uart.write(cmdstr) if msgtext: self._uart.write(msgtext) # if waitfor>1000: # pyb.delay(waitfor-1000) buf=self._uart.readline() #discard linefeed etc #print(buf) buf=self._uart.readline() #print(buf) if not buf: return None result = convert_to_string(buf) if lines>1: self.savbuf = '' for i in range(lines-1): buf=self._uart.readline() if not buf: return result #print(buf) buf = convert_to_string(buf) if not buf == '' and not buf == 'OK': self.savbuf += buf+'\n' return result def setup(self): self.command('ATE0\n') # command echo off self.command('AT+CRSL=99\n') # ringer level self.command('AT+CMIC=0,10\n') # microphone gain self.command('AT+CLIP=1\n') # caller line identification self.command('AT+CMGF=1\n') # plain text SMS self.command('AT+CALS=3,0\n') # set ringtone self.command('AT+CLTS=1\n') # enabke get local timestamp mode self.command('AT+CSCLK=0\n') # disable automatic sleep def wakechars(self): self._uart.write('AT\n') # will be ignored # pyb.delay(100) def sleep(self,n): self.command('AT+CSCLK={}\n'.format(n)) def sms_alert(self): self.command('AT+CALS=1,1\n') # set ringtone # pyb.delay(3000) self.command('AT+CALS=3,0\n') # set ringtone def call(self,numstr): self.command('ATD{};\n'.format(numstr)) def hangup(self): self.command('ATH\n') def answer(self): self.command('ATA\n') def set_volume(self,vol): if (vol>=0 and vol<=100): self.command('AT+CLVL={}\n'.format(vol)) def signal_strength(self): result = self.command('AT+CSQ\n',3) if result: params=result.split(',') if not params[0] == '': params2 = params[0].split(':') if params2[0]=='+CSQ': x = int(params2[1]) if not x == 99: return(math.floor(x/6+0.5)) return 0 def battery_charge(self): result = self.command('AT+CBC\n',3,1500) if result: params=result.split(',') if not params[0] == '': params2 = params[0].split(':') if params2[0]=='+CBC': return int(params[1]) return 0 def network_name(self): result = self.command('AT+COPS?\n',3) if result: params=result.split(',') if not params[0] == '': params2 = params[0].split(':') if params2[0]=='+COPS': if len(params)>2: names = params[2].split('"') if len(names)>1: return names[1] return '' def read_sms(self,id): result = self.command('AT+CMGR={}\n'.format(id),99) if result: params=result.split(',') if not params[0] == '': params2 = params[0].split(':') if params2[0]=='+CMGR': number = params[1].replace('"',' ').strip() date = params[3].replace('"',' ').strip() time = params[4].replace('"',' ').strip() return [number,date,time,self.savbuf] return None def send_sms(self,destno,msgtext): result = self.command('AT+CMGS="{}"\n'.format(destno),99,5000,msgtext+'\x1A') if result and result=='>' and self.savbuf: params = self.savbuf.split(':') if params[0]=='+CUSD' or params[0] == '+CMGS': return 'OK' return 'ERROR' def check_credit(self): self.command('AT+CUSD=1,"*100#"\n') def get_credit(self): return self.credit def delete_sms(self,id): self.command('AT+CMGD={}\n'.format(id),1) def date_time(self): result = self.command('AT+CCLK?\n',3) if result: if result[0:5] == "+CCLK": return result.split('"')[1] return '' def check_incoming(self): if self._uart.any(): buf=self._uart.readline() # print(buf) buf = convert_to_string(buf) params=buf.split(',') if params[0] == "RING": if self.incoming_action: self.incoming_action() elif params[0][0:5] == "+CLIP": params2 = params[0].split('"') self._clip = params2[1] if self.clip_action: self.clip_action() elif params[0][0:5] == "+CMTI": self._msgid = int(params[1]) if self.msg_action: self.msg_action() elif params[0][0:5] == "+CUSD": if len(params)>1: st = params[1].find('#') en = params[1].find('.',st) en = params[1].find('.',en+1) if st>0 and en>0: self.credit = '£'+params[1][st+1:en] if self.credit_action: self.credit_action() elif params[0] == "NO CARRIER": self.no_carrier_action() # http get command using gprs def http_get(self,url,apn="giffgaff.com"): resp = None rstate = 0 proto, dummy, surl = url.split("/", 2) is_ssl = 0 if proto == "http:": is_ssl = 0 elif proto == "https:": is_ssl == 1 else: raise ValueError("Unsupported protocol: " + proto) try: # open bearer context res = self.command('AT+SAPBR=3,1,"Contype","GPRS"\n') check_result("SAPBR 1: ",'OK',res) res = self.command('AT+SAPBR=3,1,"APN","{}"\n'.format(apn)) check_result("SAPBR 2: ",'OK',res) res = self.command('AT+SAPBR=1,1\n',1,2000) check_result("SAPBR 3: ",'OK',res) # now do http request res = self.command('AT+HTTPINIT\n',1) check_result("HTTPINIT: ",'OK',res) res = self.command('AT+HTTPPARA="CID",1\n') check_result("HTTPPARA 1: ",'OK',res) res = self.command('AT+HTTPPARA="URL","{}"\n'.format(surl)) check_result("HTTPPARA 2: ",'OK',res) res = self.command('AT+HTTPSSL={}\n'.format(is_ssl)) check_result("HTTPSSL: ",'OK',res) res = self.command('AT+HTTPACTION=0\n') check_result("HTTPACTION: ",'OK',res) for i in range(20): #limit wait to max 20 x readline timeout buf = self._uart.readline() if buf and not buf==b'\r\n': buf = convert_to_string(buf) #print(buf) prefix,retcode,bytes = buf.split(',') rstate = int(retcode) nbytes = int(bytes) break res = self.command('AT+HTTPREAD\n',1) buf = self._uart.read(nbytes) check_result("HTTPACTION: ",'+HTTPREAD: {}'.format(nbytes),res) if buf[-4:] == b'OK\r\n': # remove final OK if it was read buf = buf[:-4] resp = Response(buf) except SIM800LError as err: print(str(err)) self.command('AT+HTTPTERM\n',1) # terminate HTTP task self.command('AT+SAPBR=0,1\n',1) # close Bearer context return resp def test(self): r = self.http_get('http://exploreembedded.com/wiki/images/1/15/Hello.txt') print(r.text) class Response: def __init__(self, buf, status = 200): self.encoding = "utf-8" self._cached = buf self.status = status def close(self): self._cached = None @property def content(self): return self._cached @property def text(self): return str(self.content, self.encoding) def json(self): import ujson return ujson.loads(self.content) phone = SIM800L(1) print(phone.signal_strength())
  • UIFlow for Atom Echo

    6
    0 Votes
    6 Posts
    11k Views
    world101W
    @m5stack regarding the Attention note, will it damage the Atom Echo to play streaming music over BLE for long periods (several songs or hours of streaming music)?
  • HttpPost using UIflow

    13
    0 Votes
    13 Posts
    25k Views
    R
    @franco see the python code tab. The urequests statement comes immediately after the try statement. If something goes wrong, e.g. a typo in the address (non-existent address), this requests instruction will be treated as if it never started and the blocks Get Data and Get Status Code will not return anything and probably their use in this case cause a error.
  • GPS-Unit: Missing speed value

    4
    0 Votes
    4 Posts
    7k Views
    m5stackM
    @gaviota In subsequent updates we will add it.
  • How Do I connect ENV II in UIFlow

    2
    0 Votes
    2 Posts
    4k Views
    SkinkS
    @jhonnytank said in How Do I connect ENV II in UIFlow: I am trying to connect env II in UIFlow. In the Unit-Slector it is crossed out. Is there a method to add a suitable driver? Yes you have to take the UIFlow 1.6.0 Beta Version where you can select both ENV Units again ! Skink See Picture :[image: 1595075697711-uiflow-1.6.0-env-einheit-resized.jpg]
  • change the speed of only one of the three motors.

    3
    1
    0 Votes
    3 Posts
    5k Views
    moon3jpM
    @m5stack disappointment!!
  • How to use the infrared Diode in UI-Flow?

    2
    0 Votes
    2 Posts
    5k Views
    C
    @jhonnytank It turned on by setting pin 9 to low. I don't believe there is a photodiode; so I am picking up a arduino remote kit to read my remote a week from Friday. I can post my results when I have them if you want.
  • Bluetooth support

    17
    0 Votes
    17 Posts
    35k Views
    J
    Is there any official update on this topic? Is bluetooth gonna be supported? Thanks
  • cardkb GetKey comparison

    9
    1
    0 Votes
    9 Posts
    11k Views
    X
    @ajb2k3 sure, here you go: It didn't seem to matter where I put key = getKey, also it's really messy, but it's working for now. [image: 1594456315352-cardkb1.png]
  • Support multiple files

    4
    0 Votes
    4 Posts
    8k Views
    m5stackM
    @jesuslg123 oh ~i see... you mean is hope user could create some page. and use block to control which page will display in the screen? right? .. that is a good idea , actually our engineer have ever considered this. so maybe this function will in the future release.
  • HTTP Get - Empty response body

    9
    0 Votes
    9 Posts
    18k Views
    J
    So, I could workaround this issue after some work and before close and forget this thread here forever, let me share it: The problem: GoPro wifi API is not fully following the HTTP protocol specifications. Headers and body content is separated by \n instead of \r\n uRequests library is very strict on response parsing, while mostly any other libraries/browser/etc handle requests with some "malformed" bodies, uRequests does not. UIFlow IDE solution: Upload to the Stick5C the modified version of uRequests [image: 1594223907346-screenshot-2020-07-08-at-17.39.09.png] Override the uRequests library usage with a new import using execute code block. [image: 1594223971529-screenshot-2020-07-08-at-17.37.42.png] From that moment on (only on this app) it will use the modified library. No UIFlow IDE solution: Stop using UIFlow IDE 😢 Upload to the Stick5C the modified version of uRequests Use Visual Studio code or any other IDE to continue the development. Override the uRequests library usage with a new import on the code. I hope this is useful to someone else, any suggestion is also more than welcome. Thanks 😄