add flashing and pyqt setup

This commit is contained in:
prisar
2023-07-21 13:48:41 +05:30
commit 9e066b376e
5 changed files with 165 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
*.DS_Store
/env
build
dist

5
README.md Normal file
View File

@@ -0,0 +1,5 @@
### error -> FileNotFoundError: [Errno 2] No such file or directory: 'arduino-cli'
install arduino-cli
https://arduino.github.io/arduino-cli/0.33/installation/

66
flash.py Normal file
View File

@@ -0,0 +1,66 @@
from everywhereml.arduino import Sketch, Ino, H
"""
Create a sketch object.
A sketch is defined by:
- a name (required)
- a folder (optional)
If you leave the folder empty, the current working directory will be used.
You can use the special name ':system:' to use the default Arduino sketches folder
(as reported by the command `arduino-cli config dump`)
"""
sketch = Sketch(name="PyDuino", folder=":system:")
"""
Then you can add files to the project (either the .ino main file or
C++ header files)
"""
sketch += Ino("""
#include "hello.h"
void setup() {
Serial.begin(115200);
}
void loop() {
hello();
delay(1000);
}
""")
sketch += H("hello.h", """
void hello() {
Serial.println("hello smi5");
}
""")
"""
Compile sketch for Arduino Nano 33 BLE board.
The board you target must appear in the `arduino-cli board listall` command.
If you know the FQBN (Fully Qualified Board Name), you can use that too.
"""
if sketch.compile(board='arduino:avr:nano:cpu=atmega328old').is_successful:
print('Log', sketch.output)
print('Sketch stats', sketch.stats)
else:
print('ERROR', sketch.output)
"""
You can specify the exact port
"""
# sketch.upload(port='/dev/cu.usbmodem14201')
sketch.upload(port='/dev/cu.usbserial-1420')
# """
# Or even part of it.
# The library will look for the best match.
# """
# sketch.upload(port='ttyUSB')
# sketch.upload(port='/dev/cu.usbserial-1420') #/dev/cu.usbmodem
print(sketch.output)

40
hemocube.py Normal file
View File

@@ -0,0 +1,40 @@
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel, QPushButton, QLineEdit
# 1. Import QApplication and all the required widgets
# from PyQt5.QtWidgets import QApplication, QLabel, QWidget
def addLabel(layout, text):
layout.addWidget(QLabel(text))
if __name__ == "__main__":
app = QApplication([])
window = QWidget()
layout = QVBoxLayout(window)
# Create a label Widget and add it to the layout
label = QLabel('Enter some text!')
layout.addWidget(label)
line_edit = QLineEdit()
layout.addWidget(line_edit)
# Create a QPushButton object with a caption on it
qbtn= QPushButton('Add Label')
# Add the QPushButton to the layout
layout.addWidget(qbtn)
# Close the application when the button is pressed
# Here I am using slots & signals, which I will demonstrate later in this tutorial
qbtn.clicked.connect(lambda:addLabel(layout, line_edit.text()))
window.setWindowTitle("PyQt App")
window.setGeometry(100, 100, 280, 80)
# helloMsg = QLabel("<h1>Hello, World!</h1>", parent=window)
# helloMsg.move(60, 15)
window.show()
# 5. Run your application's event loop
sys.exit(app.exec())

50
hemocube.spec Normal file
View File

@@ -0,0 +1,50 @@
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(
['hemocube.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='hemocube',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='hemocube',
)