OK, so I made this little graphing program, witch simply reads anna analoug value and displays it via TV-out. here is the code:
#include <TVout.h>
#include <fontALL.h>
TVout TV;
int value;
void setup() {
Serial.begin(9600);
TV.begin(_PAL,128,72);
TV.select_font(font8x8);
TV.println("ready to graph.");
TV.println();
TV.println("please enter 1-9 in serial to start.");
while(Serial.available()==0)
{
}
TV.clear_screen();
byte ch=Serial.read();
if(ch >= '0' && ch <= '9')
{
value = (value * 10) + (ch - '0');
}else
{
TV.println("ERROR:");
TV.println();
TV.println("not a number!");
while(1)
{
//hang
}
}
value=value*100;//convert
TV.draw_row(71,0,128,WHITE);
TV.draw_column(0,0,72,WHITE);
}
int newx=0;
int newy=0;
int prevx=newx;
int prevy=newy;
void loop() {
prevx=newx;
prevy=newy;
newx==analogRead(0);
newy++;
Serial.println("X="+newx);
Serial.println("Y="+newy);
Serial.println("RAM: "+memoryFree());
TV.draw_line(prevx,prevy,newx,newy,WHITE);
delay(value);
}
//RAM debugging:
extern int __bss_end;
extern void *__brkval;
int memoryFree()
{
int freeValue;
if((int)__brkval == 0)
freeValue = ((int)&freeValue) - ((int)&__bss_end);
else
freeValue = ((int)&freeValue) - ((int)__brkval);
return freeValue;
}
now, this did not work. after entering the speed via cerial, it goes into the graphing screen and is meant to log the value. it displays the X and Y lines at the bottom and left of the screen, but the actual data line is not present. so, as you can see, I added some debug statements. now here is the weird part. I am receving this in serial:
=
RAM:
AM:
M:
:
ready to graph.
eady to graph.
ady to graph.
dy to graph.
y to graph.
to graph.
to graph.
o graph.
graph.
graph.
raph.
aph.
ph.
h.
.
please enter 1-9 in serial to start.
lease enter 1-9 in serial to start.
ease enter 1-9 in serial to start.
ase enter 1-9 in serial to start.
se enter 1-9 in serial to start.
e enter 1-9 in serial to start.
enter 1-9 in serial to start.
enter 1-9 in serial to start.
nter 1-9 in serial to start.
ter 1-9 in serial to start.
er 1-9 in serial to start.
r 1-9 in serial to start.
1-9 in serial to start.
1-9 in serial to start.
1-9 in serial to start.
1-9 in serial to start.
-9 in serial to start.
9 in serial to start.
in serial to start.
in serial to start.
n serial to start.
serial to start.
serial to start.
erial to start.
rial to start.
ial to start.
al to start.
l to start.
to start.
to start.
to start.
o start.
start.
start.
tart.
art.
rt.
t.
.
ERROR:
RROR:
ROR:
OR:
R:
:
not a number!
ot a number!
t a number!
a number!
a number!
number!
number!
umber!
mber!
ber!
er!
r!
!
C
?ðAlR
ðAlR
ðAlR
AlR
AlR
AlR
AlR
lR
lR
R
R
E
h
È
and so fourth with random junk. what it looks like to me, is it is going trough every RAM bit 1 step at a time, in reverse. witch explains why the sentences of data are incomplete. (it does not look for the start but the end of strings, I know why.) I have tryed to change all strings to TV.printPGM(PSTR("string for program memory here")), but similar occurs. even stranger is that it hangs and does not output the Y or available RAM (put there to see if it was a memory problem(well of course it is, but to see if it was out of memory)). what can I do?
I have an UNO and according to my benchmark program I have 1154 bytes of memory used by TV-out at the current resolution out of 2Ks, so that seems sufficient. but that is without any other vars, just text on the screen.