MrDEB
Well-Known Member
Be hacking at this swordfish basic code and inserting led markers but code still does not declimate the numbers (SEE SUD ROUTINES)
the COUNTER is working but still the matrix is not displaying correctly. I had a similar code that worked but with a harddrive issue most is gone. Trying to rebuild working code.
Am sure it is something simple but I have yet to get the correct configuration
the COUNTER is working but still the matrix is not displaying correctly. I had a similar code that worked but with a harddrive issue most is gone. Trying to rebuild working code.
Am sure it is something simple but I have yet to get the correct configuration
Code:
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2022 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 2/18/2022 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2022 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 2/14/2022 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2022 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 2/12/2022 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2022 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 2/10/2022 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2022 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 2/9/2022 *
* Version : 1.0 *
* Notes : PORTB and D are the leds ON MATRIX OLD BOARDS *
* : porta are the player leds *
*****************************************************************************
}
Device = 18F43k22 ' Tell the compiler what chip we are using
Clock = 8 ' Tell the compiler what we will be setting the clock to (Mhz)
#OPTION DIGITALLIO_INIT=TRUE
Include "SetDigitalIO.bas" // Include this file when we compile so that we can use keywords like 'setalldigital'
Include "utils.bas"
Include "convert.bas"
Include "intosc.bas"
Dim y As Byte
Dim x As Byte
Dim Player As Byte
Dim counter As Byte
Dim Switch As PORTE.1 //old boards
//PLAYER LEDS OLD BOARDS porta
Dim led0 As PORTC.0
Dim led1 As PORTC.1
Dim led2 As PORTC.2
Dim led3 As PORTC.3
Dim led4 As PORTC.4
Dim led5 As PORTC.5
Dim led6 As PORTC.6
Dim led7 As PORTC.7
//player buttons
Dim Button0 As PORTA.0
Dim Button1 As PORTA.1
Dim Button2 As PORTA.2
Dim Button3 As PORTA.3
Dim Button4 As PORTA.4
Dim Button5 As PORTA.5
Dim Button6 As PORTA.6
Dim Button7 As PORTA.7
'Dim Battery As porta.2 'hlvd
'Dim Power As porta.1 'hlvd
Const Cathodes_Data(8)As Byte = (%01111111, ' KEEP THESE AS THEY DON"T CHANGE PER LETTER
%10111111, ' this is for scanning the rows
%11011111, //cathodes
%11101111,
%11110111,
%11111011,
%11111101,
%11111110)
Const Cat_Data(8)As Byte = (%10000000,
%01000000,
%00100000,
%00010000,
%00001000,
%00000100,
%00000010,
%00000001)
Const One(8)As Byte = (%00000000,
%00000000,
%00000000,
%00000000,
%00010000,
%00000000,
%00000000,
%00000000)
' number 2
Const Two(8)As Byte = (%10000000,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000,
%00000001)
Const Three(8) As Byte =(%10000000,
%00000000,
%00000000,
%00010000,
%00000000,
%00000000,
%00000000,
%00000001)
Const Four(8) As Byte =(%10000001,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000,
%10000001)
Const Five(8) As Byte = (%10000001,
%00000000,
%00000000,
%00010000,
%00000000,
%00000000,
%00000000,
%10000001)
Const Six(8) As Byte = (%10000001,
%00000000,
%00000000,
%10000001,
%00000000,
%00000000,
%10000001,
%00000000)
Const Seven(8) As Byte =(%10010001,
%00000000,
%00000000,
%10000001,
%00000000,
%00000000,
%10000001,
%00000000)
Const Eight(8) As Byte =(%10010010,
%00000000,
%00000000,
%10010010,
%00000000,
%00000000,
%10000010,
%00000000)
Const Nine(8) As Byte= (%10010010,
%00000000,
%00000000,
%10010010,
%00000000,
%00000000,
%10010010,
%00000000)
Const Ten(8) As Byte= (%10010010,
%00000000,
%10010010,
%00000000,
%10000010,
%00000000,
%10000010,
%00000000)
Const Eleven(8) As Byte=(%10010010,
%00000000,
%10010010,
%00000000,
%10010010,
%00000000,
%10000010,
%00000000)
Const Tweleve(8)As Byte=(%10010010,
%00000000,
%10010010,
%00000000,
%10010010,
%00000000,
%10010010,
%00000000)
// Arrays
Sub T_12() //12
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Tweleve(x)// colums 8 (L-R the X is the scan
DelayuS(100)
PORTD = %00000000 //eliminate ghosting
DelayuS(100)
Next
End Sub
Sub E_11() //11
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Eleven(x)// colums 8 (L-R the X is the scan
DelayUS(100)
PORTD = %00000000
DelayUS(100)
Next
End Sub
Sub T_10() //10
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Ten(x)// colums 8 (L-R the X is the scan
DelayUS(100)
PORTD = %00000000
DelayUS(100)
Next
End Sub
Sub N_9() //9
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Nine(x)// colums 8 (L-R the X is the scan
DelayUS(100)
PORTD = %00000000
DelayUS(100)
Next
End Sub
Sub E_8() //8
For x = 0 To 7
PORTB =Cathodes_Data(x) //rows top to bottom
PORTD = Eight(x)// colums 8 (L-R the X is the scan
DelayUS(100)
PORTD = %00000000
DelayUS(100)
Next
End Sub
Sub S_7() //7
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Seven(x)// colums 8 (L-R the X is the scan
DelayUS(100)
PORTD =%00000000
DelayUS(100)
Next
End Sub
Sub S_6() //SIX
For x = 0 To 7
PORTB =Cathodes_Data(x) //rows top to bottom
PORTD = Six(x)// colums 8 (L-R the X is the scan
DelayUS(100)
PORTD = %00000000
DelayUS(100)
Next
End Sub
Sub F_5() //5
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Five(x)// colums 8 (L-R the X is the scan
DelayUS(100)
PORTD = %00000000
DelayUS(100)
Next
End Sub
Sub F_4() //FOUR
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Four(x)// colums 8 (L-R the X is the scan
DelayUS(100)
PORTD = %00000000
DelayUS(100)
Next
End Sub
Sub T_3()
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Three(x)// colums 8 (L-R the X is the scan
DelayUS(100)
PORTD = %00000000
DelayUS(100)
Next
End Sub
Sub T_2() //2
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Two(x)// colums 8 (L-R the X is the scan
DelayUS(100)
PORTD = %00000000
DelayUS(100)
Next
End Sub
Sub O_1() //1
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = One(x)// colums 8 (L-R the X is the scan
DelayUS(100)
PORTD = %00000000
DelayUS(100)
Next
End Sub
Sub Matrix_sel()
If counter = 12 Then
T_12()
End If
'COUNTER = COUNTER - 1
If counter = 11 Then
E_11()
End If
' COUNTER = COUNTER - 1
If counter = 10 Then
T_10()
End If
If counter = 9 Then
N_9()
End If
If counter = 8 Then
E_8()
End If
If counter = 7 Then
S_7()
End If
If counter = 6 Then
S_6()
End If
If counter = 5 Then
F_5()
End If
If counter = 4 Then
F_4()
End If
If counter = 3 Then
T_3()
End If
If counter = 2 Then
T_2()
End If
If counter = 1 Then
O_1()
End If
If counter <>0 Then
T_12()
EndIf
End Sub
Sub Matrix_Change()
counter = (counter - 1)
DELAYMS(400)
End Sub
SetAllDigital // Make all Pins digital I/O's
'TRISA=0 //inputs on old boards // LED port - all outputs on new mexi train boards
TRISC = 0 //PLAYER LEDS
TRISD=0 //ANODES
TRISB = 0 // CATHODES
'WPUB = $ff // enable pullups on all porta pins
'INTCON2.bits(7) = 0 // set bit RBPU = 0 turns on pullups
x = 0
y = 0
//Input (Switch) // counter button
//PLAYER LEDS porta
Output (led0)
Output (led1)
Output (led2)
Output (led3)
Output (led4)
Output (led5)
Output (led6)
Output (led7)
//PLAYER INPUT BUTTONS
Input(Button0)
Input(Button1)
Input(Button2)
Input(Button3)
Input(Button4)
Input(Button5)
Input(Button6)
Input(Button7)
//HLVD
'Output (Battery)
'Output (Power)
led0 =0
led1 =0
led2 =0
led3 =0
led4 =0
led5 =0
led6 =0
led7 =0
Input(Switch) //PORTE.1
counter = 12
While true
' Matrix_sel() //when SWITCH is pressed then COUNTER = COUNTER - 1
If counter = 12 Then T_12()End If
If counter = 11 Then E_11()End If
If counter = 10 Then T_10()End If
If counter = 9 Then N_9()End If
If counter = 8 Then E_8()End If
If counter = 7 Then S_7()End If
If counter = 6 Then S_6()End If
If counter = 5 Then F_5() End If
If counter = 4 Then F_4()EndIf
If counter = 3 Then T_3()EndIf
If counter = 2 Then T_2()EndIf
If counter = 1 Then O_1()EndIf
If counter <>0 Then T_12()EndIf
IF SWITCH = 0 THEN Matrix_Change() endif //DECREMENT MATRIX
If (Button0 = 0)Then delayms(400) Toggle(led0) EndIf //delayms is for button debounce
If (Button1 = 0)Then delayms(400) Toggle(led1) EndIf
If (Button2 = 0)Then delayms(400) Toggle(led2) EndIf
If (Button3 = 0)Then delayms(400) Toggle(led3) EndIf
If (Button4 = 0)Then delayms(400) Toggle(led4) EndIf
If (Button5 = 0)Then delayms(400) Toggle(led5) EndIf
If (Button6 = 0)Then delayms(400) Toggle(led6) EndIf
If (Button7 = 0)Then delayms(400) Toggle(led7) EndIf
//testing if COUNTER is decrementing === YES
if counter <= 12 then led2=1 end if
if counter <12 then led4 = 1 endif
if counter <11 then toggle(led2) delayms(500) toggle(led2)endif
'press()
' If Switch=0 GoTo SkipCode
' DelayMS(delayms(400))
'SkipCode:
' counter = counter - 1
Wend