• Am running latest build etc .. of the little temperature project at http://www.espruino.com/temperature_disp­lay_pcd8544

    If just left, the display will eventually freeze on a given temperature and requires the board to be reset etc.

    Today, I caught the following error message ...
    (http://i328.photobucket.com/albums/l359/­cpm17/CaptureEspruino_zps2776483f.jpg)

    Any ideas ?

    I'm also having trouble save() ing the code. If crashes are inevitable, I'd like just to reboot and have it execute the saved code. It appears to save() ok, but a reset and/or re-power never starts the code executing again. Have to copy over from the IDE every time.

    Help appreciated !

    Pat

  • Well, this could potentially be an issue I've fixed in the next version (to do with the internal clock getting very confused after a while). I'll do another release in an hour or so and will see if it helps.

    The reset doesn't work because the LCD needs setting up when Espruino restarts, and that isn't done in the example. I'll update the website's example, but for now try:

    SPI1.setup({ baud: 1000000, sck:B3, mosi:B5 });
    var ow = new OneWire(B13);
    
    var g, temp;
    
    function onInit() {
      clearInterval();
    
      temp = require("DS18B20").connect(ow);
      g = require("PCD8544").connect(SPI1,B6,B7,B8­, function() {
        setInterval(onTimer, 500);
      });
    }
    
    function onTimer() {
      // Get the temperature
      var t = temp.getTemp();
      // Round it to the nearest 0.1
      t = Math.round(t*10)/10;
      // Now draw!
      g.clear();
      g.setFontBitmap(); // simple 8x8 font
      g.drawString("Temp",0,0);
      g.drawLine(0,10,84,10);
      g.setFontVector(25); // large font
      g.drawString(t, 0, 15);
      g.flip(); // copy this to the screen
    };
    
    onInit();
    

    Note the use of onInit - which is called automatically.

  • Ok, new version 1v59 released - it should be a lot better.

  • Gordon, thanks ever so. I'll give it a shot now and report back !

  • Running all day. Not a wobble. Fixed, I would say :)

    Still does not survive a reset/power cycle though after a save()

    Pat

  • Still does not survive a reset/power cycle though after a save()

    What's it doing wrong? I've done similar things and had them survive power cycle and come back up and run (until they crashed due to the timer bug - this was pre-v59)... I'm looking at my old code, and I see that I had onInit() doing setTimeout(doInit,2000); and had the code to initialize the LCD and sensors in that. IIRC something didn't work if I started driving it immediately. I think it was the LCD (same one you're using).

  • That's strange. I guess it could be worked into the LCD driver. I've got a bunch of them here and I've never had a problem though...

  • Not really sure what the problem is .. or how to debug .. the main problem of constant crashing is banished, though :)

  • My next slight mystery (apart from not surviving a reset/power cycle) is that the font has become very ugly. I am not sure at what point this happened, and actually thought it might be the LCD, so replaced. But same effect ...

    SPI1.setup({ baud: 1000000, sck:B3, mosi:B5 });
    var ow = new OneWire(B13);
    var g, temp;
    function onInit() {
      clearInterval();
      temp = require("DS18B20").connect(ow);
      g = require("PCD8544").connect(SPI1,B6,B7,B8­, function() {
        setInterval(onTimer, 500);
      });
    }
    function onTimer() {
      // Get the temperature
      var t = temp.getTemp();
      // Round it to the nearest 0.1
      t = Math.round(t*10)/10;
      // Now draw!
      g.clear();
      g.setFontBitmap(); // simple 8x8 font
      g.drawString("Temp",2,0);
      g.drawLine(0,10,84,10);
      g.setFontVector(25); // large font
      g.drawString(t, 0, 15);
      g.flip(); // copy this to the screen
    }
    onInit();
    

    Incidentally the default 0,0 for Temp, puts the text off the LHS of the screen slightly, so I changed to 2,0. Changing setFontVector to other numbers has little effect .

    Is this to be expected/as intended ?

    Pat

  • Yes - it's because some people complained that the vector font was too 'thick' and didn't scale down well to smaller sizes, so I changed it in one of the later versions of Espruino.

    This always happens. A few people complain and I change something based on their suggestions, and then loads more people complain about the change :) You can't keep everyone happy...

    The thing with Temp's positioning may be an issue with the code that drives the LCD. I think for some reason it misses off the first vertical 8 pixel bar (the first byte sent to the display).

    Can you try moving SPI1.setup({ baud: 1000000, sck:B3, mosi:B5 }); into the beginning of onInit? Someone had a problem with I2C in another thread, and I wonder if this is related.

  • Hehe :) I think I can live with it .. not a thing of beauty, but perfectly functional.

    Moving SPI1 into onInit - no change. I'll find the other thread and take a look. Again this did work at some point in the past, but stupidly did not pay attention when it changed.

  • I guess if someone made a font editor for this then we might be able to get a font that rendered nicely.

    I just fixed this in the LCD driver. Try loading it into your board again and it should 'just work'.

    The issue was that because the Espruino board remembers pin state, it'd raise the reset line on bootup, and would then almost immediately lower it to reset the LCD. It turns out the LCD didn't like it much :)

  • Aaha, so that's why the restart made the LCD unhappy! I'd worked around it by putting connect() in a timeout - I had just assumed it needed a second or two before it would accept commands.

    Regarding the vector fonts (some background for @Pat) - The original vector font looked fine at large sizes (like a huge temperature number), but it looked absolutely miserable at small sizes - it was unreadable; all the lines were bold, and at small sizes, the holes and gaps between lines in the letters were filled up by the width of the lines. But this was okay, you could just use the bitmap font. But to reduce binary size, the bitmap font is now smaller than it used to be (as you probably can see, it's kind of hard to read on the Nokia5110 screen). This prompted people (including me) to complain, because we couldn't print readable text at a reasonable size on the Nokia 5110 screen (either vector which was too large, or hard to read at small sizes, or bitmap which was too tiny). And so now we have a vector font that shows up at small sizes - but at large sizes, it doesn't seem to come out so well.

    We do now have the ability to define bitmap fonts of our own design now. This may be helpful for you - but making gigantic bitmap fonts is not memory efficient. It does solve the issue that originally motivated the complaints about the vector font though (by giving us a way to get the 8x8 font that's more readable on displays like the Nokia5110). I need to play with that this weekend...

    Amazing how something like displaying text can be tricky like this - it's one of those things where functionality (effectively communicating text to viewer) and aesthetics are hard to separate, and that just makes it much harder. Plus, we're all used to systems that can throw tons of resources at rendering fonts.

  • Ok, so this code

    var ow = new OneWire(B13);
    var g, temp;
    function onInit() {
      SPI1.setup({ baud: 1000000, sck:B3, mosi:B5 });
      clearInterval();
      temp = require("DS18B20").connect(ow);
      g = require("PCD8544").connect(SPI1,B6,B7,B8­, function() {
        setInterval(onTimer, 500);
      });
    }
    function onTimer() {
      // Get the temperature
      var t = temp.getTemp();
      // Round it to the nearest 0.1
      t = Math.round(t*10)/10;
      // Now draw!
      g.clear();
      g.setFontBitmap(); // simple 8x8 font
      g.drawString("Temp",2,0);
      g.drawLine(0,10,84,10);
      g.setFontVector(25); // large font
      g.drawString(t, 0, 15);
      g.flip(); // copy this to the screen
    }
    onInit();
    

    survives the reset.

    Gordon, when you say "I just fixed this in the LCD driver. Try loading it into your board again and it should 'just work'." .. you need to push a firmware update ?

    Pat

  • Nope, just have to send the code to the espruino again (using the IDE), and when it grabs the LCD module, it will get the latest version - If you look at the EspruinoDocs repo on github, you can see the latest version of the module (with this change) - and that latest change change is in the version in espruino.com/modules, which is where the web-ide goes to look for modules.

  • Ah, got it. Thanks. I am learning. Slowly.

  • Hmm. Perhaps I am missing something .. this is my code, I changed the Temp drawstring back to 0,0 and sent the code to espruino, but the display of "Temp" is off the screen again ..

    var ow = new OneWire(B13);
    var g, temp;
    function onInit() {
      SPI1.setup({ baud: 1000000, sck:B3, mosi:B5 });
      clearInterval();
      temp = require("DS18B20").connect(ow);
      g = require("PCD8544").connect(SPI1,B6,B7,B8­, function() {
        setInterval(onTimer, 500);
      });
    }
    function onTimer() {
      // Get the temperature
      var t = temp.getTemp();
      // Round it to the nearest 0.1
      t = Math.round(t*10)/10;
      // Now draw!
      g.clear();
      g.setFontBitmap(); // simple 8x8 font
      g.drawString("Temp",0,0);
      g.drawLine(0,10,84,10);
      g.setFontVector(25); // large font
      g.drawString(t, 0, 15);
      g.flip(); // copy this to the screen
    }
    onInit();
    
  • No, you're not missing anything. I didn't fix that issue - just the one where it didn't start up :)

  • Actually I've just fixed that issue now too, so next time you send the code it should work.

  • Ah. Thanks :)

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

Constant crashing of TEMPERATURE ON A PCD8544 DISPLAY, WITH DS18B20 TEMPERATURE SENSOR

Posted by Avatar for Pat @Pat

Actions