Avatar for SergeP


Member since Nov 2016 • Last active Oct 2020
  • 18 conversations

Most recent activity

  • in ESP32
    Avatar for SergeP

    I've just tried to write an image to my famous clock :) and found a bug with transparent color.

    var image={ width:9 , height:13 , bpp:24 ,
      transparent: 0x1,
    gt.drawImage(image, 5, 1);
    neopixel.write(pin, gt.buffer);

    I expect transparent point is in first image line (I can find it even if image is mirrored because there is second color line near) but it is actually in last one. If I set transparent to 0x10000 I see transparent point in first line while expect it in last one.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for SergeP

    It works! Wonderful! Thank you, @Gordon!
    I choose good time for upgrade :) I've used v1.92 without the timeout bug and now I am using pre-v2.06, again without the bug. SPI is now working with TLE94112, too.
    Now I still have 2 problems only: temperature is readed not every time by OneWire (about 1 reading of 100 is unsuccessful, while it was very stable at v1.92, I've never seen that last 3 years, or about 1 500 000 x 4 reads) and EspruinoHub often does something strange (but I have another topic to discuss that). And, of course, unstable connection in EspruinoWebIDE: usually I should restart IDE server 2 or 3 times before I can connect to device, but the problem is development stage only, so it is not so significant.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for SergeP

    I've got cutting edge v2.05.107 and it looks like working! Wow!
    Tomorrow I'll check it in my greenhouse.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for SergeP

    Yes. The stripped version works when I remove the setTimeout. But my full version is based on Timeouts from Timeouts from Timeouts etc... Usually I do not ever know if some function is called from timeout or not.
    Is it possible to use timeouts from timeouts safely? Or the only way is to wait for update? I have only one setInterval in the program and it can be removed easily, if that is significant.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for SergeP

    I'm not entirely sure about the reasoning for that anyway?

    It's just to make an update of full BLE advertizing, while there are many calls of updateAdv in many functions. So I can call updateAdv in every place where I change some part of advertizing data but actually I have only one update where all these fields are changed. It is update aggregator.
    I use similar code in many places. For example, in my big clock there may be few additional info, and it is resonable to update screen one time, after all data is redrawed to screenbuffer.
    Ok, I'll try to turn it off and check.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for SergeP

    I especially like the MQTT idea, but can this run also on a windows10 machine in case I have to use one?

    I do not know. May be, but it is a question to somebody who have tried already. I use bananapi M64 board as a server, and both EspruinoHub and mosquitto (and BlueTooth) on the server. May be it may be started at Windows 10, too. And yes, EspruinoHub converts BLE messages to MQTT messages. What is good for me is that I can implement some tree.js controller in 10 minutes.

    Any idea how to implement a good reliable distance measuring

    May be it will be interesting for you to measure smaller distance (0.02-1 m) with better resolution? You can use VL53L0X in the case. I've used it and have found not bad. It may be used at longer distances, too. But conditions are not usual, as far as I remember.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for SergeP

    Full code of my greenhouse controller can work at standalone Puck.js. I can add it here. But it is too complex, I think. So I've cropped it. Now it is small part of code but still has the effect in setTimeout. I've just test it and results are: 1266 seconds by getTime() while only 139 with setTimeout in dump(). So the code is here. Last setTimeout is for the test.
    I've observed that it depends on setInterval (there is only one in my code) which is calles NRF.setAdvertizing(). If I remove setInterval, setTimeout looks like work correctly (I'm not sure). If I do not disconnect from device in EspruinoWebIDE It may be works correctly, too.

    Upd: I can not upload file (do not know why) so code is below:

    var Day = true;
    // usage types: 0 - unused, 1 - watering, 2 - anti-overheat fog
    // wateringTime is in minutes (after start), while startHour is in hours after dawn
    var channels = [
      {wateringStartedAt: 0 },
      {wateringStartedAt: 0 },
      {wateringStartedAt: 0 },
      {wateringStartedAt: 0 },
      {wateringStartedAt: 0 },
      {wateringStartedAt: 0 },
    var VArr = new Uint8Array(4);
    let updatePending = false;
    function updateAdv() {
      if (!updatePending) {
        updatePending = true;
        setTimeout(function () {
          updatePending = false;
          let pack = 0;
          for (let i = 0; i < channels.length; i++)
            pack = (pack << 1) + (channels[channels.length - 1 - i].wateringStartedAt ? 1 : 0);
          VArr[2] = (Day << 7) + pack;
          VArr[3] = 255;
            0x1813: VArr
          }, {
            name: "Green", // The name of the device
            showName: true, // include full name, or nothing
            interval: 600 // Advertising interval in msec
        }, 0);
    setInterval(function () {
      VArr[1] = Puck.light() * 255;
    }, 120000);