Skip to content

Commit

Permalink
change build script not to override i2c
Browse files Browse the repository at this point in the history
  • Loading branch information
arfrie22 committed Aug 5, 2024
1 parent 0944c73 commit 36fda48
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ set -e

function enable_i2c {
if command -v raspi-config &> /dev/null; then
if [[ $(sudo raspi-config nonint get_i2c) -eq 1 ]] ; then
echo "Enabling i2c"
sudo modprobe i2c-dev
sudo raspi-config nonint do_i2c 0
if [[ ! -z $(grep 'dtparam=i2c_arm=on$' /boot/config.txt) ]] ; then
echo "Setting the i2c clock speed to 400 kHz, you will have to reboot for this to take effect."
sudo sed -i -e 's/dtparam=i2c_arm=on$/dtparam=i2c_arm=on,i2c_arm_baudrate=400000/g' /boot/config.txt
fi
fi
if [[ $(grep -c '^dtparam=i2c_arm=on$' /boot/config.txt) -ge 1 ]] ; then
echo "Setting the i2c clock speed to 400 kHz, you will have to reboot for this to take effect."
sudo sed -i -e 's/dtparam=i2c_arm=on$/dtparam=i2c_arm=on,i2c_arm_baudrate=400000/g' /boot/config.txt
fi
else
echo "Can not automatically enable i2c you might have to do this manually"
fi
Expand Down

0 comments on commit 36fda48

Please sign in to comment.