' ' Coryright 2004, Dan Rasmussen, Paul Norton, Jon Morgan ' ' This file is part of Radii: radio's next generation ' ' Radii is free software; you can redistribute it and/or modify ' it under the terms of the GNU General Public License as published by ' the Free Software Foundation; either version 2 of the License, or ' (at your option) any later version. ' ' Radii 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 General Public License for more details. ' ' You should have received a copy of the GNU General Public License ' along with Radii; if not, write to the Free Software ' Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ' '------------------------------------------------------------------------------ 'This code is wrtten for the OOPic System (www.oopic.com) 'This program reads an oQencode Object 'and outputs the value on I/O lines 8 - 15. Dim STN As New oQencode Dim BAND As New oQencode Dim ledUp As New oDio1 Dim ledDown As New oDio1 Dim bVal As Word Dim oldBVal As Word Dim skipOneB As New oBit Dim val As Word Dim oldVal As Word Dim tUp As Word Dim tDown As Word Dim skipOne As New oBit 'oSerial uses ports write=22, read=23 Dim serPort As New oSerial Dim selSw As New oDio1 Dim favSw As New oDio1 Dim othSw As New oDio1 Sub Main() ' Select switch settings 'OOPic.Pullup = cvTrue selSw.IOLine = 1 selSw.Direction = cvInput favSw.IOLine = 2 favSw.Direction = cvInput othSw.IOLine = 3 othSw.Direction = cvInput STN.IOLine1 = 8 STN.IOLine2 = 11 STN.Operate = cvTrue BAND.IOLine1 = 14 BAND.IOLine2 = 15 BAND.Operate = cvTrue ledUp.IOLine = 28 ledUp.Direction = cvOutput ledUp.Value = cvOff ledDown.IOLine = 24 ledDown.Direction = cvOutput ledDown.Value = cvOff serPort.Baud = cv9600 serPort.operate = cvTrue val = STN.Value oldVal = val skipOne = 0 bVal = STN.Value oldBVal = val skipOneB = 0 Do val = STN.Value bVal = BAND.Value If selSw.Value = cvPressed Then ledDown.Value = cvOn serPort.Value = 2 serPort.String = "S" serPort.Value = 3 OOPic.delay = 100 ledDown.Value = cvOff ' Ignore incidental encoder val chanes by resetting oldVal oldVal = val oldBVal = bVal end if If favSw.Value = cvPressed Then ledDown.Value = cvOn serPort.Value = 2 serPort.String = "F" serPort.Value = 3 OOPic.delay = 100 ledDown.Value = cvOff ' Ignore incidental encoder val chanes by resetting oldVal oldVal = val oldBVal = bVal end if If othSw.Value = cvPressed Then ledDown.Value = cvOn serPort.Value = 2 serPort.String = "O" serPort.Value = 3 OOPic.delay = 100 ledDown.Value = cvOff ' Ignore incidental encoder val chanes by resetting oldVal oldVal = val oldBVal = bVal end if if val < oldVal then if 0 = skipOne then ledDown.Value = cvOn serPort.Value = 2 serPort.String = "D" serPort.Value = 3 OOPic.delay = 10 ledDown.Value = cvOff skipOne = 1 else skipOne = skipOne - 1 end if end if if val > oldVal then if 0 = skipOne then ledUp.Value = cvOn serPort.Value = 2 serPort.String = "U" serPort.Value = 3 OOPic.delay = 10 ledUp.Value = cvOff skipOne = 1 else skipOne = skipOne - 1 end if end if if bVal < oldBVal then if 0 = skipOneB then ledDown.Value = cvOn serPort.Value = 2 serPort.String = "d" serPort.Value = 3 OOPic.delay = 10 ledDown.Value = cvOff skipOneB = 1 else skipOneB = skipOneB - 1 end if end if if bVal > oldBVal then if 0 = skipOneB then ledUp.Value = cvOn serPort.Value = 2 serPort.String = "u" serPort.Value = 3 OOPic.delay = 10 ledUp.Value = cvOff skipOneB = 1 else skipOneB = skipOneB - 1 end if end if oldVal = val oldBVal = bVal OOPic.delay = 5 ' if ENC.Moved = cvTrue then ' if ENC.Direction = 1 then ' led1.Value = cvOn ' else ' led1.Value = cvOff ' end if ' end if Loop End Sub