Skip to content

Commit

Permalink
showing new image on webapp
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke-Billard committed Mar 23, 2024
1 parent ed3e989 commit cfe3a3b
Show file tree
Hide file tree
Showing 32 changed files with 56 additions and 18 deletions.
16 changes: 16 additions & 0 deletions camera.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from picamera2 import Picamera2
from time import sleep


def take_picture(delay):
camera = Picamera2()
while True:
camera.start()
camera.capture_file("/home/pi/Desktop/PyFarm_Capstone/PyeFarm/PyeFarmProject/frontend/static/images/test.jpg")
camera.stop()
sleep(delay)



if __name__ == "__main__":
take_picture(10)
2 changes: 1 addition & 1 deletion frontend/src/components/CameraViewPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import FormcontrolLabel from "@mui/material/FormControlLabel";
import HomeIcon from "@mui/icons-material/HomeRounded";
import CameraIcon from "@mui/icons-material/CameraAltRounded";

import Greenhouse from "../../static/images/greenhouse.jpg";
import Greenhouse from "../../static/images/test.jpg";

export default class CameraViewPage extends Component{
constructor(props){
Expand Down
20 changes: 18 additions & 2 deletions frontend/src/components/PlantPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import CameraIcon from "@mui/icons-material/CameraAltRounded";
import PlantIcon from "@mui/icons-material/ParkRounded";
//import '../../static/css/index.css';s


// Global vars
let cameraHref = (window.location.href).concat("/cameraview");

Expand All @@ -24,7 +25,22 @@ export default class PlantPage extends Component{
}

render() {
var current_soil_temp;
var current_soil_moisture;

return (
<script src="SearchPage.js"></script>,
$(document).ready(function(){
console.log(response_array);
var num_data_entries = response_array.length;
current_soil_temp = response_array[num_data_entries - 1].soil_temp;
current_soil_moisture = response_array[num_data_entries - 1].soil_moisture;
console.log("current soil temp: " + current_soil_temp);
console.log("current soil moisture: " + current_soil_moisture);
$('#cur_soil_temp').text(current_soil_temp);
$('#cur_soil_moisture').text(current_soil_moisture);
}),

<body style={{margin: "0", padding: 0, backgroundColor:"white", height:"100vh", width:"100vw", position:"relative"}}>
{/* Solid Rectangle at top of page*/}
<div style={{display: "inline-block", width:"100vw", height:"3vh", background:"#68AC67", align:"center" }}></div>
Expand Down Expand Up @@ -128,15 +144,15 @@ export default class PlantPage extends Component{
<p style={{width:"4vw"}}>&nbsp;</p>
</Grid>
<Grid item xs={false} align ="left">
<Button disabled="true" style={{width:"20vw", height:"25vh",backgroundColor: '#A3BD8B', border: "3px solid black", borderRadius:"5px"}}>
<Button id="cur_soil_temp" disabled="true" style={{width:"20vw", height:"25vh",backgroundColor: '#A3BD8B', border: "3px solid black", borderRadius:"5px"}}>
<b style={{width:"20vw", color:"black", font:"Oxygen", fontSize:20}}> °C <br /> <br /> <div style={{ borderTop: "2px solid #000000 ", marginLeft: 0, marginRight: 0 }}></div> <br /> tempVar </b>
</Button>
</Grid>
<Grid item xs={false} align ="left">
<p style={{width:"4vw"}}>&nbsp;</p>
</Grid>
<Grid item xs={false} align ="left">
<Button disabled="true" style={{width:"20vw", height:"25vh",backgroundColor: '#85B658', border: "3px solid black", borderRadius:"5px"}}>
<Button id="cur_soil_moisture" disabled="true" style={{width:"20vw", height:"25vh",backgroundColor: '#85B658', border: "3px solid black", borderRadius:"5px"}}>
<b style={{width:"20vw", color:"black", font:"Oxygen", fontSize:20}}> % <br /> <br /> <div style={{ borderTop: "2px solid #000000 ", marginLeft: 0, marginRight: 0 }}></div> <br /> moistVar </b>
</Button>
</Grid>
Expand Down
15 changes: 10 additions & 5 deletions frontend/src/components/SearchPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import {SelectComponent} from './SelectComponent';

// temporary import
import tempPlant from "../../static/images/plant.png"
import Greenhouse from "../../static/images/greenhouse.jpg";
import Greenhouse from "../../static/images/test.jpg";

// temporary camera page link
let cameraHref = (window.location.href).concat("/plant/cameraview");

//global variable for response data
var response_array;

export default class SearchPage extends Component{
constructor(props){
super(props);
Expand Down Expand Up @@ -50,8 +53,10 @@ export default class SearchPage extends Component{
current_air_humid = response[num_data_entries - 1].air_humid
console.log("current air temp: " + current_air_temp);
console.log("current air humidity: " + current_air_humid);
$('#cur_temp').text(current_air_temp);
$('#cur_humid').text(current_air_humid);
$('#cur_temp').text(current_air_temp + " " + "°C");
$('#cur_humid').text(current_air_humid + " " + "%");
response_array = response;
console.log(response_array)
}

});
Expand Down Expand Up @@ -146,7 +151,7 @@ export default class SearchPage extends Component{
<p style={{width:"3vw"}}>&nbsp;</p>
</Grid>
<Grid item xs={false} align ="left">
<Button id = "cur_temp" disabled="true" style={{width:"20vw", backgroundColor: '#67AE66', border: "3px solid black", borderRadius:"5px"}}>
<Button id = "cur_temp" disabled="true" style={{width:"20vw", backgroundColor: '#67AE66', border: "3px solid black", borderRadius:"5px", color:"black"}}>
<b style={{width:"19vw", color:"black", font:"Oxygen", fontSize:20}}></b>
</Button>
</Grid>
Expand Down Expand Up @@ -183,7 +188,7 @@ export default class SearchPage extends Component{
<p style={{width:"3vw"}}>&nbsp;</p>
</Grid>
<Grid item xs={false} align ="left">
<Button id = "cur_humid" disabled="true" style={{width:"20vw", backgroundColor: '#85B658', border: "3px solid black", borderRadius:"5px"}}>
<Button id = "cur_humid" disabled="true" style={{width:"20vw", backgroundColor: '#85B658', border: "3px solid black", borderRadius:"5px", color:"black"}}>
<b style={{width:"19vw", color:"black", font:"Oxygen", fontSize:20}}></b>
</Button>
</Grid>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion frontend/static/frontend/main.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions frontend/static/frontend/main.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
!*** ./src/components/App.js ***!
\*******************************/

/*!********************************!*\
!*** ./static/images/test.jpg ***!
\********************************/

/*!*********************************!*\
!*** ./static/images/plant.png ***!
\*********************************/
Expand All @@ -26,10 +30,6 @@
!*** ./src/components/SearchPage.js ***!
\**************************************/

/*!**************************************!*\
!*** ./static/images/greenhouse.jpg ***!
\**************************************/

/*!****************************************!*\
!*** ./node_modules/react-is/index.js ***!
\****************************************/
Expand Down
Binary file added frontend/static/images/test.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion frontend/templates/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</div>

<script src ="{% static "frontend/main.js" %}"></script>
<!--<script src ="{% static "frontend/src/components/SearchPage.js" %}"></script>-->
<script src ="{% static "frontend/src/components/SearchPage.js" %}"></script>
<script src ="{% static "frontend/src/components/PlantPage.js" %}"></script>
</body>
</html>
8 changes: 4 additions & 4 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import serial_test
from threading import Thread


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'PyeFarmProject.settings')
Expand All @@ -21,7 +20,8 @@ def main():


if __name__ == '__main__':
serial_comm_thread = Thread(target = serial_test.serial_comm, args = ())
serial_comm_thread.start()
#serial_comm_thread = Thread(target = serial_test.serial_comm, args = ())
#serial_comm_thread.start()

main()
serial_comm_thread.join()
#serial_comm_thread.join()

0 comments on commit cfe3a3b

Please sign in to comment.