Difference between revisions of "Blog 18"

From BitWizard WIKI
Jump to: navigation, search
(Backlight/Contrast)
(Settings Menu)
Line 10: Line 10:
 
In this post I will show the menu I made, where you can change the: Backlight, Contrast and Volume.
 
In this post I will show the menu I made, where you can change the: Backlight, Contrast and Volume.
  
The overall script is based on the scroll menu from [[blog 1312314]]
+
The overall script is based on the scroll menu from [[blog 13]].
 +
The menu you can scroll through with button 5(up) and 6(down). On the screen than will be visible which 2 menu you can go to.
 +
With button 1 and 2 you can choose which of the 2 you want to edit.
  
 
  #!/bin/bash
 
  #!/bin/bash

Revision as of 12:31, 19 November 2015

Settings Menu

Hardware I used on my Raspberry Pi:

Programmed in:

  • bash

In this post I will show the menu I made, where you can change the: Backlight, Contrast and Volume.

The overall script is based on the scroll menu from blog 13. The menu you can scroll through with button 5(up) and 6(down). On the screen than will be visible which 2 menu you can go to. With button 1 and 2 you can choose which of the 2 you want to edit.

#!/bin/bash

bw_tool -I -D /dev/i2c-1 -a 94 -W 10:00

while true; do
BUTTON=`bw_tool -I -D /dev/i2c-1 -a 94 -R 30:b`

array=(   Volume Contrast Backlight )
# Element 0      1        2 

Narray=(  VOLUME CONTRAST BACKLIGHT )
# Element 0      1        2

  if [ $BUTTON  != "00" ]; then
     bw_tool -I -D /dev/i2c-1 -a 94 -W 10:00
  fi

  if [ $BUTTON  = "20" ]; then
     ./${array[$Number]}
  fi

  if [ $BUTTON  = "10" ]; then
    ./${array[$Numb2]}
  fi

  if [ $BUTTON  = "08" ]; then
     Number=0
  fi

  if [ $BUTTON  = "04" ]; then
     exit
  fi

  if [ $BUTTON  = "02" ]; then
     Number=$(((Number + 2) % 3 ))
  fi

  if [ $BUTTON  = "01" ]; then
     Number=$(((Number + 1) % 3 ))
  fi

Numb2=$((Number + 1))
Numb3=$((Numb2 + 1))

bw_tool -I -D /dev/i2c-1 -a 94 -W 11:00
bw_tool -I -D /dev/i2c-1 -a 94 -t "$Numb2""."${Narray[$Number]}
bw_tool -I -D /dev/i2c-1 -a 94 -W 11:20
bw_tool -I -D /dev/i2c-1 -a 94 -t "$Numb3""."${Narray[$Numb2]} 

sleep 1

done
BacklightHigh.jpg

Backlight/Contrast

#!/bin/bash
 
bw_tool -I -D /dev/i2c-1 -a 94 -W 10:00

while true; do
BUTTON=`bw_tool -I -D /dev/i2c-1 -a 94 -R 30:b`

array=(   00 19 33 4c 66 7F 99 B2 CC E5 FF )
# Element 0  1  2  3  4  5  6  7  8  9  10

Narray=(   00 10 20 30 40 50 60 70 80 90 100 )
# Name     0  1  2  3  4  5  6  7  8  9  10 

 if [ $BUTTON  != "00" ]; then
    bw_tool -I -D /dev/i2c-1 -a 94 -W 10:00
 fi

 if [ $BUTTON  = "04" ]; then
    exit
 fi

 if [ $BUTTON  = "02" ]; then
    Number=$(((Number + 10) % 11 )) # can be changed to 11 if you want it to get 1 down
 fi

 if [ $BUTTON  = "01" ]; then
    Number=$(((Number + 1) % 11 )) #can be changed to 1 if you want to get it up by 1 / I did 2 because speed
 fi

bw_tool -I -D /dev/i2c-1 -a 94 -W 11:00
bw_tool -I -D /dev/i2c-1 -a 94 -t "$Numb2"${Narray[$Number]}
bw_tool -I -D /dev/i2c-1 -a 94 -W 13:${array[$Number]}

sleep 1
done
BacklightLow.jpg

Volume

#!/bin/bash

DISPL="bw_tool -I -D /dev/i2c-1 -a 94"

while true; do
BUTTON=`bw_tool -I -D /dev/i2c-1 -a 94 -R 30:b`

array=(   00 10 20 30 40 50 60 70 80 90 100 )
# Element 0  1  2  3  4  5  6  7  8  9  10

  if [ $BUTTON  != "00" ]; then
     bw_tool -I -D /dev/i2c-1 -a 94 -W 10:00
  fi

  if [ $BUTTON  = "04" ]; then
  exit
  fi

  if [ $BUTTON  = "20" ]; then
  amixer -c 0 set PCM 5dB-
  #mplayer ru.mp3
  fi

  if [ $BUTTON  = "10" ]; then
  amixer -c 0 set PCM 5dB+
  #mplayer ru.mp3
  fi

  if [ $BUTTON  = "02" ]; then
  amixer -c 0 set PCM 10dB-
  #mplayer ru.mp3
  fi 

  if [ $BUTTON  = "01" ]; then
  amixer -c 0 set PCM 10dB+
  #mplayer ru.mp3
  fi

$DISPL -W 11:00:b
$DISPL -t `amixer | grep Mono: | sed -e 's/%] .*//' -e 's/.* \[//'`

sleep 1
done

Useful links

User Interface