-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·89 lines (70 loc) · 3.39 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
# Author: Sebastian Romero @sebromero
# This script is used to setup the environment for the project
# Check if pip or pip3 is installed
if ! [ -x "$(command -v pip)" ] && ! [ -x "$(command -v pip3)" ]; then
echo 'Error: pip is not installed.' >&2
echo 'Please install pip by following the instructions on the following link:'
echo 'https://pip.pypa.io/en/stable/installation/'
exit 1
fi
# Use pip3 if pip is not installed
if ! [ -x "$(command -v pip)" ]; then
pip="pip3"
else
pip="pip"
fi
# Check if mpremote is installed
if ! [ -x "$(command -v mpremote)" ]; then
# Ask user to install mpremote
echo 'mpremote is not installed.'
echo 'Do you want to install it? (y/n)'
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
# Install mpremote
echo 'Installing mpremote...'
sudo $pip install mpremote
else
echo 'Please install mpremote using the following command:'
echo 'sudo pip install mpremote'
exit 1
fi
fi
echo "🔎 Searching for Arduino device..."
device_sn=$(mpremote connect list | grep -e Arduino -e MicroPython | awk '{print $2}')
echo "👀 Found device with SN: $device_sn"
echo "📦 Installing packages..."
packages=""
# This package is used to control the BME680 sensor
packages="$packages github:robert-hh/BME680-Micropython/bme680.py"
# This package is used to control the LED bar
packages="$packages github:mcauser/micropython-my9221/my9221.py"
# This package is used to control the OLED display
packages="$packages github:ubidefeo/MicroPython-Classes/lib/ssd1306_1315.py"
# This package is used to control buttons
packages="$packages github:ubidefeo/MicroPython-Classes/lib/Button.py"
# This package is used to control the rotary encoder (for RP2040)
packages="$packages github:miketeachman/micropython-rotary/rotary.py"
packages="$packages github:miketeachman/micropython-rotary/rotary_irq_rp2.py"
# This package is used to control the DFPlayer Mini MP3 player
packages="$packages github:ubidefeo/MicroPython-Classes/lib/dfplayer.py"
# Alternatives:
# packages="$packages github:mannbro/PicoDFPlayer/picodfplayer.py"
# packages="$packages github:lavron/micropython-dfplayermini/dfplayermini.py"
# This package is used to control the TM1637 four digit display
packages="$packages github:mcauser/micropython-tm1637/tm1637.py"
# This package is used to control a HD44780 LCD display
packages="$packages github:brainelectronics/micropython-i2c-lcd"
mpremote connect id:$device_sn mip install $packages
# This package is used to control a servo motor
# If you want to use easing, also install this: https://github.com/TTitanUA/smooth_servo
# For 360 degree servos, use this: https://github.com/TTitanUA/micropython_servo_pdm_360/
packages="github:TTitanUA/micropython_servo_pdm/micropython_servo_pdm/__init__.py"
packages="$packages github:TTitanUA/micropython_servo_pdm/micropython_servo_pdm/version.py"
packages="$packages github:TTitanUA/micropython_servo_pdm/micropython_servo_pdm/servo_pdm.py"
packages="$packages github:TTitanUA/micropython_servo_pdm/micropython_servo_pdm/servo_pdm_rp2.py"
packages="$packages github:TTitanUA/micropython_servo_pdm/micropython_servo_pdm/smooth_servo_simple.py"
mpremote connect id:$device_sn mip install --target /lib/micropython_servo_pdm $packages
# Reset the device to make the files appear in the filesystem
echo "🔁 Resetting device..."
mpremote connect id:$device_sn reset