Skip to content

Commit

Permalink
Add 1.2.2 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pcprince committed Jan 4, 2024
1 parent 11af7b9 commit 83b6b08
Show file tree
Hide file tree
Showing 14 changed files with 678 additions and 514 deletions.
12 changes: 6 additions & 6 deletions about.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
/****************************************************************************
* about.js
* openacousticdevices.info
* August 2021
* June 2017
*****************************************************************************/

'use strict';

/* global document */

const electron = require('electron');
const {app, process} = require('@electron/remote');
const audiomoth = require('audiomoth-hid');

const nightMode = require('./nightMode.js');

const versionDisplay = document.getElementById('version-display');
const electronVersionDisplay = document.getElementById('electron-version-display');
const audiomothHidVersionDisplay = document.getElementById('audiomoth-hid-version-display');
const websiteLink = document.getElementById('website-link');
const audiomothHidVersionDisplay = document.getElementById('audiomoth-hid-version-display');

versionDisplay.textContent = 'Version ' + electron.remote.app.getVersion();
electronVersionDisplay.textContent = 'Running on Electron version ' + electron.remote.process.versions.electron;
versionDisplay.textContent = 'Version ' + app.getVersion();
electronVersionDisplay.textContent = 'Running on Electron version ' + process.versions.electron;
audiomothHidVersionDisplay.textContent = 'AudioMoth-HID module ' + audiomoth.version;

electron.ipcRenderer.on('night-mode', (e, nm) => {
Expand All @@ -36,9 +37,8 @@ electron.ipcRenderer.on('night-mode', (e, nm) => {

});

websiteLink.addEventListener('click', function () {
websiteLink.addEventListener('click', () => {

electron.shell.openExternal('https://openacousticdevices.info');

});

8 changes: 6 additions & 2 deletions constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ exports.configurations = [{
exports.packetLengthVersions = [{
firmwareVersion: '1.0.0',
packetLength: 18
},
{
firmwareVersion: '1.2.0',
packetLength: 19
}];

const FIRMWARE_OFFICIAL_RELEASE = 0;
Expand Down Expand Up @@ -103,5 +107,5 @@ exports.getFirmwareClassification = (desc) => {

/* Version number for the latest firmware */

exports.latestFirmwareVersionArray = [1, 0, 0];
exports.latestFirmwareVersionString = '1.0.0';
exports.latestFirmwareVersionArray = ['1', '2', '0'];
exports.latestFirmwareVersionString = '1.2.0';
521 changes: 288 additions & 233 deletions index.html

Large diffs are not rendered by default.

128 changes: 78 additions & 50 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,91 @@

'use strict';

const electron = require('electron');
const {app, Menu, shell, ipcMain, BrowserWindow} = require('electron');

const app = electron.app;

const Menu = electron.Menu;

const shell = electron.shell;

const ipcMain = electron.ipcMain;
require('@electron/remote/main').initialize();

const path = require('path');

const BrowserWindow = electron.BrowserWindow;

require('electron-debug')({
showDevTools: true,
devToolsMode: 'undocked'
});

var mainWindow, aboutWindow;

function shrinkWindowHeight (windowHeight) {
const iconLocation = (process.platform === 'linux') ? '/build/icon.png' : '/build/icon.ico';
const standardWindowSettings = {
resizable: false,
fullscreenable: false,
autoHideMenuBar: true,
icon: path.join(__dirname, iconLocation),
useContentSize: true,
webPreferences: {
enableRemoteModule: true,
nodeIntegration: true,
contextIsolation: false
}
};

if (process.platform === 'darwin') {
/* Generate settings objects for windows and progress bars */

windowHeight -= 20;
function generateSettings (width, height, title) {

} else if (process.platform === 'linux') {
const uniqueSettings = {
width,
height,
title
};

windowHeight -= 20;
const settings = Object.assign({}, standardWindowSettings, uniqueSettings);
settings.parent = mainWindow;

}

return windowHeight;
return settings;

}

function openAboutWindow () {

if (aboutWindow) {

aboutWindow.show();
return;

}

const iconLocation = (process.platform === 'linux') ? '/build/icon.png' : '/build/icon.ico';
let windowWidth = 400;
let windowHeight = 310;

aboutWindow = new BrowserWindow({
width: 400,
height: shrinkWindowHeight(340),
title: 'About',
resizable: false,
fullscreenable: false,
icon: path.join(__dirname, iconLocation),
parent: mainWindow,
webPreferences: {
nodeIntegration: true
}
});
if (process.platform === 'linux') {

windowWidth = 395;
windowHeight = 310;

} else if (process.platform === 'darwin') {

windowWidth = 395;
windowHeight = 310;

}

const settings = generateSettings(windowWidth, windowHeight, 'About');
aboutWindow = new BrowserWindow(settings);

aboutWindow.setMenu(null);
aboutWindow.loadURL(path.join('file://', __dirname, '/about.html'));

aboutWindow.on('close', function () {
require('@electron/remote/main').enable(aboutWindow.webContents);

aboutWindow.on('close', (e) => {

e.preventDefault();

aboutWindow = null;
aboutWindow.hide();

});

aboutWindow.webContents.on('dom-ready', function () {
aboutWindow.webContents.on('dom-ready', () => {

mainWindow.webContents.send('poll-night-mode');

Expand Down Expand Up @@ -107,33 +122,37 @@ function toggleNightMode () {

app.on('ready', function () {

const iconLocation = (process.platform === 'linux') ? '/build/icon.png' : '/build/icon.ico';
const windowHeight = shrinkWindowHeight(661);
let windowWidth = 565;
let windowHeight = 672;

if (process.platform === 'linux') {

windowWidth = 560;
windowHeight = 653;

} else if (process.platform === 'darwin') {

windowWidth = 560;
windowHeight = 653;

}

mainWindow = new BrowserWindow({
title: 'AudioMoth USB Microphone App',
width: 565,
width: windowWidth,
height: windowHeight,
useContentSize: true,
resizable: false,
fullscreenable: false,
useContentSize: true,
icon: path.join(__dirname, iconLocation),
webPreferences: {
nodeIntegration: true
enableRemoteModule: true,
nodeIntegration: true,
contextIsolation: false
}
});

mainWindow.on('restore', function () {

/* When minimised and restored, Windows platforms alter the BrowserWindow such that the height no longer includes the menu bar */
/* This resize cannot be blocked so this fix resizes it, taking into account the menu change */
if (process.platform === 'win32') {

mainWindow.setSize(565, windowHeight + 20);

}

});
require('@electron/remote/main').enable(mainWindow.webContents);

const menuTemplate = [{
label: 'File',
Expand Down Expand Up @@ -170,6 +189,15 @@ app.on('ready', function () {

mainWindow.webContents.send('update-check');

}
}, {
type: 'separator'
}, {
label: 'AudioMoth Play Website',
click: function () {

shell.openExternal('https://play.openacousticdevices.info/');

}
}, {
type: 'separator'
Expand Down
6 changes: 3 additions & 3 deletions nightMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

'use strict';

const electron = require('electron');
const { app } = require('@electron/remote');

var nightMode = false;

Expand All @@ -29,11 +29,11 @@ function setNightMode (nm) {

if (nightMode) {

newLink.setAttribute('href', electron.remote.app.getAppPath() + '/uiNight.css');
newLink.setAttribute('href', app.getAppPath() + '/uiNight.css');

} else {

newLink.setAttribute('href', electron.remote.app.getAppPath() + '/ui.css');
newLink.setAttribute('href', app.getAppPath() + '/ui.css');

}

Expand Down
35 changes: 19 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "AudioMoth-Mic",
"version": "1.2.1",
"version": "1.2.2",
"description": "The configuration app for the AudioMoth USB microphone.",
"main": "main.js",
"author": "openacousticdevices.info",
Expand Down Expand Up @@ -57,28 +57,31 @@
}
},
"devDependencies": {
"electron": "8.5.2",
"electron-builder": "^23.0.2",
"eslint": "^7.27.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-standard": "^4.0.2"
"electron": "25.3.2",
"electron-builder": "^24.6.3",
"eslint": "^8.45.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-standard": "^4.1.0"
},
"dependencies": {
"audiomoth-hid": "^2.1.0",
"audiomoth-utils": "^1.0.3",
"bootstrap": "4.3.1",
"bootstrap-slider": "^10.6.2",
"@electron/remote": "^2.0.10",
"@popperjs/core": "^2.11.8",
"audiomoth-hid": "^2.3.0",
"audiomoth-utils": "^1.4.1",
"bootstrap": "5.3.1",
"bootstrap-slider": "^11.0.2",
"electron-debug": "3.0.1",
"electron-localshortcut": "^3.2.1",
"electron-progressbar": "^1.2.0",
"jquery": "^3.5.1",
"jsonschema": "1.2.4",
"jquery": "^3.7.0",
"jsonschema": "1.4.1",
"popper.js": "^1.15.0",
"showdown": "^1.9.1",
"strftime": "0.10.0"
"strftime": "0.10.2"
},
"engines": {
"node": ">=10.16.2"
Expand Down
2 changes: 0 additions & 2 deletions settings/uiAdvanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* August 2021
*****************************************************************************/

const electron = require('electron');

const enableLED = document.getElementById('enable-LED-checkbox');
const energySaverModeCheckbox = document.getElementById('energy-saver-mode-checkbox');
const disable48DCFilterCheckbox = document.getElementById('disable-48-dc-filter-checkbox');
Expand Down
6 changes: 0 additions & 6 deletions settings/uiFiltering.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
* August 2021
*****************************************************************************/

const electron = require('electron');
const dialog = electron.remote.dialog;
const BrowserWindow = electron.remote.BrowserWindow;

const ui = require('./../ui.js');

const constants = require('../constants.js');

const Slider = require('bootstrap-slider');
Expand Down
3 changes: 0 additions & 3 deletions settings/uiSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
* August 2021
*****************************************************************************/

const electron = require('electron');
const dialog = electron.remote.dialog;

const uiFiltering = require('./uiFiltering.js');
const uiAdvanced = require('./uiAdvanced.js');

Expand Down
3 changes: 2 additions & 1 deletion ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ input[type=number]::-webkit-outer-spin-button {

.table>tbody>tr>td,
.table>tbody>tr>th {
border-top: none;
border-color: transparent;
border-top: none;
}

body {
Expand Down

0 comments on commit 83b6b08

Please sign in to comment.