Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/flipper_plotter #47

Merged
merged 23 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
590071e
feat: Create pulse plotter from Flipper
mlyubimov Oct 6, 2023
5f54b38
feat: Add alias for composables
mlyubimov Oct 6, 2023
042c063
feat: Add composable useNumberOnly
mlyubimov Oct 6, 2023
4ec1934
fix: Deleted unnecessary code
mlyubimov Oct 6, 2023
0b76e84
refactor: Changed syntax
mlyubimov Oct 6, 2023
d70b023
feat: Added a limit on entering numbers
mlyubimov Oct 6, 2023
e428b1b
feat: Added destroy worker when leaving the page
mlyubimov Oct 7, 2023
278de94
Merge branch 'dev' into feature/flipperPlotter
mlyubimov Oct 10, 2023
f2f9ab4
feat: Moved the default theme to a constant
mlyubimov Oct 10, 2023
3822180
feat: Сhanged the color of the edge lines
mlyubimov Oct 10, 2023
8505672
feat: Renamed radio tools
mlyubimov Oct 10, 2023
c932431
feat: Сhanged the color of the edge lines without worker
mlyubimov Oct 10, 2023
0e21298
feat: Added pulse combining instead of shrinkage
mlyubimov Oct 13, 2023
4b82c9f
refactor: Moved general functions to utils
mlyubimov Oct 13, 2023
40323c6
feat: Changed the drawing method for pulses
mlyubimov Oct 13, 2023
3103289
feat: Added visual fixes
mlyubimov Oct 16, 2023
723c36b
feat: Removed package-lock from git
Oct 16, 2023
6119bd4
refactor: Deleted the code of the old plotter
Oct 16, 2023
3ec1ed4
feat: Removes an open file when the flipper is disconnected
Oct 16, 2023
a539ba8
feat: Added monitoring window resizing
Oct 16, 2023
6205000
feat: Edge lines are enabled all at once
mlyubimov Nov 2, 2023
326d8a6
Merge branch 'dev' into feature/flipperPlotter
mlyubimov Nov 2, 2023
55f91bf
fix: removed the merge error
mlyubimov Nov 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: Create pulse plotter from Flipper
  • Loading branch information
