Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Cognitive5525
    3. Posts
    C
    • Continue chat with Cognitive5525
    • Start new chat with Cognitive5525
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by Cognitive5525

    • Core-Ink Screen rotation

      I have an application where I need to put the Core-Ink upside down, hence I would like to rotate the complete screen output 180 degrees. I use only text labels

      I tried to transform the output manually but I ran i to a problem with M5TextBox function.
      It seems to limit the maximum coordinates by some value that depends on the font size.

      Here I have two labels defined with corresponding python code in the M5Flow:
      0_1690295076455_42f69ce9-120e-4fa8-a460-e0f51ec9ae2e-image.png
      This code however does not work. LABEL_1 is not shown on the screen.
      I have to change the coordinates of the LABEL_1 to less than (160,160) and then the output works but looks like this:
      0_1690295613704_51e23bc1-7c3c-4932-8f8e-2e6aa314b51e-image.png
      The coordinates of the M5TextBox seems to be limited to (200 - <font size>) i.e. 160 for DejaVu40, 176 for DejaVu24 etc.

      I have also tried the lcd.setRotation() but it does not seem to do anything.

      Yes the screenshots are from the M5flow but I have tried this on the Core-Ink :)

      posted in PRODUCTS
      C
      Cognitive5525
    • RE: M5Paper Shutdown() / Deep Sleep / Wakeup

      @jop said in M5Paper Shutdown() / Deep Sleep / Wakeup:

      overload-2 int shutdown( int seconds );

      The timer function of the BM8563* is based on a 8 bit counter which can be set to be controlled by a clock frequency of 4096, 64, 1 or 1/60 Hz. This means it can timeout with following max interval @ resolution:

      62,3 ms @ 244,1 µs
      4 s @ 15,5 ms
      255 s @ 1 s
      15300 s (255 min) @ 60 s (1 min)

      so intervals above 255 seconds (4 min and 25 seconds) needs to be timed at one minute resolution.
      I have however tested this on my CoreINK (UiFlow/mocropython) and found that it rounds down in intervals of 2 minutes (120 s) for some reason.
      I made a script to that just put the unit to sleep but increases the sleep interval with 10 sec every time and then uses the clock to measure the actual sleep time. This was the result:

      0_1683278473886_4835f713-9fcf-4986-a3f7-f9f9ca8e3512-image.png

      *) BM8563 datasheet

      posted in Cores
      C
      Cognitive5525
    • RE: Micropython for Atom S3 Lite

      I initially also had big problems connecting with Thonny
      After changing the "submit_mode" to "raw" in the ESP32 section of the config file it worked:

      [ESP32]
      port = COM10
      interrupt_on_connect = True
      sync_time = False
      local_rtc = False
      restart_interpreter_before_run = False
      submit_mode = raw
      

      for further details: https://github.com/thonny/thonny/wiki/MicroPython see the chapter Advanced configuration

      posted in Micropython
      C
      Cognitive5525
    • RE: UIflow power functions Core INK

      Update: some further notes and a workaround solution.

      I decided to dig a bit deeper into how the BM8563 RTC works and how it is initialized by the M5Stack Arduino C++ library. Without going into all the details I have so far found out the following:

      Taking out the battery and leaving the CoreINK powerless does not in it self lead to the problem, as I have stated earlier in this thread. I seems the reason is some registers of the RTC sometimes become corrupted. Exactly how this happens, I'm not sure of, but one way may be when power (aka. the battery) is removed while data are written via I2C to the RTC. Important is however the matter of the fact: it can happen!

      Apparently the the UIFlow firmware does not reset these registers correctly at start up. Digging into the Arduino library (which I knew could fix problem) I found the RTC init routine which resets the three control registers* of the BM8563. I then thought I could do the same with the I2C library in UIFlow. And sure enough, it works. So the workaround is to run the following code:

      import i2c_bus
      
      i2c0 = i2c_bus.easyI2C(i2c_bus.M_BUS, 0x51, freq=400000)
      i2c0.write_u8(0x00, 0x00)
      i2c0.write_u8(0x01, 0x00)
      i2c0.write_u8(0x0D, 0x00)
      

      some where in your script before the

      m5stack.power.restart_after_seconds(n)
      

      is called.

      I haven't tested but I suppose it is the same if you use:

      m5stack.power.restart_on(minutes=n, hours=n, date=n, weekday=n)
      

      Notes to above code:
      Please use the UIFlow I2C library (import i2c_bus) as the native Micropython I2C library (machine.I2C) messes up the "internal" I2C communication of the UIFlow firmware.
      i2c_bus.M_BUS = (21,22) aka I2C pins for the BM8563 on the CoreINK
      0x51 is the I2C address of the BM8563
      0x00,0x01 and 0x0D are the control registers which are set to 0x00
      The Arduino library for RTC init for comparison :

      void RTC::begin(void) {
          Wire1.begin(21, 22);
          WriteReg(0x00, 0x00);
          WriteReg(0x01, 0x00);
          WriteReg(0x0D, 0x00);
      }
      

      *) please refer to the BM8563 datasheet for further details.

      posted in Cores
      C
      Cognitive5525
    • RE: Int to Float conversion

      I'm not sure what A3 becomes since I can't see what A1 and A2 are, but:

      A4 = (str(int(A3, 16)))

      makes A4 a string which you can't do arithmetic on.

      Provided that A3 can be converted to an integer, I would:

      A4 = int(A3, 16)
      A5 = A3 /1000
      label0.setText(str(A5))

      posted in UIFlow
      C
      Cognitive5525
    • RE: Int to Float conversion

      Since you posted under UIFlow, then that is what you use I suppose:
      0_1682692755877_c177659d-a376-4ab0-9568-04487becf4bd-image.png
      which results in the following Python code:

      my_val = my_val / 1000

      posted in UIFlow
      C
      Cognitive5525
    • RE: Int to Float conversion

      What language?

      In Python you can simply:

      my_val = 10000
      my_val = my_val/1000

      posted in UIFlow
      C
      Cognitive5525
    • RE: UIflow power functions Core INK

      Yeah I have been looking there already and tried:

      • "dunder" init() (one is normally not supposed to run "dunder" functions)
      • set_datetime()
      • enable_timer_interrupt()

      None of those helped.

      posted in Cores
      C
      Cognitive5525
    • RE: UIflow power functions Core INK

      I fully agree with your last reply!

      but to comment ".... you will need to reset the RTC every time yo reconnect power.":
      I would be more than happy to do so in my program, but there seems to be no way to do it within the scope of the UIflow firmware - I can't find any power.rtc_init() function or what ever it could be called.
      The only workaround (as far as I have found) is to use the Arduino C++ M5.begin() and then flash back the UIflow firmware

      Anyone who replace the battery in their CoreINK risks "bricking" the low power sleep functionality unless they read this thread ;)

      By the way, do you have any idea to what the power.on() function is for? It seems meaningless to be able to power on programmatically?

      posted in Cores
      C
      Cognitive5525
    • RE: UIflow power functions Core INK

      Thanks for your comments.
      As mentioned the internal battery is removed, but the external battery is fine and charging when the unit is connected to USB. I have a Amp-meter in the loop where I can monitor I_bat.

      Let me try to explain in a different way:
      The unit is connected to the external battery only (no USB ) and loaded with a UIflow-program that calls power.restart_after_seconds(n). Everything works as expected. The unit goes to sleep and wakes up after n seconds. I can reset and power down/up etc. etc. and it is still sleeping and waking up as expected - every time.

      Then I disconnect the battery for a while for some reason - say to change the battery or simply because I don't need to use the unit for a while.

      When I reconnect the battery and power up, everything still works except the wake-up. The unit goes to sleep but does not wake up after n seconds any more.

      Erasing flash, reloading firmware and reloading the (same) program does not help - the only thing that helps so far is to flash and run M5.begin() from the Arduino C++ library and then flash back to the UIflow firmware.

      I think there is some kind of setup for or in the RTC which is not truly persistent i.e. it relies on constant power from the battery and that the (re)initialization of this particular setup is missing or buggy in the Uiflow firmware.

      posted in Cores
      C
      Cognitive5525
    • RE: UIflow power functions Core INK

      Hello ajb2k3,
      Thanks for your comment!

      Yes, agree the RTC (BM8563) needs power during the sleep period.

      Sorry but it seems I wasn't clear in my previous description: The tests described above are all done with battery power only. I feed the unit from an external battery through the BAT and GND pins via the female bus header at the underside of the CoreINK. And I do not remove the battery while the unit is sleeping - only between the tests.

      What I did is:

      1. Firmware latest UIflow. Load a simple MicroPython program that waits a bit and then calls power.restart_after_seconds(10)
      2. disconnect USB while leaving external battery connected (BAT/GND) via amp-meter.
      3. press reset button and then power on button
      4. unit starts, waits and goes to sleep
      5. unit wakes up after 10 sec waits a bit and goes to sleep again
      6. let the unit loop through step 5 a few times. The amp meter (I-bat)shows less than 100 µA while sleeping and about 50 mA while running.
      7. remove the battery and leave off for a while or short BAT/GND
      8. reconnect battery
      9. reset button and then power on button (same as step 3)
      10. unit starts, waits and goes to sleep (program is the same)
      11. unit never wakes up
      12. try manual reset and power up (like step 3) a few times but unit is now unable to wake up after each time power.restart_after_seconds(10) is called.
      13. connect USB and flash simple Arduino program that just calls M5.begin()
      14. Run Arduino program one time
      15. flash back UI firmware and load same MicroPython program as in step 1.
      16. Continuing as from step 2
      17. The unit is now able to wake-up again and keeps looping as before like in step 5
      posted in Cores
      C
      Cognitive5525
    • RE: UIflow power functions Core INK

      After some further testing I can follow up a bit here.

      The power.restart_after_seconds(<int sec>) does indeed work as expected as long as there is always battery connected to the unit.

      I however took out the battery of my unit because I am planning to use it with a larger external battery. After being without battery (and other power sources) the unit stopped to wake-up after the given time.
      In my desperation to find a solution I switched from Uiflow (MicroPython) to C++ Arduino and tried the shutdown(<int sec>) function..... and it worked as expected. By coincidence then, I switched (flashed) back again to Uiflow (without removing the battery) and now the power.restart_after_seconds() was working again.

      I have now confirmed the following several times:
      I Remove all power sources including internal battery and short BAT/GND or leave powerless for some hours: wake-up part of power.restart_after_seconds(<int sec>) does not work any more.

      I then flash and run once a simple Arduino sketch like this:

      #include "M5CoreInk.h"
      void setup() {
      M5.begin(); // Initialize CoreInk.
      //M5.shutdown(10);
      }
      void loop() {
      //Nothing here
      }
      (note I just call the M5.begin() once in setup() and nothing else)

      Then while keeping the battery connected I flash back to UIflow again and the power.restart_after_seconds(<int sec>) wake-up as expected.

      I suspect there is some kind of initialization for the BM8563 in UIflow missing or failing.

      I have tried to browse though functions (dir(), Help()) in the m5stack library:
      and I found an tried m5stack.power.power.init() without any luck.

      Does anyone have some tips to where I should look for a solution?

      posted in Cores
      C
      Cognitive5525
    • UIflow power functions Core INK

      Does anyone know how the uiflow power functions for Core INK are supposed to work?

      There is

      • power.off()
      • power.restart_after_seconds()
      • power.restart_on()
      • power.on()

      off() seems to switch off* the device.

      restart_after_seconds() takes one int argument (seconds I assume). It also seem to switch off* the device. But it does not restart after the number of seconds given.

      restart_on() haven't tried it, but I assume the same as restart_after_seconds() except it takes a time (RTC need to be set then) as argument instead of a delay.

      on() seems meaningless to me. How can this function be called if the device is off?

      *)I see the green led switch off when the device is running on its internal battery only i.e. no USB connected.

      posted in Cores
      C
      Cognitive5525