Avatar for Cyber-Lane

Cyber-Lane

Member since Feb 2014 • Last active Apr 2014
  • 2 conversations
  • 7 comments

South African, multi-platform programmer, published games developer, inventor and film geek, now living in Brighton, England.
www | Cyber-Lane
twitter | @Cyberlane

Most recent activity

    • 5 comments
    • 2,868 views
  • in JavaScript
    Avatar for Cyber-Lane

    Excuse the slow reply, it's been quite a busy day!

    It's not quite what I had in mind, but I imagine it works just fine for now while the list is quite short. Once the list becomes a bit bigger though, it may need splitting up into categories, but that's a task that can wait until it's a problem I imagine!

    As for the CORS issue, would the JSONP with callback trick not work?

  • in JavaScript
    Avatar for Cyber-Lane

    Is there a package manager planned for Espruino? If not, could there be?

    I ask simply because I am working on a good number of libraries to speak to a number of different modules, and I plan on shoving most of them as public on my GitHub account, along with blog posts explaining how they work, etc. However, I have been thinking it could be nice to have a central place for people to search and find these libraries or "packages".

    If there is anything I can do to help make this happen, please let me know. I love the concept of Espruino, and it's going to simplify a lot of my future projects (or at least the prototypes!).

  • in JavaScript
    Avatar for Cyber-Lane

    Funnily enough, similar to cephdon, I am also looking to add MP3, but I thought I would get my RAW audio working first as it's much simpler. That said, the MP3 decoders I use are pretty much the same setup, but instead of sending the raw data via PWM to a speaker, you send the raw data to the IC, wait for it to say "I'm full" and stop, wait for it to say "I'm ready for more" and send more.

    Anyway, you are right... the interpreter would take up a fair amount of from the general performance. I suppose I was kind of expecting magic, allowing me to convert all my low level C into easier to read/maintain JavaScript (wishful thinking!).

    Anyway, if cephdon is working on getting Stream support, then I might just wait! That said, I would be quite keen on getting the Espruino code compiling on one of my dev boxes as well, so I can try contribute some C back, and not just a load of JavaScript libraries.

    Thanks for the replies chaps!

  • in JavaScript
    Avatar for Cyber-Lane

    I currently having it working on a PIC16F1825 along with code to read FAT16 on an SD card, which is only 14kB of RAM, so I was kind of assuming that the Espruino would be able to cope as it's got a much more powerful MCU...

    If it was possible to essentially add the following pseudo code, I'm pretty sure it would work!

    var fs = require('fs');
    var filePointer = fs.loadFile('filename.raw'); // Does not load the file, simply keeps reference to the file.
    
    var data = filePointer.readByte(0); // reads the first byte
    data = filePointer.readByte(24); //skips 24 bytes, reads 1 more byte
    
    // or readBytes(skip, take); but 1 byte at a time is how my current code works
    

    Is the problem with how your JavaScript handler is relaying the commands to the MCU, or what's the actual issue? Maybe I can help and send pull some pull requests?

  • in JavaScript
    Avatar for Cyber-Lane

    This specific file is 438KB in size, so it's not "massive" by any means, but perhaps it's a bit too big to load in one go? I've not actually looked too deep into how much this chip can handle, so just taking wild assumptions based on me getting this working on a cheap PIC16F1825!

    I tried doing a trace on content.length instead of content itself, and unfortunately that gave the same results. I then decided to let it read the file into a variable, but do nothing with it, but instead start to blink an LED, and it does not seem to get as far as blinking the LED. If I remove the readFileSync() line, the LED blinks fine. So it would appear that it's having trouble with that one method rather than the trace() method.

    As for partial read... I'm more than happy doing some substr on the data to view specific chunks at a time (for now), just so I can confirm it is reading what I am expecting before I try to start sending it in chunks to a small speaker over PWM.

  • in JavaScript
    Avatar for Cyber-Lane

    I am trying to read the content of a raw audio file into the trace. I would much rather the ability to read in chunks (of my choosing), but from looking at the API it would suggest (to me) that it's an all or nothing operation. Anyway, I wanted to confirm the content is reading in the way I am expecting (I am porting a PIC project over).

    I have the following code

    clearInterval();
    
    var fs = require('fs');
    var files = fs.readdir();
    if (files.length > 0) {
      var filename = files[0];
      trace(filename);
      var content = fs.readFileSync(filename);
      trace(content);
    }
    

    Now I am seeing the filename is correct, however the WebIDE hangs when it comes to doing the trace for the file content. It will not even let me disconnect. After 5 minutes of nothing, I hit the reset button, and it's back to normal...

    I would like to assume that it's trying to read the entire file into memory and then falling over.

    Am I doing something wrong? Any suggestions?

Actions