• Hi !

    I use a 7-segment led display like this one on a custom board with a NRF52832 (it runs espruino v2.01).

    I have a setInterval that triggers a refreshDisplay function. This function calls three time the function turnDigitOn to display the hour.

    function turnDigitOn(digit) {
      digitalWrite([D6, D5, D4, D3, D2], digit);
    }
    

    As the refreshDisplay is called with an interval of 2ms, I was wondering if I could write it in inlineC to speed up the thing. I tried the following:

    var c = E.compiledC(`
      // void turnDigitOn(int, int, int, int, int)
      void turnDigitOn(int ioDigit1Value, int ioDigit2Value, int ioDotsValue, int ioDigit3Value, int ioDigit4Value) {
        nrf_gpio_cfg_output(6);
        nrf_gpio_cfg_output(5);
        nrf_gpio_cfg_output(4);
        nrf_gpio_cfg_output(3);
        nrf_gpio_cfg_output(2);
    
        nrf_gpio_pin_write(6, ioDigit1Value);
        nrf_gpio_pin_write(5, ioDigit2Value);
        nrf_gpio_pin_write(4, ioDotsValue);
        nrf_gpio_pin_write(3, ioDigit3Value);
        nrf_gpio_pin_write(2, ioDigit4Value);
      }
    `);
    

    but when I then I have the following error message.

    >---------------------------------------------------
                                     COMPILER MESSAGE
    ---------------------------------------------------
    out1069094144.cpp: In function 'void turnDigitOn(int, int, int, int, int)':
    out1069094144.cpp:59:26: error: 'nrf_gpio_cfg_output' was not declared in this scope
         nrf_gpio_cfg_output(6);
                              ^
    out1069094144.cpp:65:40: error: 'nrf_gpio_pin_write' was not declared in this scope
         nrf_gpio_pin_write(6, ioDigit1Value);
    

    So is there a way to use these nrf functions (nrf_gpio_cfg_output and nrf_gpio_pin_write) and most importantly, will inlineC really increase performances?

    Thanks and best regards.

About

Avatar for benoit @benoit started