Show Posts
Pages: [1] 2 3 ... 8
1  Using Arduino / Programming Questions / Re: How to assign a number (read from sd card) to a BigNumber variable! on: Today at 06:24:56 am
From the original post:
Code:
  char c;
  byte i;
  char temp_arr[22];
 
  myFile = SD.open("valori.txt");
  if (myFile) {
    while (myFile.available()) {
                 
       while(c != -1) {
          c = myFile.read();
          i++;
Where is "i" initialised?

For that matter, first time around, c is ambiguous also.

2  Using Arduino / Programming Questions / Re: How to assign a number (read from sd card) to a BigNumber variable! on: Today at 06:05:51 am
What do you say to reply #11?
me or matteo?

Code:
char temp_arr[23];
  temp_arr[23] = 0; // <=== NULL terminated

?

http://www.gammon.com.au/forum/?id=12153#trap11

That would be my fault! I originally had 22 as both parameters, matteo has just perpetuated my mistake. I always thought the index was absolute, I didn't realise it was total number of elements, oops, such that [22] gives elements 0-21, I thought was 0-22, so I hold my hand up to that.  smiley-red

@matteo I thought I had made it clear that only 1 line needed changing and yet you appear to have replaced all occurrences of 22 with 23?

 
Code:
  char temp_arr[23];
  temp_arr[22] = 0; // <=== NULL terminated

  myFile = SD.open("valori.txt");
  if (myFile) {
    do {
      myFile.readBytes(temp_arr, 22);
      Serial.println(temp_arr); // <===== List all variables as they are read from SD
      myFile.read(); // myFile.read();  <=== discard <CR><LF>
    } while (myFile.available());
  }
  myFile.close();

Regards,

Graham
3  Using Arduino / Programming Questions / Re: How to assign a number (read from sd card) to a BigNumber variable! on: September 30, 2014, 09:25:09 pm
Ok, thankyou for that, I have learnt something useful today  smiley-grin

matteo, you need to change your array definition to this apparently.
Code:
char temp_arr[23];

Regards,

Graham
4  Using Arduino / Programming Questions / Re: How to assign a number (read from sd card) to a BigNumber variable! on: September 30, 2014, 09:12:27 pm
mmmm, well I don't claim to be a genius, of your level, but passing snide remarks is not helpful when a beginner is obviously struggling.

The example code works.

There was no claim the file would ever be empty hence why the loop was constructed the way it was.

A char [22] array has 23 elements? 0 - 22 ??

The 0 in element 22 is the NULL terminator which is never overwritten and hence only defined once, thus correctly terminating the fixed length 22 character string which actually occupies elements 0-21.....

Regards,

Graham

5  Using Arduino / Programming Questions / Re: How to assign a number (read from sd card) to a BigNumber variable! on: September 30, 2014, 06:27:15 pm
Hi matteo,

Apologies for my comment which got the big number thread locked.....

Try this :-  smiley-wink

Code:
#include <SPI.h>
#include <SD.h>
#include "BigNumber.h"
File myFile;

void setup() {
  Serial.begin(19200);
  Serial.println("Initializing SD card...");
  pinMode(10, OUTPUT);
  digitalWrite(10, 1);

  if (!SD.begin(10)) {
    Serial.println("initialization failed!");
    while (1);
  }

  char temp_arr[22];
  temp_arr[22] = 0; // <=== NULL terminated

  myFile = SD.open("valori.txt");
  if (myFile) {
    do {
      myFile.readBytes(temp_arr, 22);
      Serial.println(temp_arr); // <===== List all variables as they are read from SD
      myFile.read(); myFile.read(); // <=== discard <CR><LF>
    } while (myFile.available());
  }
  myFile.close();

  // -----------questa è la tua ultima riga ----------
  //Serial.println(temp_arr); //debug
  //---------------------------------------------------
  // In this step I try to assign temp_arr to a BigNumber variable but i don't succeed!!!!!!!!!!!!
  //---------------------------------------------------
  // Well actually you would have if your char array was correctly formed!! ;)

  BigNumber::begin (20);  // initialize library
  BigNumber valore;
  valore = BigNumber (temp_arr) ;
  Serial.print ( " di grande valore!! : " );
  Serial.println(valore); // <======= This was implemented some time ago, if it doesn't work, get the latest BigNumber library.
  // printBignum (valore); // <===== obsolete
}

void loop() {
}


Quote
Initializing SD card...
0.00006012897746378622
0.00000789641873453215
0.00000468768435435468
0.00000468768435435468
0.00004879642543541864
0.00000468768435435468
0.00000898865313154677
 di grande valore!! : 0.00000898865313154677

This will only work for EXACTLY 20 decimal places, and assuming you have <CR><LF> line terminator, if doesn't work properly, remove one of the myFile.read() commands.

Hope this helps.

Regards,

Graham
6  Using Arduino / Programming Questions / Re: Arbitrary precision (big number) library port for Arduino on: September 30, 2014, 05:30:59 pm
PaulS was actually trying to tell you that ANY number <0 IS NOT an INT ..... INT is only WHOLE numbers!!
I'm pretty sure -1 is an integer.

Well, actually you have surely spotted my first obvious mistake  ? I actually meant to say <1 but as you correctly pointed out any negative whole number would also be an integer. OOPS smiley-razz

Regards,

Graham
7  Using Arduino / Programming Questions / Re: Arbitrary precision (big number) library port for Arduino on: September 30, 2014, 05:27:28 pm
Thread unlocked now that I have calmed down. smiley-wink

I am REALLY sorry Nick!!

Thankyou for this, I for one appreciate everything you do for us!

Regards,

Graham
8  Using Arduino / Programming Questions / Re: Arbitrary precision (big number) library port for Arduino on: September 29, 2014, 05:15:39 pm
Hi Nick,

Don't worry too much about matteo90, he obviously was just trying all angles, I have dealt with his problem, I think you can close his git issue. smiley

Cheers

Graham
9  Using Arduino / Programming Questions / Re: Arbitrary precision (big number) library port for Arduino on: September 29, 2014, 12:03:43 pm
Hi matteo,

This should do the trick  smiley-wink

Code:
  String inString = String("0.00781204585463546254876874875425498741249869717182");
  char *cstr = new char[inString.length() + 1];
  strcpy(cstr, inString.c_str());
  Serial.print ( " cstr    : " );
  Serial.println (  cstr  );
  BigNumber mystring = (cstr) ;
  delete [] cstr;
  Serial.print ( " mystring: " );
  printBignum (mystring);

PaulS was actually trying to tell you that ANY number <0 IS NOT an INT ..... INT is only WHOLE numbers!!

The code above is only so complicated because you chose to use a String object, if you could replace Strings with Char arrays, it would simply be a case of
Code:
BigNumber variable = (Char array);

Hope this helps.

Regards,

Graham
10  Using Arduino / Programming Questions / Re: Arbitrary precision (big number) library port for Arduino on: September 29, 2014, 09:18:14 am
Matteo90,

Can you explain what you are trying to achieve?

So you are reading a pot, this yields results in the range 0-1023, you divide the result by 1023 which instantly has the effect of producing a float, you then cube that number making an already small number MUCH smaller, then make it even smaller by dividing by 125, and subsequently even smaller still by dividing by a further 1000. What are you ACTUALLY trying to achieve? I am thinking an easier solution to this could be using large integers in preference to TINY floats?

Just a thought.

Regards,

Graham
11  Using Arduino / Programming Questions / Re: Arbitrary precision (big number) library port for Arduino on: September 29, 2014, 08:14:37 am
Matteo90,

Sadly, it is unlikely any of the guys with 1000's of posts will help, they are are generally too far up themselves to help the very people that need help!!  smiley-sad

I have not played with the Arbitrary number library for a while, and I never had a requirement to store them to SD or subsequently read them back, however, I will have a play with it later, if I come up with a solution, I will let you know.

Regards,

Graham
12  Using Arduino / Displays / Re: Proportional/TTF/OTF Fonts using UTFT and windows on: September 19, 2014, 03:01:35 pm
Hi David,

I don't know if you still follow your thread? I just wanted to say I was a little slow to the party but I am glad I discovered this thread!

I have pointed folks here from another thread, just thought you should know.

http://forum.arduino.cc/index.php?topic=164788.msg1885789#msg1885789

The major use for this that I can see, is people wishing to use the BVS fonts included in the Coldtears display font IC, that do not have that ic. So I located Bitstream Vera Sans.ttf and converted it using your ttf2c_vc2003 tool to all the sizes I know about, and this worked flawlessly thankyou!!

However one 'slight' niggle/suggestion if I may? Could you modify the tool slightly to use <output-file> as the c array name? Such that
Quote
ttf2c 112 vera.ttf BVS_112.c
   would yield a c array of the same name as the filename in this case BVS_112.c?

I am surprised a thread as old as this, offering the features you do, has not gotten more traffic or comments, so let me say a big thankyou! I for one certainly appreciate your efforts and can definitely see it receiving some use here.

Regards,

Graham
13  Products / Arduino Due / Re: Due GUI (Graphical user interface) - [now community project] on: September 19, 2014, 02:34:06 pm
Hi everyone,

Since my last post I have had chance to play with UTFT_DLB. It does what it says on the tin!! I am impressed how easily you can have ANY TTF/OTF font you could desire. Since the focus of many people is the BVS fonts included in the CTE font and icon ic, I have converted all of the sizes I am aware of into .c arrays for use with the UTFT_DLB extension library ( BVS_13, BVS_15, BVS_19, BVS_22, BVS_28, BVS_34, BVS_43, BVS_52, BVS_74, BVS_112 ).

No doubt you are aware, but for newbies I will point out that the larger the font size, the larger the array will be, such that BVS_112 alone is 232KB!

I think this is a great discovery for anybody having the same issues with missing BVS fonts that I had!!

Regards,

Graham
14  Products / Arduino Due / Re: Due GUI (Graphical user interface) - [now community project] on: September 17, 2014, 01:22:18 pm
Hi Everyone!

If anybody is still following this thread with an interest in fonts for non font-ic based displays, I came across something interesting earlier. It is a library by a fellow arduiser (word copyrighted to me meaning arduino user!  smiley-razz smiley-wink ) called arduinodlb aka ' David Badham'. He has produced an extension library to UTFT which allows

Quote
Proportional/TTF/OTF fonts to be displayed on Arduinos. It extends the UTFT library and adds ttf derived font capability. It includes a tool that runs on windows and converts any ttf/otf font into a compact proportional bitmap font for use on TFT displays.

See his original thread here http://forum.arduino.cc/index.php?topic=189964.0.

I have not played with or tried his library yet, but it sounds like an ideal addition to DUEGUI!! I would be interested to hear others' thoughts? Henning already has the market covered for monospaced fonts, but I felt there was a need for proportional spaced such as the built in BVS font on the CTE SD1963 displays?

For those of us not fortunate enough to have such a display, the font abilities of the UTFT library are somewhat limited, 've3sjk' recently raised this point although completely overlooking the fact that ediaz already allowed us to use UTFT fonts on non font-ic equipped displays!

I have a question of my own at this point, my CPLD 5" CTE display does not have any form of font-ic, however it does have the SOIC-8 pad to allow one to be added. So what is the largest capacity viz-a-viz best recommendation for an ic to add to my display?

Regards,

Graham

Edit: I answered my own question regarding best choice of IC, it would appear to be the Winbond W25Q128FV  128mbit(16MB Hi-speed 104MHz QSPI) - it turned out to be a little more difficult than anticipated trying to locate them in the UK( including Scotland!! smiley-wink ) however!
15  Products / Arduino Due / Re: Due GUI (Graphical user interface) - [now community project] on: September 16, 2014, 11:48:47 am
Hi Endevor,

Top of page 10 is a git link. Thats the latest. Ediaz did most of the work but has extracted the original UTFT/Touch etc from DUEGUI to allow it to function on whatever hardware is supported by the UTFT suite of libraries.

I ran into problems with the 'invisibility' function and how best to implement fonts on non-font ic equipped displays (although you can still use bigfont/smallfont built in to UTFT).

I vaguely remember something about interrupts........ was the reason not compatible with Mega? Don't quote me! Since the UTFT libraries do run on the Mega, you have nothing to lose by trying?!

Regards,

Graham
Pages: [1] 2 3 ... 8