initial commit
This commit is contained in:
10
arduino_board_list.sh
Executable file
10
arduino_board_list.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Search for all possible boards, remove the header, and clean up whitespace lines
|
||||
arduino-cli board search | tail -n +2 | sed '/^\s*$/d' > /tmp/arduino_boards.txt
|
||||
|
||||
# Ensure the file has the correct permissions for Lua to read
|
||||
chmod 644 /tmp/arduino_boards.txt
|
||||
|
||||
# Print a message indicating that the process is complete
|
||||
echo "All possible boards have been listed in /tmp/arduino_boards.txt"
|
||||
38
board_selection.lua
Normal file
38
board_selection.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
-- Open the file for reading
|
||||
local file = io.open("/tmp/arduino_boards.txt", "r")
|
||||
if not file then
|
||||
print("Error: Could not open /tmp/arduino_boards.txt")
|
||||
return
|
||||
end
|
||||
|
||||
-- Read the file into a table
|
||||
local boards = {}
|
||||
for line in file:lines() do
|
||||
local board_name, fqbn = line:match("^(.-)%s+(%w+:%w+)$")
|
||||
if board_name and fqbn then
|
||||
table.insert(boards, { name = board_name, fqbn = fqbn })
|
||||
end
|
||||
end
|
||||
file:close()
|
||||
|
||||
-- Display the header
|
||||
print("Available Arduino Boards:")
|
||||
print("No. Board Name FQBN")
|
||||
print("---------------------------------------------------------")
|
||||
|
||||
-- Display the list of boards
|
||||
for i, board in ipairs(boards) do
|
||||
print(string.format("%-3d %-40s %s", i, board.name, board.fqbn))
|
||||
end
|
||||
|
||||
-- Ask the user to choose a board
|
||||
io.write("Enter the number of the board you want to select: ")
|
||||
local choice = tonumber(io.read())
|
||||
|
||||
if choice and boards[choice] then
|
||||
local selected_board = boards[choice]
|
||||
print("You selected: " .. selected_board.name)
|
||||
print("FQBN: " .. selected_board.fqbn)
|
||||
else
|
||||
print("Invalid selection.")
|
||||
end
|
||||
Reference in New Issue
Block a user