
Posts made by felmue
-
RE: Micropython, CardComputer - issue reading Keyboard
Hello @MartynW
I tried your code and changed two things to make it work:
- changed the inputs to pullups (as you already thought it should be) - the output matrix then is all 1s except for the button pressed.
- used some additional brackets for A1 and A2 to force the AND operation to happen first
self.pinMap['A0'].value( row & 0b001 ) self.pinMap['A1'].value( ( row & 0b010 ) >> 1 ) self.pinMap['A2'].value( ( row & 0b100 ) >> 2 )
Full code:
from time import sleep_ms from machine import Pin class KeyBoard(): def __init__(self): keyPins = [ ('C0', 13, Pin.IN, Pin.PULL_UP), ('C1', 15, Pin.IN, Pin.PULL_UP), ('C2', 3, Pin.IN, Pin.PULL_UP), ('C3', 4, Pin.IN, Pin.PULL_UP), ('C4', 5, Pin.IN, Pin.PULL_UP), ('C5', 6, Pin.IN, Pin.PULL_UP), ('C6', 7, Pin.IN, Pin.PULL_UP), ('A0', 8, Pin.OUT, None), ('A1', 9, Pin.OUT, None), ('A2', 11, Pin.OUT, None) ] self.pinMap = dict() for (name, pin, direction, pull) in keyPins: self.pinMap[name] = Pin(pin, direction, pull) def scan(self): for row in range(0,8): self.pinMap['A0'].value( row & 0b001 ) self.pinMap['A1'].value( ( row & 0b010 ) >> 1 ) self.pinMap['A2'].value( ( row & 0b100 ) >> 2 ) sleep_ms(250) print(f'{row:04b}\t',end='') for col in ['C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6']: sleep_ms(0) val = self.pinMap[col].value() print(f'{val:01b} ', end='') print('') print('\n\n\n\n') def scan2(self): for row in (7, 3, 6, 2, 5, 1, 4, 0): self.pinMap['A0'].value( row & 0b001 ) self.pinMap['A1'].value( ( row & 0b010 ) >> 1 ) self.pinMap['A2'].value( ( row & 0b100 ) >> 2 ) sleep_ms(250) print(f'{row:04b}\t',end='') for col in ['C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6']: sleep_ms(0) val = self.pinMap[col].value() print(f'{val:01b} ', end='') print('') print('\n\n\n\n') keyboard = KeyBoard() while True: keyboard.scan() # keyboard.scan2() sleep_ms(500)
BTW: I like your coding style with the pinMap etc. (Note: I am not very familiar with Micropython.)
Thanks
Felix -
RE: mqtt and button on atomS3
Hello @alwa123
it looks like the MQTT library used is called
umqtt
. It has two methods to wait/check for server messages:wait_msg()
andcheck_msg()
. The former is blocking, the latter is non blocking. See here - section API reference.The block
MQTT apply for messaging
createsmqtt_client.wait_msg()
, the blocking variant. In order for the button events to work the non blocking variant should be used inloop()
.This can be done with an
Execute code
block containingmqtt_client.check_msg()
. See below.@m5stack : could you please add an MQTT block for the non blocking variant?
Thanks
Felix -
RE: Pb.Hub and RGB Unit
Hello guys
I received a PbHub v1.1 (STM32 version) today and I can confirm too that only one RGB LED can be driven.
@m5stack : could you please elaborate what exactly the issue is? The documentation says that the default number of RGB LEDs for the STM32 version PbHub is 74 (seventy four). How can I use more than one RGB LED? Do I need an external power supply?
Thanks
Felix -
RE: M5Dial - Button not working?
Hello @Fredde
make sure you have the
Update button, touch, etc. in loop
block activated inloop
. E.g.def loop(): global label0 M5.update()
Thanks
Felix -
RE: Cannot compile M5Paper Weather sketch
Hello @Steve1
looks like that issue isn't new. See here.
Maybe try to contact the owner of the code?
Thanks
Felix -
RE: Cardputer & Sensors
Hello @Bipman
by default Port A is meant for I2C, but it can be used for I/O (Port B) or UART (Port C) as well.
Note: But please be aware, that it can be only one type of port at any given time. Also, since its default use is Port A (I2C) there are internal pull-up resistors (10 k) in place on both lines which might have a negative effect when used in a different mode.
If you need Port A and Port B at the same time there is the PbHUB unit which can be used to connect some of the Port B units.
If you need all three types of ports (A, B and C) together then I am afraid M5Cardputer is the wrong device to use as core. There are simply no more GPIOs available for a dedicated Port B and/or Port C. Please see schematic here.
Thanks
Felix -
RE: Cardputer & Sensors
Hello @Bipman
the Cardputer does have a Port A on the side like most cores. See documentation here.
Thanks
Felix -
RE: RCT M5Atom Lite
Hello @vgamlc
no, the M5Atom Lite doesn't have an integrated RTC (RealTimeClock). Please also see here.
That said, you can add one using the RTC unit.
Thanks
Felix -
RE: M5Dial mising nfc machine module...
Hello @jamesarm97
please check out the example code below to get the card UID into an UIFlow2 label.
Notes:
- you need to create a label first
- observe the
global rdr
statement at the top of the firstExecute code
block. It is required to make the functiongetUID
work - observe the function
getUID
is of the type with return parameter, although it is not set. The return value is set by thereturn
statement in theExecute code
block.
Please find the complete example here.
Thanks
Felix -
RE: M5Dial mising nfc machine module...
Hello guys
I found an existing MFRC522 library which I modified so it can be used with UIFlow2 and M5Dial.
The
mrfc522.py
library file can be downloaded into M5Dial using Chrome, UIFlow2 and itsDevice File Manager
. Place it alongside the already existingboot.py
andmain.py
.After that you can use an
Execute code
block to run an example to read the version, scan, read or write a card.Note : tested with UIFlow2.0.0 Alpha-28 firmware.
Thanks
Felix -
RE: Flow 2 Execute block
Hello @nunley21
in UIFlow2 the
Execute code
block is underSystem
.Edit: looks like @dozauk was quicker!
Thanks
Felix -
RE: Resetting RTC flag
Hello @Steve1
well, there is an alternative method you could use. The power button also acts as regular button. So you could check if the power button was still pressed when M5Paper starts running. Something like this at the beginning of
setup()
:M5.begin(true, false, true, true, true); M5.RTC.begin(); M5.update(); bool pwrBtnStart = M5.BtnP.isPressed(); // true if started by PWR button
Note: for it to work you'll need to press and hold the power button long enough for the code to reach the statement checking the button. In my tests I need to hold the power button for about 5 seconds.
Note: a disadvantage of the power button check method is that when M5Paper is powered on by USB it thinks it was an RTC start.
Thanks
Felix -
RE: Core2 with 4 Relay UNIT, example code crashes
Hello @Pugmartin
you are correct, the example is broken in at least two ways. Firstly it doesn't compile and secondly a statement is missing.
I had success compiling using the example here.
To fix the crash it needs a small fix in
setup()
- add this line beforerelay.init(0)
:relay.begin(); // new line relay.init(0); // existing line
Thanks
Felix -
RE: Resetting RTC flag
Hello @Steve1
try to check the timer interrupt enable bit as well, like this:
if ((data & 0b00000101) == 0b00000101)
Thanks
Felix -
RE: M5 Stack Dial Fail buning
Hello @MiAutomations
M5Dial contains an M5StampS3 which can be forced into download mode via button. See documentation here.
To enter the download mode, press the G0 button on StampS3 at boot time.
BTW: UIFlow2 firmware is not the M5 Stack Dial Demo which was pre-installed on M5Dial.
You can find the M5Dial demo code here.
Thanks
Felix -
RE: Converting M5CoreInk sketch to M5Paper
Hello @Steve1
what makes you think it doesn't wake up anymore? Knowing whether M5Paper is actually running or not can be tricky as the data on the display stays w/ or w/o power.
Anyways, when I run your code with USB power connected, then yes, it looks like it never wakes up, but in reality it stays powered on and just idles in
loop()
.In contrast, when I run your code from battery, it actually does shutdown and restarts after about 5 seconds.
Note: M5Paper cannot shutdown as long as it is powered by USB.
Thanks
Felix -
RE: UIFlow V1.12.8 Atom Lite RTC read error
Hello @Piet
not sure what's going on. I can read hours, minutes and seconds just fine. Below code runs without error for me.
from m5stack import * from m5ui import * from uiflow import * import unit rtc_0 = unit.get(unit.RTC8563, unit.PORTA) print(rtc_0.get_date_time(2)) print(rtc_0.get_date_time(1)) print(rtc_0.get_date_time(0))
Which UIFlow firmware version is installed on your M5Atom Lite? I have UIFlow firmware v1.12.8 running on my M5Atom Lite.
Thanks
Felix