Giter VIP home page Giter VIP logo

Comments (6)

indrekluuk avatar indrekluuk commented on May 29, 2024 1

Hey!

The "pinMode(13,INPUT);" should go inside "void initializeScreenAndCamera()"

void initializeScreenAndCamera() {
  pinMode(13,INPUT);
  ...

Currently isButtonPressed() doesn't return a value. It should be something like this:

bool isButtonPressed() {
  buttonState=digitalRead(13);
  if(buttonState==HIGH) {
    digitalWrite(8,HIGH);
    return true;
  } else {
    digitalWrite(8,LOW);
    return false;
  }
}

The "if(isButtonPressed() && !isFrameSent){" should surround everything inside "processFrame()"

void processFrame() {
  if(isButtonPressed() && !isFrameSent){ // button check starts here

    startNewFrame(uartPixelFormat);

    noInterrupts();
    camera.waitForVsync();

    for (uint16_t y = 0; y < lineCount; y++) {

#if UART_MODE==7
      // separate loop for full VGA
      for (uint16_t x = 0; x < lineLength; x++) {
        // ignore first pixel byte
        camera.waitForPixelClockRisingEdge();

        // second byte is grayscale byte
        camera.waitForPixelClockRisingEdge();
        uint8_t pixelByte;
        camera.readPixelByte(pixelByte);
        sendPixelByteGrayscale(pixelByte);
      }
      // delay for last byte
      pixelSendingDelay();

#else

      lineBufferIndex = 0;
      uint8_t sendWhileReadCounter = 0;

      lineBuffer[0] = 0; // first byte from Camera is half a pixel

      for (uint16_t x = 1; x < lineLength*2+1; x++) {
        // start sending first bytes while reading pixels from camera
        if (uartSendWhileReadingCount > 0) {
          if (sendWhileReadCounter) {
            sendWhileReadCounter--;
          } else {
            sendNextPixelByte();
            sendWhileReadCounter = uartSendWhileReadingCount;
          }
        }

        camera.waitForPixelClockRisingEdge();
        camera.readPixelByte(lineBuffer[x]);
      }

      // send rest of the line
      while (lineBufferIndex < lineLength * 2) {
        sendNextPixelByte();
        pixelSendingDelay();
      }
#endif

      endOfLine();
    }
    interrupts();

    frameCounter++;
    debugPrint("Frame " + String(frameCounter));
    //debugPrint("Frame " + String(frameCounter, 16)); // send number in hexadecimal


  
    isFrameSent = true;  // button check ends here
  } else {
    isFrameSent = false;
  }
}

Please note that I have not tested it myself, but it should work with code something like this.

from liveov7670.

indrekluuk avatar indrekluuk commented on May 29, 2024 1

Hey! That's great!

from liveov7670.

indrekluuk avatar indrekluuk commented on May 29, 2024

Hey!

You can do something like this:

bool isFrameSent = false;
void processFrame() {
  if (isButtonPressed() && !isFrameSent) {

    // frame sending code here

    isFrameSent = true;
  } else {
    isFrameSent = false;
  }
}

where isButtonPressed() is a function that checks the button's pin.

from liveov7670.

Asinedecila avatar Asinedecila commented on May 29, 2024

Hey!

You can do something like this:

bool isFrameSent = false;
void processFrame() {
  if (isButtonPressed() && !isFrameSent) {

    // frame sending code here

    isFrameSent = true;
  } else {
    isFrameSent = false;
  }
}

where isButtonPressed() is a function that checks the button's pin.

Thank you very much for your answer, I'll try and come back with a feedback.

from liveov7670.

Asinedecila avatar Asinedecila commented on May 29, 2024

Hey ! I tried what you told me, but something is still wrong. This is the code that I changed:


**int buttonState=0;

bool isButtonPressed(){
  pinMode(13,INPUT);
  buttonState=digitalRead(13);
  if(buttonState==HIGH)
  {  digitalWrite(8,HIGH);
    }
    else { digitalWrite(8,LOW);
  
       }
  }
bool  isFrameSent=false;**

// this is called in Arduino loop() function
void processFrame() {
  
  startNewFrame(uartPixelFormat);

  noInterrupts();
  camera.waitForVsync();

  for (uint16_t y = 0; y < lineCount; y++) {

#if UART_MODE==7
    // separate loop for full VGA
    for (uint16_t x = 0; x < lineLength; x++) {
      // ignore first pixel byte
      camera.waitForPixelClockRisingEdge();

      // second byte is grayscale byte
      camera.waitForPixelClockRisingEdge();
      uint8_t pixelByte;
      camera.readPixelByte(pixelByte);
      sendPixelByteGrayscale(pixelByte);
    }
    // delay for last byte
    pixelSendingDelay();

#else

    lineBufferIndex = 0;
    uint8_t sendWhileReadCounter = 0;

    lineBuffer[0] = 0; // first byte from Camera is half a pixel
  //digitalWrite(8,LOW);
    for (uint16_t x = 1; x < lineLength*2+1; x++) {
      
  
      // start sending first bytes while reading pixels from camera
       if (uartSendWhileReadingCount > 0) {
       **if(isButtonPressed() && !isFrameSent){**   //I don't know if this is the line where I should put this if
        if (sendWhileReadCounter) {
          sendWhileReadCounter--;
          
        } else {
          sendNextPixelByte();
          sendWhileReadCounter = uartSendWhileReadingCount;
          
        }
      }
      camera.waitForPixelClockRisingEdge();
      camera.readPixelByte(lineBuffer[x]);

    // send rest of the line
    while (lineBufferIndex < lineLength * 2) {
      sendNextPixelByte();
      pixelSendingDelay();
    }
#endif

    endOfLine();
  
 **isFrameSent=true; //This is also what I wrote
} 
  else isFrameSent=false;
     }**
  interrupts();
  
}

  frameCounter++;
  debugPrint("Frame " + String(frameCounter));
  //debugPrint("Frame " + String(frameCounter, 16)); // send number in hexadecimal
  
}

I think there is also a conflict between the java application with the LISTEN button and the button that I put on the arduino because I got this:
github
2021-04-20_18 26 10 067

I need this code in one of my school projects, please help me solve this.

from liveov7670.

Asinedecila avatar Asinedecila commented on May 29, 2024

Hey again ! IT S WORKINGGGG !!! Thank you very very much! YOU'RE AWESOME!

from liveov7670.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.