Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209
Posted: 01:18am 27 Aug 2015
Copy link to clipboard
Print this post
kiiid Guru Joined: 11/05/2013 Location: United KingdomPosts: 671
Posted: 01:29am 27 Aug 2015
Copy link to clipboard
Print this post
Here is a little idea: command buffer built into the keyboard. If the keyboard knows when the mite is in command mode, it could replace up and down arrows with previously entered command lines
Is there a single character available to delete the current line. Maybe ESC?
This would not be to difficult to add, same as macros that can contain little code snippets or other often used sequences. :)
With compromise to the visual clarity the same function can be performed by sending Ctrl-C to the mite
http://rittle.org
--------------
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9586
'MAIN
Do
SetRow(-1)
PAUSE Delay
If ReadColumns() <> 255 then
print ScanMatrix$()
endif
Loop
SUB SetRow(value)
'Row pins 2,3,4,5,6,7,9,10,25
if value = -1 then
'Set all bits to 0. This will allow detecting any keypress
PORT(2,6,9,2,25,1) = 0
else
'Set a bit to 0
PORT(2,6,9,2,25,1) = 512 - (2 ^ value)
endif
END SUB
FUNCTION ReadColumns()
LOCAL FirstScan, ScanCode
'Read the column port and do a simplistic debounce
'Column pins 15,16,17,21,22,23,24,26
FirstScan = PORT(15,3,21,4,26,1)
PAUSE DebounceDelay
ScanCode = PORT(15,3,21,4,26,1)
If FirstScan <> ScanCode then ScanCode = 255
ReadColumns = ScanCode
END FUNCTION
FUNCTION ScanMatrix$()
LOCAL K$,Keys$, RowNumber, ScanCode
'Decode the ScanCode
if ScanCode <> 255 then
'One or more keys were pressed
if DEBUG = 1 then PRINT ScanCode
for ColumnNumber = 0 to 7
'Check every bit in the column
if (Scancode and (255 - (2 ^ ColumnNumber))) = 0 then
if CAP = 0 AND SFT = 0 then
K$ = MID$(Lookup(RowNumber), ColumnNumber + 1, 1)
else
'For now use the same lookup table, use RowNumber + 9 when debugged
K$ = MID$(Lookup(RowNumber), ColumnNumber + 1, 1)
endif
if DEBUG = 1 then
PRINT RowNumber + "," + ColumnNumber + "=>" + K$
endif
Keys$ = Keys$ + K$
endif
next
endif
RowNumber = RowNumber + 1
Loop until RowNumber > 8
ScanMatrix$ = Keys$
END FUNCTION
Smoke makes things work. When the smoke gets out, it stops!
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2932
Posted: 01:53am 27 Aug 2015
Copy link to clipboard
Print this post
ALSO
SetRow(RowNumber) in ScanMatrix (under the first DO) you will need to change to SetRow(RowNumber + 1)
No,this should be OK. Bit numbers 0 - 8.
Yes - I was thinking 2 ^ 0 = 0 - my mistake!
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2932
Posted: 01:55am 27 Aug 2015
Copy link to clipboard
Print this post
Grogs - Change 512 - (2 ^ value) in the SetRows(value) sub and re-try!
To 511 - (2 ^ value) Edited by WhiteWizzard 2015-08-28
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2932
Posted: 01:58am 27 Aug 2015
Copy link to clipboard
Print this post
Grogs - could you add line numbers to the listing to make it easier to refer to points in the code - cheers!
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9586
Posted: 02:02am 27 Aug 2015
Copy link to clipboard
Print this post
Changed to 511. Result:
As to line numbers, just copy and paste the code into MMEdit for line numbers.Smoke makes things work. When the smoke gets out, it stops!
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209
Posted: 02:05am 27 Aug 2015
Copy link to clipboard
Print this post
G,
You still need to change this: (not only change OR to AND. :)
What do you get when you change
[code]
if (Scancode OR (255 - (2 ^ ColumnNumber))) = 0 then
[/code]
into this:
[code]
if (Scancode AND (2 ^ ColumnNumber)) = 0 then
[/code]
Microblocks. Build with logic.
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2932
Posted: 02:06am 27 Aug 2015
Copy link to clipboard
Print this post
Thanks - which line is printing these numbers???
Sorry - don't have MMEdit on this device
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209
Posted: 02:08am 27 Aug 2015
Copy link to clipboard
Print this post
Thanks - which line is printing these numbers???
Sorry - don't have MMEdit on this device
That should be this line in ScanMatrix$ function:
[code]
if DEBUG = 1 then PRINT ScanCode
[/code]
The empty lines are printed in Main
[code]
print ScanMatrix$()
[/code]
Edited by TZAdvantage 2015-08-28Microblocks. Build with logic.
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9586
'MAIN
Do
SetRow(-1)
PAUSE Delay
If ReadColumns() <> 255 then
print ScanMatrix$()
endif
Loop
SUB SetRow(value)
'Row pins 2,3,4,5,6,7,9,10,25
if value = -1 then
'Set all bits to 0. This will allow detecting any keypress
PORT(2,6,9,2,25,1) = 0
else
'Set a bit to 0
PORT(2,6,9,2,25,1) = 511 - (2 ^ value)
endif
END SUB
FUNCTION ReadColumns()
LOCAL FirstScan, ScanCode
'Read the column port and do a simplistic debounce
'Column pins 15,16,17,21,22,23,24,26
FirstScan = PORT(15,3,21,4,26,1)
PAUSE DebounceDelay
ScanCode = PORT(15,3,21,4,26,1)
If FirstScan <> ScanCode then ScanCode = 255
ReadColumns = ScanCode
END FUNCTION
FUNCTION ScanMatrix$()
LOCAL K$,Keys$, RowNumber, ScanCode
'Decode the ScanCode
if ScanCode <> 255 then
'One or more keys were pressed
if DEBUG = 1 then PRINT ScanCode
for ColumnNumber = 0 to 7
'Check every bit in the column
if (Scancode and (2 ^ ColumnNumber)) = 0 then
if CAP = 0 AND SFT = 0 then
K$ = MID$(Lookup(RowNumber), ColumnNumber + 1, 1)
else
'For now use the same lookup table, use RowNumber + 9 when debugged
K$ = MID$(Lookup(RowNumber), ColumnNumber + 1, 1)
endif
if DEBUG = 1 then
PRINT RowNumber + "," + ColumnNumber + "=>" + K$
endif
Keys$ = Keys$ + K$
endif
next
endif
RowNumber = RowNumber + 1
Loop until RowNumber > 8
ScanMatrix$ = Keys$
END FUNCTION
Smoke makes things work. When the smoke gets out, it stops!
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2932
Posted: 02:18am 27 Aug 2015
Copy link to clipboard
Print this post
str$()
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2932
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209
Posted: 02:20am 27 Aug 2015
Copy link to clipboard
Print this post
Getting close. :)
I had this first:
[code]
PRINT RowNumber","ColumnNumber"=>"K$
[/code]
But found it a bit unclear. Claaning up code introduces error. Well that never happened before. :) :)
Edited by TZAdvantage 2015-08-28Microblocks. Build with logic.
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2932
'MAIN
Do
SetRow(-1)
PAUSE Delay
If ReadColumns() <> 255 then
print ScanMatrix$()
endif
Loop
SUB SetRow(value)
'Row pins 2,3,4,5,6,7,9,10,25
if value = -1 then
'Set all bits to 0. This will allow detecting any keypress
PORT(2,6,9,2,25,1) = 0
else
'Set a bit to 0
PORT(2,6,9,2,25,1) = 511 - (2 ^ value)
endif
END SUB
FUNCTION ReadColumns()
LOCAL FirstScan, ScanCode
'Read the column port and do a simplistic debounce
'Column pins 15,16,17,21,22,23,24,26
FirstScan = PORT(15,3,21,4,26,1)
PAUSE DebounceDelay
ScanCode = PORT(15,3,21,4,26,1)
If FirstScan <> ScanCode then ScanCode = 255
ReadColumns = ScanCode
END FUNCTION
FUNCTION ScanMatrix$()
LOCAL K$,Keys$, RowNumber, ScanCode
Keys$ = ""
RowNumber = 0
Do
SetRow(RowNumber)
ScanCode = ReadColumns()
'Decode the ScanCode
if ScanCode <> 255 then
'One or more keys were pressed
if DEBUG = 1 then PRINT ScanCode
for ColumnNumber = 0 to 7
'Check every bit in the column
if (Scancode and (2 ^ ColumnNumber)) = 0 then
if CAP = 0 AND SFT = 0 then
K$ = MID$(Lookup(RowNumber), ColumnNumber + 1, 1)
else
'For now use the same lookup table, use RowNumber + 9 when debugged
K$ = MID$(Lookup(RowNumber), ColumnNumber + 1, 1)
endif
if DEBUG = 1 then
PRINT str$(RowNumber) + "," + str$(ColumnNumber) + "=>" + K$
endif
Keys$ = Keys$ + K$
endif
next
endif
RowNumber = RowNumber + 1
Loop until RowNumber > 8
ScanMatrix$ = Keys$
END FUNCTION
Edited by Grogster 2015-08-28Smoke makes things work. When the smoke gets out, it stops!
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209
Posted: 02:25am 27 Aug 2015
Copy link to clipboard
Print this post
That looks better!
Now the tedious task of filling the lookup table with the right characters.
Microblocks. Build with logic.
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2932
Posted: 02:26am 27 Aug 2015
Copy link to clipboard
Print this post
Now try with Debug=0 (should be quicker!
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209
Posted: 02:28am 27 Aug 2015
Copy link to clipboard
Print this post
Also add a ; otherwise each character will be on a new line.
[code]
print ScanMatrix$();
[/code]
The lookup table has only placeholders for the right characters.
If you see a 'v' that should be a 'q' then find it in the lookup table and change the 'v' into a 'q'. Repeat for all characters.
This will allow many different kinds of keyboards to be used, just need to put in the right values in the lookup table.
If you wired the keyboard as in the latest matrix, then you can use it to fill the lookup table quickly.
Can you also test holding two keys down at the same time. (Only do this when you have diodes in your matrix otherwise you can short two row outputs)
Edited by TZAdvantage 2015-08-28Microblocks. Build with logic.
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2932
Posted: 02:32am 27 Aug 2015
Copy link to clipboard
Print this post
If you were to type eight characters at a time (as per each Lookup string) then TZA's task of populating the matrix becomes easy.
So take the first Lookup characters 'abcdefgh' and press each in turn to show the eight resulting characters.
With all 9 Lookups reported back then TZA can simply put the resulting characters in the correct place in the lookup matrix.
Hope this makes sense . . . .
Page 7 of 14
Print this page
The Back Shed's forum code is written, and hosted, in Australia.