Advertisement
Guest User

Untitled

a guest
Feb 5th, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 32.00 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. temp_dir="/tmp/screen"
  4. mmc_dir="/mnt/mmc"
  5. sunxi_tools_dir="/opt/sunxi-tools"
  6. bin_file="script.bin"
  7. fex_file="script.fex"
  8.  
  9. tempfile1=/tmp/dialog_1_$$
  10. tempfile2=/tmp/dialog_2_$$
  11. tempfile3=/tmp/dialog_3_$$
  12. tempfile4=/tmp/dialog_4_$$
  13.  
  14. # Define some functions
  15. SET_NONE() {
  16.     #get line number
  17.     line=$(grep -nr "screen0_output_type" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  18.    
  19.     dialog --title "Confirmation" --yesno "Disable screen ?" 0 0
  20.     case $? in
  21.       0)  
  22.     #replace line
  23.     sed -i $line's/.*/screen0_output_type = 0/' $temp_dir/$fex_file
  24.     dialog --infobox "Changes saved" 3 17
  25.     sleep 2
  26.     ;;
  27.       1|255)
  28.     dialog --infobox "No changes done" 3 19
  29.     sleep 2
  30.     ;;
  31.     esac
  32. }
  33.  
  34. SET_HDMI() {
  35.     #get line number
  36.     line=$(grep -nr "screen0_output_type" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  37.     mode=$(grep -nr "screen0_output_mode" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  38.    
  39.     dialog --backtitle "OLimeXino-A20 screen configuration" \
  40.     --menu "Select screen mode:" 12 55 8 \
  41.     0   "480i"       \
  42.     1   "576i"       \
  43.     2   "480p"       \
  44.     3   "576p"       \
  45.     4   "720p50"     \
  46.     5   "720p60"     \
  47.     6   "1080i50"    \
  48.     7   "1080i60"    \
  49.     8   "1080p24"    \
  50.     9   "1080p50"    \
  51.     10  "1080p60"    \
  52.     11  "pal"        \
  53.     14  "ntsc"      2> $tempfile3
  54.  
  55. retv=$?
  56. choice=$(cat $tempfile3)
  57.  
  58. # Check if ESC of CANCLE are pressed
  59. if [ $retv -eq 1 -o $retv -eq 255 ];
  60. then
  61.   clear
  62.   exit
  63. fi
  64.  
  65. case $choice in
  66.   0)
  67.     dialog --title "Confirmation" --yesno "Set HDMI to 480i ?" 0 0
  68.     case $? in
  69.       0)  
  70.     #replace line
  71.     sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
  72.     sed -i $mode's/.*/screen0_output_mode = 0/' $temp_dir/$fex_file
  73.     dialog --infobox "Changes saved" 3 17
  74.     sleep 2
  75.     ;;
  76.       1|255)
  77.     dialog --infobox "No changes done" 3 19
  78.     sleep 2
  79.     ;;
  80.     esac
  81.     ;;
  82.   1)
  83.     dialog --title "Confirmation" --yesno "Set HDMI to 576i ?" 0 0
  84.     case $? in
  85.       0)  
  86.     #replace line
  87.     sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
  88.     sed -i $mode's/.*/screen0_output_mode = 1/' $temp_dir/$fex_file
  89.     dialog --infobox "Changes saved" 3 17
  90.     sleep 2
  91.     ;;
  92.       1|255)
  93.     dialog --infobox "No changes done" 3 19
  94.     sleep 2
  95.     ;;
  96.     esac
  97.     ;;
  98.   2)
  99.     dialog --title "Confirmation" --yesno "Set HDMI to 480p ?" 0 0
  100.     case $? in
  101.       0)  
  102.     #replace line
  103.     sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
  104.     sed -i $mode's/.*/screen0_output_mode = 2/' $temp_dir/$fex_file
  105.     dialog --infobox "Changes saved" 3 17
  106.     sleep 2
  107.     ;;
  108.       1|255)
  109.     dialog --infobox "No changes done" 3 19
  110.     sleep 2
  111.     ;;
  112.     esac
  113.     ;;
  114.   3)
  115.     dialog --title "Confirmation" --yesno "Set HDMI to 576p ?" 0 0
  116.     case $? in
  117.       0)  
  118.     #replace line
  119.     sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
  120.     sed -i $mode's/.*/screen0_output_mode = 3/' $temp_dir/$fex_file
  121.     dialog --infobox "Changes saved" 3 17
  122.     sleep 2
  123.     ;;
  124.       1|255)
  125.     dialog --infobox "No changes done" 3 19
  126.     sleep 2
  127.     ;;
  128.     esac
  129.     ;;
  130.   4)
  131.     dialog --title "Confirmation" --yesno "Set HDMI to 720p50 ?" 0 0
  132.     case $? in
  133.       0)  
  134.     #replace line
  135.     sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
  136.     sed -i $mode's/.*/screen0_output_mode = 4/' $temp_dir/$fex_file
  137.     dialog --infobox "Changes saved" 3 17
  138.     sleep 2
  139.     ;;
  140.       1|255)
  141.     dialog --infobox "No changes done" 3 19
  142.     sleep 2
  143.     ;;
  144.     esac
  145.     ;;
  146.   5)
  147.     dialog --title "Confirmation" --yesno "Set HDMI to 720p60 ?" 0 0
  148.     case $? in
  149.       0)  
  150.     #replace line
  151.     sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
  152.     sed -i $mode's/.*/screen0_output_mode = 5/' $temp_dir/$fex_file
  153.     dialog --infobox "Changes saved" 3 17
  154.     sleep 2
  155.     ;;
  156.       1|255)
  157.     dialog --infobox "No changes done" 3 19
  158.     sleep 2
  159.     ;;
  160.     esac
  161.     ;;  
  162.   6)
  163.     dialog --title "Confirmation" --yesno "Set HDMI to 1080i50 ?" 0 0
  164.     case $? in
  165.       0)  
  166.     #replace line
  167.     sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
  168.     sed -i $mode's/.*/screen0_output_mode = 6/' $temp_dir/$fex_file
  169.     dialog --infobox "Changes saved" 3 17
  170.     sleep 2
  171.     ;;
  172.       1|255)
  173.     dialog --infobox "No changes done" 3 19
  174.     sleep 2
  175.     ;;
  176.     esac
  177.     ;;  
  178.   7)
  179.     dialog --title "Confirmation" --yesno "Set HDMI to 1080i60 ?" 0 0
  180.     case $? in
  181.       0)  
  182.     #replace line
  183.     sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
  184.     sed -i $mode's/.*/screen0_output_mode = 7/' $temp_dir/$fex_file
  185.     dialog --infobox "Changes saved" 3 17
  186.     sleep 2
  187.     ;;
  188.       1|255)
  189.     dialog --infobox "No changes done" 3 19
  190.     sleep 2
  191.     ;;
  192.     esac
  193.     ;;  
  194.   8)
  195.     dialog --title "Confirmation" --yesno "Set HDMI to 1080p24 ?" 0 0
  196.     case $? in
  197.       0)  
  198.     #replace line
  199.     sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
  200.     sed -i $mode's/.*/screen0_output_mode = 8/' $temp_dir/$fex_file
  201.     dialog --infobox "Changes saved" 3 17
  202.     sleep 2
  203.     ;;
  204.       1|255)
  205.     dialog --infobox "No changes done" 3 19
  206.     sleep 2
  207.     ;;
  208.     esac
  209.     ;;  
  210.   9)
  211.     dialog --title "Confirmation" --yesno "Set HDMI to 1080p50 ?" 0 0
  212.     case $? in
  213.       0)  
  214.     #replace line
  215.     sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
  216.     sed -i $mode's/.*/screen0_output_mode = 9/' $temp_dir/$fex_file
  217.     dialog --infobox "Changes saved" 3 17
  218.     sleep 2
  219.     ;;
  220.       1|255)
  221.     dialog --infobox "No changes done" 3 19
  222.     sleep 2
  223.     ;;
  224.     esac
  225.     ;;  
  226.   10)
  227.     dialog --title "Confirmation" --yesno "Set HDMI to 1080p60 ?" 0 0
  228.     case $? in
  229.       0)  
  230.     #replace line
  231.     sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
  232.     sed -i $mode's/.*/screen0_output_mode = 10/' $temp_dir/$fex_file
  233.     dialog --infobox "Changes saved" 3 17
  234.     sleep 2
  235.     ;;
  236.       1|255)
  237.     dialog --infobox "No changes done" 3 19
  238.     sleep 2
  239.     ;;
  240.     esac
  241.     ;;  
  242.   11)
  243.     dialog --title "Confirmation" --yesno "Set HDMI to pal ?" 0 0
  244.     case $? in
  245.       0)  
  246.     #replace line
  247.     sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
  248.     sed -i $mode's/.*/screen0_output_mode = 11/' $temp_dir/$fex_file
  249.     dialog --infobox "Changes saved" 3 17
  250.     sleep 2
  251.     ;;
  252.       1|255)
  253.     dialog --infobox "No changes done" 3 19
  254.     sleep 2
  255.     ;;
  256.     esac
  257.     ;;  
  258.   14)
  259.     dialog --title "Confirmation" --yesno "Set HDMI to ntsc ?" 0 0
  260.     case $? in
  261.       0)  
  262.     #replace line
  263.     sed -i $line's/.*/screen0_output_type = 3/' $temp_dir/$fex_file
  264.     sed -i $mode's/.*/screen0_output_mode = 14/' $temp_dir/$fex_file
  265.     dialog --infobox "Changes saved" 3 17
  266.     sleep 2
  267.     ;;
  268.       1|255)
  269.     dialog --infobox "No changes done" 3 19
  270.     sleep 2
  271.     ;;
  272.     esac
  273.     ;;  
  274. esac
  275.    
  276.    
  277. }
  278.  
  279. SET_VGA() {
  280.     #get line number
  281.     line=$(grep -nr "screen0_output_type" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  282.     mode=$(grep -nr "screen0_output_mode" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  283.    
  284.     dialog --backtitle "OLimeXino-A20 screen configuration" \
  285.     --menu "Select screen mode:" 0 0 0 \
  286.     0   "1680x1050"  \
  287.     1   "1440x900"   \
  288.     2   "1360x768"   \
  289.     3   "1280x1024"  \
  290.     4   "1024x768"   \
  291.     5   "800x600"    \
  292.     6   "640x480"    \
  293.     10  "1920x1080"  \
  294.     11  "1280x720"   2> $tempfile4
  295.  
  296. retv=$?
  297. choice=$(cat $tempfile4)
  298.  
  299. # Check if ESC of CANCLE are pressed
  300. if [ $retv -eq 1 -o $retv -eq 255 ];
  301. then
  302.   clear
  303.   exit
  304. fi
  305.  
  306. case $choice in
  307.   0)
  308.     dialog --title "Confirmation" --yesno "Set VGA to 1680x1050 ?" 0 0
  309.     case $? in
  310.       0)  
  311.     #replace line
  312.     sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
  313.     sed -i $mode's/.*/screen0_output_mode = 0/' $temp_dir/$fex_file
  314.     dialog --infobox "Changes saved" 3 17
  315.     sleep 2
  316.     ;;
  317.       1|255)
  318.     dialog --infobox "No changes done" 3 19
  319.     sleep 2
  320.     ;;
  321.     esac
  322.     ;;
  323.   1)
  324.     dialog --title "Confirmation" --yesno "Set VGA to 1440x900 ?" 0 0
  325.     case $? in
  326.       0)  
  327.     #replace line
  328.     sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
  329.     sed -i $mode's/.*/screen0_output_mode = 1/' $temp_dir/$fex_file
  330.     dialog --infobox "Changes saved" 3 17
  331.     sleep 2
  332.     ;;
  333.       1|255)
  334.     dialog --infobox "No changes done" 3 19
  335.     sleep 2
  336.     ;;
  337.     esac
  338.     ;;
  339.   2)
  340.     dialog --title "Confirmation" --yesno "Set VGA to 1360x768 ?" 0 0
  341.     case $? in
  342.       0)  
  343.     #replace line
  344.     sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
  345.     sed -i $mode's/.*/screen0_output_mode = 2/' $temp_dir/$fex_file
  346.     dialog --infobox "Changes saved" 3 17
  347.     sleep 2
  348.     ;;
  349.       1|255)
  350.     dialog --infobox "No changes done" 3 19
  351.     sleep 2
  352.     ;;
  353.     esac
  354.     ;;
  355.   3)
  356.     dialog --title "Confirmation" --yesno "Set VGA to 1280x1024 ?" 0 0
  357.     case $? in
  358.       0)  
  359.     #replace line
  360.     sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
  361.     sed -i $mode's/.*/screen0_output_mode = 3/' $temp_dir/$fex_file
  362.     dialog --infobox "Changes saved" 3 17
  363.     sleep 2
  364.     ;;
  365.       1|255)
  366.     dialog --infobox "No changes done" 3 19
  367.     sleep 2
  368.     ;;
  369.     esac
  370.     ;;
  371.   4)
  372.     dialog --title "Confirmation" --yesno "Set VGA to 1024x768 ?" 0 0
  373.     case $? in
  374.       0)  
  375.     #replace line
  376.     sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
  377.     sed -i $mode's/.*/screen0_output_mode = 4/' $temp_dir/$fex_file
  378.     dialog --infobox "Changes saved" 3 17
  379.     sleep 2
  380.     ;;
  381.       1|255)
  382.     dialog --infobox "No changes done" 3 19
  383.     sleep 2
  384.     ;;
  385.     esac
  386.     ;;
  387.   5)
  388.     dialog --title "Confirmation" --yesno "Set VGA to 800x600 ?" 0 0
  389.     case $? in
  390.       0)  
  391.     #replace line
  392.     sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
  393.     sed -i $mode's/.*/screen0_output_mode = 5/' $temp_dir/$fex_file
  394.     dialog --infobox "Changes saved" 3 17
  395.     sleep 2
  396.     ;;
  397.       1|255)
  398.     dialog --infobox "No changes done" 3 19
  399.     sleep 2
  400.     ;;
  401.     esac
  402.     ;;  
  403.   6)
  404.     dialog --title "Confirmation" --yesno "Set VGA to 640x480 ?" 0 0
  405.     case $? in
  406.       0)  
  407.     #replace line
  408.     sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
  409.     sed -i $mode's/.*/screen0_output_mode = 6/' $temp_dir/$fex_file
  410.     dialog --infobox "Changes saved" 3 17
  411.     sleep 2
  412.     ;;
  413.       1|255)
  414.     dialog --infobox "No changes done" 3 19
  415.     sleep 2
  416.     ;;
  417.     esac
  418.     ;;  
  419.   10)
  420.     dialog --title "Confirmation" --yesno "Set VGA to 1920x1080 ?" 0 0
  421.     case $? in
  422.       0)  
  423.     #replace line
  424.     sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
  425.     sed -i $mode's/.*/screen0_output_mode = 10/' $temp_dir/$fex_file
  426.     dialog --infobox "Changes saved" 3 17
  427.     sleep 2
  428.     ;;
  429.       1|255)
  430.     dialog --infobox "No changes done" 3 19
  431.     sleep 2
  432.     ;;
  433.     esac
  434.     ;;  
  435.   11)
  436.     dialog --title "Confirmation" --yesno "Set VGA to 1280x720 ?" 0 0
  437.     case $? in
  438.       0)  
  439.     #replace line
  440.     sed -i $line's/.*/screen0_output_type = 4/' $temp_dir/$fex_file
  441.     sed -i $mode's/.*/screen0_output_mode = 11/' $temp_dir/$fex_file
  442.     dialog --infobox "Changes saved" 3 17
  443.     sleep 2
  444.     ;;
  445.       1|255)
  446.     dialog --infobox "No changes done" 3 19
  447.     sleep 2
  448.     ;;
  449.     esac
  450.     ;;  
  451. esac
  452.    
  453.    
  454. }
  455.  
  456. SET_LCD() {
  457.  
  458.   dialog --backtitle "OLimeXino-A20 screen configuration" \
  459.     --menu "Select screen mode:" 0 0 0 \
  460.     "4.3"   "480x272"    \
  461.     "7.0"   "800x480"    \
  462.     "10.3"  "1024x600"   \
  463.     "15.6"  "1366x768"  2> $tempfile2
  464.  
  465.   retv=$?
  466.   choice=$(cat $tempfile2)
  467.  
  468.   # Check if ESC of CANCLE are pressed
  469.   if [ $retv -eq 1 -o $retv -eq 255 ];
  470.   then
  471.     clear
  472.     exit
  473.   fi
  474.  
  475.   case $choice in
  476.     "4.3")
  477.     x=480
  478.     y=272
  479.     freq=9
  480.     hbp=40
  481.     ht=525
  482.     vbp=8
  483.     vt=576
  484.     vspw=5
  485.     hspw=30
  486.         #extra options
  487.     lcd_if=0
  488.     lcd_lvds_bitwidth=0
  489.     lcd_io_cfg0=0
  490.     lcd_bl_en_used=1
  491.     fb0_scaler_mode_enable=0
  492.     fb0_width=0
  493.     fb0_height=0
  494.     gpio_num=75
  495.  
  496.     ;;
  497.     "7.0")
  498.     x=800
  499.     y=480
  500.     freq=33
  501.     hbp=46
  502.     ht=1055
  503.     vbp=23
  504.     vt=1050
  505.     vspw=1
  506.     hspw=30
  507.         #extra options
  508.     lcd_if=0
  509.     lcd_lvds_bitwidth=0
  510.     lcd_io_cfg0=0
  511.     lcd_bl_en_used=1
  512.     fb0_scaler_mode_enable=0
  513.     fb0_width=0
  514.     fb0_height=0
  515.     gpio_num=75
  516.  
  517.     ;;
  518.     "10.3")
  519.     x=1024
  520.     y=600
  521.     freq=45
  522.     hbp=160
  523.     ht=1200
  524.     vbp=23
  525.     vt=1250
  526.     vspw=2
  527.     hspw=10
  528.     #extra options
  529.     lcd_if=0
  530.     lcd_lvds_bitwidth=0
  531.     lcd_io_cfg0=0
  532.     lcd_bl_en_used=1
  533.     fb0_scaler_mode_enable=0
  534.     fb0_width=0
  535.     fb0_height=0
  536.     gpio_num=75
  537.     ;;
  538.     "15.6")
  539.     x=1366
  540.     y=768
  541.     freq=70
  542.     hbp=54
  543.     ht=1440
  544.     vbp=23
  545.     vt=1616
  546.     vspw=0
  547.     hspw=0
  548.     #extra options
  549.     lcd_if=3
  550.     lcd_lvds_bitwidth=1
  551.     lcd_io_cfg0="0x04000000"
  552.     lcd_bl_en_used=0
  553.     fb0_scaler_mode_enable=1
  554.     fb0_width=1366
  555.     fb0_height=768
  556.     gpio_num=81
  557.     ;;
  558.    
  559.    
  560.   esac
  561.  
  562.   dialog --title "Confirmation" --yesno "Set LCD to '$x'x'$y' ?" 0 0    
  563.   case $? in
  564.       0)
  565.     #Edit fex file
  566.     line_x=$(grep -nr -m 1 "lcd_x" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  567.     if [ -z $line_x ];
  568.     then
  569.       dialog --infobox "Cannot find lcd_x variable!" 0 0
  570.       sleep 2
  571.       exit
  572.     fi
  573.    
  574.     line_y=$(grep -nr -m 1 "lcd_y" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  575.     if [ -z $line_y ];
  576.     then
  577.       dialog --infobox "Cannot find lcd_y variable!" 0 0
  578.       sleep 2
  579.       exit
  580.     fi
  581.    
  582.     line_freq=$(grep -nr -m 1 "lcd_dclk_freq" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  583.     if [ -z $line_freq ];
  584.     then
  585.       dialog --infobox "Cannot find lcd_dclk_freq variable!" 0 0
  586.       sleep 2
  587.       exit
  588.     fi
  589.    
  590.     line_hbp=$(grep -nr -m 1 "lcd_hbp" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  591.     if [ -z $line_hbp ];
  592.     then
  593.       dialog --infobox "Cannot find lcd_hbp variable!" 0 0
  594.       sleep 2
  595.       exit
  596.     fi
  597.    
  598.     line_ht=$(grep -nr -m 1 "lcd_ht" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  599.     if [ -z $line_ht ];
  600.     then
  601.       dialog --infobox "Cannot find lcd_ht variable!" 0 0
  602.       sleep 2
  603.       exit
  604.     fi
  605.    
  606.     line_vbp=$(grep -nr -m 1 "lcd_vbp" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  607.     if [ -z $line_vbp ];
  608.     then
  609.       dialog --infobox "Cannot find lcd_vbp variable!" 0 0
  610.       sleep 2
  611.       exit
  612.     fi
  613.    
  614.     line_vt=$(grep -nr -m 1 "lcd_vt" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  615.     if [ -z $line_vt ];
  616.     then
  617.       dialog --infobox "Cannot find lcd_vt variable!" 0 0
  618.       sleep 2
  619.       exit
  620.     fi
  621.    
  622.     line_vspw=$(grep -nr -m 1 "lcd_vspw" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  623.     if [ -z $line_vspw ];
  624.     then
  625.       dialog --infobox "Cannot find lcd_vspw variable!" 0 0
  626.       sleep 2
  627.       exit
  628.     fi
  629.    
  630.     line_hspw=$(grep -nr -m 1 "lcd_hspw" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  631.     if [ -z $line_hspw ];
  632.     then
  633.       dialog --infobox "Cannot find lcd_hspw variable!" 0 0
  634.       sleep 2
  635.       exit
  636.     fi
  637.    
  638.     line_screen0_output_type=$(grep -nr "screen0_output_type" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  639.     if [ -z $line_screen0_output_type ];
  640.     then
  641.       dialog --infobox "Cannot find screen0_output_type variable!" 0 0
  642.       sleep 2
  643.       exit
  644.     fi
  645.        
  646.    
  647.    
  648.     #EXTRA OPTIONS
  649.  
  650.     line_lcd_if=$(grep -nr -m 1 "lcd_if" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  651.     if [ -z $line_lcd_if ];
  652.     then
  653.       dialog --infobox "Cannot find lcd_if variable!" 0 0
  654.       sleep 2
  655.       exit
  656.     fi
  657.    
  658.     line_lcd_lvds_bitwidth=$(grep -nr -m 1 "lcd_lvds_bitwidth" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  659.     if [ -z $line_lcd_lvds_bitwidth ];
  660.     then
  661.       dialog --infobox "Cannot find lcd_lvds_bitwidth variable!" 0 0
  662.       sleep 2
  663.       exit
  664.     fi
  665.    
  666.    
  667.     line_lcd_io_cfg0=$(grep -nr -m 1 "lcd_io_cfg0" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  668.     if [ -z $line_lcd_io_cfg0 ];
  669.     then
  670.       dialog --infobox "Cannot find lcd_io_cfg0 variable!" 0 0
  671.       sleep 2
  672.       exit
  673.     fi
  674.    
  675.     line_lcd_bl_en_used=$(grep -nr -m 1 "lcd_bl_en_used" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  676.     if [ -z $line_lcd_bl_en_used ];
  677.     then
  678.       dialog --infobox "Cannot find lcd_bl_en_used variable!" 0 0
  679.       sleep 2
  680.       exit
  681.     fi
  682.    
  683.     line_fb0_scaler_mode_enable=$(grep -nr -m 1 "fb0_scaler_mode_enable" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  684.     if [ -z $line_fb0_scaler_mode_enable ];
  685.     then
  686.       dialog --infobox "Cannot find fb0_scaler_mode_enable variable!" 0 0
  687.       sleep 2
  688.       exit
  689.     fi
  690.    
  691.     line_fb0_width=$(grep -nr -m 1 "fb0_width" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  692.     if [ -z $line_fb0_width ];
  693.     then
  694.       dialog --infobox "Cannot find fb0_width variable!" 0 0
  695.       sleep 2
  696.       exit
  697.     fi
  698.    
  699.     line_fb0_height=$(grep -nr -m 1 "fb0_height" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  700.     if [ -z $line_fb0_height ];
  701.     then
  702.       dialog --infobox "Cannot find fb0_height variable!" 0 0
  703.       sleep 2
  704.       exit
  705.     fi
  706.    
  707.     line_gpio_num=$(grep -nr -m 1 "gpio_num" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  708.     if [ -z $line_gpio_num ];
  709.     then
  710.       dialog --infobox "Cannot find gpio_num variable!" 0 0
  711.       sleep 2
  712.       exit
  713.     fi
  714.    
  715.    
  716.    
  717.     sed -i $line_screen0_output_type's/.*/screen0_output_type = 1/' $temp_dir/$fex_file
  718.     sed -i $line_x's/.*/lcd_x = '$x'/' $temp_dir/$fex_file
  719.     sed -i $line_y's/.*/lcd_y = '$y'/' $temp_dir/$fex_file
  720.     sed -i $line_freq's/.*/lcd_dclk_freq = '$freq'/' $temp_dir/$fex_file
  721.     sed -i $line_hbp's/.*/lcd_hbp = '$hbp'/' $temp_dir/$fex_file
  722.     sed -i $line_ht's/.*/lcd_ht = '$ht'/' $temp_dir/$fex_file
  723.     sed -i $line_vbp's/.*/lcd_vbp = '$vbp'/' $temp_dir/$fex_file
  724.     sed -i $line_vt's/.*/lcd_vt = '$vt'/' $temp_dir/$fex_file
  725.     sed -i $line_vspw's/.*/lcd_vspw = '$vspw'/' $temp_dir/$fex_file
  726.     sed -i $line_hspw's/.*/lcd_hspw = '$hspw'/' $temp_dir/$fex_file
  727.    
  728.     sed -i $line_lcd_if's/.*/lcd_if = '$lcd_if'/' $temp_dir/$fex_file
  729.     sed -i $line_lcd_lvds_bitwidth's/.*/lcd_lvds_bitwidth = '$lcd_lvds_bitwidth'/' $temp_dir/$fex_file
  730.     sed -i $line_lcd_io_cfg0's/.*/lcd_io_cfg0 = '$lcd_io_cfg0'/' $temp_dir/$fex_file
  731.     sed -i $line_lcd_bl_en_used's/.*/lcd_bl_en_used = '$lcd_bl_en_used'/' $temp_dir/$fex_file
  732.    
  733.     sed -i $line_fb0_scaler_mode_enable's/.*/fb0_scaler_mode_enable = '$fb0_scaler_mode_enable'/' $temp_dir/$fex_file
  734.     sed -i $line_fb0_width's/.*/fb0_width = '$fb0_width'/' $temp_dir/$fex_file
  735.     sed -i $line_fb0_height's/.*/fb0_height = '$fb0_height'/' $temp_dir/$fex_file
  736.     sed -i $line_gpio_num's/.*/gpio_num = '$gpio_num'/' $temp_dir/$fex_file
  737.    
  738.    
  739.    
  740.    
  741.     # DO SOME EXTRA THINGS ONLY FOR 15.6 LCD
  742.     choice=$(cat $tempfile2)
  743.     if [ "$choice" = "15.6" ];
  744.     then
  745.       # ADD P113
  746.       line_pll3=$(grep -nr -m 1 "pll3" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  747.       if [ -z $line_pll3 ];
  748.       then
  749.         #There is no p113 in the fex file
  750.         line_clock=$(grep -nr -m 1 "\[clock\]" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  751.         if [ -z $line_clock ];
  752.         then
  753.           dialog --infobox "Cannot find [clock] variable!" 0 0
  754.           sleep 2
  755.           exit
  756.         fi
  757.         sed -i $line_clock'a\pll3 = 297' $temp_dir/$fex_file
  758.       else
  759.         #Tgere is p113
  760.         sed -i $line_pll3's/.*/pll3 = 297/' $temp_dir/$fex_file
  761.       fi
  762.      
  763. #     REMOVE LCDD22
  764.       sed -i '/lcdd22/d' $temp_dir/$fex_file
  765.       sed -i '/lcdd23/d' $temp_dir/$fex_file
  766.       sed -i '/lcdclk/d' $temp_dir/$fex_file
  767.       sed -i '/lcdde/d' $temp_dir/$fex_file
  768.       sed -i '/lcdhsync/d' $temp_dir/$fex_file
  769.       sed -i '/lcdvsync/d' $temp_dir/$fex_file
  770.      
  771.      
  772.       # CHECK FOR PIN76
  773.       line_gpio_pin_76=$(grep -nr -m 1 "gpio_pin_76" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  774.       if [ -z $line_gpio_pin_76 ];
  775.         then
  776.           line_gpio_pin_75=$(grep -nr -m 1 "gpio_pin_75" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  777.           if [ -z $line_gpio_pin_75 ];
  778.           then
  779.         dialog --infobox "Cannot find gpio_pin_75 variable!" 0 0
  780.         sleep 2
  781.         exit
  782.           fi
  783.           sed -i $line_gpio_pin_75'a\gpio_pin_76 = port:PD22<1><default><default><1>' $temp_dir/$fex_file      
  784.         else
  785.           sed -i $line_gpio_pin_76's/.*/gpio_pin_76 = port:PD22<1><default><default><1>/' $temp_dir/$fex_file
  786.         fi
  787.      
  788.       # CHECK FOR PIN77
  789.       line_gpio_pin_77=$(grep -nr -m 1 "gpio_pin_77" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  790.       if [ -z $line_gpio_pin_77 ];
  791.         then
  792.           line_gpio_pin_76=$(grep -nr -m 1 "gpio_pin_76" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  793.           if [ -z $line_gpio_pin_76 ];
  794.           then
  795.         dialog --infobox "Cannot find gpio_pin_76 variable!" 0 0
  796.         sleep 2
  797.         exit
  798.           fi
  799.           sed -i $line_gpio_pin_76'a\gpio_pin_77 = port:PD23<1><default><default><1>' $temp_dir/$fex_file      
  800.         else
  801.           sed -i $line_gpio_pin_77's/.*/gpio_pin_77 = port:PD23<1><default><default><1>/' $temp_dir/$fex_file
  802.         fi
  803.      
  804.       # CHECK FOR PIN78
  805.       line_gpio_pin_78=$(grep -nr -m 1 "gpio_pin_78" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  806.       if [ -z $line_gpio_pin_78 ];
  807.         then
  808.           line_gpio_pin_77=$(grep -nr -m 1 "gpio_pin_77" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  809.           if [ -z $line_gpio_pin_77 ];
  810.           then
  811.         dialog --infobox "Cannot find gpio_pin_77 variable!" 0 0
  812.         sleep 2
  813.         exit
  814.           fi
  815.           sed -i $line_gpio_pin_77'a\gpio_pin_78 = port:PD24<1><default><default><default>' $temp_dir/$fex_file    
  816.         else
  817.           sed -i $line_gpio_pin_78's/.*/gpio_pin_78 = port:PD24<1><default><default><default>/' $temp_dir/$fex_file
  818.         fi
  819.      
  820.       # CHECK FOR PIN79
  821.       line_gpio_pin_79=$(grep -nr -m 1 "gpio_pin_79" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  822.       if [ -z $line_gpio_pin_79 ];
  823.         then
  824.           line_gpio_pin_78=$(grep -nr -m 1 "gpio_pin_78" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  825.           if [ -z $line_gpio_pin_78 ];
  826.           then
  827.         dialog --infobox "Cannot find gpio_pin_78 variable!" 0 0
  828.         sleep 2
  829.         exit
  830.           fi
  831.           sed -i $line_gpio_pin_78'a\gpio_pin_79 = port:PD25<1><default><default><default>' $temp_dir/$fex_file    
  832.         else
  833.           sed -i $line_gpio_pin_79's/.*/gpio_pin_79 = port:PD25<1><default><default><default>/' $temp_dir/$fex_file
  834.         fi
  835.      
  836.       # CHECK FOR PIN80
  837.       line_gpio_pin_80=$(grep -nr -m 1 "gpio_pin_80" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  838.       if [ -z $line_gpio_pin_80 ];
  839.         then
  840.           line_gpio_pin_79=$(grep -nr -m 1 "gpio_pin_79" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  841.           if [ -z $line_gpio_pin_79 ];
  842.           then
  843.         dialog --infobox "Cannot find gpio_pin_79 variable!" 0 0
  844.         sleep 2
  845.         exit
  846.           fi
  847.           sed -i $line_gpio_pin_79'a\gpio_pin_80 = port:PD26<0><default><default><default>' $temp_dir/$fex_file    
  848.         else
  849.           sed -i $line_gpio_pin_80's/.*/gpio_pin_80 = port:PD26<0><default><default><default>/' $temp_dir/$fex_file
  850.         fi
  851.      
  852.       # CHECK FOR PIN81
  853.       line_gpio_pin_81=$(grep -nr -m 1 "gpio_pin_81" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  854.       if [ -z $line_gpio_pin_81 ];
  855.       then
  856.         line_gpio_pin_80=$(grep -nr -m 1 "gpio_pin_80" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  857.         if [ -z $line_gpio_pin_80 ];
  858.         then
  859.           dialog --infobox "Cannot find gpio_pin_80 variable!" 0 0
  860.           sleep 2
  861.           exit
  862.         fi
  863.         sed -i $line_gpio_pin_80'a\gpio_pin_81 = port:PD27<0><default><default><default>' $temp_dir/$fex_file      
  864.       else
  865.         sed -i $line_gpio_pin_81's/.*/gpio_pin_81 = port:PD27<0><default><default><default>/' $temp_dir/$fex_file
  866.       fi
  867.      
  868.      
  869.        
  870.       # CHECK FOR PIN76
  871.       line_pin_76=$(grep -nr -m 1 "pin_76" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  872.       if [ -z $line_pin_76 ];
  873.         then
  874.           line_pin_75=$(grep -nr -m 1 "pin_75" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  875.           if [ -z $line_pin_75 ];
  876.           then
  877.         dialog --infobox "Cannot find pin_75 variable!" 0 0
  878.         sleep 2
  879.         exit
  880.           fi
  881.           sed -i $line_pin_75'a\pin_76 = port:PD22<1><default><default><1>' $temp_dir/$fex_file    
  882.         else
  883.           sed -i $line_pin_76's/.*/pin_76 = port:PD22<1><default><default><1>/' $temp_dir/$fex_file
  884.         fi
  885.      
  886.       # CHECK FOR PIN77
  887.       line_pin_77=$(grep -nr -m 1 "pin_77" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  888.       if [ -z $line_pin_77 ];
  889.         then
  890.           line_pin_76=$(grep -nr -m 1 "pin_76" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  891.           if [ -z $gpio_pin_76 ];
  892.           then
  893.         dialog --infobox "Cannot find pin_76 variable!" 0 0
  894.         sleep 2
  895.         exit
  896.           fi
  897.           sed -i $line_pin_76'a\pin_77 = port:PD23<1><default><default><1>' $temp_dir/$fex_file    
  898.         else
  899.           sed -i $line_pin_77's/.*/pin_77 = port:PD23<1><default><default><1>/' $temp_dir/$fex_file
  900.         fi
  901.      
  902.       # CHECK FOR PIN78
  903.       line_pin_78=$(grep -nr -m 1 "pin_78" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  904.       if [ -z $line_pin_78 ];
  905.         then
  906.           line_pin_77=$(grep -nr -m 1 "pin_77" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  907.           if [ -z $line_pin_77 ];
  908.           then
  909.         dialog --infobox "Cannot find pin_77 variable!" 0 0
  910.         sleep 2
  911.         exit
  912.           fi
  913.           sed -i $line_pin_77'a\pin_78 = port:PD24<1><default><default><default>' $temp_dir/$fex_file      
  914.         else
  915.           sed -i $line_pin_78's/.*/pin_78 = port:PD24<1><default><default><default>/' $temp_dir/$fex_file
  916.         fi
  917.      
  918.       # CHECK FOR PIN79
  919.       line_pin_79=$(grep -nr -m 1 "pin_79" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  920.       if [ -z $line_pin_79 ];
  921.         then
  922.           line_pin_78=$(grep -nr -m 1 "pin_78" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  923.           if [ -z $line_pin_78 ];
  924.           then
  925.         dialog --infobox "Cannot find pin_78 variable!" 0 0
  926.         sleep 2
  927.         exit
  928.           fi
  929.           sed -i $line_pin_78'a\pin_79 = port:PD25<1><default><default><default>' $temp_dir/$fex_file      
  930.         else
  931.           sed -i $line_pin_79's/.*/pin_79 = port:PD25<1><default><default><default>/' $temp_dir/$fex_file
  932.         fi
  933.      
  934.       # CHECK FOR PIN80
  935.       line_pin_80=$(grep -nr -m 1 "pin_80" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  936.       if [ -z $line_pin_80 ];
  937.         then
  938.           line_pin_79=$(grep -nr -m 1 "pin_79" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  939.           if [ -z $line_pin_79 ];
  940.           then
  941.         dialog --infobox "Cannot find pin_79 variable!" 0 0
  942.         sleep 2
  943.         exit
  944.           fi
  945.           sed -i $line_pin_79'a\pin_80 = port:PD26<0><default><default><default>' $temp_dir/$fex_file      
  946.         else
  947.           sed -i $line_pin_80's/.*/pin_80 = port:PD26<0><default><default><default>/' $temp_dir/$fex_file
  948.         fi
  949.      
  950.       # CHECK FOR PIN81
  951.       line_pin_81=$(grep -nr -m 1 "pin_81" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  952.       if [ -z $line_pin_81 ];
  953.       then
  954.         line_pin_80=$(grep -nr -m 1 "pin_80" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  955.         if [ -z $line_pin_80 ];
  956.         then
  957.           dialog --infobox "Cannot find pin_80 variable!" 0 0
  958.           sleep 2
  959.           exit
  960.         fi
  961.         sed -i $line_pin_80'a\pin_81 = port:PD27<0><default><default><default>' $temp_dir/$fex_file    
  962.       else
  963.         sed -i $line_pin_81's/.*/pin_81 = port:PD27<0><default><default><default>/' $temp_dir/$fex_file
  964.       fi
  965.      
  966.      
  967.      
  968.     else
  969.       #NOT 15.6
  970.       # REMOVE p133
  971.       sed -i '/pll3/d' $temp_dir/$fex_file
  972.       # REMOVE SOME GPIO
  973.       sed -i '/gpio_pin_76/d' $temp_dir/$fex_file
  974.       sed -i '/gpio_pin_77/d' $temp_dir/$fex_file
  975.       sed -i '/gpio_pin_78/d' $temp_dir/$fex_file
  976.       sed -i '/gpio_pin_79/d' $temp_dir/$fex_file
  977.       sed -i '/gpio_pin_80/d' $temp_dir/$fex_file
  978.       sed -i '/gpio_pin_81/d' $temp_dir/$fex_file
  979.       sed -i '/pin_76/d' $temp_dir/$fex_file
  980.       sed -i '/pin_77/d' $temp_dir/$fex_file
  981.       sed -i '/pin_78/d' $temp_dir/$fex_file
  982.       sed -i '/pin_79/d' $temp_dir/$fex_file
  983.       sed -i '/pin_80/d' $temp_dir/$fex_file
  984.       sed -i '/pin_81/d' $temp_dir/$fex_file
  985.      
  986.       # CHECK FOR LCDD22
  987.       line_lcdd22=$(grep -nr -m 1 "lcdd22" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  988.       if [ -z $line_lcdd22 ];
  989.       then
  990.         line_lcdd21=$(grep -nr -m 1 "lcdd21" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  991.         if [ -z $line_lcdd21 ];
  992.         then
  993.           dialog --infobox "Cannot find lcdd21 variable!" 0 0
  994.           sleep 2
  995.           exit
  996.         fi
  997.         sed -i $line_lcdd21'a\lcdd22 = port:PD22<2><0><default><default>' $temp_dir/$fex_file      
  998.       else
  999.         sed -i $line_lcdd22's/.*/lcdd22 = port:PD22<2><0><default><default>/' $temp_dir/$fex_file
  1000.       fi
  1001.    
  1002.       # CHECK FOR LCDD23
  1003.       line_lcdd23=$(grep -nr -m 1 "lcdd23" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  1004.       if [ -z $line_lcdd23 ];
  1005.         then
  1006.           line_lcdd22=$(grep -nr -m 1 "lcdd22" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  1007.           if [ -z $line_lcdd22 ];
  1008.           then
  1009.         dialog --infobox "Cannot find lcdd22 variable!" 0 0
  1010.         sleep 2
  1011.         exit
  1012.           fi
  1013.           sed -i $line_lcdd22'a\lcdd23 = port:PD23<2><0><default><default>' $temp_dir/$fex_file    
  1014.         else
  1015.           sed -i $line_lcdd23's/.*/lcdd23 = port:PD23<2><0><default><default>/' $temp_dir/$fex_file
  1016.         fi
  1017.      
  1018.      
  1019.       # CHECK FOR LCDCLK
  1020.       line_lcdclk=$(grep -nr -m 1 "lcdclk" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  1021.       if [ -z $line_lcdd23 ];
  1022.         then
  1023.           line_lcdd23=$(grep -nr -m 1 "lcdd23" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  1024.           if [ -z $line_lcdd22 ];
  1025.           then
  1026.         dialog --infobox "Cannot find lcdd23 variable!" 0 0
  1027.         sleep 2
  1028.         exit
  1029.           fi
  1030.           sed -i $line_lcdd23'a\lcdclk = port:PD24<2><0><default><default>' $temp_dir/$fex_file    
  1031.         else
  1032.           sed -i $line_lcdclk's/.*/lcdclk = port:PD24<2><0><default><default>/' $temp_dir/$fex_file
  1033.         fi
  1034.        
  1035.       # CHECK FOR LCDDE dialog --infobox $choice 0 0
  1036.       line_lcdde=$(grep -nr -m 1 "lcdde" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  1037.       if [ -z $line_lcdde ];
  1038.         then
  1039.           line_lcdclk=$(grep -nr -m 1 "lcdclk" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  1040.           if [ -z $line_lcdclk ];
  1041.           then
  1042.         dialog --infobox "Cannot find lcdclk variable!" 0 0
  1043.         sleep 2
  1044.         exit
  1045.           fi
  1046.           sed -i $line_lcdclk'a\lcdde = port:PD25<2><0><default><default>' $temp_dir/$fex_file     
  1047.         else
  1048.           sed -i $line_lcdde's/.*/lcdde = port:PD25<2><0><default><default>/' $temp_dir/$fex_file
  1049.         fi
  1050.  
  1051.       # CHECK FOR LCDHSYNC
  1052.       line_lcdhsync=$(grep -nr -m 1 "lcdhsync" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  1053.       if [ -z $line_lcdhsync ];
  1054.         then
  1055.           line_lcdde=$(grep -nr -m 1 "lcdde" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  1056.           if [ -z $line_lcdde ];
  1057.           then
  1058.         dialog --infobox "Cannot find lcdde variable!" 0 0
  1059.         sleep 2
  1060.         exit
  1061.           fi
  1062.           sed -i $line_lcdde'a\lcdhsync = port:PD26<2><0><default><default>' $temp_dir/$fex_file       
  1063.         else
  1064.           sed -i $line_lcdhsync's/.*/lcdhsync = port:PD26<2><0><default><default>/' $temp_dir/$fex_file
  1065.         fi
  1066.      
  1067.       # CHECK FOR LCDVSYNC
  1068.       line_lcdvsync=$(grep -nr -m 1 "lcdvsync" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  1069.       if [ -z $line_lcdvsync ];
  1070.       then
  1071.         line_lcdhsync=$(grep -nr -m 1 "lcdhsync" $temp_dir/$fex_file | awk '{print$1}' FS=":")
  1072.         if [ -z $line_lcdhsync ];
  1073.         then
  1074.           dialog --infobox "Cannot find lcdhsync variable!" 0 0
  1075.           sleep 2
  1076.           exit
  1077.         fi
  1078.         sed -i $line_lcdhsync'a\lcdvsync = port:PD27<2><0><default><default>' $temp_dir/$fex_file      
  1079.       else
  1080.         sed -i $line_lcdvsync's/.*/lcdvsync = port:PD27<2><0><default><default>/' $temp_dir/$fex_file
  1081.       fi
  1082.    
  1083.    
  1084.     fi
  1085.    
  1086.    
  1087.     dialog --infobox "Changes saved" 3 17
  1088.     sleep 2
  1089.     ;;
  1090.       1|255)
  1091.     dialog --infobox "No changes done" 3 19
  1092.     sleep 2
  1093.     ;;
  1094.     esac  
  1095. }
  1096.  
  1097. MAIN() {
  1098.  
  1099.   # Now to some fancy stuff
  1100.   dialog --backtitle "OLimeXino-A20 screen configuration" \
  1101.   --menu "Select output type:" 12 55 8 \
  1102.   "None" "Disable all screens" \
  1103.   "LCD" "Set configuration for LCD" \
  1104.   "HDMI" "Set configuration for HDMI" \
  1105.   "VGA" "Set configuration for VGA" 2> $tempfile1
  1106.  
  1107.   retv=$?
  1108.   choice=$(cat $tempfile1)
  1109.  
  1110.   # Check if ESC of CANCLE are pressed
  1111.   if [ $retv -eq 1 -o $retv -eq 255 ];
  1112.   then
  1113.     clear
  1114.     exit
  1115.   fi
  1116.  
  1117.   # Check selected option
  1118.   case $choice in
  1119.     "None") SET_NONE;;
  1120.     "LCD") SET_LCD;;
  1121.     "HDMI") SET_HDMI;;
  1122.     "VGA") SET_VGA
  1123.   esac
  1124. }
  1125. trap "rm -f $tempfile1" 0 1 2 5 15
  1126.  
  1127. umount /dev/mmcblk0p1 > /dev/null 2>&1
  1128. #Export PATH
  1129. #Check for /opt/sunxi-tools
  1130. if [ ! -d $sunxi_tools_dir ];
  1131. then
  1132.   dialog --infobox "No sunxi-tools found!" 3 26
  1133.   sleep 2
  1134.   clear
  1135.   exit
  1136. fi
  1137. export PATH=$PATH:$sunxi_tools_dir
  1138.  
  1139. # Check for /mnt/mmc
  1140. if [ ! -d $mmc_dir ];
  1141. then
  1142.   mkdir -p $mmc_dir
  1143. fi
  1144.  
  1145. # Check for /mnt/mmc
  1146. if [ ! -d $temp_dir ];
  1147. then
  1148.   mkdir -p $temp_dir
  1149. fi
  1150.  
  1151. mount /dev/mmcblk0p1 $mmc_dir
  1152. sleep 1
  1153. if [ $? -ne 0 ];
  1154. then
  1155.   dialog --infobox "Failed to mount sd-card" 0 0
  1156.   sleep 2
  1157.   exit
  1158. fi
  1159.  
  1160.  
  1161. # Copy current script
  1162. cp $mmc_dir/$bin_file $temp_dir/
  1163.  
  1164.  
  1165.  
  1166. # bin2fex
  1167. bin2fex $temp_dir/$bin_file > $temp_dir/$fex_file
  1168.  
  1169.  
  1170. # Remove binfile
  1171. rm $temp_dir/$bin_file
  1172.  
  1173. MAIN
  1174.  
  1175. # Adding timestamp
  1176. TIME=$(date)
  1177. sed -i "\$a;LAST EDITED: $TIME" $temp_dir/$fex_file
  1178.  
  1179.  
  1180.  
  1181. # make the bin file
  1182. fex2bin $temp_dir/$fex_file > $temp_dir/$bin_file
  1183.  
  1184.  
  1185. # Copy current script
  1186. cp -vf $temp_dir/$bin_file $mmc_dir
  1187.  
  1188.  
  1189. # Unmount
  1190. umount /dev/mmcblk0p1
  1191.  
  1192.  
  1193. rm -rf $temp_dir
  1194.  
  1195. dialog --title "Reboot" --yesno "Reboot the board? " 0 0
  1196. case $? in
  1197.   0)        reboot;;
  1198.   1|255)    clear;;
  1199. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement