Commit 3750cbc7 authored by David's avatar David

Will use the forking method. It's less bad.

Will just fake "integration"
parent 26c0e882
......@@ -35,6 +35,7 @@ repositories {
jcenter()
maven { url "https://dl.bintray.com/jerady/maven" }
maven { url "http://dl.bintray.com/jetbrains/spek" }
maven { url 'https://jitpack.io' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
......@@ -73,6 +74,16 @@ dependencies {
"io.github.microutils:kotlin-logging:1.5.6",
'io.github.config4k:config4k:0.4.0'
//V4l4j for the raspberry pi, to get video directly from v4l
//Seems to be reasonably effective. OpenCV would be cool, but it's icky.
// The other option is fork out to rpi commands directly
//This requires the bcm2835_v4l2 module to be loaded
// Need to figure out how to get this to build, it's a huge PITA
//implementation 'com.github.sarxos:v4l4j:0.9.1-r507'
implementation 'com.github.Hopding:JRPiCam:1.1.1'
//Gonna use the DarkSky forecast info
implementation 'tk.plogitech:darksky-forecast-api-jackson:1.3.1',
'org.slf4j:jul-to-slf4j:1.7.25'
......
package `is`.kow.deskscreen
import `is`.kow.deskscreen.camera.CameraController
import `is`.kow.deskscreen.views.DefaultView
import javafx.scene.input.MouseEvent
import javafx.scene.input.TouchEvent
......@@ -11,6 +12,8 @@ class RootView : View() {
val displayController: DisplayController by inject()
val transitionsController: TransitionsController by inject()
val cameraController: CameraController by inject()
override val root = stackpane {
transitionsController.setStartingView(find(DefaultView::class))
......
package `is`.kow.deskscreen.camera
import `is`.kow.deskscreen.MainController
import com.hopding.jrpicam.RPiCamera
import mu.KotlinLogging
import tornadofx.*
import java.awt.image.BufferedImage
import java.nio.file.Paths
class CameraController : Controller() {
val logger = KotlinLogging.logger {}
private val camera: RPiCamera?
private val mainController: MainController by inject()
init {
//Only care that the folders exist
//TODO: add a cleanup mechanism that only keeps some number of pictures, or some amount of space or something
//Or just always use toBufferedStill
Paths.get("/home/pi/Pictures").toFile().mkdirs()
camera = if (mainController.isPi) {
try {
RPiCamera("/home/pi/Pictures")
} catch (e: Exception) {
//Crapopolis
logger.error("Unable to initialize camera", e)
null
}
} else {
null
}
}
fun takePicture(): BufferedImage? {
return camera
?.setRotation(270)
?.setDateTimeOn()
?.setFullPreviewOn()
?.takeBufferedStill()
}
}
\ No newline at end of file
package `is`.kow.deskscreen.camera
import tornadofx.*
class CameraView: View() {
override val root = borderpane {
center = label("LOADING SPINNER UNTIL I SWAP IT")
left = label("Figure out the left size")
right = label("Figure out the right size")
}
}
\ No newline at end of file
package `is`.kow.deskscreen.views
import `is`.kow.deskscreen.Styles
import `is`.kow.deskscreen.camera.CameraController
import `is`.kow.deskscreen.temperature.TemperatureView
import com.github.thomasnield.rxkotlinfx.actionEvents
import io.reactivex.schedulers.Schedulers
import javafx.geometry.Pos
import javafx.scene.paint.CycleMethod
import javafx.scene.paint.LinearGradient
import javafx.scene.paint.Stop
import mu.KotlinLogging
import org.kordamp.ikonli.fontawesome5.FontAwesomeSolid
import org.kordamp.ikonli.javafx.FontIcon
import tornadofx.*
import java.util.*
//TODO: need to ensure a max width
class NamePlateView : View() {
val temperatureView: TemperatureView by inject()
private val logger = KotlinLogging.logger {}
private val temperatureView: TemperatureView by inject()
private val cameraController: CameraController by inject()
override val root = borderpane {
style {
......@@ -48,7 +57,26 @@ class NamePlateView : View() {
}
}
right = temperatureView.root
right = borderpane {
left = button("", FontIcon.of(FontAwesomeSolid.CAMERA, 30)) {
style {
baseColor = c("black")
}
//TODO: switch to a view that uses the sides to display a countdown, and then displays the rendered image after taking
//And allows for a retake....
//TODO: then figure out what to do with the image?
actionEvents()
.observeOn(Schedulers.io())
.map {
Optional.ofNullable(cameraController.takePicture()) //TODO: Need to wrap in optional for desktop
}
.doOnNext {
logger.error("PICTURE TAKEN!")
}
.subscribe()
}
right = temperatureView.root
}
bottom = hbox {
style {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment