johnwasser:
I think your problem is that you are using integers where the original program probably uses 'float' type for everything. Maybe this will help:float cR = x / 120.0;
float cX = y / 120.0;
float zR = 0;
float zX = 0;
int r = 0;
That's brilliant, it's working! Thank you.
I simplified the code too.
void loop()
{
tp = ts.getPoint();
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
if (tp.z > MINPRESSURE && tp.z < MAXPRESSURE) {
for(int y = 170; y > -170; y--){
for(int x = -240; x < 240; x++){
float cR = x/120.0;
float cX = y/120.0;
float zR = 0;
float zX = 0;
int r = 0;
do{
r++;
float old_zR = zR;
zR = cR+((zR*zR)-(zX*zX));
zX = (2*old_zR*zX)+cX;
} while(!(r > 50 || zR > 2));
if (zR < 2){
tft.drawPixel(x+240, y+170, BLACK);
}
else{
tft.drawPixel(x+240, y+170, r*500);
}
}
}
} }
