Skip to content

Update micropython.js and initial windows width #37

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

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ ipcMain.handle('set-window-size', (event, minWidth, minHeight) => {
function createWindow () {
// Create the browser window.
win = new BrowserWindow({
width: 700,
width: 720,
height: 640,
webPreferences: {
nodeIntegration: true,
337 changes: 0 additions & 337 deletions micropython.js

This file was deleted.

619 changes: 86 additions & 533 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -38,10 +38,11 @@
"license": "MIT",
"dependencies": {
"about-window": "^1.15.2",
"micropython.js": "github:murilopolese/micropython.js#v1.2.2",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so now the micropython.js is a module brought in from your repo?
interesting :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I would propose so. In the future it should be a npm package under the Arduino organization, I believe.

"mkdirp": "^1.0.3",
"serialport": "^10.4.0"
},
"engines": {
"node": "16"
"node": "18"
}
}
22 changes: 5 additions & 17 deletions preload.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
console.log('preload')
const { contextBridge, ipcRenderer } = require('electron')

const Micropython = require('./micropython.js')
const Micropython = require('micropython.js')
const board = new Micropython()

function extractFileArray(output) {
output = output.replace(/'/g, '"');
output = output.split('OK')
let files = output[2] || ''
files = files.slice(0, files.indexOf(']')+1)
files = JSON.parse(files)
return files
}

const Serial = {
loadPorts: async () => {
let ports = await board.listPorts()
@@ -57,19 +48,17 @@ const Serial = {
board.serial.on('data', fn)
},
listFiles: async () => {
let output = await board.fs_ls()
return extractFileArray(output)
const output = await board.fs_ls()
return output
},
loadFile: async (file) => {
let output = await board.fs_cat(file)
output = output.split('OK')
return output[2] || ''
const output = await board.fs_cat(file)
return output || ''
},
removeFile: async (file) => {
return board.fs_rm(file)
},
saveFileContent: async (filename, content) => {
content = content.replace(//g, ``)
return board.fs_save(content || ' ', filename)
},
uploadFile: async (folder, filename) => {
@@ -79,7 +68,6 @@ const Serial = {
},
downloadFile: async (folder, filename) => {
let contents = await Serial.loadFile(filename)
contents = contents.replace(//g, ``)
return ipcRenderer.invoke('save-file', folder, filename, contents)
},
renameFile: async (oldName, newName) => {
3 changes: 1 addition & 2 deletions ui/arduino/store.js
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ function store(state, emitter) {
const disk = window.BridgeDisk
const win = window.BridgeWindow

win.setWindowSize(700, 640)
win.setWindowSize(720, 640)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to set the window's size when it's already set in its initial new BrowserWindow() call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because the app sets a default global screen constraints and the UI can "request" new window constraints. In this case particularly it's the same value.


state.ports = []
state.diskFiles = []
@@ -187,7 +187,6 @@ function store(state, emitter) {
let content = ''
if (state.selectedDevice === 'serial') {
content = await serial.loadFile(filename)
content = content.replace(//g, ``) // XXX: Remove character that breaks execution
}

if (state.selectedDevice === 'disk') {