Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

QR Code BAR Code Scanner GUI-O

 
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
matjazs

Bascom Member



Joined: 08 Nov 2016
Posts: 104

PostPosted: Mon Mar 14, 2022 8:48 pm    Post subject: QR Code BAR Code Scanner GUI-O Reply with quote

This is a new very simple solution - QR Code / Barcode Scanner made with Bascom AVR - using the GUI-O android application.
It was tested on Arduino Nano hardware (ATMEGA328) and HC06 Bluetooth module.
See more in pictures, video, Bascom code and schematic.
www.gui-o.com

Youtube smartphone screen video:
https://www.youtube.com/watch?v=fKkbKufauV8


Code:
'GUI-O QR-Code scanner 2022-03

$regfile = "m328pbdef.dat"

$crystal = 11059200
$baud = 9600
$hwstack = 30
$swstack = 30
$framesize = 30
Config Serialin = Buffered , Size = 150
'------------------------------------------------------------------------------
Const Timer1reload = 5400
Config Timer1 = Timer , Prescale = 1024
Load Timer1 , Timer1reload
On Ovf1 Timer1_isr
Enable Timer1
Start Timer1

'------------------------------------------------------------------------------

$lib "GetToken.Lib"                                         'https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=2543&highlight=gettoken
$external Gettoken
Declare Function Gettoken(strinput As String , Byval Bseparator As Byte , Byval Bcount As Byte ) As String

Dim Sep As Byte
Dim Pozicija As Byte

'------------------------------------------------------------------------------
Dim Rdata As String * 150
Dim Data_key As Byte
Dim Znak As String * 15
Dim Init As String * 5

Dim Tekst As String * 255
Dim Prek As Bit
Dim Tekst1 As String * 5

Gosub Guio_ini

Enable Interrupts
'------------------------------------------------------------------------------
Do

  If Ischarwaiting() = 1 Then
   Gosub Read_data
  End If

Loop

End                                                         'end program

'------------------------------------------------------------------------------
 Read_data:
 Reset Watchdog
 Data_key = Inkey()
 If Data_key = "@" Then Input Rdata Noecho                  'reading string/command from GUI-O

Sep = &H20
Pozicija = 1
Znak = Gettoken(rdata , Sep , Pozicija)                     'parsing text postion-1, sign-space

If Znak = "bre1" Then                                       'if code appear
   Sep = &H20
   Pozicija = 2
   Tekst = Gettoken(rdata , Sep , Pozicija)

     Disable Timer1
     Print "@sj1 VIS:1"                                     'LED appear                                   '
     Print "@ta1 TXT:'" ; Tekst ; "'"                       'Show text
     Print "@ton1 EDUR:500"                                 'Phone vibra activateted for 200ms
     Wait 2
     Print "@sj1 VIS:0"                                     'LED disappear
     Enable Timer1
     Clear Serialin

   'End If
End If

Init = Mid(rdata , 1 , 4)
If Init = "init" Then                                       'initialization when GUI-O start
  Gosub Guio_ini
End If

Rdata = ""
Return

'-------------------------------------------------------------------------------
Guio_ini:
Disable Timer1
Print "@sls 50"
Print "@cls"
Print "@clh"
Print "@gse COD:0 TSC:39"
Print "@guis BGC:#000000 ASR:0.449671"
Print "|IM UID:imd X:50 Y:25 W:100 H:100 ROT:0 SHE:0 VIS:1 OPA:0.38 SCM:0 IP:'https://i.imgur.com/F5jECBr.jpg'"
Print "|LB UID:lbname X:8 Y:8 ALP:1 SHE:1 ROT:0 FGC:#FFFFFF FSZ:4 FFA:'font7' TXT:'QR code scanner'"
Print "|BRE UID:bre1 X:50 Y:55 W:90 H:30 VIS:1 OPA:1 FGC:#990000 BTH:0.8 BRP:1 BRCF:0"
Print "|LB UID:lb1 X:60 Y:38 ALP:1 SHE:1 ROT:0 FGC:#FFFFFF FSZ:2 URL:1 FFA:'font0' TXT:'www.gui-o.com'"
Print "|SI UID:sj1 X:91 Y:42 W:4 VIS:0 ROT:0 BGC:#B0C4DE FGC:#990000 SHE:0 EN:1"       'LEd Read

Print "|TON UID:ton1 HID:ton EDUR:1000 TONT:24"
Print "|TA UID:ta1 X:50 Y:80 W:80 H:20 VIS:1 BGC:#121212 FGC:#6D9DC5 SHE:1 FSZ:2 RAD:1.5 BSZ:250 CL:1 "
Print "@hls 20"
Enable Timer1
Return
'-------------------------------------------------------------------------------

Timer1_isr:
Load Timer1 , Timer1reload
Toggle Prek


  If Prek = 1 Then:
   Print "@bre1 BRCF:1"                                     'focus
  End If


  If Prek = 0 Then
    Print "@bre1 BRR:1"                                     'snapshot
  End If
Return
'-------------------------------------------------------------------------------
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6198
Location: Holland

blank.gif
PostPosted: Wed Mar 16, 2022 10:16 am    Post subject: Reply with quote

Thank you for sharing. It looks great. I worked with small scanners but they are expensive. This is a great solution.
Also thank you for the video. Very Happy

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

Bascom Member



Joined: 19 Jan 2012
Posts: 102
Location: Athens,Greece

greece.gif
PostPosted: Wed Mar 16, 2022 5:44 pm    Post subject: Reply with quote

interesting, as i understand QR reading is performed by android application and send bare text to mcu
_________________
Christos
Back to top
View user's profile
matjazs

Bascom Member



Joined: 08 Nov 2016
Posts: 104

PostPosted: Wed Mar 16, 2022 7:17 pm    Post subject: Reply with quote

Yes. This is an example. The read text can be sent from MCU via the serial port or the information can be used for anything else.

GUI-O is an application that also contains hardware components.

This means accelerometer, GPS, SMS, Vibra, speaker, photo, files, real time clock, ... https://www.gui-o.com/assets/gui-o_developer_manual.pdf

You need to install the GUI-O application https://play.google.com/store/apps/details?id=com.guio.guioapp
on your phone (Android device), connect to the MCU (bluetooth, USB, WiFi) and during the GUI-O initialization process tell
what you want on the screen (which widget) and what data you need from the Android device.
In some cases, it is similar like using Nextion display.

The MCU communicates via the RS232 serial port.
Very simple.
Back to top
View user's profile
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