🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    UIFlow - Micropython - USB plugged in

    Scheduled Pinned Locked Moved UIFlow
    4 Posts 2 Posters 4.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      jjshoe
      last edited by

      Is it possible using UIFlow/Blockly to detect when USB is plugged in? From other threads (https://forum.m5stack.com/topic/3611/detecting-when-plugged-in-vs-when-charging) it looks like I need to be able to implement this:

      M5.Axp.isACIN();

      1 Reply Last reply Reply Quote 0
      • C Offline
        crami25
        last edited by

        You can use this function in UIFlow:
        Whenever the USB is plugged in, the battery is charged.
        You will find the block in the Hardware/Power section:
        0_1675361595278_889f78b8-6ae1-44c8-90f4-57ad1873112a-image.png

        1 Reply Last reply Reply Quote 0
        • J Offline
          jjshoe
          last edited by

          @crami25 said in UIFlow - Micropython - USB plugged in:

          You can use this function in UIFlow:
          Whenever the USB is plugged in, the battery is charged.
          You will find the block in the Hardware/Power section:
          0_1675361595278_889f78b8-6ae1-44c8-90f4-57ad1873112a-image.png

          Actually isCharging returns false after the battery goes full for a while, I realize I can then do logic to check the battery capacity, and isCharging, was just hoping there was a simpler way.

          1 Reply Last reply Reply Quote 0
          • J Offline
            jjshoe
            last edited by

            The python version of the c function looks like its probably not available:

            >>> dir(hardware.axp192.Axp192)
            ['__class__', '__init__', '__module__', '__name__', '__qualname__', '__bases__', '__dict__', 'deinit', 'setBusPowerMode', 'powerAll', 'setLCDBrightness', 'setPowerLED', 'setSpkEnable', 'powerOff', 'CURRENT_100MA', 'CURRENT_190MA', 'CURRENT_280MA', 'CURRENT_360MA', 'CURRENT_450MA', 'CURRENT_550MA', 'CURRENT_630MA', 'CURRENT_700MA', 'getTempInAXP192', 'getChargeState', 'getBatVoltage', 'getBatCurrent', 'getVinVoltage', 'getVinCurrent', 'getVBusVoltage', 'getVBusCurrent', 'setChargeState', 'setChargeCurrent', 'setLDOVoltage', 'setLDOEnable', 'setDCVoltage', 'disableAllIRQ', 'clearAllIRQ', 'enableBtnIRQ', 'setESPVoltage', 'setLCDBacklightVoltage', 'setLCDEnable', 'setLCDReset', 'setVibrationIntensity', 'setVibrationEnable', '_regChar', '_read8bit', '_read12Bit', '_read13Bit', '_read16Bit']
            >>> 
            

            However, I found two alternative ways to detect this, i2c being my favorite: https://imgur.com/a/nscmAHF

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post