I'm having this problem in Arduino, but I don't get much help over on the arduino.cc forum, so I thought I'd try over here. After all, there IS an AVR in there () and I think this is more of a C conceptual problem than an Arduino problem.
uint8_t i = 0, X = 0, Y = 140;
for (i = 0; i < 10; i++) {
Partial_Update_Init_Background1(WIDTH_PIXELS, //X size
HEIGHT_PIXELS, //Y size
0xff); //image data
if (i == 2) {
Partial_Update_Display_Area(X, Y, digits2[i].width, digits2[i].height, digits2[i].dig); // x location in bytes, y loc. in pixels
delay(1000);
}
Partial_Update_Display_Area(X, Y, digits2[4].width, digits2[4].height, digits2[4].dig); // x location in bytes, y loc. in pixels
delay(1000);
}
The above code is intended to cause the value of i to be displayed on an epaper display (e.g. when i is 0, 0 should appear on the display). Partial_Update_Display_Area() is what actually does the displaying, and the second call of this function above is all I should need. I've hard-coded the indexes in this call arbitrarily to 4 (it works fine with any value 0 - 9) because if I use i, garbage ensues. In the if statement, however, I can use any value for i (0 - 9) and the function works as it should. The if statement is only there as part of my effort to track down what the problem is, so far to no avail. If I replace the == in the if statement with < (e.g. i < 4), the Partial_Update_Display_Area() breaks there, too. What might be causing this behavior (using a variable works fine in some situations but not in the one I really need it in)? Thanks for any tips.