diff --git a/README.md b/README.md index 0316cdd..3b1f0b5 100644 --- a/README.md +++ b/README.md @@ -1,81 +1,48 @@ ![rpidatv banner](/doc/img/spectreiq.jpg) # rpidatv -**rpidatv** is a digital television transmitter for Raspberry Pi (B,B+,PI2,PI3,Pizero) which output directly to GPIO. +**rpidatv** is a digital television transmitter for Raspberry Pi (B,B+,PI2,PI3,Pizero) which outputs directly to GPIO. This version has been developed for use with an external synthesized oscillaotor and modulator/filter board. *(Created by Evariste Courjaud F5OEO. Code is GPL)* -# Installation -Install a Raspbian Lite : ([Raspbian Lite](http://www.raspberrypi.org/downloads/raspbian/)) +# Installation for BATC Version + +The preferred installation method only needs a Windows PC connected to the same (inetrnet-connected) network as your Raspberry Pi. + +- First download the March 2016 release of Raspbian Jessie Lite on to your Windows PC from here http://downloads.raspberrypi.org/raspbian_lite/images//raspbian_lite-2016-03-18/. Evariste has not tested with later Raspbian images. There are some problems with the latest version of Raspbian, which Evariste and I are working to resolve. + +- Unzip the image and then transfer it to a Micro-SD Card using Win32diskimager https://sourceforge.net/projects/win32diskimager/ + +- Power up the Pi with the new card inserted, and a network connection. No keyboard or display required. + +- Find the IP address of your Raspberry Pi using an IP Scanner (such as Advanced IP Scanner http://filehippo.com/download_advanced_ip_scanner/ for Windows, or Fing on an iPhone) to get the Pi's IP address + +- From your windows PC use Putty (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) to log in to the IP address that you noted earlier. + +- Log in (user: pi/password: raspberry), and type "sudo raspi-config" to open the configuration tool. Select option 1 to expand the file system to the whole disk. + +- Exit raspi-config (press tab twice then press return), and reboot. + +- Power-off, connect the camera, reconnect power and reboot. Log in again. + +- Cut and paste the following code in, one line at a time: ```sh -$ wget https://raw.githubusercontent.com/F5OEO/rpidatv/master/install.sh -$ chmod +x install.sh -$ ./install.sh +wget https://raw.githubusercontent.com/davecrump/rpidatv/master/install.sh +chmod +x install.sh +./install.sh ``` - -# Hardware -Plug a wire on GPIO 12, means Pin 32 of the GPIO header : this act as the antenna. Length depend on transmit frequency, but with few centimeters it works for local testing. - -# Modulator -**rpidatv** is located in rpidatv/bin folder -``` -rpidatv -2.0.0 -Usage: -rpidatv -i File Input -s Symbolrate -c Fec [-o OutputMode] [-f frequency output] [-l] [-p Power] [-h] --i path to Transport File Input --s SymbolRate in KS (125-4000) --c Fec : 1/2 or 3/4 or 5/6 or 7/8 --m OutputMode - {RF(Modulate QSK in RF need -f option to set frequency)} - {IQ(Output QPSK I/Q} - {PARALLEL(Output parallel (DTX1,MINIMOD..)} - {IQWITHCLK(Output I/Q with CLK (F5LGJ)} - {DIGITHIN (Output I/Q for Digithin)} --f Frequency to output in RF Mode in MHZ --l loop file input --p Power on output 1..7 --x GPIO Pin output for I or RF {12,18,40} --y GPIO Pin output for Q {13,19,41,45} --h help (print this help). -Example : sudo ./rpidatv -i sample.ts -s 250 -c 1/2 -o RF -f 437.5 -l -``` - # Transport stream -**rpidatv** needs a DVB transport stream in input. In the past, ffmpeg was used to generate transport stream. Because ffmpeg is not completely DVB compliant and induces latency, an other tool is proposed : **avc2ts** - -# H264 encoder and transport stream encapsulator -**avc2ts** is located in rpidatv/bin folder -``` -avc2ts -1.0.0 -Usage: -rpi-avc2ts -o OutputFile -b BitrateVideo -m BitrateMux -x VideoWidth -y VideoHeight -f Framerate -n MulticastGroup [-d PTS/PCR][-v][-h] --o path to Transport File Output --b VideoBitrate in bit/s --m Multiplex Bitrate (should be around 1.4 VideoBitrate) --x VideoWidth (should be 16 pixel aligned) --y VideoHeight (should be 16 pixel aligned) --f Framerate (25 for example) --n Multicast group (optionnal) example 230.0.0.1:10000 --d Delay PTS/PCR in ms --v Enable Motion vectors --i IDR Period --t TypeInput {0=Picamera,1=InternalPatern,2=USB Camera,3=Rpi Display,4=VNC} --e Extra Arg: - - For usb camera name of device (/dev/video0) - - For VNC : IP address of VNC Server. Password must be datv --p Set the PidStart: Set PMT=PIDStart,Pidvideo=PidStart+1,PidAudio=PidStart+2 --s Set Servicename : Typically CALL --h help (print this help). -Example : ./rpi-avc2ts -o result.ts -b 1000000 -m 1400000 -x 640 -y 480 -f 25 -n 230.0.0.1:1000 -``` - -# Console interface -A console interface is provided under rpidatv/scripts +- For French menus and keyboard, replace the last line above with ```sh -$ /home/pi/rpidatv/scripts/gbmenu.sh -``` -# Touchscreen interface -![Rpidatvgui](/doc/img/rpidatvgui.jpg) -A graphical interface is provided under rpidatv/bin/ folder -```sh -$ /home/pi/rpidatv/bin/rpidatvgui +./install.sh fr ``` +- When it has finished, accept the reboot offered or type "sudo reboot now", log in again and then start the software by typing: + +```sh +/home/pi/rpidatv/scripts/menu.sh menu +``` + +You can now explore the menu options and play. + +Evariste has only tested on an RPi2, I have been using an RPi3. I succeeded in generating a direct RF output (from GPIO pin 32) on 437 MHz at 333KS using the on-board camera as the source; it would not work reliably at higher SRs. The big win for me is that I could feed the I and Q signals from pins 32 and 33 directly into the LC filter on my old DigiLite modulator and generate a 2MS QPSK H264 DVB-S signal from the on-board camera. Some adjustment of the bias is required as the I and Q signals from the Pi are 3.3v, not 5v as provided by the DigiLite encoder. + + diff --git a/bin/adf4351 b/bin/adf4351 new file mode 100755 index 0000000..9b04f4b Binary files /dev/null and b/bin/adf4351 differ diff --git a/bin/leandvb b/bin/leandvb new file mode 100755 index 0000000..cde9018 Binary files /dev/null and b/bin/leandvb differ diff --git a/bin/rpidatvgui b/bin/rpidatvgui new file mode 100755 index 0000000..75a20e9 Binary files /dev/null and b/bin/rpidatvgui differ diff --git a/bin/tcanim b/bin/tcanim new file mode 100755 index 0000000..aa1e508 Binary files /dev/null and b/bin/tcanim differ diff --git a/install.sh b/install.sh index 2819e3f..fff7258 100755 --- a/install.sh +++ b/install.sh @@ -1,86 +1,91 @@ #!/bin/bash -set -e +# Updated by davecrump on 20161208 + +set -e # Don't report errors.... + +# Update the package manager, then install the packages we need sudo dpkg --configure -a sudo apt-get clean sudo apt-get update sudo apt-get -y install apt-transport-https git rpi-update sudo apt-get -y install cmake libusb-1.0-0-dev g++ libx11-dev buffer libjpeg-dev indent libfreetype6-dev ttf-dejavu-core bc usbmount fftw3-dev wiringpi libvncserver-dev -#rpi-update to get latest firmware +# rpi-update to get latest firmware sudo rpi-update -# ---------- install rpidatv ----------- - +# Get the source software and copy to the Pi cd /home/pi -#git clone git://github.com/F5OEO/rpidatv -> BUG IN QEMU : Go to download method -wget https://github.com/F5OEO/rpidatv/archive/master.zip +wget https://github.com/davecrump/rpidatv/archive/master.zip unzip -o master.zip mv rpidatv-master rpidatv rm master.zip -#rpidatv core +# Compile rpidatv core cd rpidatv/src make sudo make install -#rpidatv gui + +# Compile rpidatv gui cd gui make sudo make install cd ../ -#avc2ts -cd avc2ts -#git clone git://github.com/kierank/libmpegts +# Get libmpegts and compile +cd avc2ts wget https://github.com/kierank/libmpegts/archive/master.zip unzip master.zip mv libmpegts-master libmpegts rm master.zip - cd libmpegts ./configure make -#make avc2ts + +# Compile avc2ts cd ../ make sudo make install +# Compile adf4351 +cd /home/pi/rpidatv/src/adf4351 +make +cp adf4351 ../../bin/ - -#install rtl_sdr +# Get rtl_sdr cd /home/pi -#git clone https://github.com/keenerd/rtl-sdr wget https://github.com/keenerd/rtl-sdr/archive/master.zip unzip master.zip mv rtl-sdr-master rtl-sdr rm master.zip +# Compile and install rtl-sdr cd rtl-sdr/ && mkdir build && cd build cmake ../ -DINSTALL_UDEV_RULES=ON make && sudo make install && sudo ldconfig sudo bash -c 'echo -e "\n# for RTL-SDR:\nblacklist dvb_usb_rtl28xxu\n" >> /etc/modprobe.d/blacklist.conf' cd ../../ -#install leandvb +# Get leandvb cd /home/pi/rpidatv/src -#git clone git://github.com/pabr/leansdr wget https://github.com/pabr/leansdr/archive/master.zip unzip master.zip mv leansdr-master leansdr rm master.zip +# Compile leandvb cd leansdr/src/apps make cp leandvb ../../../../bin/ - -#install tstools +# Get tstools cd /home/pi/rpidatv/src wget https://github.com/F5OEO/tstools/archive/master.zip unzip master.zip mv tstools-master tstools rm master.zip +# Compile tstools cd tstools make cp bin/ts2es ../../bin/ @@ -94,7 +99,6 @@ cd /home/pi/rpidatv/src/hello_video make cp hello_video.bin ../../bin/ - # TouchScreen GUI # FBCP : Duplicate Framebuffer 0 -> 1 cd /home/pi/ @@ -102,7 +106,8 @@ wget https://github.com/tasanakorn/rpi-fbcp/archive/master.zip unzip master.zip mv rpi-fbcp-master rpi-fbcp rm master.zip -#git clone https://github.com/tasanakorn/rpi-fbcp + +# Compile fbcp cd rpi-fbcp/ mkdir build cd build/ @@ -111,46 +116,50 @@ make sudo install fbcp /usr/local/bin/fbcp cd ../../ -#Install Waveshare DTOVERLAY +# Install Waveshare DTOVERLAY cd /home/pi/rpidatv/scripts/ sudo cp ./waveshare35a.dtbo /boot/overlays/ - -#Fallback IP to 192.168.1.60 +# Fallback IP to 192.168.1.60 sudo bash -c 'echo -e "\nprofile static_eth0\nstatic ip_address=192.168.1.60/24\nstatic routers=192.168.1.1\nstatic domain_name_servers=192.168.1.1\ninterface eth0\nfallback static_eth0" >> /etc/dhcpcd.conf' -#enable camera +# Enable camera sudo bash -c 'echo -e "\ngpu_mem=128\nstart_x=1\n" >> /boot/config.txt' -#disable sync option for usbmount +# Disable sync option for usbmount sudo sed -i 's/sync,//g' /etc/usbmount/usbmount.conf +# Install executable for hardware shutdown button +wget 'https://github.com/philcrump/pi-sdn/releases/download/v1.0/pi-sdn' -O /home/pi/pi-sdn +chmod +x /home/pi/pi-sdn -if [ "$1" == "Autostart" ]; -then -echo "Doing autostart..." -##Menu autostart +# Record Version Number cd /home/pi/rpidatv/scripts/ -##make kayboard in french -sudo cp keyfr /etc/default/keyboard -##do Menu as auto install -bash install_autostart.sh +cp latest_version.txt installed_version.txt +cd /home/pi -#change hostname -CURRENT_HOSTNAME=`sudo cat /etc/hostname | sudo tr -d " \t\n\r"` -NEW_HOSTNAME="rpidatv" -if [ $? -eq 0 ]; then - sudo sh -c "echo '$NEW_HOSTNAME' > /etc/hostname" - sudo sed -i "s/127.0.1.1.*$CURRENT_HOSTNAME/127.0.1.1\t$NEW_HOSTNAME/g" /etc/hosts -fi -#change password to tv -echo "pi:tv" | sudo chpasswd +# Switch to French if required +if [ "$1" == "fr" ]; +then + echo "Installing French Language and Keyboard" + cd /home/pi/rpidatv/scripts/ + sudo cp configs/keyfr /etc/default/keyboard + cp configs/rpidatvconfig.fr rpidatvconfig.txt + cd /home/pi + echo "Completed French Install" else -echo "completed without autostart" + echo "Completed English Install" fi -#always enable HDMI at 720p -#sudo bash -c 'echo -e "\nhdmi_force_hotplug=1\nhdmi_drive=2\nhdmi_group=1\nhdmi_mode=4\n" >> /boot/config.txt' + +# Offer reboot +printf "A reboot will be required before using the software." +printf "Do you want to reboot now? (y/n)\n" +read -n 1 +printf "\n" +if [[ "$REPLY" = "y" || "$REPLY" = "Y" ]]; then + echo "rebooting" + sudo reboot now +fi +exit -#remove script that starts raspi config on first boot -#sudo rm -rf /etc/profile.d/raspi-config.sh diff --git a/scripts/a.sh b/scripts/a.sh index 8959c73..5e9f717 100755 --- a/scripts/a.sh +++ b/scripts/a.sh @@ -97,6 +97,7 @@ case "$MODE_OUTPUT" in OUTPUT=videots MODE=IQ $PATHSCRIPT"/ctlfilter.sh" + $PATHSCRIPT"/ctlvco.sh" #GAIN=0 ;; QPSKRF) @@ -113,7 +114,9 @@ case "$MODE_OUTPUT" in OUTPUT=videots DIGITHIN_MODE=1 MODE=DIGITHIN - #GAIN=0 + $PATHSCRIPT"/ctlfilter.sh" + $PATHSCRIPT"/ctlvco.sh" + #GAIN=0 ;; DTX1) MODE=PARALLEL @@ -311,8 +314,6 @@ $PATHRPI"/avc2ts" -b $BITRATE_VIDEO -m $BITRATE_TS -x $VIDEO_WIDTH -y $VIDEO_HEI ;; #============================================ ANALOG ============================================================= - - "ANALOGCAM") sudo modprobe -r bcm2835_v4l2 case "$MODE_OUTPUT" in @@ -328,6 +329,7 @@ $PATHRPI"/avc2ts" -b $BITRATE_VIDEO -m $BITRATE_TS -x $VIDEO_WIDTH -y $VIDEO_HEI ;; +#============================================ DESKTOP ============================================================= "DESKTOP") sudo modprobe -r bcm2835_v4l2 case "$MODE_OUTPUT" in @@ -358,11 +360,11 @@ $PATHRPI"/mnc" -l -i eth0 -p $PORT $UDPINADDR > videots & # *********************************** TRANSPORT STREAM INPUT FILE ****************************************** "FILETS") - + case "$MODE_OUTPUT" in "BATC") sudo nice -n -30 $PATHRPI"/ffmpeg" -loglevel $MODE_DEBUG -i $TSVIDEOFILE -y $OUTPUT_BATC & ;; - + *) sudo $PATHRPI"/rpidatv" -i $TSVIDEOFILE -s $SYMBOLRATE_K -c $FECNUM"/"$FECDEN -f $FREQUENCY_OUT -p $GAIN -m $MODE -x $PIN_I -y $PIN_Q &;; esac diff --git a/scripts/configs/autologin.conf b/scripts/configs/autologin.conf new file mode 100644 index 0000000..ea5c0ca --- /dev/null +++ b/scripts/configs/autologin.conf @@ -0,0 +1,3 @@ +[Service] +ExecStart= +ExecStart=-/sbin/agetty --autologin pi --noclear %I 38400 linux diff --git a/scripts/configs/button.bashrc b/scripts/configs/button.bashrc new file mode 100755 index 0000000..2488b25 --- /dev/null +++ b/scripts/configs/button.bashrc @@ -0,0 +1,122 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +[ -z "$PS1" ] && return + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \$\[\033[00m\] ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# some more ls aliases +#alias ll='ls -l' +#alias la='ls -A' +#alias l='ls -CF' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if [ -f /etc/bash_completion ] && ! shopt -oq posix; then + . /etc/bash_completion +fi + +## Tidy shutdown by hardware button +## Button to 3.3v on physical pin 15. LED to indicate still running on pin 13 +## See https://github.com/philcrump/pi-sdn +## Calls .pi-sdn if present and runs "sudo pi-sdn 3 2 &" + +if [ -f ~/.pi-sdn ]; then + . ~/.pi-sdn +fi + +## Facility to Disable WiFi +## Calls .wifi_off if present and runs "sudo ifconfig wlan0 down" + +if [ -f ~/.wifi_off ]; then + . ~/.wifi_off +fi + +./rpidatv/scripts/rpibutton.sh + diff --git a/scripts/configs/console.bashrc b/scripts/configs/console.bashrc new file mode 100755 index 0000000..602ec8b --- /dev/null +++ b/scripts/configs/console.bashrc @@ -0,0 +1,132 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \$\[\033[00m\] ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# some more ls aliases +#alias ll='ls -l' +#alias la='ls -A' +#alias l='ls -CF' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi +#con2fbmap 1 1 + +## Tidy shutdown by hardware button +## Button to 3.3v on physical pin 15. LED to indicate still running on pin 13 +## See https://github.com/philcrump/pi-sdn +## Calls .pi-sdn if present and runs "sudo pi-sdn 3 2 &" + +if [ -f ~/.pi-sdn ]; then + . ~/.pi-sdn +fi + +## Facility to Disable WiFi +## Calls .wifi_off if present and runs "sudo ifconfig wlan0 down" + +if [ -f ~/.wifi_off ]; then + . ~/.wifi_off +fi + +./rpidatv/scripts/menu.sh menu diff --git a/scripts/configs/console.txt b/scripts/configs/console.txt new file mode 100644 index 0000000..cb6a2b3 --- /dev/null +++ b/scripts/configs/console.txt @@ -0,0 +1,2 @@ +## Console selected + diff --git a/scripts/configs/console_tx.bashrc b/scripts/configs/console_tx.bashrc new file mode 100755 index 0000000..0aa2729 --- /dev/null +++ b/scripts/configs/console_tx.bashrc @@ -0,0 +1,133 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \$\[\033[00m\] ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# some more ls aliases +#alias ll='ls -l' +#alias la='ls -A' +#alias l='ls -CF' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi +#con2fbmap 1 1 + +## Tidy shutdown by hardware button +## Button to 3.3v on physical pin 15. LED to indicate still running on pin 13 +## See https://github.com/philcrump/pi-sdn +## Calls .pi-sdn if present and runs "sudo pi-sdn 3 2 &" + +if [ -f ~/.pi-sdn ]; then + . ~/.pi-sdn +fi + +## Facility to Disable WiFi +## Calls .wifi_off if present and runs "sudo ifconfig wlan0 down" + +if [ -f ~/.wifi_off ]; then + . ~/.wifi_off +fi + + +./rpidatv/scripts/menu.sh diff --git a/scripts/configs/display.bashrc b/scripts/configs/display.bashrc new file mode 100755 index 0000000..33c53b8 --- /dev/null +++ b/scripts/configs/display.bashrc @@ -0,0 +1,124 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +[ -z "$PS1" ] && return + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \$\[\033[00m\] ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# some more ls aliases +#alias ll='ls -l' +#alias la='ls -A' +#alias l='ls -CF' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if [ -f /etc/bash_completion ] && ! shopt -oq posix; then + . /etc/bash_completion +fi + +## Tidy shutdown by hardware button +## Button to 3.3v on physical pin 15. LED to indicate still running on pin 13 +## See https://github.com/philcrump/pi-sdn +## Calls .pi-sdn if present and runs "sudo pi-sdn 3 2 &" + +if [ -f ~/.pi-sdn ]; then + . ~/.pi-sdn +fi + +## Facility to Disable WiFi +## Calls .wifi_off if present and runs "sudo ifconfig wlan0 down" + +if [ -f ~/.wifi_off ]; then + . ~/.wifi_off +fi + +sudo killall fbcp +fbcp & + ./rpidatv/bin/rpidatvgui + diff --git a/scripts/configs/displaywaveshare.bashrc b/scripts/configs/displaywaveshare.bashrc new file mode 100755 index 0000000..7859bd6 --- /dev/null +++ b/scripts/configs/displaywaveshare.bashrc @@ -0,0 +1,124 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +[ -z "$PS1" ] && return + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \$\[\033[00m\] ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# some more ls aliases +#alias ll='ls -l' +#alias la='ls -A' +#alias l='ls -CF' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if [ -f /etc/bash_completion ] && ! shopt -oq posix; then + . /etc/bash_completion +fi + +## Tidy shutdown by hardware button +## Button to 3.3v on physical pin 15. LED to indicate still running on pin 13 +## See https://github.com/philcrump/pi-sdn +## Calls .pi-sdn if present and runs "sudo pi-sdn 3 2 &" + +if [ -f ~/.pi-sdn ]; then + . ~/.pi-sdn +fi + +## Facility to Disable WiFi +## Calls .wifi_off if present and runs "sudo ifconfig wlan0 down" + +if [ -f ~/.wifi_off ]; then + . ~/.wifi_off +fi + +sudo killall fbcp +fbcp & + ./rpidatv/bin/rpidatvgui 1 + diff --git a/scripts/configs/hdmitouch.txt b/scripts/configs/hdmitouch.txt new file mode 100644 index 0000000..002e14d --- /dev/null +++ b/scripts/configs/hdmitouch.txt @@ -0,0 +1,7 @@ +hdmi_group=2 +hdmi_mode=1 +hdmi_mode=87 +hdmi_cvt 800 480 60 6 0 0 0 +dtparam=spi=on + +dtoverlay=ads7846,cs=1,penirq=25,penirq_pull=2,speed=50000,keep_vref_on=0,swapxy=0,pmax=255,xohms=150,xmin=200,xmax=3900,ymin=200,ymax=3900 diff --git a/scripts/keyfr b/scripts/configs/keyfr similarity index 100% rename from scripts/keyfr rename to scripts/configs/keyfr diff --git a/scripts/keygb b/scripts/configs/keygb similarity index 100% rename from scripts/keygb rename to scripts/configs/keygb diff --git a/scripts/configs/keyus b/scripts/configs/keyus new file mode 100644 index 0000000..3fecbcc --- /dev/null +++ b/scripts/configs/keyus @@ -0,0 +1,10 @@ +# KEYBOARD CONFIGURATION FILE + +# Consult the keyboard(5) manual page. + +XKBMODEL="pc105" +XKBLAYOUT="us" +XKBVARIANT="" +XKBOPTIONS="" + +BACKSPACE="guess" diff --git a/scripts/configs/lcd_markers.txt b/scripts/configs/lcd_markers.txt new file mode 100644 index 0000000..57bb02b --- /dev/null +++ b/scripts/configs/lcd_markers.txt @@ -0,0 +1,4 @@ + +## Begin LCD Driver +## No driver loaded +## End LCD Driver diff --git a/scripts/configs/prompt.bashrc b/scripts/configs/prompt.bashrc new file mode 100755 index 0000000..0acb62b --- /dev/null +++ b/scripts/configs/prompt.bashrc @@ -0,0 +1,130 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \$\[\033[00m\] ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# some more ls aliases +#alias ll='ls -l' +#alias la='ls -A' +#alias l='ls -CF' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi + +## Tidy shutdown by hardware button +## Button to 3.3v on physical pin 15. LED to indicate still running on pin 13 +## See https://github.com/philcrump/pi-sdn +## Calls .pi-sdn if present and runs "sudo pi-sdn 3 2 &" + +if [ -f ~/.pi-sdn ]; then + . ~/.pi-sdn +fi + +## Facility to Disable WiFi +## Calls .wifi_off if present and runs "sudo ifconfig wlan0 down" + +if [ -f ~/.wifi_off ]; then + . ~/.wifi_off +fi + diff --git a/scripts/configs/rpidatvconfig.fr b/scripts/configs/rpidatvconfig.fr new file mode 100644 index 0000000..09fb9fb --- /dev/null +++ b/scripts/configs/rpidatvconfig.fr @@ -0,0 +1,21 @@ +modeinput=PATERNAUDIO +symbolrate=250 +fec=7 +freqoutput=437 +rfpower=7 +modeoutput=QPSKRF +tsvideofile=/home/pi/rpidatv/video/f4day.ts +call=F5OEO +paternfile=/home/pi/rpidatv/video +udpinaddr=230.0.0.2 +pidvideo=1001 +pidpmt=1000 +serviceid=1 +gpio_i=12 +gpio_q=13 +pathmedia=/home/pi/rpidatv/video +locator=JNO6EP +pidstart=1000 +pidaudio=1002 +display=Waveshare +menulanguage=fr diff --git a/scripts/configs/text.pi-sdn b/scripts/configs/text.pi-sdn new file mode 100755 index 0000000..b09dd02 --- /dev/null +++ b/scripts/configs/text.pi-sdn @@ -0,0 +1,8 @@ +## called by .bashrc at log-on to enable hardware button shutdown +## If this file is in ~, then hardware button shutdown is enabled + +sudo ~/pi-sdn 3 2 & + +## + + diff --git a/scripts/configs/text.wifi_off b/scripts/configs/text.wifi_off new file mode 100755 index 0000000..d480574 --- /dev/null +++ b/scripts/configs/text.wifi_off @@ -0,0 +1,6 @@ +## called by .bashrc at log-on to diable wifi +## If this file is not in ~, then wifi is allowed to start + +sudo ifconfig wlan0 down + +## Only way to restart wifi is to reboot diff --git a/scripts/configs/tontec35.txt b/scripts/configs/tontec35.txt new file mode 100644 index 0000000..d44134e --- /dev/null +++ b/scripts/configs/tontec35.txt @@ -0,0 +1,3 @@ +dtparam=spi=on +dtoverlay=mz61581 + diff --git a/scripts/configs/waveshare.txt b/scripts/configs/waveshare.txt new file mode 100644 index 0000000..5ac9aed --- /dev/null +++ b/scripts/configs/waveshare.txt @@ -0,0 +1,3 @@ +dtparam=spi=on +dtoverlay=waveshare35a +dtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=1000000,keep_vref_on=1,swapxy=1,pmax=255,xohms=60,xmin=200,xmax=3900,ymin=200,ymax=3900 diff --git a/scripts/configs/wpa_markers.txt b/scripts/configs/wpa_markers.txt new file mode 100644 index 0000000..258460e --- /dev/null +++ b/scripts/configs/wpa_markers.txt @@ -0,0 +1,4 @@ + +##STARTNW +## No network loaded +##ENDNW diff --git a/scripts/configs/wpa_text.txt b/scripts/configs/wpa_text.txt new file mode 100644 index 0000000..28dd283 --- /dev/null +++ b/scripts/configs/wpa_text.txt @@ -0,0 +1,4 @@ +network={ + ssid="PixienetG" + psk=b7a2fc71b648e214d337ca533c8c506167fc8f463477c50df379067cc3341912 +} diff --git a/scripts/ctlfilter.sh b/scripts/ctlfilter.sh index e6d0298..7a14231 100755 --- a/scripts/ctlfilter.sh +++ b/scripts/ctlfilter.sh @@ -1,28 +1,56 @@ ########## ctlfilter.sh ############ # Called by a.sh in IQ mode to switch in correct -# Nyquist Filter +# Nyquist Filter and band switching +# Written by Dave G8GKQ 26 Nov 16 and 4 Dec 16 + +# SR Outputs: + +# <130 000 +# <260 001 +# <360 010 +# <550 011 +# <1100 100 +# <2200 101 +# >=2200 110 + +# Band Outputs: + +# <100 00 (71 MHz) +# <250 01 (146.5 MHz) +# <950 10 (437 MHz) +# <4400 11 (1255 MHz) + +# Non integer frequencies are rounded down ############ Set Environment Variables ############### - PATHSCRIPT=/home/pi/rpidatv/scripts CONFIGFILE=$PATHSCRIPT"/rpidatvconfig.txt" -############### PIN DEFINITION ########### +############### PIN DEFINITIONS ########### -#filter_bit0 LSB of filter control word=GPIO 16 / Header 36 +#filter_bit0 LSB of filter control word = BCM 16 / Header 36 filter_bit0=16 -#filter_bit1 Mid Bit of filter control word=GPIO 26 / Header 37 +#filter_bit1 Mid Bit of filter control word = BCM 26 / Header 37 filter_bit1=26 -#filter_bit0 MSB of filter control word=GPIO 20 / Header 38 +#filter_bit0 MSB of filter control word = BCM 20 / Header 38 filter_bit2=20 +#band_bit_0 LSB of band switching word = BCM 1 / Header 28 +band_bit0=1 + +#band_bit_1 MSB of band switching word = BCM 19 / Header 35 +band_bit1=19 + +# Set all as outputs gpio -g mode $filter_bit0 out gpio -g mode $filter_bit1 out gpio -g mode $filter_bit2 out +gpio -g mode $band_bit0 out +gpio -g mode $band_bit1 out ############### Function to read Config File ############### @@ -47,45 +75,62 @@ SYMBOLRATEK=$(get_config_var symbolrate $CONFIGFILE) ############### Switch GPIOs based on Symbol Rate ######## -case "$SYMBOLRATEK" in - 125) +if (( $SYMBOLRATEK \< 130 )); then gpio -g write $filter_bit0 0; gpio -g write $filter_bit1 0; - gpio -g write $filter_bit2 0; - ;; - 250) - gpio -g write $filter_bit0 1; + gpio -g write $filter_bit2 0; +elif (( $SYMBOLRATEK \< 260 )); then + gpio -g write $filter_bit0 1; gpio -g write $filter_bit1 0; gpio -g write $filter_bit2 0; - ;; - 333) +elif (( $SYMBOLRATEK \< 360 )); then gpio -g write $filter_bit0 0; gpio -g write $filter_bit1 1; gpio -g write $filter_bit2 0; - ;; - 500) +elif (( $SYMBOLRATEK \< 550 )); then gpio -g write $filter_bit0 1; gpio -g write $filter_bit1 1; gpio -g write $filter_bit2 0; - ;; - 1000) +elif (( $SYMBOLRATEK \< 1100 )); then gpio -g write $filter_bit0 0; gpio -g write $filter_bit1 0; gpio -g write $filter_bit2 1; - ;; - 2000) +elif (( $SYMBOLRATEK \< 2200 )); then gpio -g write $filter_bit0 1; gpio -g write $filter_bit1 0; gpio -g write $filter_bit2 1; - ;; - *) - gpio -g write $filter_bit0 1; - gpio -g write $filter_bit1 0; +else + gpio -g write $filter_bit0 0; + gpio -g write $filter_bit1 1; gpio -g write $filter_bit2 1; - ;; -esac +fi + +############### Read Frequency ######################### + +FREQ_OUTPUT=$(get_config_var freqoutput $CONFIGFILE) + +INT_FREQ_OUTPUT=${FREQ_OUTPUT%.*} + +############### Switch GPIOs based on Frequency ######## + +if (( $INT_FREQ_OUTPUT \< 100 )); then + gpio -g write $band_bit0 0; + gpio -g write $band_bit1 0; +elif (( $INT_FREQ_OUTPUT \< 250 )); then + gpio -g write $band_bit0 1; + gpio -g write $band_bit1 0; +elif (( $INT_FREQ_OUTPUT \< 950 )); then + gpio -g write $band_bit0 0; + gpio -g write $band_bit1 1; +elif (( $INT_FREQ_OUTPUT \< 4400 )); then + gpio -g write $band_bit0 1; + gpio -g write $band_bit1 1; +else + gpio -g write $band_bit0 0; + gpio -g write $band_bit1 0; +fi ### End ### -# Revert to a.sh # +# Revert to menu.sh or a.sh # diff --git a/scripts/ctlvco.sh b/scripts/ctlvco.sh new file mode 100755 index 0000000..ff35833 --- /dev/null +++ b/scripts/ctlvco.sh @@ -0,0 +1,40 @@ +########## ctlvco.sh ############ + +# Called by a.sh in IQ mode to set ADF4351 +# vco to correct frequency + +############ Set Environment Variables ############### + +PATHSCRIPT=/home/pi/rpidatv/scripts +PATHRPI=/home/pi/rpidatv/bin +CONFIGFILE=$PATHSCRIPT"/rpidatvconfig.txt" + +############### Function to read Config File ############### + +get_config_var() { +lua - "$1" "$2" < "$3.bak" @@ -51,7 +57,7 @@ fi RET=$? if [ $RET -eq 1 ]; then ## This is the section where you control what happens when the user hits Cancel -Cancel +Cancel elif [ $RET -eq 0 ]; then if [[ -d "/$1$pathselect" ]]; then Filebrowser "/$1$pathselect" @@ -59,7 +65,6 @@ elif [ $RET -eq 0 ]; then ## Do your thing here, this is just a stub of the code I had to do what I wanted the script to do. fileout=`file "$1$pathselect"` filename=`readlink -m $1$pathselect` - else echo pathselect $1$pathselect whiptail --title "$FileMenuTitle" --msgbox "$FileMenuContext" 8 44 @@ -67,9 +72,7 @@ elif [ $RET -eq 0 ]; then unset imgpath Filebrowser fi - fi - } Pathbrowser() { @@ -95,7 +98,7 @@ elif [ $RET -eq 0 ]; then fileout=`file "$1$pathselect"` filenametemp=`readlink -m $1$pathselect` filename=`dirname $filenametemp` - + else echo pathselect $1$pathselect whiptail --title "$FileMenuTitle" --msgbox "$FileMenuContext" 8 44 @@ -103,9 +106,8 @@ elif [ $RET -eq 0 ]; then unset imgpath Pathbrowser fi - -fi +fi } do_input_setup() { @@ -244,7 +246,6 @@ case "$MODE_INPUT" in Radio9=OFF Radio10=OFF ;; - esac chinput=$(whiptail --title "$StrInputSetupTitle" --radiolist \ @@ -282,28 +283,27 @@ chinput=$(whiptail --title "$StrInputSetupTitle" --radiolist \ ;; IPTSIN) UDPINADDR=$(get_config_var udpinaddr $CONFIGFILE) - + UDPINADDR=$(whiptail --inputbox "$StrInputSetupIPTSINName" 8 78 $UDPINADDR --title "$StrInputSetupIPTSINTitle" 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then set_config_var udpinaddr "$UDPINADDR" $CONFIGFILE - fi + fi ;; ANALOGCAM) ANALOGCAMNAME=$(get_config_var analogcamname $CONFIGFILE) - ANALOGCAMNAME=$(whiptail --inputbox "$StrInputSetupANALOGCAMName" 8 78 $ANALOGCAMNAME --title "$StrInputSetupANALOGCAMTitle" 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then set_config_var analogcamname "$ANALOGCAMNAME" $CONFIGFILE - fi + fi ;; VNC) VNCADDR=$(get_config_var vncaddr $CONFIGFILE) - + VNCADDR=$(whiptail --inputbox "$StrInputSetupVNCName" 8 78 $VNCADDR --title "$StrInputSetupVNCTitle" 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then set_config_var vncaddr "$VNCADDR" $CONFIGFILE - fi - ;; + fi + ;; esac set_config_var modeinput "$chinput" $CONFIGFILE fi @@ -411,56 +411,56 @@ choutput=$(whiptail --title "$StrOutputSetupTitle" --radiolist \ "DTX1" "$StrOutputSetupDTX1" $Radio5 \ "DATVEXPRESS" "$StrOutputSetupDATVExpress" $Radio6 \ "IP" "$StrOutputSetupIP" $Radio7 3>&2 2>&1 1>&3) -if [ $? -eq 0 ]; then - +if [ $? -eq 0 ]; then + case "$choutput" in - IQ) + IQ) PIN_I=$(get_config_var gpio_i $CONFIGFILE) PIN_I=$(whiptail --inputbox "$StrPIN_IContext" 8 78 $PIN_I --title "$StrPIN_ITitle" 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then - set_config_var gpio_i "$PIN_I" $CONFIGFILE + set_config_var gpio_i "$PIN_I" $CONFIGFILE fi PIN_Q=$(get_config_var gpio_q $CONFIGFILE) PIN_Q=$(whiptail --inputbox "$StrPIN_QContext" 8 78 $PIN_Q --title "$StrPIN_QTitle" 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then - set_config_var gpio_q "$PIN_Q" $CONFIGFILE + set_config_var gpio_q "$PIN_Q" $CONFIGFILE fi - ;; + ;; QPSKRF) FREQ_OUTPUT=$(get_config_var freqoutput $CONFIGFILE) - FREQ=$(whiptail --inputbox "$StrOutputRFFreqContext" 8 78 $FREQ_OUTPUT --title "$StrOutputRFFreqTitle" 3>&1 1>&2 2>&3) - if [ $? -eq 0 ]; then - set_config_var freqoutput "$FREQ" $CONFIGFILE - fi + ##FREQ=$(whiptail --inputbox "$StrOutputRFFreqContext" 8 78 $FREQ_OUTPUT --title "$StrOutputRFFreqTitle" 3>&1 1>&2 2>&3) + ##if [ $? -eq 0 ]; then + ## set_config_var freqoutput "$FREQ" $CONFIGFILE + ##fi GAIN_OUTPUT=$(get_config_var rfpower $CONFIGFILE) GAIN=$(whiptail --inputbox "$StrOutputRFGainContext" 8 78 $GAIN_OUTPUT --title "$StrOutputRFGainTitle" 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then - set_config_var rfpower "$GAIN" $CONFIGFILE + set_config_var rfpower "$GAIN" $CONFIGFILE fi ;; BATC) BATC_OUTPUT=$(get_config_var batcoutput $CONFIGFILE) ADRESS=$(whiptail --inputbox "$StrOutputBATCContext" 8 78 $BATC_OUTPUT --title "$StrOutputBATCTitle" 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then - set_config_var batcoutput "$ADRESS" $CONFIGFILE - fi + set_config_var batcoutput "$ADRESS" $CONFIGFILE + fi ;; DIGITHIN) PIN_I=$(get_config_var gpio_i $CONFIGFILE) PIN_I=$(whiptail --inputbox "$StrPIN_IContext" 8 78 $PIN_I --title "$StrPIN_ITitle" 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then - set_config_var gpio_i "$PIN_I" $CONFIGFILE + set_config_var gpio_i "$PIN_I" $CONFIGFILE fi PIN_Q=$(get_config_var gpio_q $CONFIGFILE) PIN_Q=$(whiptail --inputbox "$StrPIN_QContext" 8 78 $PIN_Q --title "$StrPIN_QTitle" 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then - set_config_var gpio_q "$PIN_Q" $CONFIGFILE + set_config_var gpio_q "$PIN_Q" $CONFIGFILE fi FREQ_OUTPUT=$(get_config_var freqoutput $CONFIGFILE) FREQ=$(whiptail --inputbox "$StrOutputRFFreqContext" 8 78 $FREQ_OUTPUT --title "$StrOutputRFFreqTitle" 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then - set_config_var freqoutput "$FREQ" $CONFIGFILE - fi + set_config_var freqoutput "$FREQ" $CONFIGFILE + fi sudo ./si570 -f $FREQ -m off ;; DTX1) ;; @@ -468,22 +468,22 @@ if [ $? -eq 0 ]; then FREQ_OUTPUT=$(get_config_var freqoutput $CONFIGFILE) FREQ=$(whiptail --inputbox "$StrOutputRFFreqContext" 8 78 $FREQ_OUTPUT --title "$StrOutputRFFreqTitle" 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then - set_config_var freqoutput "$FREQ" $CONFIGFILE + set_config_var freqoutput "$FREQ" $CONFIGFILE fi GAIN_OUTPUT=$(get_config_var rfpower $CONFIGFILE) GAIN=$(whiptail --inputbox "$StrOutputRFGainContext" 8 78 $GAIN_OUTPUT --title "$StrOutputRFGainTitle" 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then - set_config_var rfpower "$GAIN" $CONFIGFILE + set_config_var rfpower "$GAIN" $CONFIGFILE fi ;; - IP) + IP) UDPOUTADDR=$(get_config_var udpoutaddr $CONFIGFILE) - + UDPOUTADDR=$(whiptail --inputbox "$StrOutputSetupIPTSOUTName" 8 78 $UDPOUTADDR --title "$StrOutputSetupIPTSOUTTitle" 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then set_config_var udpoutaddr "$UDPOUTADDR" $CONFIGFILE - fi - ;; + fi + ;; esac set_config_var modeoutput "$choutput" $CONFIGFILE fi @@ -554,7 +554,7 @@ do_fec_setup() "7" "7/8" $Radio5 3>&2 2>&1 1>&3) if [ $? -eq 0 ]; then set_config_var fec "$FEC" $CONFIGFILE -fi +fi } do_PID_setup() @@ -573,39 +573,47 @@ set_config_var pidaudio "$PID" $CONFIGFILE fi } +do_freq_setup() +{ +FREQ_OUTPUT=$(get_config_var freqoutput $CONFIGFILE) +FREQ=$(whiptail --inputbox "$StrOutputRFFreqContext" 8 78 $FREQ_OUTPUT --title "$StrOutputRFFreqTitle" 3>&1 1>&2 2>&3) +if [ $? -eq 0 ]; then + set_config_var freqoutput "$FREQ" $CONFIGFILE +fi +} + do_output_setup() { menuchoice=$(whiptail --title "$StrOutputTitle" --menu "$StrOutputContext" 16 78 5 \ "1 SymbolRate" "$StrOutputSR" \ "2 FEC" "$StrOutputFEC" \ "3 Output mode" "$StrOutputMode" \ "4 PID" "$StrPIDSetup" \ + "5 Frequency" "$StrOutputRFFreqContext" \ 3>&2 2>&1 1>&3) case "$menuchoice" in 1\ *) do_symbolrate_setup ;; 2\ *) do_fec_setup ;; 3\ *) do_output_setup_mode ;; - 4\ *) do_PID_setup ;; + 4\ *) do_PID_setup ;; + 5\ *) do_freq_setup ;; esac } do_transmit() { - - $PATHSCRIPT"/a.sh" >/dev/null 2>/dev/null & - #$PATHSCRIPT"/a.sh" & - do_status - do_stop_transmit - + $PATHSCRIPT"/a.sh" >/dev/null 2>/dev/null & + do_status # Wait here transmitting until user presses a key + do_stop_transmit } do_stop_transmit() { sudo killall rpidatv >/dev/null 2>/dev/null sudo killall ffmpeg >/dev/null 2>/dev/null - sudo killall tcanim >/dev/null 2>/dev/null + sudo killall tcanim >/dev/null 2>/dev/null sudo killall avc2ts >/dev/null 2>/dev/null - + sudo $PATHRPI"/adf4351" off } do_display_on() @@ -635,8 +643,6 @@ do_receive_status() whiptail --title "RECEIVE" --msgbox "$INFO" 8 78 sudo killall rpidatvgui >/dev/null 2>/dev/null sudo killall leandvb >/dev/null 2>/dev/null - - } do_receive() @@ -657,104 +663,181 @@ do_receive() /home/pi/rpidatv/bin/rpidatvgui 0 1 >/dev/null 2>/dev/null & do_receive_status;; esac - } do_autostart_setup() { -MODE_STARTUP=$(get_config_var startup $CONFIGFILE) -case "$MODE_STARTUP" in - Console) - Radio1=ON - Radio2=OFF - Radio3=OFF - ;; - Display) - Radio1=OFF - Radio2=ON - Radio3=OFF - ;; - Button) - Radio1=OFF - Radio2=OFF - Radio3=ON - ;; - *) - Radio1=ON - Radio2=OFF - Radio3=OFF - -esac + MODE_STARTUP=$(get_config_var startup $CONFIGFILE) -chstartup=$(whiptail --title "$StrAutostartSetupTitle" --radiolist \ - "$StrAutostartSetupContext" 20 78 8 \ - "Console" "$AutostartSetupConsole" $Radio1 \ - "Display" "$AutostartSetupDisplay" $Radio2 \ - "Button" "$AutostartSetupButton" $Radio3 \ - 3>&2 2>&1 1>&3) + Radio1=OFF + Radio2=OFF + Radio3=OFF + Radio4=OFF + Radio5=OFF + Radio6=OFF + Radio7=OFF -if [ $? -eq 0 ]; then - - case "$chstartup" in - Console) cp $PATHSCRIPT"/install_bashrc" /home/pi/.bashrc >/dev/null 2>/dev/null;; - Display) MODE_DISPLAY=$(get_config_var display $CONFIGFILE) - case "$MODE_DISPLAY" in - Waveshare) - cp $PATHSCRIPT"/install_display_inversed.fr" /home/pi/.bashrc >/dev/null 2>/dev/null;; - *) - cp $PATHSCRIPT"/install_display.fr" /home/pi/.bashrc >/dev/null 2>/dev/null;; - esac;; - - Button) cp $PATHSCRIPT"/install_button" /home/pi/.bashrc >/dev/null 2>/dev/null;; - - esac - set_config_var startup "$chstartup" $CONFIGFILE -fi + case "$MODE_STARTUP" in + Prompt) + Radio1=ON;; + Console) + Radio2=ON;; + Display) + Radio3=ON;; + Button) + Radio4=ON;; + TX_boot) + Radio5=ON;; + Display_boot) + Radio6=ON;; + Button_boot) + Radio7=ON;; + *) + Radio1=ON;; + esac + + chstartup=$(whiptail --title "$StrAutostartSetupTitle" --radiolist \ + "$StrAutostartSetupContext" 20 78 8 \ + "Prompt" "$AutostartSetupPrompt" $Radio1 \ + "Console" "$AutostartSetupConsole" $Radio2 \ + "Display" "$AutostartSetupDisplay" $Radio3 \ + "Button" "$AutostartSetupButton" $Radio4 \ + "TX_boot" "$AutostartSetupTX_boot" $Radio5 \ + "Display_boot" "$AutostartSetupDisplay_boot" $Radio6 \ + "Button_boot" "$AutostartSetupButton_boot" $Radio7 \ + 3>&2 2>&1 1>&3) + + if [ $? -eq 0 ]; then + case "$chstartup" in + Prompt) + sudo systemctl disable getty@tty1.service + sudo rm /etc/systemd/system/getty@tty1.service.d/autologin.conf >/dev/null 2>/dev/null + cp $PATHCONFIGS"/prompt.bashrc" /home/pi/.bashrc;; + Console) + sudo systemctl disable getty@tty1.service + sudo rm /etc/systemd/system/getty@tty1.service.d/autologin.conf >/dev/null 2>/dev/null + cp $PATHCONFIGS"/console.bashrc" /home/pi/.bashrc;; + Display) + sudo systemctl disable getty@tty1.service + sudo rm /etc/systemd/system/getty@tty1.service.d/autologin.conf >/dev/null 2>/dev/null + MODE_DISPLAY=$(get_config_var display $CONFIGFILE) + case "$MODE_DISPLAY" in + Waveshare) + cp $PATHCONFIGS"/displaywaveshare.bashrc" /home/pi/.bashrc;; + *) + cp $PATHCONFIGS"/display.bashrc" /home/pi/.bashrc;; + esac;; + Button) + sudo systemctl disable getty@tty1.service + sudo rm /etc/systemd/system/getty@tty1.service.d/autologin.conf /dev/null 2>/dev/null + cp $PATHCONFIGS"/button.bashrc" /home/pi/.bashrc;; + TX_boot) + sudo mkdir -pv /etc/systemd/system/getty@tty1.service.d/ + sudo cp $PATHCONFIGS"/autologin.conf" /etc/systemd/system/getty@tty1.service.d/ + sudo systemctl enable getty@tty1.service + cp $PATHCONFIGS"/console_tx.bashrc" /home/pi/.bashrc;; + Display_boot) + sudo mkdir -pv /etc/systemd/system/getty@tty1.service.d/ + sudo cp $PATHCONFIGS"/autologin.conf" /etc/systemd/system/getty@tty1.service.d/ + sudo systemctl enable getty@tty1.service + MODE_DISPLAY=$(get_config_var display $CONFIGFILE) + case "$MODE_DISPLAY" in + Waveshare) + cp $PATHCONFIGS"/displaywaveshare.bashrc" /home/pi/.bashrc;; #>/dev/null 2>/dev/null;; + *) + cp $PATHCONFIGS"/display.bashrc" /home/pi/.bashrc;; #>/dev/null 2>/dev/null;; + esac;; + Button_boot) + sudo mkdir -pv /etc/systemd/system/getty@tty1.service.d/ + sudo cp $PATHCONFIGS"/autologin.conf" /etc/systemd/system/getty@tty1.service.d/ + sudo systemctl enable getty@tty1.service + cp $PATHCONFIGS"/button.bashrc" /home/pi/.bashrc;; + esac + set_config_var startup "$chstartup" $CONFIGFILE + fi } do_display_setup() { MODE_DISPLAY=$(get_config_var display $CONFIGFILE) case "$MODE_DISPLAY" in - Tontec35) + + Tontec35) Radio1=ON Radio2=OFF Radio3=OFF + Radio4=OFF ;; HDMITouch) Radio1=OFF Radio2=ON Radio3=OFF - ;; + Radio4=OFF + ;; Waveshare) Radio1=OFF Radio2=OFF Radio3=ON + Radio4=OFF ;; + Console) + Radio1=OFF + Radio2=OFF + Radio3=OFF + Radio4=ON + ;; *) Radio1=ON Radio2=OFF Radio3=OFF - + Radio4=OFF esac chdisplay=$(whiptail --title "$StrDisplaySetupTitle" --radiolist \ - "$StrDisplaySetupContext" 20 78 8 \ - "Tontec35" "$DisplaySetupTontec" $Radio1 \ - "HDMITouch" "$DisplaySetupHDMI" $Radio2 \ - "Waveshare" "$DisplaySetupRpiLCD" $Radio3 \ - 3>&2 2>&1 1>&3) + "$StrDisplaySetupContext" 20 78 8 \ + "Tontec35" "$DisplaySetupTontec" $Radio1 \ + "HDMITouch" "$DisplaySetupHDMI" $Radio2 \ + "Waveshare" "$DisplaySetupRpiLCD" $Radio3 \ + "Console" "$DisplaySetupConsole" $Radio4 \ + 3>&2 2>&1 1>&3) -if [ $? -eq 0 ]; then - - case "$chdisplay" in - Tontec35) sudo bash -c 'echo -e "\ndtparam=spi=on\ndtoverlay=mz61581\n" >> /boot/config.txt' ;; - HDMITouch) sudo bash -c 'echo -e "\nhdmi_group=2\nhdmi_mode=1\nhdmi_mode=87\nhdmi_cvt 800 480 60 6 0 0 0\ndtparam=spi=on\n\ndtoverlay=ads7846,cs=1,penirq=25,penirq_pull=2,speed=50000,keep_vref_on=0,swapxy=0,pmax=255,xohms=150,xmin=200,xmax=3900,ymin=200,ymax=3900" >> /boot/config.txt' ;; - Waveshare) sudo bash -c 'echo -e "\ndtparam=spi=on\ndtoverlay=waveshare35a\ndtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=1000000,keep_vref_on=1,swapxy=1,pmax=255,xohms=60,xmin=200,xmax=3900,ymin=200,ymax=3900\n" >> /boot/config.txt' ;; +## This section modifies and replaces the end of /boot/config.txt +## to allow (only) the correct LCD drivers to be loaded at next boot - - esac - set_config_var display "$chdisplay" $CONFIGFILE +## Set constants for the amendment of /boot/config.txt below + +PATHCONFIGS="/home/pi/rpidatv/scripts/configs" ## Path to config files +lead='^## Begin LCD Driver' ## Marker for start of inserted text +tail='^## End LCD Driver' ## Marker for end of inserted text +CHANGEFILE="/boot/config.txt" ## File requiring added text +APPENDFILE=$PATHCONFIGS"/lcd_markers.txt" ## File containing both markers +TRANSFILE=$PATHCONFIGS"/transfer.txt" ## File used for transfer + +if [ $? -eq 0 ]; then ## If the selection has changed + + grep -q "$lead" "$CHANGEFILE" ## Is the first marker already present? + if [ $? -ne 0 ]; then + sudo bash -c 'cat '$APPENDFILE' >> '$CHANGEFILE' ' ## If not append the markers + fi + + case "$chdisplay" in ## Select the correct driver text + + Tontec35) INSERTFILE=$PATHCONFIGS"/tontec35.txt" ;; ## Message to be added + HDMITouch) INSERTFILE=$PATHCONFIGS"/hdmitouch.txt" ;; + Waveshare) INSERTFILE=$PATHCONFIGS"/waveshare.txt" ;; + Console) INSERTFILE=$PATHCONFIGS"/console.txt" ;; + + esac + + ## Replace whatever is between the markers with the driver text + + sed -e "/$lead/,/$tail/{ /$lead/{p; r $INSERTFILE + }; /$tail/p; d }" $CHANGEFILE >> $TRANSFILE + + sudo cp "$TRANSFILE" "$CHANGEFILE" ## Copy from the transfer file + rm $TRANSFILE ## Delete the transfer file + + set_config_var display "$chdisplay" $CONFIGFILE fi } @@ -764,23 +847,151 @@ CURRENTIP=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '( whiptail --title "IP" --msgbox "$CURRENTIP" 8 78 } +do_WiFi_setup() +{ +$PATHSCRIPT"/wifisetup.sh" +} + +do_WiFi_Off() +{ +sudo ifconfig wlan0 down ## Disable it now +cp $PATHCONFIGS"/text.wifi_off" /home/pi/.wifi_off ## Disable at start-up +} + +do_Enable_DigiThin() +{ +whiptail --title "Not implemented yet" --msgbox "Not Implemented yet. Please press enter to continue" 8 78 +} + +do_125KS() +{ +whiptail --title "Not implemented yet" --msgbox "Not Implemented yet. Please press enter to continue" 8 78 +} + +do_EasyCap() +{ +whiptail --title "Not implemented yet" --msgbox "Not Implemented yet. Please press enter to continue" 8 78 +} + +do_Update() +{ +whiptail --title "Not implemented yet" --msgbox "Not Implemented yet. Please press enter to continue" 8 78 +} + do_system_setup() { -menuchoice=$(whiptail --title "$StrSystemTitle" --menu "$StrSystemContext" 16 78 5 \ - "1 Autostart" "$StrAutostartMenu" \ - "2 Display" "$StrDisplayMenu" \ - "3 IP" "$StrIPMenu" \ - 3>&2 2>&1 1>&3) - case "$menuchoice" in - 1\ *) do_autostart_setup ;; - 2\ *) do_display_setup ;; - 3\ *) do_IP_setup ;; - esac +menuchoice=$(whiptail --title "$StrSystemTitle" --menu "$StrSystemContext" 16 78 9 \ + "1 Autostart" "$StrAutostartMenu" \ + "2 Display" "$StrDisplayMenu" \ + "3 IP" "$StrIPMenu" \ + "4 WiFi Set-up" "SSID and password" \ + "5 WiFi Off" "Turn the WiFi Off" \ + "6 Enable DigiThin" "Not Implemented Yet" \ + "7 Enable 125KS" "Not implemented yet" \ + "8 Set EasyCap" "Not implemented yet" \ + "9 Update" "Not implemented yet" \ + 3>&2 2>&1 1>&3) + case "$menuchoice" in + 1\ *) do_autostart_setup ;; + 2\ *) do_display_setup ;; + 3\ *) do_IP_setup ;; + 4\ *) do_WiFi_setup ;; + 5\ *) do_WiFi_Off ;; + 6\ *) do_Enable_DigiThin ;; + 7\ *) do_125KS ;; + 8\ *) do_EasyCap ;; + 9\ *) do_Update ;; + esac } +do_language_setup() +{ +menuchoice=$(whiptail --title "$StrLanguageTitle" --menu "$StrOutputContext" 16 78 6 \ + "1 French Menus" "Menus Francais" \ + "2 English Menus" "Change Menus to English" \ + "3 French Keyboard" "$StrKeyboardChange" \ + "4 UK Keyboard" "$StrKeyboardChange" \ + "5 US Keyboard" "$StrKeyboardChange" \ + 3>&2 2>&1 1>&3) + case "$menuchoice" in + 1\ *) set_config_var menulanguage "fr" $CONFIGFILE ;; + 2\ *) set_config_var menulanguage "en" $CONFIGFILE ;; + 3\ *) sudo cp $PATHCONFIGS"/keyfr" /etc/default/keyboard ;; + 4\ *) sudo cp $PATHCONFIGS"/keygb" /etc/default/keyboard ;; + 5\ *) sudo cp $PATHCONFIGS"/keyus" /etc/default/keyboard ;; + esac + + # Check Language + + MENU_LANG=$(get_config_var menulanguage $CONFIGFILE) + + # Set Language + + if [ "$MENU_LANG" == "en" ]; then + source $PATHSCRIPT"/langgb.sh" + else + source $PATHSCRIPT"/langfr.sh" + fi +} + +do_Exit() +{ +exit +} + +do_Reboot() +{ +sudo reboot now +} + +do_Shutdown() +{ +sudo shutdown now +} + +do_TouchScreen() +{ +reset +~/rpidatv/bin/rpidatvgui 1 +} + +do_EnableButtonSD() +{ +cp $PATHCONFIGS"/text.pi-sdn" ~/.pi-sdn ## Load it at logon +~/.pi-sdn ## Load it now +} + +do_DisableButtonSD() +{ +rm ~/.pi-sdn ## Stop it being loaded at log-on +sudo pkill -x pi-sdn ## kill the current process +} + +do_shutdown_menu() +{ +menuchoice=$(whiptail --title "Shutdown Menu" --menu "Select Choice" 16 78 7 \ + "1 Shutdown now" "Immediate Shutdown" \ + "2 Reboot now" "Immediate reboot" \ + "3 Exit to Linux" "Exit menu to Command Prompt" \ + "4 Restore TouchScreen" "Exit Menu, restart LCD" \ + "5 Button Enable" "Enable Shutdown Button" \ + "6 Button Disable" "Disable Shutdown Button" \ + 3>&2 2>&1 1>&3) + case "$menuchoice" in + 1\ *) do_Shutdown ;; + 2\ *) do_Reboot ;; + 3\ *) do_Exit ;; + 4\ *) do_TouchScreen ;; + 5\ *) do_EnableButtonSD ;; + 6\ *) do_DisableButtonSD ;; + esac +} + + + OnStartup() { - CALL=$(get_config_var call $CONFIGFILE) +CALL=$(get_config_var call $CONFIGFILE) MODE_INPUT=$(get_config_var modeinput $CONFIGFILE) MODE_OUTPUT=$(get_config_var modeoutput $CONFIGFILE) SYMBOLRATEK=$(get_config_var symbolrate $CONFIGFILE) @@ -795,10 +1006,27 @@ INFO=$CALL":"$MODE_INPUT"-->"$MODE_OUTPUT"("$SYMBOLRATEK"KSymbol FEC "$FECNUM"/" do_transmit } -#********************************************* MAIN MENU ************************************************** +#********************************************* MAIN MENU ********************************* +#************************* Execution of Console Menu starts here ************************* + +# Check Language + +MENU_LANG=$(get_config_var menulanguage $CONFIGFILE) + +# Set Language + +if [ "$MENU_LANG" == "en" ]; then + source $PATHSCRIPT"/langgb.sh" +else + source $PATHSCRIPT"/langfr.sh" +fi + status="0" -OnStartup -#$PATHRPI"/rpibutton.sh" & + +if [ "$1" != "menu" ]; then # if tx on boot + OnStartup # go straight to transmit +fi + sleep 0.2 while [ "$status" -eq 0 ] @@ -820,28 +1048,32 @@ INFO=$CALL":"$MODE_INPUT"-->"$MODE_OUTPUT"("$SYMBOLRATEK"KSymbol FEC "$FECNUM"/" #do_transmit #do_status #do_display_on -#"1 Transmission" "Demarre la transmission"\ - menuchoice=$(whiptail --title "$StrMainMenuTitle" --menu "$INFO" 16 82 6 \ - "0 Transmit" "Go transmit" \ + + menuchoice=$(whiptail --title "$StrMainMenuTitle" --menu "$INFO" 16 82 8 \ + "0 Transmit" "Go to transmit" \ "1 Source" "$StrMainMenuSource" \ - "2 Sortie" "$StrMainMenuOutput" \ + "2 Output" "$StrMainMenuOutput" \ "3 Station" "$StrMainMenuCall" \ "4 Receive" "Receive via rtlsdr" \ "5 System" "$StrMainMenuSystem" \ - 3>&2 2>&1 1>&3) - + "6 Language" "Set Language and Keyboard" \ + "7 Shutdown" "Shutdown and reboot options" \ + 3>&2 2>&1 1>&3) + case "$menuchoice" in - 0\ *) do_transmit ;; + 0\ *) do_transmit ;; 1\ *) do_input_setup ;; 2\ *) do_output_setup ;; 3\ *) do_station_setup ;; - 4\ *) do_receive ;; - 5\ *) do_system_setup ;; - *) - + 4\ *) do_receive ;; + 5\ *) do_system_setup ;; + 6\ *) do_language_setup ;; + 7\ *) do_shutdown_menu ;; + *) + whiptail --title "$StrMainMenuExitTitle" --msgbox "$StrMainMenuExitContext" 8 78 status=1 - + kill -1 $(pidof -x frmenu.sh) >/dev/null 2>/dev/null kill -1 $(pidof -x gbmenu.sh) >/dev/null 2>/dev/null sleep 1 @@ -850,7 +1082,5 @@ INFO=$CALL":"$MODE_INPUT"-->"$MODE_OUTPUT"("$SYMBOLRATEK"KSymbol FEC "$FECNUM"/" esac exitstatus1=$status1 done -else - whiptail --title "Testing" --msgbox "Bye" 8 78 exit diff --git a/scripts/rpidatvconfig.txt b/scripts/rpidatvconfig.txt index fdc30c9..ed9e9a5 100644 --- a/scripts/rpidatvconfig.txt +++ b/scripts/rpidatvconfig.txt @@ -1,19 +1,23 @@ -modeinput=PATERNAUDIO -symbolrate=250 +modeinput=CAMH264 +symbolrate=2000 fec=7 -freqoutput=437 +freqoutput=1249 rfpower=7 -modeoutput=QPSKRF +modeoutput=IQ tsvideofile=/home/pi/rpidatv/video/f4day.ts -call=F5OEO +call=BATC paternfile=/home/pi/rpidatv/video udpinaddr=230.0.0.2 -pidvideo=1001 -pidpmt=1000 +pidvideo=256 +pidpmt=255 serviceid=1 gpio_i=12 gpio_q=13 pathmedia=/home/pi/rpidatv/video -locator=JNO6EP -pidstart=1000 -pidaudio=1002 +locator=IO90LU +pidstart=255 +pidaudio=257 +display=Waveshare +menulanguage=en +analogcamname=/dev/video0 +startup=Display diff --git a/scripts/wifisetup.sh b/scripts/wifisetup.sh new file mode 100755 index 0000000..ee2122f --- /dev/null +++ b/scripts/wifisetup.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +# Script used to set up WiFi from rpidatv menu + +reset # Clear the screen + +# Check that wifi has not been disabled + +if [ -f ~/.wifi_off ]; then + printf "WiFi was disabled at start-up.\n" + printf "You cannot set up the WiFi until it is re-enabled.\n" + printf "Do you want to re-enable it and reboot immediately? (y/n)\n" + read -n 1 + printf "\n" + if [ "$REPLY" = "Y" ]; then + echo "rebooting" + rm ~/.wifi_off + sudo reboot now + fi + if [ "$REPLY" = "y" ]; then + echo "rebooting" + rm ~/.wifi_off + sudo reboot now + fi + exit +fi + +## Wifi is enabled so +## Check current network name + +printf "Current WiFi Status:\n\n" +iwgetid +printf "\nDo you want to set up a new network? (y/n)\n" +read -n 1 +printf "\n" +if [ "$REPLY" = "N" ]; then + exit +fi +if [ "$REPLY" = "n" ]; then + exit +fi + +## Set up new network + +printf "\nThe following networks are available:\n" +printf "\n" +sudo iwlist wlan0 scan | grep 'ESSID' +printf "\n" +printf "Type the SSID of the network that you want to connect to (without qoutes) and press enter\n" +printf "\n" + +read SSID + +printf "\n" +printf "Type the network password and press enter\n" +printf "Characters will not be displayed\n" +printf "\n" + +stty -echo + +read PW + +stty echo +printf "\nWorking....\n\n" +stty -echo + +PSK_TEXT=$(wpa_passphrase "$SSID" "$PW" | grep 'psk=' | grep -v '#psk') + +PATHCONFIGS="/home/pi/rpidatv/scripts/configs" ## Path to config files + +## Build text for supplicant file + +rm $PATHCONFIGS"/wpa_text.txt" + +echo -e "network={" >> $PATHCONFIGS"/wpa_text.txt" +echo -e " ssid="\"""$SSID"\"" >> $PATHCONFIGS"/wpa_text.txt" +echo -e " "$PSK_TEXT >> $PATHCONFIGS"/wpa_text.txt" +echo -e "}" >> $PATHCONFIGS"/wpa_text.txt" + +## Copy the existing wpa_supplicant file to work on + +sudo cp /etc/wpa_supplicant/wpa_supplicant.conf $PATHCONFIGS"/wpa_supcopy.txt" +sudo chown pi:pi $PATHCONFIGS"/wpa_supcopy.txt" + +## Define the parameters for the replace script + +lead='^##STARTNW' ## Marker for start of inserted text +tail='^##ENDNW' ## Marker for end of inserted text +CHANGEFILE=$PATHCONFIGS"/wpa_supcopy.txt" ## File requiring added text +APPENDFILE=$PATHCONFIGS"/wpa_markers.txt" ## File containing both markers +TRANSFILE=$PATHCONFIGS"/transfer.txt" ## File used for transfer +INSERTFILE=$PATHCONFIGS"/wpa_text.txt" ## File to be included + +grep -q "$lead" "$CHANGEFILE" ## Is the first marker already present? +if [ $? -ne 0 ]; then + sudo bash -c 'cat '$APPENDFILE' >> '$CHANGEFILE' ' ## If not append the markers +fi + +## Replace whatever is between the markers with the insert text + +sed -e "/$lead/,/$tail/{ /$lead/{p; r $INSERTFILE + }; /$tail/p; d }" $CHANGEFILE >> $TRANSFILE + +sudo cp "$TRANSFILE" "$CHANGEFILE" ## Copy from the transfer file +rm $TRANSFILE ## Delete the transfer file + +## Give the file root ownership and copy it back over the original + +sudo chown root:root $PATHCONFIGS"/wpa_supcopy.txt" +sudo cp $PATHCONFIGS"/wpa_supcopy.txt" /etc/wpa_supplicant/wpa_supplicant.conf +sudo rm $PATHCONFIGS"/wpa_supcopy.txt" + +stty echo + +##bring wifi down and up again + +sudo ifdown wlan0 +sudo ifup wlan0 + +printf "WiFi Configured\n" +sleep 1 + +exit diff --git a/src/adf4351/Makefile b/src/adf4351/Makefile new file mode 100644 index 0000000..5b281dd --- /dev/null +++ b/src/adf4351/Makefile @@ -0,0 +1,13 @@ +all: adf4351 + +CFLAGS = -Wall -g -O2 -Wno-unused-variable +LDFLAGS = -lm -lrt -lpthread -lwiringPi + +adf4351 : adf4351.h adf4351.c ctladf4351.c + $(CC) $(CFLAGS) -o adf4351 adf4351.c ctladf4351.c $(LDFLAGS) +clean: + rm -f *.o + + + + diff --git a/src/adf4351/adf4351 b/src/adf4351/adf4351 new file mode 100755 index 0000000..9b04f4b Binary files /dev/null and b/src/adf4351/adf4351 differ diff --git a/src/adf4351/adf4351.c b/src/adf4351/adf4351.c new file mode 100644 index 0000000..a38c0c5 --- /dev/null +++ b/src/adf4351/adf4351.c @@ -0,0 +1,588 @@ +/***************************************************************************//** + * @file adf4350.c + * @brief Implementation of ADF4350 Driver. + * @author DBogdan (dragos.bogdan@analog.com) + * +******************************************************************************** + * Copyright 2012-2015(c) Analog Devices, Inc. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * - Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * - The use of this software may or may not infringe the patent rights + * of one or more patent holders. This license does not release you + * from the requirement that you obtain separate licenses from these + * patent holders to use this software. + * - Use of the software either in source or binary form, must be run + * on or directly connected to an Analog Devices Inc. component. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +*******************************************************************************/ +/* wiringPiSPI.c: + * Simplified SPI access routines + * Copyright (c) 2012-2015 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "adf4351.h" + +// The SPI bus parameters +// Variables as they need to be passed as pointers later on + +const static char *spiDev0 = "/dev/spidev0.0" ; +const static char *spiDev1 = "/dev/spidev0.1" ; +const static uint8_t spiBPW = 8 ; +const static uint16_t spiDelay = 0 ; + +static uint32_t spiSpeeds [2] ; +static int spiFds [2] ; + +int SPIDataRW (int channel, unsigned char *data, int len) +{ + struct spi_ioc_transfer spi ; + + channel &= 1 ; + +// Mentioned in spidev.h but not used in the original kernel documentation +// test program )-: + + memset (&spi, 0, sizeof (spi)) ; + + spi.tx_buf = (unsigned long)data ; + spi.rx_buf = (unsigned long)data ; + spi.len = len ; + spi.delay_usecs = spiDelay ; + spi.speed_hz = spiSpeeds [channel] ; + spi.bits_per_word = spiBPW ; + + //return ioctl (spiFds [channel], SPI_IOC_MESSAGE(1), &spi) ; + return 0; +} + +/***************************************************************************//** + * @brief Was used to open the spi device set up the SPI mode. Now unused + * + * @param data - int channel, int speed, int mode + * + * @return Always Returns 0 +*******************************************************************************/ + +int SPISetupMode (int channel, int speed, int mode) +{ + int fd ; + + mode &= 3 ; // Mode is 0, 1, 2 or 3 + channel &= 1 ; // Channel is 0 or 1 + + return 0; +} + + +/******************************************************************************/ +/************************ Local variables and types ***************************/ +/******************************************************************************/ +static struct adf4350_state +{ + struct adf4350_platform_data *pdata; + uint32_t clkin; + uint32_t chspc; /* Channel Spacing */ + uint32_t fpfd; /* Phase Frequency Detector */ + uint32_t min_out_freq; + uint32_t r0_fract; + uint32_t r0_int; + uint32_t r1_mod; + uint32_t r4_rf_div_sel; + uint32_t regs[6]; + uint32_t regs_hw[6]; + uint32_t val; +}adf4350_st; + +uint8_t adf4350_slave_select; + +/***************************************************************************//** + * @brief Writes 4 bytes (32 bits) of data to ADF4350. + * + * @param data - Data value to write + * + * @return Always Returns 0 +*******************************************************************************/ +int32_t adf4350_write(uint32_t data) +{ + // Nominate pins using WiringPi numbers + + // LE pin 27 wPi 30 + // CLK pin 29 wPi 21 + // Data pin 31 wPi 22 + + uint8_t LE_4351_GPIO = 30; + uint8_t CLK_4351_GPIO = 21; + uint8_t DATA_4351_GPIO = 22; + + // Set all nominated pins to outputs + + pinMode(LE_4351_GPIO, OUTPUT); + pinMode(CLK_4351_GPIO, OUTPUT); + pinMode(DATA_4351_GPIO, OUTPUT); + + // Set idle conditions + + digitalWrite(LE_4351_GPIO, HIGH); + digitalWrite(CLK_4351_GPIO, LOW); + digitalWrite(DATA_4351_GPIO, LOW); + + //Select device LE low + + digitalWrite(LE_4351_GPIO, LOW); + + // printf(" ADF4351 Register (one of the five) Updated\n"); + + // Initialise loop + + uint16_t i; + + // Send all 32 bits + + for (i = 0; i <32; i++) + { + // Test left-most bit + + if (data & 0x80000000) + digitalWrite(DATA_4351_GPIO, HIGH); + else + digitalWrite(DATA_4351_GPIO, LOW); + + // Pulse clock + + digitalWrite(CLK_4351_GPIO, HIGH); + delay(1); + digitalWrite(CLK_4351_GPIO, LOW); + delay(1); + // shift data left so next bit will be leftmost + + data <<= 1; + } + + //Set ADF4351 LE high + + digitalWrite(LE_4351_GPIO, HIGH); + + return 0; +} + +/***************************************************************************//** + * @brief Updates the registers values. + * + * @param st - The selected structure. + * + * @return Returns 0 in case of success or negative error code. +*******************************************************************************/ +int32_t adf4350_sync_config(struct adf4350_state *st) +{ + int32_t ret, i, doublebuf = 0; + + for (i = ADF4350_REG5; i >= ADF4350_REG0; i--) + { + if ((st->regs_hw[i] != st->regs[i]) || + ((i == ADF4350_REG0) && doublebuf)) + { + switch (i) + { + case ADF4350_REG1: + case ADF4350_REG4: + doublebuf = 1; + break; + } + + st->val = (st->regs[i] | i); + ret = adf4350_write(st->val); + if (ret < 0) + return ret; + st->regs_hw[i] = st->regs[i]; + } + } + + return 0; +} + +/***************************************************************************//** + * @brief Increases the R counter value until the ADF4350_MAX_FREQ_PFD is + * greater than PFD frequency. + * + * @param st - The selected structure. + * @param r_cnt - Initial r_cnt value. + * + * @return Returns 0 in case of success or negative error code. +*******************************************************************************/ +int32_t adf4350_tune_r_cnt(struct adf4350_state *st, uint16_t r_cnt) +{ + struct adf4350_platform_data *pdata = st->pdata; + + do + { + r_cnt++; + st->fpfd = (st->clkin * (pdata->ref_doubler_en ? 2 : 1)) / + (r_cnt * (pdata->ref_div2_en ? 2 : 1)); + } while (st->fpfd > ADF4350_MAX_FREQ_PFD); + + return r_cnt; +} + +/***************************************************************************//** + * @brief Computes the greatest common divider of two numbers + * + * @return Returns the gcd. +*******************************************************************************/ +uint32_t gcd(uint32_t x, uint32_t y) +{ + int32_t tmp; + + tmp = y > x ? x : y; + + + while((x % tmp) || (y % tmp)) + { + tmp--; + } + + return tmp; +} + +/***************************************************************************//** + * @brief Sets the ADF4350 frequency. + * + * @param st - The selected structure. + * @param freq - The desired frequency value. + * + * @return calculatedFrequency - The actual frequency value that was set. +*******************************************************************************/ +int64_t adf4350_set_freq(struct adf4350_state *st, uint64_t freq) +{ + struct adf4350_platform_data *pdata = st->pdata; + uint64_t tmp; + uint32_t div_gcd, prescaler, chspc; + uint16_t mdiv, r_cnt = 0; + uint8_t band_sel_div; + int32_t ret; + + if ((freq > ADF4350_MAX_OUT_FREQ) || (freq < ADF4350_MIN_OUT_FREQ)) + return -1; + + if (freq > ADF4350_MAX_FREQ_45_PRESC) { + prescaler = ADF4350_REG1_PRESCALER; + mdiv = 75; + } + else + { + prescaler = 0; + mdiv = 23; + } + + st->r4_rf_div_sel = 0; + + while (freq < ADF4350_MIN_VCO_FREQ) + { + freq <<= 1; + st->r4_rf_div_sel++; + } + + /* + * Allow a predefined reference division factor + * if not set, compute our own + */ + if (pdata->ref_div_factor) + r_cnt = pdata->ref_div_factor - 1; + + chspc = st->chspc; + + do + { + do + { + do + { + r_cnt = adf4350_tune_r_cnt(st, r_cnt); + st->r1_mod = st->fpfd / chspc; + if (r_cnt > ADF4350_MAX_R_CNT) + { + /* try higher spacing values */ + chspc++; + r_cnt = 0; + } + } while ((st->r1_mod > ADF4350_MAX_MODULUS) && r_cnt); + } while (r_cnt == 0); + + + tmp = freq * (uint64_t)st->r1_mod + (st->fpfd > 1); + + tmp = (tmp / st->fpfd); /* Div round closest (n + d/2)/d */ + + st->r0_fract = tmp % st->r1_mod; + tmp = tmp / st->r1_mod; + + st->r0_int = tmp; + } while (mdiv > st->r0_int); + + band_sel_div = st->fpfd % ADF4350_MAX_BANDSEL_CLK > ADF4350_MAX_BANDSEL_CLK / 2 ? + st->fpfd / ADF4350_MAX_BANDSEL_CLK + 1 : + st->fpfd / ADF4350_MAX_BANDSEL_CLK; + + if (st->r0_fract && st->r1_mod) { + div_gcd = gcd(st->r1_mod, st->r0_fract); + st->r1_mod /= div_gcd; + st->r0_fract /= div_gcd; + } + else + { + st->r0_fract = 0; + st->r1_mod = 1; + } + + st->regs[ADF4350_REG0] = ADF4350_REG0_INT(st->r0_int) | + ADF4350_REG0_FRACT(st->r0_fract); + + st->regs[ADF4350_REG1] = ADF4350_REG1_PHASE(1) | + ADF4350_REG1_MOD(st->r1_mod) | + prescaler; + + st->regs[ADF4350_REG2] = + ADF4350_REG2_10BIT_R_CNT(r_cnt) | + ADF4350_REG2_DOUBLE_BUFF_EN | + (pdata->ref_doubler_en ? ADF4350_REG2_RMULT2_EN : 0) | + (pdata->ref_div2_en ? ADF4350_REG2_RDIV2_EN : 0) | + (pdata->r2_user_settings & (ADF4350_REG2_PD_POLARITY_POS | + ADF4350_REG2_LDP_6ns | ADF4350_REG2_LDF_INT_N | + ADF4350_REG2_CHARGE_PUMP_CURR_uA(5000) | + ADF4350_REG2_MUXOUT(0x7) | ADF4350_REG2_NOISE_MODE(0x9))); + + st->regs[ADF4350_REG3] = pdata->r3_user_settings & + (ADF4350_REG3_12BIT_CLKDIV(0xFFF) | + ADF4350_REG3_12BIT_CLKDIV_MODE(0x3) | + ADF4350_REG3_12BIT_CSR_EN); + + st->regs[ADF4350_REG4] = + ADF4350_REG4_FEEDBACK_FUND | + ADF4350_REG4_RF_DIV_SEL(st->r4_rf_div_sel) | + ADF4350_REG4_8BIT_BAND_SEL_CLKDIV(band_sel_div) | + ADF4350_REG4_RF_OUT_EN | + (pdata->r4_user_settings & + (ADF4350_REG4_OUTPUT_PWR(0x3) | + ADF4350_REG4_AUX_OUTPUT_PWR(0x3) | + ADF4350_REG4_AUX_OUTPUT_EN | + ADF4350_REG4_AUX_OUTPUT_FUND | + ADF4350_REG4_MUTE_TILL_LOCK_EN)); + + st->regs[ADF4350_REG5] = ADF4350_REG5_LD_PIN_MODE_DIGITAL | 0x00180000; + + ret = adf4350_sync_config(st); + if(ret < 0) + { + return ret; + } + + tmp = (uint64_t)((st->r0_int * st->r1_mod) + st->r0_fract) * (uint64_t)st->fpfd; + tmp = tmp / ((uint64_t)st->r1_mod * ((uint64_t)1 << st->r4_rf_div_sel)); + + return tmp; +} + +/***************************************************************************//** + * @brief Initializes the ADF4350. + * + * @param spiBaseAddr - SPI peripheral AXI base address. + * @param ssNo - Slave select line on which the slave is connected. + * + * @return Returns 0 in case of success or negative error code. +*******************************************************************************/ +int32_t adf4350_setup(uint32_t spi_device_id, uint8_t slave_select, + adf4350_init_param init_param) +{ + struct adf4350_state *st = &adf4350_st; + + adf4350_slave_select = slave_select; + + SPISetupMode(spi_device_id,500000,0);//To CHeck last parameters : fixeme ! + st->pdata = (struct adf4350_platform_data *)malloc(sizeof(*st->pdata)); + if (!st->pdata) + return -1; + + st->pdata->clkin = init_param.clkin; + + st->pdata->channel_spacing = init_param.channel_spacing; + + st->pdata->power_up_frequency = init_param.power_up_frequency; + st->pdata->ref_div_factor = init_param.reference_div_factor; + st->pdata->ref_doubler_en = init_param.reference_doubler_enable; + st->pdata->ref_div2_en = init_param.reference_div2_enable; + + /* r2_user_settings */ + + st->pdata->r2_user_settings = init_param.phase_detector_polarity_positive_enable ? + ADF4350_REG2_PD_POLARITY_POS : 0; + st->pdata->r2_user_settings |= init_param.lock_detect_precision_6ns_enable ? + ADF4350_REG2_LDP_6ns : 0; + st->pdata->r2_user_settings |= init_param.lock_detect_function_integer_n_enable ? + ADF4350_REG2_LDF_INT_N : 0; + st->pdata->r2_user_settings |= ADF4350_REG2_CHARGE_PUMP_CURR_uA(init_param.charge_pump_current); + st->pdata->r2_user_settings |= ADF4350_REG2_MUXOUT(init_param.muxout_select); + st->pdata->r2_user_settings |= init_param.low_spur_mode_enable ? ADF4350_REG2_NOISE_MODE(0x3) : 0; + + /* r3_user_settings */ + + st->pdata->r3_user_settings = init_param.cycle_slip_reduction_enable ? + ADF4350_REG3_12BIT_CSR_EN : 0; + st->pdata->r3_user_settings |= init_param.charge_cancellation_enable ? + ADF4351_REG3_CHARGE_CANCELLATION_EN : 0; + st->pdata->r3_user_settings |= init_param.anti_backlash_3ns_enable ? + ADF4351_REG3_ANTI_BACKLASH_3ns_EN : 0; + st->pdata->r3_user_settings |= init_param.band_select_clock_mode_high_enable ? + ADF4351_REG3_BAND_SEL_CLOCK_MODE_HIGH : 0; + st->pdata->r3_user_settings |= ADF4350_REG3_12BIT_CLKDIV(init_param.clk_divider_12bit); + st->pdata->r3_user_settings |= ADF4350_REG3_12BIT_CLKDIV_MODE(init_param.clk_divider_mode); + + /* r4_user_settings */ + + st->pdata->r4_user_settings = init_param.aux_output_enable ? + ADF4350_REG4_AUX_OUTPUT_EN : 0; + st->pdata->r4_user_settings |= init_param.aux_output_fundamental_enable ? + ADF4350_REG4_AUX_OUTPUT_FUND : 0; + st->pdata->r4_user_settings |= init_param.mute_till_lock_enable ? + ADF4350_REG4_MUTE_TILL_LOCK_EN : 0; + st->pdata->r4_user_settings |= ADF4350_REG4_OUTPUT_PWR(init_param.output_power); + st->pdata->r4_user_settings |= ADF4350_REG4_AUX_OUTPUT_PWR(init_param.aux_output_power); + + adf4350_out_altvoltage0_refin_frequency(st->pdata->clkin); + adf4350_out_altvoltage0_frequency_resolution(st->pdata->channel_spacing); + adf4350_out_altvoltage0_frequency(st->pdata->power_up_frequency); + + // printf("ADF4350 successfully initialized.\n"); + + /*int i; + for(i=0;i<6;i++) + printf("RegHw%d %x\n",i,st->regs[i]); + printf("Reg2 %x\n",st->pdata->r2_user_settings); + printf("Reg3 %x\n",st->pdata->r3_user_settings); + printf("Reg4 %x\n",st->pdata->r4_user_settings);*/ + + return 0; +} + +/***************************************************************************//** + * @brief Stores PLL 0 frequency in Hz. + * + * @param Hz - The selected frequency. + * + * @return Returns the selected frequency. +*******************************************************************************/ +int64_t adf4350_out_altvoltage0_frequency(int64_t Hz) +{ + return adf4350_set_freq(&adf4350_st, Hz); +} + +/***************************************************************************//** + * @brief Stores PLL 0 frequency resolution/channel spacing in Hz. + * + * @param Hz - The selected frequency. + * + * @return Returns the selected frequency. +*******************************************************************************/ +int32_t adf4350_out_altvoltage0_frequency_resolution(int32_t Hz) +{ + if(Hz != INT32_MAX) + { + adf4350_st.chspc = Hz; + } + + return adf4350_st.chspc; +} + +/***************************************************************************//** + * @brief Sets PLL 0 REFin frequency in Hz. + * + * @param Hz - The selected frequency. + * + * @return Returns the selected frequency. +*******************************************************************************/ +int64_t adf4350_out_altvoltage0_refin_frequency(int64_t Hz) +{ + if(Hz != INT32_MAX) + { + adf4350_st.clkin = Hz; + } + + return adf4350_st.clkin; +} + +/***************************************************************************//** + * @brief Powers down the PLL. + * + * @param pwd - Power option. + * Example: 0 - Power up the PLL. + * 1 - Power down the PLL. + * + * @return Returns the PLL's power status. +*******************************************************************************/ +int32_t adf4350_out_altvoltage0_powerdown(int32_t pwd) +{ + struct adf4350_state *st = &adf4350_st; + + if(pwd == 1) + { + st->regs[ADF4350_REG2] |= ADF4350_REG2_POWER_DOWN_EN; + adf4350_sync_config(st); + } + if(pwd == 0) + { + st->regs[ADF4350_REG2] &= ~ADF4350_REG2_POWER_DOWN_EN; + adf4350_sync_config(st); + } + + return (st->regs[ADF4350_REG2] & ADF4350_REG2_POWER_DOWN_EN); +} diff --git a/src/adf4351/adf4351.h b/src/adf4351/adf4351.h new file mode 100644 index 0000000..1370709 --- /dev/null +++ b/src/adf4351/adf4351.h @@ -0,0 +1,198 @@ +/***************************************************************************//** + * @file adf4350.h + * @brief Header file of ADF4350 Driver. + * @author DBogdan (dragos.bogdan@analog.com) +******************************************************************************** + * Copyright 2012-2015(c) Analog Devices, Inc. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * - Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * - The use of this software may or may not infringe the patent rights + * of one or more patent holders. This license does not release you + * from the requirement that you obtain separate licenses from these + * patent holders to use this software. + * - Use of the software either in source or binary form, must be run + * on or directly connected to an Analog Devices Inc. component. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * +*******************************************************************************/ +#ifndef __ADF4350_H__ +#define __ADF4350_H__ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ +#include + +/******************************************************************************/ +/********************** Macros and Constants Definitions **********************/ +/******************************************************************************/ + +/* Channels */ +#define ADF4350_RX_CHANNEL 0 +#define ADF4350_TX_CHANNEL 1 + +/* Registers */ +#define ADF4350_REG0 0 +#define ADF4350_REG1 1 +#define ADF4350_REG2 2 +#define ADF4350_REG3 3 +#define ADF4350_REG4 4 +#define ADF4350_REG5 5 + +/* REG0 Bit Definitions */ +#define ADF4350_REG0_FRACT(x) (((x) & 0xFFF) << 3) +#define ADF4350_REG0_INT(x) (((x) & 0xFFFF) << 15) + +/* REG1 Bit Definitions */ +#define ADF4350_REG1_MOD(x) (((x) & 0xFFF) << 3) +#define ADF4350_REG1_PHASE(x) (((x) & 0xFFF) << 15) +#define ADF4350_REG1_PRESCALER (1 << 27) + +/* REG2 Bit Definitions */ +#define ADF4350_REG2_COUNTER_RESET_EN (1 << 3) +#define ADF4350_REG2_CP_THREESTATE_EN (1 << 4) +#define ADF4350_REG2_POWER_DOWN_EN (1 << 5) +#define ADF4350_REG2_PD_POLARITY_POS (1 << 6) +#define ADF4350_REG2_LDP_6ns (1 << 7) +#define ADF4350_REG2_LDP_10ns (0 << 7) +#define ADF4350_REG2_LDF_FRACT_N (0 << 8) +#define ADF4350_REG2_LDF_INT_N (1 << 8) +#define ADF4350_REG2_CHARGE_PUMP_CURR_uA(x) (((((x)-312) / 312) & 0xF) << 9) +#define ADF4350_REG2_DOUBLE_BUFF_EN (1 << 13) +#define ADF4350_REG2_10BIT_R_CNT(x) ((x) << 14) +#define ADF4350_REG2_RDIV2_EN (1 << 24) +#define ADF4350_REG2_RMULT2_EN (1 << 25) +#define ADF4350_REG2_MUXOUT(x) ((x) << 26) +#define ADF4350_REG2_NOISE_MODE(x) ((x) << 29) + +/* REG3 Bit Definitions */ +#define ADF4350_REG3_12BIT_CLKDIV(x) ((x) << 3) +#define ADF4350_REG3_12BIT_CLKDIV_MODE(x) ((x) << 16) +#define ADF4350_REG3_12BIT_CSR_EN (1 << 18) +#define ADF4351_REG3_CHARGE_CANCELLATION_EN (1 << 21) +#define ADF4351_REG3_ANTI_BACKLASH_3ns_EN (1 << 22) +#define ADF4351_REG3_BAND_SEL_CLOCK_MODE_HIGH (1 << 23) + +/* REG4 Bit Definitions */ +#define ADF4350_REG4_OUTPUT_PWR(x) ((x) << 3) +#define ADF4350_REG4_RF_OUT_EN (1 << 5) +#define ADF4350_REG4_AUX_OUTPUT_PWR(x) ((x) << 6) +#define ADF4350_REG4_AUX_OUTPUT_EN (1 << 8) +#define ADF4350_REG4_AUX_OUTPUT_FUND (1 << 9) +#define ADF4350_REG4_AUX_OUTPUT_DIV (0 << 9) +#define ADF4350_REG4_MUTE_TILL_LOCK_EN (1 << 10) +#define ADF4350_REG4_VCO_PWRDOWN_EN (1 << 11) +#define ADF4350_REG4_8BIT_BAND_SEL_CLKDIV(x) ((x) << 12) +#define ADF4350_REG4_RF_DIV_SEL(x) ((x) << 20) +#define ADF4350_REG4_FEEDBACK_DIVIDED (0 << 23) +#define ADF4350_REG4_FEEDBACK_FUND (1 << 23) + +/* REG5 Bit Definitions */ +#define ADF4350_REG5_LD_PIN_MODE_LOW (0 << 22) +#define ADF4350_REG5_LD_PIN_MODE_DIGITAL (1 << 22) +#define ADF4350_REG5_LD_PIN_MODE_HIGH (3 << 22) + +/* Specifications */ +#define ADF4350_MAX_OUT_FREQ 4400000000ULL /* Hz */ +#define ADF4350_MIN_OUT_FREQ 34375000 /* Hz */ +#define ADF4350_MIN_VCO_FREQ 2200000000ULL /* Hz */ +#define ADF4350_MAX_FREQ_45_PRESC 3000000000ULL /* Hz */ +#define ADF4350_MAX_FREQ_PFD 32000000 /* Hz */ +#define ADF4350_MAX_BANDSEL_CLK 125000 /* Hz */ +#define ADF4350_MAX_FREQ_REFIN 250000000 /* Hz */ +#define ADF4350_MAX_MODULUS 4095 +#define ADF4350_MAX_R_CNT 1023 + +/******************************************************************************/ +/************************ Types Definitions ***********************************/ +/******************************************************************************/ +struct adf4350_platform_data +{ + uint32_t clkin; + uint32_t channel_spacing; + uint64_t power_up_frequency; + + uint16_t ref_div_factor; /* 10-bit R counter */ + uint8_t ref_doubler_en; + uint8_t ref_div2_en; + + uint32_t r2_user_settings; + uint32_t r3_user_settings; + uint32_t r4_user_settings; + int32_t gpio_lock_detect; +}; + +typedef struct +{ + uint32_t clkin; + uint32_t channel_spacing; + uint32_t power_up_frequency; + uint32_t reference_div_factor; + uint8_t reference_doubler_enable; + uint8_t reference_div2_enable; + + /* r2_user_settings */ + uint8_t phase_detector_polarity_positive_enable; + uint8_t lock_detect_precision_6ns_enable; + uint8_t lock_detect_function_integer_n_enable; + uint32_t charge_pump_current; + uint32_t muxout_select; + uint8_t low_spur_mode_enable; + + /* r3_user_settings */ + uint8_t cycle_slip_reduction_enable; + uint8_t charge_cancellation_enable; + uint8_t anti_backlash_3ns_enable; + uint8_t band_select_clock_mode_high_enable; + uint32_t clk_divider_12bit; + uint32_t clk_divider_mode; + + /* r4_user_settings */ + uint8_t aux_output_enable; + uint8_t aux_output_fundamental_enable; + uint8_t mute_till_lock_enable; + uint32_t output_power; + uint32_t aux_output_power; +}adf4350_init_param; + +/******************************************************************************/ +/************************ Functions Declarations ******************************/ +/******************************************************************************/ +/*! Initializes the ADF4350. */ +int32_t adf4350_setup(uint32_t spi_device_id, uint8_t slave_select, + adf4350_init_param init_param); +/*! Writes 4 bytes of data to ADF4350. */ +int32_t adf4350_write(uint32_t data); +/*! Stores PLL 0 frequency in Hz. */ +int64_t adf4350_out_altvoltage0_frequency(int64_t Hz); +/*! Stores PLL 0 frequency resolution/channel spacing in Hz. */ +int32_t adf4350_out_altvoltage0_frequency_resolution(int32_t Hz); +/*! Sets PLL 0 REFin frequency in Hz. */ +int64_t adf4350_out_altvoltage0_refin_frequency(int64_t Hz); +/*! Powers down the PLL. */ +int32_t adf4350_out_altvoltage0_powerdown(int32_t pwd); + +#endif // __ADF4350_H__ + diff --git a/src/adf4351/ctladf4351.c b/src/adf4351/ctladf4351.c new file mode 100644 index 0000000..f98400d --- /dev/null +++ b/src/adf4351/ctladf4351.c @@ -0,0 +1,92 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "adf4351.h" + +adf4350_init_param MyAdf= +{.clkin=25000000, +.channel_spacing=5000, +.power_up_frequency=437000000, +.reference_div_factor=0, +.reference_doubler_enable=0, +.reference_div2_enable=0, + + // r2_user_settings +.phase_detector_polarity_positive_enable=1, +.lock_detect_precision_6ns_enable=0, +.lock_detect_function_integer_n_enable=0, +.charge_pump_current=7, // FixMe +.muxout_select=0, +.low_spur_mode_enable=1, + + // r3_user_settings +.cycle_slip_reduction_enable=1, +.charge_cancellation_enable=0, +.anti_backlash_3ns_enable=0, +.band_select_clock_mode_high_enable=1, +.clk_divider_12bit=0, +.clk_divider_mode=0, + + // r4_user_settings +.aux_output_enable=1, +.aux_output_fundamental_enable=1, +.mute_till_lock_enable=0, +.output_power=0,//-4dbm +.aux_output_power=0 + +}; +uint32_t registers[6] = {0x4580A8, 0x80080C9, 0x4E42, 0x4B3, 0xBC803C, 0x580005}; +//REG 0 +//REG1 1000000000001000000011001 001 +//REG2 100111001000 010 +//REG3 10010110 011 +//REG4 101111001000000000111 100 + + +/***************************************************************************//** + * @brief Powers off or sets the Synth frequency. + * + * @param "off" or freq in MHz (float). + * + * @return 0 or 1 if freq out of bounds +*******************************************************************************/ + +int main(int argc, char *argv[]) +{ + if (wiringPiSetup() == -1); + + if (strcmp(argv[1], "off") == 0) + { + // Turn VCO Off and return + + adf4350_out_altvoltage0_powerdown(1); + + return 0; + } + else if ( atof(argv[1])>=35 && atof(argv[1])<=4400 ) + { + // Valid freq, so set it + uint32_t adf4350_requested_frequency = 1000000 * atof(argv[1]); + + adf4350_setup(0,0,MyAdf); + adf4350_out_altvoltage0_frequency(adf4350_requested_frequency); + + return 0; + } + else + { + // Requested freq out of limits so print error and return 1 + printf("ERROR: Requested Frequency out of limits"); + + return 1; + + } +} diff --git a/src/gui/rpidatvtouch.c b/src/gui/rpidatvtouch.c index 6dc735f..9d89701 100644 --- a/src/gui/rpidatvtouch.c +++ b/src/gui/rpidatvtouch.c @@ -40,12 +40,12 @@ int wscreen, hscreen; float scaleXvalue, scaleYvalue; // Coeff ratio from Screen/TouchArea -typedef struct { +typedef struct { int r,g,b; } color_t; -typedef struct { +typedef struct { char Text[255]; color_t Color; } status_t; @@ -53,40 +53,58 @@ typedef struct { #define MAX_STATUS 10 typedef struct { int x,y,w,h; - + status_t Status[MAX_STATUS]; int IndexStatus; int NoStatus; int LastEventTime; } button_t; -#define MAX_BUTTON 20 +#define MAX_BUTTON 25 int IndexButtonInArray=0; button_t ButtonArray[MAX_BUTTON]; int IsDisplayOn=0; #define TIME_ANTI_BOUNCE 500 -//GLOBAL PARAM + +//GLOBAL PARAMETERS + int fec; int SR; char ModeInput[255]; -int TabSR[5]= {125,250,333,500,1000}; +char freqtxt[255]; + +// Values to be stored in and read from rpidatvconfig.txt: + +int TabSR[5]= {250,333,500,1000,2000}; int TabFec[5]={1,2,3,5,7}; char TabModeInput[5][255]={"CAMMPEG-2","CAMH264","PATERNAUDIO","FILETS","CARRIER"}; -int Inversed=0;//Display is inversed (Waveshare) +char TabFreq[5][255]={"71","146.5","437","1249","1255"}; + +int Inversed=0;//Display is inversed (Waveshare=1) + pthread_t thfft,thbutton; -GetConfigParam(char *PathConfigFile,char *Param, char *Value) +/***************************************************************************//** + * @brief Looks up the value of Param in PathConfigFile and sets value + * Used to look up the configuration from rpidatvconfig.txt + * + * @param PatchConfigFile (str) the name of the configuration text file + * @param Param the string labeling the parameter + * @param Value the looked-up value of the parameter + * + * @return void +*******************************************************************************/ + +void GetConfigParam(char *PathConfigFile,char *Param, char *Value) { char * line = NULL; - size_t len = 0; + size_t len = 0; int read; - //printf("Read %s\n",PathConfigFile); - FILE *fp=fopen(PathConfigFile,"r"); + FILE *fp=fopen(PathConfigFile,"r"); if(fp!=0) { while ((read = getline(&line, &len, fp)) != -1) { - //printf("%s", line); if(strncmp (line,Param,strlen(Param)) == 0) { strcpy(Value,line+strlen(Param)+1); @@ -100,10 +118,10 @@ GetConfigParam(char *PathConfigFile,char *Param, char *Value) else printf("Config file not found \n"); fclose(fp); - + } -SetConfigParam(char *PathConfigFile,char *Param,char *Value) +void SetConfigParam(char *PathConfigFile,char *Param,char *Value) { char * line = NULL; size_t len = 0; @@ -113,7 +131,7 @@ SetConfigParam(char *PathConfigFile,char *Param,char *Value) strcat(BackupConfigName,".bak"); //printf("Read %s\n",PathConfigFile); FILE *fp=fopen(PathConfigFile,"r"); - + FILE *fw=fopen(BackupConfigName,"w+"); if(fp!=0) { @@ -155,11 +173,11 @@ int IsButtonPushed(int NbButton,int x,int y) } else { - scaledX = wscreen-y/scaleXvalue; //FOR INVERSED TOUCSCREEN (AIW) - scaledY = hscreen-x/scaleYvalue; + scaledX = wscreen-y/scaleXvalue; //FOR INVERSED TOUCSCREEN (AIW) + scaledY = hscreen-x/scaleYvalue; } //printf("x=%d y=%d scaledx %d scaledy %d\n",x,y,scaledX,scaledY); - int margin=20; + int margin=10; // was 20 if((scaledX<=(ButtonArray[NbButton].x+ButtonArray[NbButton].w-margin))&&(scaledX>=ButtonArray[NbButton].x+margin) && (scaledY<=(ButtonArray[NbButton].y+ButtonArray[NbButton].h-margin))&&(scaledY>=ButtonArray[NbButton].y+margin) /*&&(mymillis()-ButtonArray[NbButton].LastEventTime>TIME_ANTI_BOUNCE)*/) @@ -169,7 +187,7 @@ int IsButtonPushed(int NbButton,int x,int y) } else return 0; - + } int AddButton(int x,int y,int w,int h) @@ -185,27 +203,25 @@ int AddButton(int x,int y,int w,int h) return IndexButtonInArray++; } -AddButtonStatus(int ButtonIndex,char *Text,color_t *Color) +int AddButtonStatus(int ButtonIndex,char *Text,color_t *Color) { button_t *Button=&(ButtonArray[ButtonIndex]); strcpy(Button->Status[Button->IndexStatus].Text,Text); Button->Status[Button->IndexStatus].Color=*Color; - return Button->IndexStatus++; - + return Button->IndexStatus++; } -DrawButton(int ButtonIndex) +void DrawButton(int ButtonIndex) { button_t *Button=&(ButtonArray[ButtonIndex]); - + Fill(Button->Status[Button->NoStatus].Color.r, Button->Status[Button->NoStatus].Color.g, Button->Status[Button->NoStatus].Color.b, 1); Roundrect(Button->x,Button->y,Button->w,Button->h, Button->w/10, Button->w/10); Fill(255, 255, 255, 1); // White text TextMid(Button->x+Button->w/2, Button->y+Button->h/2, Button->Status[Button->NoStatus].Text, SerifTypeface, Button->w/strlen(Button->Status[Button->NoStatus].Text)/*25*/); - } -SetButtonStatus(int ButtonIndex,int Status) +void SetButtonStatus(int ButtonIndex,int Status) { button_t *Button=&(ButtonArray[ButtonIndex]); Button->NoStatus=Status; @@ -215,15 +231,15 @@ int GetButtonStatus(int ButtonIndex) { button_t *Button=&(ButtonArray[ButtonIndex]); return Button->NoStatus; - + } -GetNextPicture(char *PictureName) +void GetNextPicture(char *PictureName) { - + DIR *d; struct dirent *dir; - + d = opendir(ImageFolder); if (d) { @@ -235,18 +251,15 @@ GetNextPicture(char *PictureName) if( len > 4 && strcmp(dir->d_name + len - 4, ".jpg") == 0) { printf("%s\n", dir->d_name); - + strncpy(PictureName,dir->d_name,strlen(dir->d_name)-4); break; } - - } + } } - + closedir(d); } - - } int openTouchScreen(int NoDevice) @@ -285,7 +298,7 @@ Supported events: int getTouchScreenDetails(int *screenXmin,int *screenXmax,int *screenYmin,int *screenYmax) { - unsigned short id[4]; + //unsigned short id[4]; unsigned long bit[EV_MAX][NBITS(KEY_MAX)]; char name[256] = "Unknown"; int abs[6] = {0}; @@ -325,9 +338,9 @@ int getTouchScreenDetails(int *screenXmin,int *screenXmax,int *screenYmin,int *s } } - } + } } - + return IsAtouchDevice; } @@ -339,7 +352,7 @@ int getTouchSample(int *rawX, int *rawY, int *rawPressure) size_t rb; /* the events (up to 64 at once) */ struct input_event ev[64]; - static int Last_event=0; + //static int Last_event=0; //not used? rb=read(fd,ev,sizeof(struct input_event)*64); *rawX=-1;*rawY=-1; int StartTouch=0; @@ -388,13 +401,12 @@ int getTouchSample(int *rawX, int *rawY, int *rawPressure) void UpdateWindow() { int i; - for(i=0;i/dev/null 2>/dev/null" if((strcmp(ModeInput,TabModeInput[0])==0)||(strcmp(ModeInput,TabModeInput[1])==0)) //CAM { printf("DISPLAY OFF \n"); - IsDisplayOn=0; + IsDisplayOn=0; finish(); - + system("v4l2-ctl --overlay=1 >/dev/null 2>/dev/null"); } - + system(PATH_SCRIPT_A); - + } -TransmitStop() +void TransmitStop() { printf("Transmit Stop\n"); + system("sudo /home/pi/rpidatv/bin/adf4351 off"); // Turn the VCO off system("sudo killall rpidatv >/dev/null 2>/dev/null"); system("sudo killall ffmpeg >/dev/null 2>/dev/null"); system("sudo killall tcanim >/dev/null 2>/dev/null"); @@ -483,86 +504,81 @@ void coordpoint(VGfloat x, VGfloat y, VGfloat size, VGfloat pcolor[4]) { #define FFT_SIZE 256 int FinishedButton=0; + void *DisplayFFT(void * arg) { FILE * pFileIQ = NULL; int fft_size=FFT_SIZE; fftwf_complex *fftin; - fftin = (fftwf_complex *)fftwf_malloc(sizeof(fftwf_complex) * fft_size); - fftout = (fftwf_complex *)fftwf_malloc(sizeof(fftwf_complex) * fft_size); + fftin = (fftwf_complex *)fftwf_malloc(sizeof(fftwf_complex) * fft_size); + fftout = (fftwf_complex *)fftwf_malloc(sizeof(fftwf_complex) * fft_size); fftwf_plan plan ; plan = fftwf_plan_dft_1d(fft_size, fftin, fftout, FFTW_FORWARD, FFTW_ESTIMATE ); - system("mkfifo fifo.iq"); - printf("Entering FFT thread\n"); + printf("Entering FFT thread\n"); pFileIQ = fopen("fifo.iq", "r"); - - + while(FinishedButton==0) - { - int Nbread; - int log2_N=11; //FFT 1024 - int ret; - + { + int Nbread; // value set later but not used + //int log2_N=11; //FFT 1024 not used? + //int ret; // not used? + Nbread=fread( fftin,sizeof(fftwf_complex),FFT_SIZE,pFileIQ); fftwf_execute( plan ); - + //printf("NbRead %d %d\n",Nbread,sizeof(struct GPU_FFT_COMPLEX)); - + fseek(pFileIQ,(1200000-FFT_SIZE)*sizeof(fftwf_complex),SEEK_CUR); } fftwf_free(fftin); fftwf_free(fftout); - } - void *WaitButtonEvent(void * arg) { -int rawX, rawY, rawPressure,i; + int rawX, rawY, rawPressure; - - while(getTouchSample(&rawX, &rawY, &rawPressure)==0); FinishedButton=1; } -ProcessLeandvb() +void ProcessLeandvb() { - #define PATH_SCRIPT_LEAN "sudo /home/pi/rpidatv/scripts/leandvbgui.sh 2>&1" + #define PATH_SCRIPT_LEAN "sudo /home/pi/rpidatv/scripts/leandvbgui.sh 2>&1" char *line=NULL; size_t len = 0; ssize_t read; - int rawX, rawY, rawPressure; + // int rawX, rawY, rawPressure; // not used FILE *fp; - VGfloat px[1000]; - VGfloat py[1000]; + // VGfloat px[1000]; // Variable not used + // VGfloat py[1000]; // Variable not used VGfloat shapecolor[4]; RGBA(255, 255, 128,1, shapecolor); printf("Entering LeandProcess\n"); - FinishedButton=0; + FinishedButton=0; // Thread FFT pthread_create (&thfft,NULL, &DisplayFFT,NULL); - + //END ThreadFFT - // Thread FFT + +// Thread FFT pthread_create (&thbutton,NULL, &WaitButtonEvent,NULL); - -//END ThreadFFT +//END ThreadFFT fp=popen(PATH_SCRIPT_LEAN, "r"); if(fp==NULL) printf("Process error\n"); while (((read = getline(&line, &len, fp)) != -1)&&(FinishedButton==0)) { - + char strTag[20]; int NbData; static int Decim=0; @@ -574,10 +590,11 @@ ProcessLeandvb() static float FREQ=0; if((strcmp(strTag,"SYMBOLS")==0)) { - + token = strtok(line," "); token = strtok(NULL," "); sscanf(token,"%d",&NbData); + if(Decim%25==0) { //Start(wscreen,hscreen); @@ -590,7 +607,7 @@ ProcessLeandvb() { strcpy(sLock,"Lock"); Fill(0,255,0, 1); - + } else { @@ -599,7 +616,7 @@ ProcessLeandvb() } Roundrect(200,0,100,50, 10, 10); Fill(255, 255, 255, 1); // White text - Text(200, 20, sLock, SerifTypeface, 25); + Text(200, 20, sLock, SerifTypeface, 25); //Signal Strength char sSignalStrength[100]; @@ -617,30 +634,28 @@ ProcessLeandvb() Roundrect(500,0,(MER*8),50, 10, 10); Fill(255, 255, 255, 1); // White text Text(500,20, sMER, SerifTypeface, 25); - - - } + if(Decim%25==0) { static VGfloat PowerFFTx[FFT_SIZE]; static VGfloat PowerFFTy[FFT_SIZE]; StrokeWidth(2); - + Stroke(150, 150, 200, 0.8); int i; if(fftout!=NULL) { for(i=0;i=0)&&(i<=4)) //SR + if((i>=0)&&(i<=4)) //Frequency + { + SelectFreq(i); + } + if((i>=5)&&(i<=9)) //SR { SelectSR(i); } - if((i>=5)&&(i<=9)) //FEC + if((i>=10)&&(i<=14)) //FEC { SelectFec(i); } - if((i>=10)&&(i<=14)) //Source + if((i>=15)&&(i<=19)) //Source { SelectSource(i,1); } - if((i>=15)&&(i<=16)) //Source + if((i>=20)&&(i<=21)) //PTT { - + printf("Status %d\n",GetButtonStatus(i)); - if((i==15)&&(GetButtonStatus(i)==0)) + if((i==20)&&(GetButtonStatus(i)==0)) { - - - usleep(500000); SelectPTT(i,1); UpdateWindow(); TransmitStart(); - break; + break; } - if((i==15)&&(GetButtonStatus(i)==1)) + if((i==20)&&(GetButtonStatus(i)==1)) { - - TransmitStop(); usleep(500000); SelectPTT(i,0); - UpdateWindow(); + UpdateWindow(); break; } - if(i==16) + if(i==21) { printf("DISPLAY OFF \n"); //finish(); BackgroundRGB(0,0,0,255); ReceiveStart(); BackgroundRGB(255,255,255,255); - IsDisplayOn=1; - - SelectPTT(15,0); - SelectPTT(16,0); + IsDisplayOn=1; + + SelectPTT(20,0); + SelectPTT(21,0); UpdateWindow(); IsDisplayOn=1; //usleep(500000); @@ -853,29 +867,29 @@ int rawX, rawY, rawPressure,i; if(IsDisplayOn==1) { UpdateWindow(); - // DrawButton(i); + // DrawButton(i) // End(); } /*if((i==0)&&(GetButtonStatus(i)==0)) - { + { printf("DISPLAY OFF \n"); finish(); IsDisplayOn=0; } if((i==0)&&(GetButtonStatus(i)==1)) - { + { printf("DISPLAY ON \n"); init(&wscreen, &hscreen); Start(wscreen,hscreen); - IsDisplayOn=1; + IsDisplayOn=1; UpdateWindow(); }*/ //FixMe : Add a Antibounce } } //circleCursor(scaledX,h-scaledY); - + // key = getchar(); // if (key == endchar || key == '\n') { @@ -888,7 +902,10 @@ static void terminate(int dummy) { printf("Terminate\n"); - + char Commnd[255]; + sprintf(Commnd,"stty echo"); + system(Commnd); + /*restoreterm(); finish();*/ exit(1); @@ -897,16 +914,20 @@ terminate(int dummy) // main initializes the system and shows the picture. // Exit and clean up when you hit [RETURN]. int main(int argc, char **argv) { - int n; - char *progname = argv[0]; + // int n; // not used? + // char *progname = argv[0]; // not used? int NoDeviceEvent=0; saveterm(); init(&wscreen, &hscreen); rawterm(); int screenXmax, screenXmin; int screenYmax, screenYmin; - int ReceiveDirect=0; + int ReceiveDirect=0; int i; + char Param[255]; + char Value[255]; + +// Catch sigaction and call terminate for (i = 0; i < 16; i++) { struct sigaction sa; @@ -914,8 +935,18 @@ int main(int argc, char **argv) { sa.sa_handler = terminate; sigaction(i, &sa, NULL); } + +// Determine if using waveshare screen +// Either by first argument or from rpidatvconfig.txt if(argc>1) Inversed=atoi(argv[1]); + strcpy(Param,"display"); + + GetConfigParam(PATH_CONFIG,Param,Value); + if(strcmp(Value,"Waveshare")==0) + Inversed=1; + +// Determine if ReceiveDirect 2nd argument if(argc>2) ReceiveDirect=atoi(argv[2]); @@ -925,6 +956,7 @@ int main(int argc, char **argv) { ProcessLeandvb(); // For FrMenu and no } +// Check for presence of touchscreen for(NoDeviceEvent=0;NoDeviceEvent<5;NoDeviceEvent++) { if (openTouchScreen(NoDeviceEvent) == 1) @@ -937,108 +969,145 @@ int main(int argc, char **argv) { perror("No Touchscreen found"); exit(1); } + +// Calculate screen parameters scaleXvalue = ((float)screenXmax-screenXmin) / wscreen; //printf ("X Scale Factor = %f\n", scaleXvalue); scaleYvalue = ((float)screenYmax-screenYmin) / hscreen; //printf ("Y Scale Factor = %f\n", scaleYvalue); +// Define button grid + int wbuttonsize=wscreen/5; + int hbuttonsize=hscreen/6; - - int wbuttonsize=wscreen/5; - int hbuttonsize=hscreen/5; - +// Frequency int button=AddButton(0*wbuttonsize+20,0+hbuttonsize*0+20,wbuttonsize*0.9,hbuttonsize*0.9); color_t Col; Col.r=0;Col.g=0;Col.b=128; - AddButtonStatus(button,"SR125",&Col); + AddButtonStatus(button," 71 MHz ",&Col); Col.r=0;Col.g=128;Col.b=0; - AddButtonStatus(button,"SR125",&Col); + AddButtonStatus(button," 71 MHz ",&Col); button=AddButton(1*wbuttonsize+20,hbuttonsize*0+20,wbuttonsize*0.9,hbuttonsize*0.9); Col.r=0;Col.g=0;Col.b=128; - AddButtonStatus(button,"SR250",&Col); + AddButtonStatus(button,"146.5 MHz",&Col); Col.r=0;Col.g=128;Col.b=0; - AddButtonStatus(button,"SR250",&Col); + AddButtonStatus(button,"146.5 MHz",&Col); button=AddButton(2*wbuttonsize+20,hbuttonsize*0+20,wbuttonsize*0.9,hbuttonsize*0.9); Col.r=0;Col.g=0;Col.b=128; - AddButtonStatus(button,"SR333",&Col); + AddButtonStatus(button,"437 MHz ",&Col); Col.r=0;Col.g=128;Col.b=0; - AddButtonStatus(button,"SR333",&Col); + AddButtonStatus(button,"437 MHz ",&Col); button=AddButton(3*wbuttonsize+20,hbuttonsize*0+20,wbuttonsize*0.9,hbuttonsize*0.9); Col.r=0;Col.g=0;Col.b=128; - AddButtonStatus(button,"SR500",&Col); + AddButtonStatus(button,"1249 MHz",&Col); Col.r=0;Col.g=128;Col.b=0; - AddButtonStatus(button,"SR500",&Col); + AddButtonStatus(button,"1249 MHz",&Col); button=AddButton(4*wbuttonsize+20,hbuttonsize*0+20,wbuttonsize*0.9,hbuttonsize*0.9); Col.r=0;Col.g=0;Col.b=128; - AddButtonStatus(button,"SR1000",&Col); + AddButtonStatus(button,"1255 MHz",&Col); Col.r=0;Col.g=128;Col.b=0; - AddButtonStatus(button,"SR1000",&Col); -// FEC - button=AddButton(0*wbuttonsize+20,hbuttonsize*1+20,wbuttonsize*0.9,hbuttonsize*0.9); + AddButtonStatus(button,"1255 MHz",&Col); + +// Symbol Rate + + button=AddButton(0*wbuttonsize+20,0+hbuttonsize*1+20,wbuttonsize*0.9,hbuttonsize*0.9); Col.r=0;Col.g=0;Col.b=128; - AddButtonStatus(button,"FEC 1/2",&Col); + AddButtonStatus(button,"SR 250",&Col); Col.r=0;Col.g=128;Col.b=0; - AddButtonStatus(button,"FEC 1/2",&Col); - + AddButtonStatus(button,"SR 250",&Col); + button=AddButton(1*wbuttonsize+20,hbuttonsize*1+20,wbuttonsize*0.9,hbuttonsize*0.9); Col.r=0;Col.g=0;Col.b=128; + AddButtonStatus(button,"SR 333",&Col); + Col.r=0;Col.g=128;Col.b=0; + AddButtonStatus(button,"SR 333",&Col); + + button=AddButton(2*wbuttonsize+20,hbuttonsize*1+20,wbuttonsize*0.9,hbuttonsize*0.9); + Col.r=0;Col.g=0;Col.b=128; + AddButtonStatus(button,"SR 500",&Col); + Col.r=0;Col.g=128;Col.b=0; + AddButtonStatus(button,"SR 500",&Col); + + button=AddButton(3*wbuttonsize+20,hbuttonsize*1+20,wbuttonsize*0.9,hbuttonsize*0.9); + Col.r=0;Col.g=0;Col.b=128; + AddButtonStatus(button,"SR1000",&Col); + Col.r=0;Col.g=128;Col.b=0; + AddButtonStatus(button,"SR1000",&Col); + + button=AddButton(4*wbuttonsize+20,hbuttonsize*1+20,wbuttonsize*0.9,hbuttonsize*0.9); + Col.r=0;Col.g=0;Col.b=128; + AddButtonStatus(button,"SR2000",&Col); + Col.r=0;Col.g=128;Col.b=0; + AddButtonStatus(button,"SR2000",&Col); + +// FEC + + button=AddButton(0*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0.9); + Col.r=0;Col.g=0;Col.b=128; + AddButtonStatus(button,"FEC 1/2",&Col); + Col.r=0;Col.g=128;Col.b=0; + AddButtonStatus(button,"FEC 1/2",&Col); + + button=AddButton(1*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0.9); + Col.r=0;Col.g=0;Col.b=128; AddButtonStatus(button,"FEC 2/3",&Col); Col.r=0;Col.g=128;Col.b=0; AddButtonStatus(button,"FEC 2/3",&Col); - -button=AddButton(2*wbuttonsize+20,hbuttonsize*1+20,wbuttonsize*0.9,hbuttonsize*0.9); + + button=AddButton(2*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0.9); Col.r=0;Col.g=0;Col.b=128; AddButtonStatus(button,"FEC 3/4",&Col); Col.r=0;Col.g=128;Col.b=0; AddButtonStatus(button,"FEC 3/4",&Col); - -button=AddButton(3*wbuttonsize+20,hbuttonsize*1+20,wbuttonsize*0.9,hbuttonsize*0.9); + + button=AddButton(3*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0.9); Col.r=0;Col.g=0;Col.b=128; AddButtonStatus(button,"FEC 5/6",&Col); Col.r=0;Col.g=128;Col.b=0; AddButtonStatus(button,"FEC 5/6",&Col); -button=AddButton(4*wbuttonsize+20,hbuttonsize*1+20,wbuttonsize*0.9,hbuttonsize*0.9); + button=AddButton(4*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0.9); Col.r=0;Col.g=0;Col.b=128; AddButtonStatus(button,"FEC 7/8",&Col); Col.r=0;Col.g=128;Col.b=0; AddButtonStatus(button,"FEC 7/8",&Col); //SOURCE -button=AddButton(0*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0.9); - Col.r=0;Col.g=0;Col.b=128; + + button=AddButton(0*wbuttonsize+20,hbuttonsize*3+20,wbuttonsize*0.9,hbuttonsize*0.9); + Col.r=0;Col.g=0;Col.b=128; AddButtonStatus(button,"CAM MPEG2",&Col); Col.r=0;Col.g=128;Col.b=0; AddButtonStatus(button,"CAM MPEG2",&Col); - - button=AddButton(1*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0.9); - Col.r=0;Col.g=0;Col.b=128; + + button=AddButton(1*wbuttonsize+20,hbuttonsize*3+20,wbuttonsize*0.9,hbuttonsize*0.9); + Col.r=0;Col.g=0;Col.b=128; AddButtonStatus(button,"CAM H264",&Col); Col.r=0;Col.g=128;Col.b=0; - AddButtonStatus(button,"CAM H264",&Col); + AddButtonStatus(button,"CAM H264",&Col); -char PictureName[255]; + char PictureName[255]; //strcpy(PictureName,ImageFolder); GetNextPicture(PictureName); -button=AddButton(2*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0.9); - Col.r=0;Col.g=0;Col.b=128; - AddButtonStatus(button,"Patern",&Col); - Col.r=0;Col.g=128;Col.b=0; - AddButtonStatus(button,PictureName,&Col); - -button=AddButton(3*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0.9); + button=AddButton(2*wbuttonsize+20,hbuttonsize*3+20,wbuttonsize*0.9,hbuttonsize*0.9); + Col.r=0;Col.g=0;Col.b=128; + AddButtonStatus(button,"Pattern",&Col); + Col.r=0;Col.g=128;Col.b=0; + AddButtonStatus(button,"Pattern",&Col); + + button=AddButton(3*wbuttonsize+20,hbuttonsize*3+20,wbuttonsize*0.9,hbuttonsize*0.9); Col.r=0;Col.g=0;Col.b=128; AddButtonStatus(button,"TS File",&Col); Col.r=0;Col.g=128;Col.b=0; - AddButtonStatus(button,"Video Name",&Col); + AddButtonStatus(button,"TSFile",&Col); -button=AddButton(4*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0.9); + button=AddButton(4*wbuttonsize+20,hbuttonsize*3+20,wbuttonsize*0.9,hbuttonsize*0.9); Col.r=0;Col.g=0;Col.b=128; AddButtonStatus(button,"Carrier",&Col); Col.r=0;Col.g=128;Col.b=0; @@ -1046,36 +1115,67 @@ button=AddButton(4*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0 //TRANSMIT -button=AddButton(0*wbuttonsize+20,hbuttonsize*3+20,wbuttonsize*1.2,hbuttonsize*1.2); + button=AddButton(0*wbuttonsize+20,hbuttonsize*4+20,wbuttonsize*1.2,hbuttonsize*1.2); Col.r=0;Col.g=0;Col.b=128; AddButtonStatus(button,"TX ",&Col); Col.r=255;Col.g=0;Col.b=0; - AddButtonStatus(button,"TX ON",&Col); + AddButtonStatus(button,"TX ON",&Col); -button=AddButton(1*wbuttonsize*3+20,hbuttonsize*3+20,wbuttonsize*1.2,hbuttonsize*1.2); + button=AddButton(1*wbuttonsize*3+20,hbuttonsize*4+20,wbuttonsize*1.2,hbuttonsize*1.2); Col.r=0;Col.g=0;Col.b=128; AddButtonStatus(button,"RX ",&Col); Col.r=0;Col.g=128;Col.b=0; - AddButtonStatus(button,"RX ON",&Col); - + AddButtonStatus(button,"RX ON",&Col); + Start(wscreen,hscreen); IsDisplayOn=1; - - char Param[]="symbolrate"; - char Value[255]; +// Determine button highlights + + // Frequency + + strcpy(Param,"freqoutput"); + GetConfigParam(PATH_CONFIG,Param,Value); + strcpy(freqtxt,Value); + printf("Value=%s %s\n",Value,"Freq"); + if(strcmp(Value,"71")==0) + { + SelectFreq(0); + } + if(strcmp(Value,"146.5")==0) + { + SelectFreq(1); + } + if(strcmp(Value,"437")==0) + { + SelectFreq(2); + } + if(strcmp(Value,"1249")==0) + { + SelectFreq(3); + } + if(strcmp(Value,"1255")==0) + { + SelectFreq(4); + } + + // Symbol Rate + + strcpy(Param,"symbolrate"); GetConfigParam(PATH_CONFIG,Param,Value); - SR=atoi(Value); + printf("Value=%s %s\n",Value,"SR"); switch(SR) { - case 125:SelectSR(0);break; - case 250:SelectSR(1);break; - case 333:SelectSR(2);break; - case 500:SelectSR(3);break; - case 1000:SelectSR(4);break; + case 250:SelectSR(5);break; + case 333:SelectSR(6);break; + case 500:SelectSR(7);break; + case 1000:SelectSR(8);break; + case 2000:SelectSR(9);break; } + // FEC + strcpy(Param,"fec"); strcpy(Value,""); GetConfigParam(PATH_CONFIG,Param,Value); @@ -1083,42 +1183,46 @@ button=AddButton(1*wbuttonsize*3+20,hbuttonsize*3+20,wbuttonsize*1.2,hbuttonsize fec=atoi(Value); switch(fec) { - case 1:SelectFec(5);break; - case 2:SelectFec(6);break; - case 3:SelectFec(7);break; - case 5:SelectFec(8);break; - case 7:SelectFec(9);break; + case 1:SelectFec(10);break; + case 2:SelectFec(11);break; + case 3:SelectFec(12);break; + case 5:SelectFec(13);break; + case 7:SelectFec(14);break; } - + + // Input Mode + strcpy(Param,"modeinput"); GetConfigParam(PATH_CONFIG,Param,Value); strcpy(ModeInput,Value); + printf("Value=%s %s\n",Value,"Input Mode"); // if(strcmp(Value,"CAMH264")==0) { - SelectSource(11,1); - + SelectSource(16,1); } if(strcmp(Value,"CAMMPEG-2")==0) { - SelectSource(10,1); - + SelectSource(15,1); } if(strcmp(Value,"PATERNAUDIO")==0) { - SelectSource(12,1); - + SelectSource(17,1); } if(strcmp(Value,"CARRIER")==0) { - SelectSource(13,1); + SelectSource(18,1); } + UpdateWindow(); - + + + printf("Update Window\n"); + // RESIZE JPEG TO BE DONE /*char PictureName[255]; strcpy(PictureName,ImageFolder); GetNextPicture(PictureName); - + Image(0,0,300,200,PictureName); End(); diff --git a/update.sh b/update.sh index a459b75..6223169 100755 --- a/update.sh +++ b/update.sh @@ -1,32 +1,41 @@ #!/bin/bash -set -e +# Updated by davecrump 20161210 + +set -e # Don't report errors # ---------- Update rpidatv ----------- cd /home/pi -#git clone git://github.com/F5OEO/rpidatv -> BUG IN QEMU : Go to download method wget https://github.com/F5OEO/rpidatv/archive/master.zip -O master.zip unzip -o master.zip cp -f -r rpidatv-master rpidatv rm master.zip -#rpidatv core +# Compile rpidatv core cd rpidatv/src make clean make sudo make install -#rpidatv gui + +# Compile rpidatv gui cd gui make clean make sudo make install cd ../ -#avc2ts + +# Compile avc2ts cd avc2ts make clean make sudo make install +#install adf4351 +cd /home/pi/rpidatv/src/adf4351 +make +cp adf4351 ../../bin/ +cd /home/pi/rpidatv +