9 years ago.

the code didn't work as planned

the code should clear the pixel when the condition is not equal to 0, but it didn't give that output.

  1. include "mbed.h"
  2. include "N5110.h" int screen(int i,int j); N5110 lcd(p7,p8,p9,p10,p11,p13,p21); int main() { lcd.init(); lcd.setPixel(3,3); lcd.setPixel(2,3); lcd.setPixel(4,3); lcd.setPixel(3,4); lcd.setPixel(3,5); lcd.setPixel(3,6); lcd.setPixel(3,7); lcd.setPixel(4,4); lcd.setPixel(5,3); lcd.setPixel(4,2); lcd.setPixel(4,7); lcd.setPixel(5,6); lcd.setPixel(7,4); lcd.setPixel(1,4); lcd.setPixel(2,4); lcd.refresh(); while(1); { for (int i=0; i<84; i++) { for(int j=0; j<48; j++) {

int ky=0; if (lcd.getPixel(i,j)!=0) { ky=1; lcd.clearPixel(i,j); lcd.refresh(); } else if (lcd.getPixel(i,j)==0) { ky=0; lcd.setPixel(i,j); lcd.refresh(); } return ky;

} } } }

1 Answer

9 years ago.

Taking a quick glance at that code it seems you're stuck in a while loop. The semicolon after your while (1) will put you in a permanent loop preventing you from ever reaching the for-loops & your clearing logic.

while(1); {

it's still didn't give the output that i want, i have removed the while loop

posted by Muhammad Maarof 23 Apr 2015

The program will exit as soon as it hits return ky; return causes the current function to exit. You are in main() so when you exit that your program is over.

posted by Andy A 23 Apr 2015