code clean up

pull/1/head
Thomas Ballmann 4 years ago
parent 2f4c343d88
commit 7c385836d3

@ -13,39 +13,38 @@
app
>
<!-- https://cdn.vuetifyjs.com/images/parallax/material.jpg -->
<v-img class="device-screen-image" :aspect-ratio="16/9" src="/fs/screen.bmp">
<v-img class="device-screen-image" :aspect-ratio="16/9" :src="device_screen_src">
<v-row align="end" class="lightbox white--text pa-2 fill-height">
<!--
<v-col>
<!--<div class="subheading">update in 2min</div>-->
<!--<div class="body-1">heyfromjonathan@gmail.com</div>-->
<div class="subheading">update in 2min</div>
<div class="body-1">heyfromjonathan@gmail.com</div>
</v-col>
-->
</v-row>
</v-img>
<v-list-item>
<v-list-item-icon class="mr-3">
<v-progress-circular
:rotate="-90"
:size="50"
:width="5"
:value="playlistProgress"
>
{{ playlistRemaining }}
</v-progress-circular>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title class="title">
paperdash.io
{{ stats.playlist.current }}
</v-list-item-title>
<v-list-item-subtitle>
Weather
8. March 2020
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<div class="d-flex justify-center py-5">
<v-progress-circular
class=""
:rotate="-90"
:size="100"
:width="15"
value="40"
color="teal"
>
40
</v-progress-circular>
</div>
<v-divider></v-divider>
<v-list-item>
@ -76,29 +75,16 @@
<v-list-item>
<v-list-item-content>
<v-progress-linear value="74" height="20">
19%
Total: {{ stats.device.fs.total | prettyBytes }}<br/>
Free: {{ stats.device.fs.free | prettyBytes }}
<v-progress-linear :value="fsUsagePercent" height="25">
<template v-slot="{ value }">
<strong class="white--text">{{ Math.ceil(value) }}%</strong>
</template>
</v-progress-linear>
</v-list-item-content>
</v-list-item>
<!--
<v-list>
<v-list-item
v-for="(link, i) in items"
:key="i"
:to="link.to"
active-class="primary white--text"
>
<v-list-item-action>
<v-icon v-text="link.icon" />
</v-list-item-action>
<v-list-item-title v-text="link.title" />
</v-list-item>
</v-list>
-->
</v-navigation-drawer>
<!--
@ -112,7 +98,6 @@
-->
<v-app-bar app color="orange lighten-1" dark short>
<!-- -->
<v-app-bar-nav-icon @click="drawer = !drawer">
<v-icon>$device</v-icon>
</v-app-bar-nav-icon>
@ -121,14 +106,11 @@
<v-spacer></v-spacer>
<v-template
v-for="(link, i) in items"
:key="i"
>
<v-btn icon :to="link.to">
<template v-for="(link, i) in items">
<v-btn icon :to="link.to" :key="i">
<v-icon v-text="link.icon" />
</v-btn>
</v-template>
</template>
</v-app-bar>
@ -142,7 +124,7 @@
</template>
<script>
import apiDevice from './api/device'
import "@/assets/app.css"
// eslint-disable-next-line
//import imageBmp from "@/assets/black.bmp"
@ -152,14 +134,21 @@
export default {
name: 'App',
data: () => ({
isLoading: false,
isLoading: true,
stats: null,
drawer: true,
items: [
{title: 'Dashboard', icon: '$dashboard', to: '/'},
{title: 'Sandbox', icon: '$sandbox', to: '/sandbox'},
//{title: 'Sandbox', icon: '$sandbox', to: '/sandbox'},
{title: 'Wifi', icon: '$wifi', to: '/wifi'},
{title: 'Settings', icon: '$settings', to: '/settings'},
],
],
playlistRemaining: 0,
playlistTimerProgress: 30,
device_screen_src: null
}),
created () {
this.$vuetify.icons.values.device = {component: () => import(/* webpackChunkName: "icons" */'!vue-svg-loader!@material-icons/svg/svg/cast/baseline.svg')}
@ -167,7 +156,51 @@
this.$vuetify.icons.values.settings = {component: () => import(/* webpackChunkName: "icons" */'!vue-svg-loader!@material-icons/svg/svg/settings/baseline.svg')}
this.$vuetify.icons.values.wifi = {component: () => import(/* webpackChunkName: "icons" */'!vue-svg-loader!@material-icons/svg/svg/wifi/baseline.svg')}
this.$vuetify.icons.values.sandbox = {component: () => import(/* webpackChunkName: "icons" */'!vue-svg-loader!@material-icons/svg/svg/gesture/baseline.svg')} // gesture, brush, palette,
this.reloadStats(() => {
this.isLoading = false
})
},
watch: {
playlistRemaining: {
handler(value) {
if (value > 0) {
setTimeout(() => {
this.playlistRemaining--
}, 1000)
} else {
this.reloadStats()
}
},
}
},
computed: {
fsUsagePercent () {
let fs = this.stats.device.fs
return parseInt(100 / fs.total * fs.used)
},
playlistProgress () {
return parseInt(100 / 60 * this.stats.playlist.remaining)
}
},
methods: {
reloadStats (cb) {
console.log("reloadStats")
this.device_screen_src = "/fs/screen.bmp?" + new Date()
apiDevice.getStats(stats => {
this.stats = stats
this.playlistRemaining = stats.playlist.remaining
this.playlistTimerProgress = parseInt(100 / 60 * stats.playlist.remaining)
if (cb) {
cb()
}
})
}
}
};
</script>

