Avatar for NewAtEspruino


Member since Nov 2020 • Last active Feb 2021
  • 4 conversations

Most recent activity

  • in JavaScript
    Avatar for NewAtEspruino

    Thank you so much @fanoush and @Gordon for the explanation.
    @Gordon : the values doesn't always have 6 decimal places, it could be at times 5 or at times none.
    1180.952381 and 1180.95238100000 are the same number, however, I was just curious to know why values like 1175.824176 get stored as 1175.82417599999 or with extra zeroes at the end.

    Thanks for all your help as always!

  • in JavaScript
    Avatar for NewAtEspruino

    Hello @Gordon,
    I tried using TypedArray

    var arr_data = new Float32Array(300);
    arr_data[i] = parseFloat(s); // this is in a for loop where I read each value from csv as string

    since my numbers are in decimals.
    However, when I try to store the float value in the above array, it doesn't get stored as it is.
    For example: 1180.952381 from the .csv is stored as 1180.95239257812

    I tried using Float64Array and it gave a better result however not the exact value
    1180.952381 is stored as 1180.95238100000
    and 1175.824176 is stored as 1175.82417599999

    I believe using Float32Array would be better considering memory usage, however not sure why the values aren't getting stored in the original form


  • in JavaScript
    Avatar for NewAtEspruino

    Hi @fanoush,
    That's a great idea too. Did not strike me.
    Thanks a lot!
    I will try it out as well.

  • in JavaScript
    Avatar for NewAtEspruino

    Hi @Gordon,
    Yes, they are numbers, actually decimal numbers - around 10 digit long numbers.
    I Will try using a typed array and see if it works
    Thank you very much!

  • in JavaScript
    Avatar for NewAtEspruino

    Thanks a lot, @fanoush and @Gordon for your replies.

    Until I received the responses here, I did try reading the file using indexOf.
    It's a file with 1 column having 17K rows. I wanted to separate these 17K values and store them in an array since I need to do analyze these values and compute something further.

    Obviously, since 17K is a very large number, I for instance tried reading only the first 500 values. (Could separate out every value from the file based on carriage return ) and could print all of them. No problem.

    However, the moment I try to store these 500 values in an array, I face the low memory problem.
    It works well if I store only 100 values in the array. However, the computation that I need to do on this data, requires at least 500 values for me to analyze it well because I am working on a pattern. Can't analyze with only 100 values.
    Is there any way I could achieve this - storing 500 values or maybe at least 300?

    Thanks a lot once again for all your help!

  • in JavaScript
    Avatar for NewAtEspruino

    I am trying to read a very lengthy(approx. 15K rows) .csv file using require("Storage").read("xxx.csv").
    And the next step is to create an array for the values in the .csv file.
    However, .split("\r\n") function on require("Storage").read("xxx.csv") gives me an error - see the attached image for the error details.

    Is there a way that I could read only say first 200 rows from the .csv at a time? and then the next 200?
    I don't see any other API at the moment to read the file in chunks, except .read(), so wanted to confirm.

    Pls. note that I am using Espruino emulator and also have some other functionality coded at the moment for the smart watch.

    Thanks a lot!

  • in Bangle.js
    Avatar for NewAtEspruino

    Hello All,
    Am back with continuation of this thread :)
    For a recap- I had this (pic attached) built with steps value as 2,500 which was a static value, a constant.
    I have to now color the semicircle green depending on value (got at run time, it would keep changing).

    I went through this entire thread once again. And looks like there is a lot that has been experimented.
    Thanks a lot once again for all your help.
    I am now going to start looking through the code you all have shared here.
    Just had one query because I am not sure if I understood it correctly(after looking at the watch face example) - Is a feature like this now being provided by bangle.js? Or, else I will start working on my code (as suggested in #17)

    Thanks a lot once again!