Umidigi Uwatch 2 Espruino port

Posted on
  • Hi all,
    I'm working on the Uwatch 2 from umidigi and thanks to @fanoush and @Gordon I was able to have espruino running on it, version is 2v05.29 and I started from this github repo https://github.com/kabbi/espruino-uwatch­ . I'm facing some issues regarding the battery operations. The first one is the about the isCharging() basically it does not detect the pin change from low to high when I plug the charging plug, thanks to @fanoush suggestion I added some printf to understand what happen when isCharging() is called from javascript as you can see below:

    bool jswrap_uwatch_isCharging() {
    [#ifdef](https://forum.espruino.com/sear­ch/?q=%23ifdef) BAT_PIN_CHARGING
      jsiConsolePrintf("*-> isCharging Debug: \n");
      jsiConsolePrintf("*-> PIN: %d\n",BAT_PIN_CHARGING);
      jsiConsolePrintf("*-> ReadPin %d\n",jshPinGetValue(BAT_PIN_CHARGING));­
      return jshPinGetValue(BAT_PIN_CHARGING);
    [#else](https://forum.espruino.com/searc­h/?q=%23else)
    	
      return 0;
    [#endif](https://forum.espruino.com/sear­ch/?q=%23endif)
    }
    
    

    and this is the output in the espruino ide when I now call Uwatch.isCharging()

    >Uwatch.isCharging()
    *-> isCharging Debug:
    *-> PIN: 19
    *-> ReadPin 0
    =false
    

    The pin is defined correctly as BAT_PIN_CHARGING but it is not reading the change. Strange thing is that if I use instead digitalRead(19) I can see the pin change when I plug / unplug the charger cable. I would like to fix this if is possible in some way.

    The second issue is about the getBattery() function, it included in the UWATCH.py and is present in the jswrap_uwatch.c but is not available in the interpreter itself if I try to call it in the IDE by doing E.

    I hope the informations are detailed enought

    Any help will be very appreciated

  • well, this is fork and quite old version, can you try to log jshIsPinValid(pin) and also output of nrf_gpio_pin_read(pin). Also can you put ADC1_IN0x pins back to board file (see end of other board files), nrf52 has 8 fixed analog pins. D19 is not analog but still removing them may possibly break stuff.

    the jshPinGetValue is here https://github.com/kabbi/espruino-uwatch­/blob/master/targets/nrf5x/jshardware.c#­L824 so check what it does line by line, something must be seriously broken if such basic method does not work.

  • Just to add it's really worth trying to update the firmware. I seem to recall there were some instabilities in the handling of pin state changes in early firmwares.

    Also, with later firmwares there's been a lot of work put into trying to make the standard Bangle.js code work on different watches, so when you update you could probably use the standard jswap_banglejs.c with minimal changes required

  • Hello @Gordon, nice to read you again, yes my first idea was to use the latest version of espruino because it is the most logical thing to do, but I'm new to espruino and I though that this was too difficult for me, thanks to the precious help provided by @fanoush I feel a bit more confident now so I will give a try with the latest version of espruino

  • A quick update, as suggested by @fanoush I logged a bit more code and here is the result:
    this is the isCharging() function:

    bool jswrap_uwatch_isCharging() {
    [#ifdef](https://forum.espruino.com/sear­ch/?q=%23ifdef) BAT_PIN_CHARGING
      jsiConsolePrintf("*-> isCharging Debug: \n");
      jsiConsolePrintf("*-> PIN: %d\n",BAT_PIN_CHARGING);
      jsiConsolePrintf("*-> ReadPin %d\n",jshPinGetValue(BAT_PIN_CHARGING));­
      jsiConsolePrintf("*-> DBG PIN Valid %d\n",jshIsPinValid(BAT_PIN_CHARGING));
      jsiConsolePrintf("*-> DBG PIN Nrf %d\n",nrf_gpio_pin_read(BAT_PIN_CHARGING­));
      return jshPinGetValue(BAT_PIN_CHARGING);
    [#else](https://forum.espruino.com/searc­h/?q=%23else)
    	
      return 0;
    [#endif](https://forum.espruino.com/sear­ch/?q=%23endif)
    }
    

    and here is the output:

    >Uwatch.isCharging()
    *-> isCharging Debug:
    *-> PIN: 19
    *-> ReadPin 1
    *-> DBG PIN Valid 1
    *-> DBG PIN Nrf 0
    =true
    >Uwatch.isCharging()
    *-> isCharging Debug:
    *-> PIN: 19
    *-> ReadPin 1
    *-> DBG PIN Valid 1
    *-> DBG PIN Nrf 0
    =true
    
    

    so from waht I can see the nrf_gpio_pin_read() is not working basically all the analog pins were added back to the board file by the way.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Umidigi Uwatch 2 Espruino port

Posted by Avatar for thejoker187 @thejoker187

Actions