@ -11,8 +11,14 @@ const _settings = {
playlist: {
timer: 60
},
api: {
owm: ""
weather: {
api: "",
location: 2766824,
lang: "de",
unit: "metric"
},
datetime: {
gmt_offset: 3600
},
cloud: {
mode: "active",
@ -21,6 +27,43 @@ const _settings = {
}
}
// eslint-disable-next-line
const _stats = {
"wifi": {
"ssid": "xd-design.info",
"connected": true,
"ip": "192.168.178.62",
"mac": "30:AE:A4:21:20:40",
"channel": 1,
"dns": "192.168.178.1",
"gateway": "192.168.178.1"
},
"device": {
"heap": 120496,
"bootCycle": 1,
"screen": {
"width": 640,
"height": 384
},
"fs": {
"total": 1860161,
"used": 1107663,
"free": 752498
}
},
"playlist": {
"current": "Calendar",
"remaining": 22
},
"capability": [
"png",
"wbmp"
],
"cloud": {
"sleep": 10
}
}
// eslint-disable-next-line
const _wifiScan = [{ "rssi": -59, "ssid": "xd-design.info", "bssid": "38:10:D5:34:80:1B", "channel": 11, "secure": 3 }, { "rssi": -75, "ssid": "FRITZ!Box 7430 JI", "bssid": "38:10:D5:5D:FE:7C", "channel": 1, "secure": 3 }, { "rssi": -87, "ssid": "Vodafone Hotspot", "bssid": "AA:0E:14:BD:50:ED", "channel": 1, "secure": 0 }, { "rssi": -88, "ssid": "WLAN-548426", "bssid": "E0:60:66:55:7F:C5", "channel": 1, "secure": 3 }, { "rssi": -89, "ssid": "Familie Kalinowski", "bssid": "C8:0E:14:BD:50:ED", "channel": 1, "secure": 3 }, { "rssi": -91, "ssid": "WLAN-507287", "bssid": "E0:60:66:48:6C:6B", "channel": 1, "secure": 3 }, { "rssi": -94, "ssid": "TP-LINK_7238", "bssid": "A4:2B:B0:D8:72:38", "channel": 3, "secure": 3 }]
@ -87,5 +130,19 @@ export default {
}
})
.then(response => cb(response.data))
}
},
/**
* @param cb
* @returns {PromiseLike<any> | Promise<any>}
*/
getStats(cb) {
//return cb(_stats);
// eslint-disable-next-line
return axios
.get('/stats')
.then(response => cb(response.data))
},
}

@ -3,5 +3,32 @@ import Vuetify from 'vuetify/lib'
Vue.use(Vuetify)
// usage: {{ file.size | prettyBytes }}
Vue.filter('prettyBytes', function (num) {
// jacked from: https://github.com/sindresorhus/pretty-bytes
if (typeof num !== 'number' || isNaN(num)) {
throw new TypeError('Expected a number');
}
var exponent;
var unit;
var neg = num < 0;
var units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
if (neg) {
num = -num;
}
if (num < 1) {
return (neg ? '-' : '') + num + ' B';
}
exponent = Math.min(Math.floor(Math.log(num) / Math.log(1000)), units.length - 1);
num = (num / Math.pow(1000, exponent)).toFixed(2) * 1;
unit = units[exponent];
return (neg ? '-' : '') + num + ' ' + unit;
});
export default new Vuetify({
})

@ -1,6 +1,7 @@
#ifndef DISPLAY_H
#define DISPLAY_H
//#include "EPD2_BW.h"
#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold9pt7b.h>

@ -1,8 +1,10 @@
[env:lolin32]
platform = espressif32
;platform = espressif32
platform = https://github.com/platformio/platform-espressif32.git
board = lolin32
framework = arduino
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
; https://camo.githubusercontent.com/62eafe3a5c9bf3cdc31d6db740b7e58eaa1a3ab1/687474703a2f2f7777772e6275696c646c6f672e6e65742f626c6f672f77702d636f6e74656e742f75706c6f6164732f323032302f30322f6964655f73732e706e67
; https://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables
; https://github.com/espressif/arduino-esp32/tree/master/tools/partitions

@ -166,7 +166,7 @@ void setupSettingsPost()
}
/**
*
* get current screen
*/
void setupCurrentImage()
{

@ -89,7 +89,7 @@ bool downloadRandomePicture()
pictureUrl += "&fit=crop"; // crop to needed size
pictureUrl += "&duotone=000000,FFFFFF"; // grayscale to save bytes
//downloadFile(pictureUrl, faceCalendarPicture);
downloadFile(pictureUrl, faceCalendarPicture);
return true;
}
@ -104,7 +104,7 @@ bool downloadRandomePicture()
bool updateCalendarData()
{
//downloadFile("https://images.unsplash.com/photo-1582225764554-a82806fe9f30?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjExMDM0OH0&w=390&h=384&fm=png&fit=crop&duotone=000000,FFFFFF", "/tom");
return false;
//return false;
if (downloadRandomePicture())
{

Loading…
Cancel
Save