mlyubimov committed Oct 6, 2023
commit 590071e90de8e63a0985d4db84c5dbffe7c12c27
1 change: 1 addition & 0 deletions frontend/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/node_modules
.eslintrc.js
babel.config.js
quasar.conf.js
21 changes: 21 additions & 0 deletions frontend/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"arrowParens": "always",
"bracketSameLine": false,
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto",
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxSingleQuote": true,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": false,
"singleAttributePerLine": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false,
"vueIndentScriptAndStyle": false
}
3 changes: 3 additions & 0 deletions frontend/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"boot/*": [
"src/boot/*"
],
"util/*": [
"src/util/*"
],
"vue$": [
"node_modules/vue/dist/vue.runtime.esm-bundler.js"
]
Expand Down
4 changes: 4 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"private": true,
"scripts": {
"lint": "eslint --ext .js,.vue ./",
"lint-fix": "eslint --fix --ext .js,.vue ./",
"format": "prettier --write \"**/*.{js,ts,vue,scss,sass,css,html,md,json}\" --ignore-path .eslintignore --config .prettierrc.json && npm run lint-fix",
"dev/web": "quasar dev",
"dev/electron": "quasar dev -m electron",
"build": "PRODUCTION=TRUE quasar build -m spa",
Expand All @@ -17,9 +19,11 @@
"dependencies": {
"@quasar/extras": "^1.14.0",
"core-js": "^3.6.5",
"d3": "^7.8.5",
"loglevel": "^1.8.0",
"nanoevents": "^6.0.2",
"pako": "^2.0.4",
"prettier": "^3.0.3",
"protobufjs": "~6.11.2",
"quasar": "^2.7.1",
"semver": "^7.3.6",
Expand Down
5 changes: 4 additions & 1 deletion frontend/quasar.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* eslint-env node */
const ESLintPlugin = require('eslint-webpack-plugin')
const { configure } = require('quasar/wrappers')
const path = require('node:path')

module.exports = configure(function (ctx) {
return {
Expand Down Expand Up @@ -75,7 +76,9 @@ module.exports = configure(function (ctx) {
// "chain" is a webpack-chain object https://github.com/neutrinojs/webpack-chain
chainWebpack (chain) {
chain.plugin('eslint-webpack-plugin')
.use(ESLintPlugin, [{ extensions: ['js', 'vue'] }])
.use(ESLintPlugin, [{ extensions: ['js', 'vue'] }]),
chain.resolve.alias
.set('util', path.resolve(__dirname, './src/util'))
}
},

Expand Down
124 changes: 124 additions & 0 deletions frontend/src/components/FlipperPlotter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<template>
<div id="flipperPlotter" class="full-width q-mb-md" />
<div class="full-width">
<div class="row q-col-gutter-md q-mb-md">
<q-select
class="col-1"
v-model="currentSlicer.modulation"
:options="slicerOptions"
option-value="value"
option-label="text"
emit-value
label="Slicer"
/>
<q-input
class="col-1"
v-model.number.trim="currentSlicer.short"
type="text"
label="Short"
/>
<q-input
class="col-1"
v-model.number.trim="currentSlicer.long"
type="text"
label="Long"
/>
<q-input
class="col-1"
v-model.number.trim="currentSlicer.sync"
type="text"
label="Sync"
/>
<q-input
class="col-1"
v-model.number.trim="currentSlicer.gap"
type="text"
label="Gap"
/>
<div class="col-2 flex">
<q-btn
color="primary"
icon="content_cut"
label="Slice"
size="md"
unelevated
@click="onSlice"
/>
</div>
</div>
<div class="column">
<div ref="timings" class="q-mb-md" />
<div ref="bits" />
</div>
</div>
</template>

<script>
import { defineComponent, onMounted, ref, watch } from 'vue'
import { FlipperPlotter } from 'util/flipperPlotter/flipperPlotter.js'
import { FlipperPlotterOffscreen } from 'util/flipperPlotter/flipperPlotterOffscreen.js'

export default defineComponent({
name: 'FlipperPlotter',

props: ['data', 'offscreen'],

setup (props) {
const timings = ref(null)
const bits = ref(null)

const plot = ref(null)
const slicerOptions = ref(null)
const currentSlicer = ref({
modulation: '',
short: 0,
long: 0,
sync: 0,
gap: 0
})

const onSlice = () => {
plot.value.setSlicer(currentSlicer.value)
}

const draw = () => {
const config = {
data: props.data,
timings: timings.value,
messages: bits.value
}

if (props.offscreen) {
plot.value = new FlipperPlotterOffscreen(config)
} else {
plot.value = new FlipperPlotter(config)
}

slicerOptions.value = plot.value.slicerOptions
currentSlicer.value = plot.value.slicer
}

onMounted(() => {
draw()
})

watch(
() => props.data,
() => {
plot.value.destroy()
draw()
}
)

return {
timings,
bits,

slicerOptions,
currentSlicer,

onSlice
}
}
})
</script>
119 changes: 75 additions & 44 deletions frontend/src/pages/Pulseplot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
style="min-width: 200px;"
/>

<div class="pulseplot fit position-relative" v-show="!flags.wrongFileType">
<FlipperPlotter v-if="plot" :data="data" :offscreen="flags.offscreenCanvasSupported"/>

<!-- <div class="pulseplot fit position-relative" v-show="!flags.wrongFileType">
<q-scroll-area
ref="scrollAreaRef"
v-if="plot"
Expand Down Expand Up @@ -98,24 +100,32 @@
</div>
<div class="pulseplot-timings overflow-auto q-py-sm"></div>
<div class="pulseplot-messages q-py-sm" style="word-break: break-all;"></div>
</div>
</div> -->
</q-page>
</template>

<script>
import { defineComponent, ref } from 'vue'
import { Pulseplot as PulseplotOffscreen } from '../util/pulseplot/pulseplot-offscreen'
import { Pulseplot } from '../util/pulseplot/pulseplot'
// import { Pulseplot as PulseplotOffscreen } from '../util/pulseplot/pulseplot-offscreen'
// import { Pulseplot } from '../util/pulseplot/pulseplot'
import * as observablePlot from '@observablehq/plot'
import FlipperPlotter from 'src/components/FlipperPlotter.vue'

export default defineComponent({
name: 'Pulseplot',

components: {
FlipperPlotter
},

props: {
passedFile: Object
},

setup () {
return {
observablePlot,

flags: ref({
wrongFileType: false,
offscreenCanvasSupported: true,
Expand Down Expand Up @@ -169,7 +179,7 @@ export default defineComponent({
watch: {
uploadedFile (newFile, oldFile) {
if (this.plot) {
this.plot.destroy()
// this.plot.destroy()
}
this.flags.wrongFileType = false
this.signals = null
Expand All @@ -179,7 +189,7 @@ export default defineComponent({
currentSignal (newSignal, oldSignal) {
if (newSignal) {
if (this.plot) {
this.plot.destroy()
// this.plot.destroy()
}
this.data = {
centerfreq_Hz: newSignal.frequency,
Expand Down Expand Up @@ -349,43 +359,44 @@ export default defineComponent({
},

draw () {
const config = {
parent: '.pulseplot',
data: this.data,
height: 300
}

if (this.plot) {
this.plot.destroy()
this.prevScroll = null
this.nextVanityScroll = {
percentage: null,
position: null
}
const oldCanvas = document.querySelector('.pulseplot-canvas')
oldCanvas.remove()
const canvas = document.createElement('canvas')
canvas.classList.add('pulseplot-canvas')
canvas.style.imageRendering = 'pixelated'
document.querySelector('.zoom-controls').before(canvas)
}

if (this.flags.offscreenCanvasSupported) {
this.plot = new PulseplotOffscreen(config)
} else {
this.plot = new Pulseplot(config)
}

// console.log(this.plot)
this.plot.enableScrollZoom()
if (this.plot.slicer.name !== 'No clue...' && this.plot.slicer.modulation) {
this.slicer.modulation = this.plot.slicer.modulation
this.slicer.short = this.plot.slicer.short || 0
this.slicer.long = this.plot.slicer.long || 0
this.slicer.sync = this.plot.slicer.sync || 0
this.slicer.gap = this.plot.slicer.gap || 0
this.setSlicer()
}
this.plot = true
// const config = {
// parent: '.pulseplot',
// data: this.data,
// height: 300
// }

// if (this.plot) {
// this.plot.destroy()
// this.prevScroll = null
// this.nextVanityScroll = {
// percentage: null,
// position: null
// }
// const oldCanvas = document.querySelector('.pulseplot-canvas')
// oldCanvas.remove()
// const canvas = document.createElement('canvas')
// canvas.classList.add('pulseplot-canvas')
// canvas.style.imageRendering = 'pixelated'
// document.querySelector('.zoom-controls').before(canvas)
// }

// if (this.flags.offscreenCanvasSupported) {
// this.plot = new PulseplotOffscreen(config)
// } else {
// this.plot = new Pulseplot(config)
// }

// // console.log(this.plot)
// this.plot.enableScrollZoom()
// if (this.plot.slicer.name !== 'No clue...' && this.plot.slicer.modulation) {
// this.slicer.modulation = this.plot.slicer.modulation
// this.slicer.short = this.plot.slicer.short || 0
// this.slicer.long = this.plot.slicer.long || 0
// this.slicer.sync = this.plot.slicer.sync || 0
// this.slicer.gap = this.plot.slicer.gap || 0
// this.setSlicer()
// }
},

setSlicer () {
Expand All @@ -408,13 +419,32 @@ export default defineComponent({
} else {
const dy = e.verticalPosition - this.prevScroll.verticalPosition
const dx = e.horizontalPosition - this.prevScroll.horizontalPosition

this.prevScroll = e
if (dx !== 0) {
this.plot.scroll = e.horizontalPosition - 10
}

if (dy !== 0 && dy !== this.zoomLimit.max) {
const val = (this.zoomLimit.max - e.verticalPosition) > 0 ? this.zoomLimit.max - e.verticalPosition : this.zoomLimit.min
this.zoom({ val })

let plotZoom
if (this.sliderZoom < 100) {
// this.scrollAreaRef.setScrollPosition('vertical', plotZoom)
if (dy < 0) {
plotZoom = this.plot.zoom * 1.1
// plotZoom = val * 0.1
} else {
plotZoom = this.plot.zoom * 0.9
// plotZoom = val * 1.1
}
} else {
plotZoom = val
}

// console.log(e, this.zoomLimit.max - e.verticalPosition, plotZoom, this.plot.zoom)

this.zoom({ val: plotZoom })
} else {
this.plot.redrawCanvas()
}
Expand All @@ -433,6 +463,7 @@ export default defineComponent({
} else if (val) {
result = val
}

if (result <= this.zoomLimit.min) {
this.plot.zoom = this.zoomLimit.min
} else if (result >= this.zoomLimit.max) {
Expand Down
Loading