Avatar for GermanWarez

GermanWarez

Member since Jun 2022 • Last active Mar 2023
  • 1 conversations
  • 8 comments

Most recent activity

  • in ESP8266
    Avatar for GermanWarez

    I would not use ESP8266 for a web server, because it is slow.
    But if you want to I'd suggest to read my post 'HowTo: Webserver with HTML/JavaScript/CSS/Images on ESP8266 (4 MB)'. I've created a custom firmware that supports E.openFile and E.pipe.
    E.openFile is not available because the modules Filesystem (and FlashFS) are not in the standard firmware for ESP8266.

  • in ESP32
    Avatar for GermanWarez

    For ESP8266 or ESP32? I'm busy atm, but I'll add some specialized code when I find the time to do so.
    If you want to run a web server on the ESP8266: https://github.com/GermanWarez/espruino-­esp8266-copy-file-to-storage
    It'll stop fs when serving two files in parallel. To prevent this I've implemented a sequential loader in index.html. But if you'd request the page in two browser windows in parallel it'll stop fs. Or if you change index.html to contain e.g. it'll stop fs.
    Other ways to stop fs:

    • Write to storage first (a lot), then try to copy from storage to fs. A reset between these two operations avoids the stop.
    • Write to fs often, e.g. 50kB of data in small chunks of 128 bytes.
      It looks like fs needs a lot of RAM, sometimes more than ESP8266 can offer. Storage seems like the better option for ESP8266, and maybe ESP32, too.
      For the ESP32 the limits might be higher, but being from the same family it's very likely to behave similar.
  • in ESP32
    Avatar for GermanWarez

    @gdanov:
    See targets/stm32_ll/main.c

    bool buttonState = false;
    [#ifdef](http://forum.espruino.com/searc­h/?q=%23ifdef) BTN1_PININDEX
      buttonState = jshPinInput(BTN1_PININDEX) == BTN1_ONSTATE;
    [#endif](http://forum.espruino.com/searc­h/?q=%23endif)
      jsvInit(0);
      jsiInit(!buttonState); // pressing USER button skips autoload
    

    The code is for the stm32, but it could be replicated for ESP32. Define BTN1_PININDEX (maybe jshardware.c?) and use this code. Actually it would be nice to have it in every board.

  • in ESP32
    Avatar for GermanWarez

    Same issue in 2.14. I think the filesystem just crashes silently if there are is not enough heap or too few variables.
    A webserver serving multiple files in parallel can crash the filesystem, or a webserver and some other background processes can lead to a crash (using E.pipe).
    It doesn't crash by repeated read access, if there's a sufficient free memory available. Storage is much more stable (require('Storage')).
    Disclaimer: My experience comes from the ESP8266 with a custom firmware build. Yet, I'm pretty sure there are some undiscovered bugs in the filesystem (require('fs')).

  • in General
    Avatar for GermanWarez

    Oh yeah, the soft option, and the analogWrite that is actually a PWM - it's not self-explaining. As a quick hack something like this:

        interval = setInterval(function() {
            currentPos = pos*amt + initial*(1-amt);
            digitalPulse(pin, 1, offs+E.clip(currentPos,0,1)*mul);
            if (amt >= 1) {
              clearInterval(interval);
              interval = undefined;
              // hold the position if option hold is set
              if (options.hold == true) {
                // move the calculation of the pulse width out of the interval
                // we might re-use 'initial' instead of adding 'pulseWidth' for low memory devices
                var pulseWidth = offs+E.clip(pos,0,1)*mul;
                // interval to hold the position (must use 'interval' as reference)
                interval = setInterval(function() {
                    digitalPulse(pin, 1, pulseWidth); 
                }, 20);
              }
              if (callback) callback();
            } else {
              amt += 50*time);  // equals amt += 1000.0 / (20*time);
            }
          }, 20);
    
    • Using option 'hold' instead of 'soft'
    • Use a first interval to move the servo (as it was before this change), and conditionally add a second interval to hold the position

    It would be possible to add the option 'hold' to the 'connect' function, then there's no need to include it in every call to 'move'. The code is not tested.

  • in General
    Avatar for GermanWarez

    Tbh, I'm not a fan of the merge:
    The now optional parameter 'soft' is neither clear nor concise, it can just mean anything. In the context of Espruino it usually means a software implemented function (serial, i2c, pwm, timer interrupt). It's difficult to understand that 'soft: false' in this case actually means 'move the servo slowly and then hold the position'. And the result of 'soft: true' isn't documented at all.

    In line line 116 in devices/Servo Motors.md was changed to use software PWM instead of hardware PWM, besides the fact that the description above says 'You can also use a hardware timer to produce the pulse...'. And in line 119 in devices/Servo Motors.md only the comment was modified, now it includes '... devices/Servo Motors.md'. I'd say '// move to position 0.5 over 1 second' would be correct.

  • in Espruino Work
    Avatar for GermanWarez

    Just a note: The official Espruino firmware is build using Github Actions, and this would be the best option to build custom firmware, too.

  • in ESP8266
    Avatar for GermanWarez

    I tried to use my ESP8266 as web server, and it took me quite a journey to get it to work. What I did:

    • A web server with html, js and css and image support
    • A web server without any limitations regarding file size (as long as it fits into the Storage)
    • It is slow (slow data transfer rate)
    • It needs an non-standard firmware release, with the modules FlashFS and Storage
    • Manual transfer the files to the Storage filesystem (no rsync or similar)
    • http (and ws) only, no https (and wss) support (limitation of the ESP8266)

    The complete solution is not easy, it needs also special loader to sequentially load the page contents. But it works for any file and any size. What I did:
    https://github.com/GermanWarez/espruino-­esp8266-copy-file-to-storage

    That's my initial release, including

    • custom Firmware (including Github Actions to build it)
    • a script to support the manual transfer the the files
    • a web server including a sample web page (90 seconds loading time, for around 50KB of data)
      I developed and tested the code on the ESP8266, with Espruino 2v13 and 2v14.
Actions