Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Check in next week Mike I might have some further software developments using the blindfold method--lol
It works for Washington D.C.---lol
Thank you for having a good sense of humor, and I agree about Washington D.C. (wink).
As bewildering as it might seem to a few of us who watch you take the long meandering route, as opposed to a more direct route, I don't think anyone can dispute that you always arrive at your destination with the results you were looking for. If you enjoyed the journey and accomplished your goals, what else matters? Right?
Happy Holidays and cheerful regards, Mike
And it would. In the latest code I see it could be almost a second before you leave RIDE and get back to the main button polling loop. In the original code it could have been almost twice that.In the end I want to be able to exit RIDE anytime. Seems like a button press takes a long time to react
Sub RIDE()
Dim index As Byte
Dim X As Byte
For index = 0 To Bound (Ride_Data)
DelayMS(500)//10 500us for constant on
X = Ride_Data(index)
LE = 0
ResetPin_R = 1 // disable OE RED
ResetPin_G = 1 // disable OE Green
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// CHECK SWITCHES
If s1 = 0 Then // sw 1 closed
count = 0
exit
End If
If s2 = 0 Then // sw 2 closed
count = 0
exit
End If
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Shift.Out(MSB_FIRST, X ,8)
LE = 1 //Latch data
PORTB = R_Rows(index)
DelayUS(200) //20 us
ResetPin_G = 0 // output LOW = ON HIGH = OFF
ResetPin_R = 1
LE = 0
Next
End Sub
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 11/28/2012 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 11/27/2012 *
* Version : 1.0 *
* Notes : tumbleweed code rev 2 *
* : *
*****************************************************************************
}
Device = 18F2420
Clock = 20
// external xtal
Config OSC = HS
// uncomment next line to use internal osc
//Include "InternalOscillator.bas" // module sets Config OSC = INTIO7 for you
Include "shift.bas"
Include "utils.bas"
Include "convert.bas"
Dim SDI As PORTC.4
Dim CLK As PORTC.5
Dim LE As PORTC.3
Dim RED_OE As PORTC.0
Dim GREEN_OE As PORTC.1
Dim DataPin As SDI
Dim ClockPin As CLK
Dim ResetPin_R As RED_OE
Dim ResetPin_G As GREEN_OE
// pushbutton switches inputs S1 and S2
Dim s1 As PORTA.2
Dim s2 As PORTA.3
Dim count As Byte
dim switch as byte
dim led as porta.0
Dim index As Byte
Dim X As Byte
Const Data(15)As Byte = (%00010001, %00001010 ,%00000100, %00010001, %00001010, %00000100,
%00010001, %000001010 ,%00000100, %000010001,%00001010, %00000100, %000010001,%00001010, %00000100)
Const Rows(15) As Byte =(%00000001, %000000010 ,%00000100, %000000010, %00000100, %00001000,
%00000100 ,%000001000 ,%00010000 ,%00001000,%00010000 ,%00100000, %00010000 ,%00100000, %01000000)
Const L_TRows(15) As Byte =( %01000000,%00100000,%00010000,%00100000,%000010000, %00001000,
%00010000, %00001000, %00000100 ,%00001000, %000000100,%00000010,%00000100, %000000010,%00000001)
Const Ride_Data(15)As Byte = (%00011111, %00000100 ,%00011111, %00000100, %00011111, %00000100,
%00011111, %00000100 ,%00011111, %00000100,%00011111, %00000100, %00011111,%00000100, %00011111)
Const R_Rows(15) As Byte =(%00001000, %011111111 ,%00001000, %011111111, %00001000, %01111111,
%00001000 ,%011111111 ,%00001000 ,%01111111,%00001000 ,%01111111, %00001000 ,%01111111, %00001000)
Sub RIGHT()
Dim index As Byte
Dim X As Byte
For index = 0 To Bound (Data)
DelayMS(10)//10 500us for constant on
X = Data(index)
LE = 0
ResetPin_R = 1 // disable OE RED
ResetPin_G = 1 // disable OE Green
Shift.Out(MSB_FIRST, X ,8)
LE = 1 //Latch data
PORTB = Rows(index)
DelayUS(20) //20 us
ResetPin_R = 0 // output LOW = ON HIGH = OFF
ResetPin_G = 1
LE = 0
Next
End Sub
Sub LEFT()
Dim index As Byte
Dim X As Byte
For index = 0 To Bound (Data)
DelayMS(10)//10 500us for constant on
X = Data(index)
LE = 0 // move to top
ResetPin_R = 1 // disable OE RED
ResetPin_G = 1 // disable OE Green
Shift.Out(MSB_FIRST, X ,8)
LE = 1 //Latch data
PORTB = L_TRows(index) // display byte on matrix
DelayUS(20) //10 1 us for constant on
ResetPin_R = 0 // output LOW = ON HIGH = OFF
ResetPin_G = 1
Next
End Sub
// start of main
SetAllDigital
Shift.SetOutput(DataPin)
Shift.SetClock(ClockPin)
High(ResetPin_R) // make output and set high
High(ResetPin_G) // make output and set high
Low(LE) // make output and set low
PORTB = 0
TRISB = %00000000 // make PORTB outputs
// make S1 and S2 switch inputs (assumes there are external pullups on the pins)
Input(s1)
Input(s2)
While true // durring RIDE the code jumps to here if switch = 1
// Dim index As Byte
// Dim X As Byte
For index = 0 To Bound (Ride_Data)
DelayMS(500)//10 500us for constant on
X = Ride_Data(index)
LE = 0
ResetPin_R = 1 // disable OE RED
ResetPin_G = 1 // disable OE Green
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// CHECK SWITCHES
If s1 = 0 Then // sw 1 closed
count = 0
repeat
LEFT
delayms(200)
inc(count)
until count=10
End If
If s2 = 0 Then // sw 1 closed
count = 0
repeat
RIGHT
delayms(200)
inc(count)
until count=10
End If
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Shift.Out(MSB_FIRST, X ,8)
LE = 1 //Latch data
PORTB = R_Rows(index)
DelayUS(200) //20 us
ResetPin_G = 0 // output LOW = ON HIGH = OFF
ResetPin_R = 1
LE = 0
Next
wend
End
Burt is entirely right. "RIDE" is the default state when the program is doing nothing else. "LEFT" and "RIGHT" are exceptions to the default state, initiated by a bottom press or head tip for whatever...who can keep track. Since it's always doing RIDE, put it in the main program loop.
while(1) //
{ delay_ms(25); // 25-ms 'debounce' interval
/* *
* K8LH parallel switch state logic (with "new press" filter) *
* *
* swnew ___---___---___---_____ invert active lo switches *
* swold ____---___---___---____ switch state latch *
* swnew ___-__-__-__-__-__-____ changes, press or release *
* swnew ___-_____-_____-_______ filter out 'release' bits *
* flags ___------______-------- toggle flag bits for main *
* */
swnew = ~porta; // sample active lo switches
swnew &= 0b00011000; // on the RA4..RA3 pins only
swnew ^= swold; // changes, press or release
swold ^= swnew; // update switch state latch
swnew &= swold; // filter out 'release' bits
flags ^= swnew; // toggle flag bits for main
if(swnew) // if any new press (toggle)
{ index = 0; // reset array index
} //
/* *
* refresh matrix display for "ride", "left", or "right" mode *
* */
if(!flags) // if no switches (ride mode)
{ if(index > bound(ride_data)) // if index overflow
index = 0; // reset index
shiftout(ride_data[index]); // send "ride" column SR data
redlat = 1; // red disp off & latch data
grnlat = 1; // grn disp off & latch data
portb = ride_rows[index++]; // portb = "ride" row data
grnlat = 0; // grn display on
} //
else // sw1 (right) or sw2 (left)
{ if(index > bound(turn_data)) // if index overflow
index = 0; // reset index
shiftout(turn_data[index]); // send "turn" column SR data
redlat = 1; // red disp off & latch data
grnlat = 1; // grn disp off & latch data
if(flags.3) // if sw1 (right) 'on'
portb = rt_rows[index++]; // portb = right row data
else // otherwise, sw2 (left) 'on'
portb = lt_rows[index++]; // portb = left row data
redlat = 0; // red display on
} //
} // end while(1){}
} // end main{}