Comments (6)
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.
Hey! That's great!
from liveov7670.
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.
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.
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:
I need this code in one of my school projects, please help me solve this.
from liveov7670.
Hey again ! IT S WORKINGGGG !!! Thank you very very much! YOU'RE AWESOME!
from liveov7670.
Related Issues (20)
- WAVGAT boards support? HOT 2
- Energia CC1350 Version HOT 3
- No issue: This is amazing.
- Problem with installing "ArduImageCapture" Plug-In HOT 5
- How can I make VSYNC pulse when I need to capture frame? HOT 1
- TFT image Mirrored. Please Help
- CameraOV7670.h: No such file or directory HOT 3
- I have issues getting it to output a clear image HOT 2
- Camera OV7670 on SAMD51
- Camera output turned red after showing image HOT 1
- Command checksum failed HOT 1
- How to use on LCD TFT 3,5" ILI9488
- Can't compile for Nano Every HOT 1
- ov7670 library HOT 1
- Is this code compatible with the TFT ST7735S Display?
- Pin Definitions, ESP32-Applicability and Image Classification
- green square and no Vsync no matter what I do HOT 3
- Cannot upload the code. Error: ".... was not declared in this scope"
- can't compile while trying to compile to arduino uno
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liveov7670.