-неактуально/Версия #0.2 (добавлено дублирование кода в буфер обмена): https://disk.yandex.ru/d/r8KNFdMl-lKbwA
-неактуально/Версия #0.3 (добавлено запоминание последней платы): https://disk.yandex.ru/d/bqwC7ee0gr9IyQ
Описание #0.3 : viewtopic.php?t=8610&start=20#p125421
=======================================================================
Если у вас Win10x64 , то идем в папку PortableFLProg\ideV8 и переименовываем там файл 'arduino.exe' в 'old_arduino.exe' (именно так - это важно)
Качаем этот файл https://disk.yandex.ru/d/r8KNFdMl-lKbwA и закидываем его в папку PortableFLProg\ideV8.
Теперь при нажатии кнопки в FLProg "Компилировать проект" у нас появится такое окно:
Указываем пути к Arduino 2.0 и Arduino 1.0.
Ставим галочки в каком редакторе запускать код из FLProg (можно кстати сразу в обеих версиях Ардуино открывать код))))
Можно поставить автозапуск (т.е. будет сразу запускаться выбранная Ардуина)
Обратите внимание на пункт 5:
Видео:
https://disk.yandex.ru/i/d2g5ipZ3dGXIqA
Отправлено спустя 4 минуты 1 секунду:
*возможно потребуется установить/обновить Python версии 3.11.4 (https://www.python.org/downloads/release/python-3114/)
исходник в Python:
import random
import sys
import subprocess
import os
import configparser
import os.path
import time
from tkinter import messagebox as mbox
#окно уведомлений
def onError(self):
mbox.showerror("Ошибка", self)
file_created=0
config = configparser.ConfigParser() # создаём объекта парсера
from tkinter import *
import tkinter.filedialog as fd
window = Tk()
if __name__ == "__main__":
for param in sys.argv:
print(param)
#window.title('Выбор версии Arduino IDE ' + param
window.title('Выбор версии Arduino IDE')
#subprocess.run([os.getcwd()+'\ideV8\old_arduino.exe', param])
#иначе в ошибку автозапуск ардуино падает
def clicked2():
if ((config["Arduino_1"]['path'] == '')&(chekbox_1.get()==1)):onError('не указан путь для Arduino 1.0')
else:
if ((config["Arduino_2"]['path'] == '')&(chekbox_2.get()==1)):onError('не указан путь для Arduino 2.0')
else:
if (((config["Arduino_1"]['path'] == '')&(chekbox_1.get()==0))&((config["Arduino_2"]['path'] == '')&(chekbox_1.get()==0))):onError('не указан путь для Arduino IDE и не выбрана версия')
else:
if ((chekbox_1.get()==0)&(chekbox_2.get()==0)):onError('не выбрана версия Arduino')
#Aрдуино 1
if ((config["Arduino_1"]['path'] != '')&(chekbox_1.get()==1)):subprocess.run([config["Arduino_1"]['path'], param])
#Ардуино 2
if ((config["Arduino_2"]['path'] != '')&(chekbox_2.get()==1)):subprocess.run([config["Arduino_2"]['path'], param])
#-------------------------------------------------------------------------------------------------
def clicked():
window.after(1000, window.destroy())
if ((config["Arduino_1"]['path'] == '')&(chekbox_1.get()==1)):onError('не указан путь для Arduino 1.0')
else:
if ((config["Arduino_2"]['path'] == '')&(chekbox_2.get()==1)):onError('не указан путь для Arduino 2.0')
else:
if (((config["Arduino_1"]['path'] == '')&(chekbox_1.get()==0))&((config["Arduino_2"]['path'] == '')&(chekbox_1.get()==0))):onError('не указан путь для Arduino IDE и не выбрана версия')
else:
if ((chekbox_1.get()==0)&(chekbox_2.get()==0)):onError('не выбрана версия Arduino')
#Aрдуино 1
if ((config["Arduino_1"]['path'] != '')&(chekbox_1.get()==1)):subprocess.run([config["Arduino_1"]['path'], param])
#Ардуино 2
if ((config["Arduino_2"]['path'] != '')&(chekbox_2.get()==1)):subprocess.run([config["Arduino_2"]['path'], param])
#-----------------------------запись настроек в файл при изменении пути к ардуине 1--------------------------------
def open_file1():
# Show the open file dialog by specifying path
f = fd.askopenfilename()
txt1.config(text=f)
config.set('Arduino_1', 'path', f)
with open('setting_run_arduino2.ini', 'w') as configfile:config.write(configfile)
#------------------------------запись настроек в файл при изменении пути к ардуине 2-------------------------------
def open_file2():
f = fd.askopenfilename()
txt2.config(text=f)
config.set('Arduino_2', 'path', f)
with open('setting_run_arduino2.ini', 'w') as configfile:config.write(configfile)
#------------------------------запись настроек в файл при изменении чекбокса автозапуска-------------------------------
def func_autorun():
config.set('run_app', 'chekbox_run_app', str(chekbox_run_app.get()))
with open('setting_run_arduino2.ini', 'w') as configfile:config.write(configfile)
#------------------------------запись настроек в файл при изменении чекбокса ардуине 1-------------------------------
def func_chekbox_1():
config.set('Arduino_1', 'chekbox_1', str(chekbox_1.get()))
with open('setting_run_arduino2.ini', 'w') as configfile:config.write(configfile)
#------------------------------запись настроек в файл при изменении чекбокса ардуине 2-------------------------------
def func_chekbox_2():
config.set('Arduino_2', 'chekbox_2', str(chekbox_2.get()))
with open('setting_run_arduino2.ini', 'w') as configfile:config.write(configfile)
#--------------------кнопка файла 1-----------------------------------------
open_button = Button(window, text='Путь до Arduino 1.0',bg='white', command=open_file1)
open_button.place(x = 190, y = 20, width = 150)
#-------------------поле ввода 1------------------------------------------
txt1=Label(window, text='', font=("Arial Bold", 10))
txt1.place(x = 350, y = 22)
if(file_created==1):
txt1.config(text=config["Arduino_1"]['path'])
#--------------------кнопка файла 2-----------------------------------------
open_button2 = Button(window, text='Путь до Arduino 2.0',bg='white', command=open_file2)
open_button2.place(x = 190, y = 70, width = 150)
#-------------------поле ввода 2------------------------------------------
txt2=Label(window, text='', font=("Arial Bold", 10))
txt2.place(x = 350, y = 72)
if(file_created==1):
txt1.config(text=config["Arduino_2"]['path'])
#-------------------------------------------------------------
chekbox_1 = IntVar()
checkbutton1 = Checkbutton(window, text="Запускать в Arduino 1.0", variable=chekbox_1,command=func_chekbox_1)
checkbutton1.place(x = 20, y = 21)
if(file_created==1):
checkbutton1.config(variable=config["Arduino_1"]['chekbox_1'])
#-------------------------------------------------------------
chekbox_2 = IntVar()
checkbutton2 = Checkbutton(window, text="Запускать в Arduino 2.0", variable=chekbox_2,command=func_chekbox_2)
checkbutton2.place(x = 20, y = 71)
if(file_created==1):
checkbutton2.config(variable=config["Arduino_2"]['chekbox_2'])
#-------------------------------------------------------------
txt3=Label(window,justify='left', text='1. Откройте папку "PortableFLProg -> ideV8"\n2. Переименуйте файл "arduino.exe" в "old_arduino.exe" (СТРОГО в "old_arduino.exe"!)\n3. Скопируйте в эту папку (PortableFLProg\ideV8) скачанный файл "arduino.exe"\n4. Теперь при нажатии кнопки в программе FLProg "Компилировать проект",\n будет открываться окно выбора ArduinoIDE\n5. В ПУТИ ДО Ардуино 1.0 укажите файл "old_arduino.exe" (тот который мы выше переименовывали)!!!\n\nВНИМАНИЕ: после открытия Arduino 2.0 необходимо убедиться в верности выбранной платы!\n\n*настройки можно изменять и в файле "setting_run_arduino2.ini", создающимся\n в папке "PortableFLProg" при первом запуске программы', font=("Arial Bold", 10))
txt3.place(x = 10, y = 300)
#-------------------------------------------------------------
chekbox_run_app = IntVar()
check_chekbox_run_app = Checkbutton(window, text="запускать Ардуино IDE автоматически", variable=chekbox_run_app,command=func_autorun)
check_chekbox_run_app.place(x = 230, y = 150)
if(file_created==1):
check_chekbox_run_app.config(variable=config["run_app"]['chekbox_run_app'])
#-------------------------------------------------------------
#создаю файл при первом запуске
def create_settings():
print('создаю файл настроек')
my_file = open("setting_run_arduino2.ini", "w+")
my_file = open("setting_run_arduino2.ini", "a+")
my_file.write("[run_app]\n")
my_file.write("chekbox_run_app=0\n")
my_file.write("[Arduino_1]\n")
my_file.write("path=\n")
my_file.write("chekbox_1=0\n")
my_file.write("[Arduino_2]\n")
my_file.write("path=\n")
my_file.write("chekbox_2=0\n")
my_file.write("[timer_close_app]\n")
my_file.write("value=2000\n")
my_file.close()
file_created=1
# если файла настроек нет, то создаем и ждем пока файл создастся
while not os.path.exists('setting_run_arduino2.ini'):
create_settings()
time.sleep(1)
# если файл настроек существует
if os.path.isfile('setting_run_arduino2.ini'):
# read file
config.read("setting_run_arduino2.ini") # читаем конфиг
txt1.config(text=config["Arduino_1"]['path'])
txt2.config(text=config["Arduino_2"]['path'])
chekbox_1.set(config["Arduino_1"]['chekbox_1'])
chekbox_2.set(config["Arduino_2"]['chekbox_2'])
chekbox_run_app.set(config["run_app"]['chekbox_run_app'])
else:
raise ValueError("%s isn't a file!" % 'setting_run_arduino2.ini')
btn = Button(window, text="Запустить вручную Arduino IDE",width=30, bg="lightblue", fg="red", command=clicked)
btn.place(x = 240, y = 200)
#размер окна + центрирование
WIDTH = 700
HEIGHT = 500
x = int((window.winfo_screenwidth() / 2) - (WIDTH / 2))
y = int((window.winfo_screenheight() / 2) - (HEIGHT / 2))
window.geometry(f'{WIDTH}x{HEIGHT}+{x}+{y}')
if(chekbox_run_app.get()==1):
#timer1 = int(config["timer_close_app"]['value'])
window.after(int(config["timer_close_app"]['value']), window.destroy)
#window.after(2000, window.destroy)
window.mainloop()
if(chekbox_run_app.get()==1):clicked2()