Closed Barrois closed 3 years ago
It looks like you do not initialise the variables correctly so they are undefined initially... use:
int x = 0, y = 0, mcuX = 0, mcuY = 0;
Yes ! You are right ! in fact it is in the definition of the table, which has nothing to do ... Thanks a lot for your help.
Here is my code
// https://www.deviceplus.com/arduino/jpeg-decoding-on-arduino-tutorial/ // Include the library
include
include // SPIFFS
// this function determines the minimum of two numbers
define minimum(a,b) (((a) < (b)) ? (a) : (b))
// The coordinate variables int x, y, mcuX, mcuY; // The color of the current pixel int inColor, r, g, b; unsigned int s_s_x, s_s_y; // sauve les coordonnées du point noir unsigned int tableau[32]; // deux fois 4 x 4 unsigned int quelle_carre , carre_1, carre_2; unsigned int x_noir, y_noir, noir ; void setup() {
// Begin Serial port for communication with PC Serial.begin(115200); Serial.println(FILE);
Serial.println(".........................init");
Serial.println("Initializing SPIFFS... "); SPIFFS.begin(); if(!SPIFFS.begin()){ Serial.println("SPIFFS Mount Failed"); return; } char NOM_jpg[] = "/Image7.jpg"; Serial.printf("Picture file name: %s\n", NOM_jpg);
} Serial.println("...................open....JPGFILE"); if(!jpgFile){ Serial.println("Failed to open jpgFile"); } // Decode the JPEG file JpegDec.decodeSdFile(jpgFile); //................ l'image est decodée
// https://onlinejpgtools.com/convert-jpg-to-grayscale // 0.21 r + 0.72 b + 0.07 v Méthode BT-709
tableau[s_s_x,s_s_y] = s_gris ;
// Serial.print("+++++++++++++ point le plus noir est en : "); Serial.print(s_s_x); Serial.print(" , "); // if (s_s_y > 2640 ) s_s_y = s_s_y - 2640; // ????? du à la copie Serial.print(s_s_y); // Serial.print(" et sa couleur est : "); Serial.print(" , ");
Serial.println (s_gris);
// } // }
} }
// Function to fill the packet buffer with zeros void initBuff(char* buff) { for(int i = 0; i < 240; i++) { buff[i] = 0; } }
void loop() { // Nothing here // We don't need to send the same images over and over again } int getMin(int* array, int size){ int minIndex = 0; int min = array[minIndex]; for (int i=1; i<size; i++){ // if (min<array[i]){ // What you wrote if (array[i] < min){ // What Rob wrote minIndex = i; min = array[i]; } } return minIndex; }