initial commit

This commit is contained in:
klein panic
2024-09-29 01:16:27 -04:00
commit 6f72d8aa07
2 changed files with 48 additions and 0 deletions

10
arduino_board_list.sh Executable file
View 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
View 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