Hello everybody,

2 years now I'm using owfs for monitoring home temperature and driving my
heating system. Everything is perfect. Big thanks to developers.
I have recently added to my network a Hobby board LCD driver. Following owfs man
pages I have no problem to write anything to the LCD, or to read the state of
the 3 input switches (the 3 first PIO's as per Hobby board design).
However my problem is that I cannot do this 2 things together:
To read the input switches state I read sensed.BYTE as per owfs man pages I must
first write 0 to PIO. And this is the problem as soon as I write something to
the PIO (0, 1, 8 or 255) the next write to the /LCD_H/message will fail to write
anything on LCD screen. I have try several things but cannot succeed. Obviously
I miss a re-init, printf "\x0C" >  /LCD_H/message doesn't help.
If anybody can help I would be happy!

Here is my script
The 2 functions are working, but not together.
To have the LCD correctly working I must comment this line
#echo 0 > $MYLCD/PIO.BYTE
if not 1 message on 2 isn't displayed.


#!/bin/bash

HeureDernierAffichage=0
COMPTEUR_AFFICHAGE=0
MYLCD=/tmp/1wire/29.1C9E09000000
LCD1="$MYLCD/LCD_H/screen"
LCD2="$MYLCD/LCD_H/message"
MESSAGE[1]="Bonjour Pirouette!                      Temp. Cave="
MESSAGE[2]="Bonjour Pirouette!                      Temp. Chaud="
MESSAGE[3]="Bonjour Pirouette!                      Temp. Entree="
MESSAGE[4]="Bonjour Pirouette!                      Temp. Ext="
MESSAGE[5]="Bonjour Pirouette!                      Temp. Server="


function DerouleAffichage   # scroll message 1 to 5
{
let TEMP_PASSE=`date +%s`-$HeureDernierAffichage  # message on LCD will change
every 5 seconds
echo -n "TEMP_PASSE=$TEMP_PASSE    "
if [ $TEMP_PASSE -gt 5 ]; then
  let COMPTEUR_AFFICHAGE=$COMPTEUR_AFFICHAGE+1
  if [ $COMPTEUR_AFFICHAGE -gt 5 ]; then let COMPTEUR_AFFICHAGE=1; fi # after
message 5 loop to message 1
  let HeureDernierAffichage=`date +%s`  
  printf "%s" "${MESSAGE[$COMPTEUR_AFFICHAGE]}$COMPTEUR_AFFICHAGE" > $LCD2
  echo 0 > $MYLCD/PIO.BYTE
fi
}

function TestAppuiBouton
{
  let REGISTRE=`cat $MYLCD/sensed.BYTE | sed -e "s/ //g"` 
  let "REGISTRE &= 7"  # Mask with AND keep 3 first bits
}


   # Initialise the display
  printf "\x0C" > $LCD1
  printf "1" > $MYLCD/LCD_H/clear
  printf "1" > $MYLCD/LCD_H/home

while [ 1 ]
do
  DerouleAffichage
  echo "COMPTEUR_AFFICHAGE=$COMPTEUR_AFFICHAGE   REGISTRE=$REGISTRE"
  sleep 0.5 
  TestAppuiBouton
done


Thanks 
--
Guy


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to