Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

on screen keyboard ssd1306

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
snipsnip

Bascom Member



Joined: 10 Feb 2014
Posts: 80
Location: Melbourne

australia.gif
PostPosted: Tue Oct 28, 2025 12:23 am    Post subject: on screen keyboard ssd1306 Reply with quote

Just a little OSK I'm working on for use with an encoder and switch

Code:

sub qwerty()

   const ChrTot=43 '/the total amount of charachters on keyboard
   HoldCaseVal = EncVal : EncVal = 14   '/14 puts initial curser in the middle of screen

   dim keyboard(ChrTot) as byte : dim spaceval(ChrTot) as byte : dim hozline(ChrTot) as byte : dim answer(15) as byte
   local index as byte : index = 1
   local state as byte : local x as byte : local n as byte

   '/load arrays from data tables
   for n=1 to ChrTot
      keyboard(n) = Lookup(n , numdata)   '/decimal ascii value of charachter
      spaceval(n) = lookup(n , spacedata) '/verticle spacing
      hozLine(n) = lookup(n , linedata )  '/horizontal spacing
   next n

   setfont font8x8

   do
      '/this redraws the screen to clear highlited text when its not selected
      if EncVal <> state then '/ only redraw when needed
         for n = 1 to ChrTot
            lcdat hozline(n),spaceval(n),chr(keyboard(n))
            if keyboard(n)=115 then lcdat hozline(n),spaceval(n),"save"
            if keyboard(n)=100 then lcdat hozline(n),spaceval(n),"del"
            if keyboard(n)=101 then lcdat hozline(n),spaceval(n),"exit"
         next  n
      end if


      state = EncVal


      '/this highlites text
      lcdat hozline(EncVal),spaceval(EncVal),chr(keyboard(EncVal)),1
      if EncVal=11 then lcdat hozline(EncVal),spaceval(EncVal),"save",1
      if EncVal=12 then lcdat hozline(EncVal),spaceval(EncVal),"del",1
      if EncVal=13 then lcdat hozline(EncVal),spaceval(EncVal),"exit",1


      if EncVal > ChrTot then EncVal=ChrTot

      '/ save/del/exit actions
      if EncVal=13 and EncSwitch=0 then exit sub


      '/input selection
      if EncSwitch = 0  then
         answer(index) = keyboard(EncVal)
         lcdat 8,spaceval(index),chr(answer(index)),1
         'incr  index:if index>10 then index=10
         if index < 10 then incr index  '/sets the charachter limit of the answer
         bitwait EncSwitch, set
      end if

   loop


   EncVal=1


   numdata:'0 0  1  2  3  4  5  6  7  8  9     [save][del][exit]        A  B  C  D  E  F      G  H  I  J  K  L     M  N  O  P  Q  R     S  T  U  V  W   !     X  Y  Z  .  -  *
      data 48,48,49,50,51,52,53,54,55,56,57    ,115,  100,  101        ,65,66,67,68,69,70    ,71,72,73,74,75,76   ,77,78,79,80,81,82   ,83,84,85,86,87,33   ,88,89,90,46,45,42
   spacedata:
      data 1,11,21,31,41,51,61,71,81,91,101     ,80,80,80               ,1,11,21,31,41,51     ,1,11,21,31,41,51    ,1,11,21,31,41,51    ,1,11,21,31,41,51    ,1,11,21,31,41,51
   linedata:
      data 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1       ,3,4,5                  ,3,3,3,3,3,3            ,4,4,4,4,4,4          ,5,5,5,5,5,5       ,6,6,6,6,6,6        ,7,7,7 ,7,7 ,7

end sub
 


Last edited by snipsnip on Thu Oct 30, 2025 4:29 pm; edited 1 time in total
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6270
Location: Holland

blank.gif
PostPosted: Wed Oct 29, 2025 10:05 am    Post subject: Reply with quote

It looks interesting but i do not know the purpose. What is OSK ?
It will be helpful to share some calling code and some documentation.
In any case : thanks for sharing this intriguing code. Very Happy

_________________
Mark
Back to top
View user's profile Visit poster's website
AndersL

Bascom Member



Joined: 25 Jan 2010
Posts: 94
Location: Kragerø,Norway

norway.gif
PostPosted: Wed Oct 29, 2025 1:36 pm    Post subject: Reply with quote

My quess:On Screen Keyboard Smile
_________________
Anders
Back to top
View user's profile
snipsnip

Bascom Member



Joined: 10 Feb 2014
Posts: 80
Location: Melbourne

australia.gif
PostPosted: Wed Oct 29, 2025 11:59 pm    Post subject: Reply with quote

albertsm wrote:
It looks interesting but i do not know the purpose. What is OSK ?
It will be helpful to share some calling code and some documentation.
In any case : thanks for sharing this intriguing code. Very Happy



sorry about that, I got called away from home for work just after I posted and forgot to bring the project with me. I'll post a vid when I get back.

but yeah it's just a little on screen keyboard for an ssd 1306 (or whatever), flexible placement of characters as defined in the data tables.
the highlighted text is cleared with a refresh. Used with an encoder and switch. I'm using it to input GPS waypoint / points of interest naming, Lat, Lon entry.

For context - if anyone is interested, see below for the project. i'm only calling it from the main program for testing, not yet fully done - it's very much a work in progress.
https://github.com/scross-art/Bascom-gps-stuff/blob/main/gps%20functions.inc
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6270
Location: Holland

blank.gif
PostPosted: Fri Oct 31, 2025 10:17 am    Post subject: Reply with quote

Thanks for the explanation. And for the github link. Interesting project.
A screen keyboard can be a challenging task. Especial when you want to make it universal.
Good luck with the project and keep us updated.
I have several projects that need to be finished myself. It is not always easy to find enough time since more important things disturb things.

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum