Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

4D systems Visi-Genie library V1.0

 
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
Pikczu

Bascom Member



Joined: 22 Jan 2006
Posts: 62
Location: Dublin, Ireland

ireland.gif
PostPosted: Sun Nov 03, 2019 6:09 pm    Post subject: 4D systems Visi-Genie library V1.0 Reply with quote

Hi All,
I would like to share 4D systems Visi-Genie library for Bascom AVR.
The library as the *.INC file.
Library contains:
'Function Xor_this()
'Sub 4d_uart_rx()
'Sub 4d_read_obj_sub( )
'Sub 4d_write_obj()
'Sub 4d_write_contrast( )
'Sub 4d_write_str_old( ) for bascom version before 2.0.8.2
'Sub 4d_write_str( ) for bascom version 2.0.8.2 and above

I still have to add:
Write_stru' Unicode string simply I did not use Unicode so did not write it
Write_magic bytes' used with an extra license for worksho4 pro
Write_magic Dbytes ' used with an extra license for worksho4 pro
Report_Magic_event_bytes 'used with an extra license for worksho4 pro
Report_Magic_event_Dbytes 'used with an extra license for worksho4 pro

In the attachment below you can find table with the commands.
Zipped library, and zipped demo for Xmega128A3U.

I could not paste the code looks like i have reached the characters limit per post.

Regards
Pawel aka Pikczu
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 871
Location: France

france.gif
PostPosted: Mon Nov 04, 2019 11:48 am    Post subject: Reply with quote

Hi Pawel
Thanks fo sharing
Can you send us a video or a image ?
what type of screen did you use?
how does 4D system communicate?
Serial, I2C, Spi ...?

JP Wink

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 4824
Location: Holland

blank.gif
PostPosted: Mon Nov 04, 2019 1:02 pm    Post subject: Reply with quote

thank you for sharing Very Happy

I think this lib can benefit from a variable printbin. like done for inputbin.
So i will add that.

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

Bascom Member



Joined: 22 Jan 2006
Posts: 62
Location: Dublin, Ireland

ireland.gif
PostPosted: Mon Nov 04, 2019 10:07 pm    Post subject: Reply with quote

Hi JP, Mark and All.

Duval JP wrote:
Hi Pawel
Thanks, fo sharing
Can you send us a video or a image?
what type of screen did you use?
how does 4D system communicate?
Serial, I2C, Spi ...?
JP Wink

I have the 7 inch with capacitive touch screen, the model is GEN4-70DCT-CLB.
You can get more details from the link below:
https://4dsystems.com.au/products/4d-intelligent-hmi-display-modules/sk-gen4-70dct-clb
Display communicates with the host over serial port.
But there is also 30Pin ZIF connector with number of pins available for the user.
The most important part is the IDE which comes with four different environments.
https://4dsystems.com.au/workshop4

Quote:
Designer:
This environment enables the user to write 4DGL code in its natural form to program the display module.[/i]
ViSi - Genie:
An advanced environment that does not require any 4DGL coding at all. Everything is done automatically for you. Simply lay the display out with the objects you want (similar to ViSi), set the events to drive them and the code is written for you automatically. ViSi-Genie provides the latest rapid development experience from 4D Systems.
ViSi:
A visual programming experience that enables drag-and-drop type placement of objects to assist with 4DGL code generation and allows the user to visualise how the display will look while being developed.
Serial:
This environment is also provided to transform the display module into a slave serial display module. It allows the user to control the display from any host microconroller or device with a serial port.


The Bascom Library is for Visi Genie - that means you can just create the layout in the workshop4 and use serial to send commands. There is no need to write even one line of the code in workshop4 IDE.

What ever layout you create can be tested from the ide:





albertsm wrote:
thank you for sharing Very Happy

I think this lib can benefit from a variable printbin. like done for inputbin.
So i will add that.


I have created two version of the sub for sending the strings, one for the older version:

Code:
Sub 4d_write_str_old(byval 4d_str_indx As Byte , Byval 4d_string_tmp As String )
'*******************************************************************************
'Syntax: Call 4d_write_str_old(index hex value , "your text" )
'The body of the command is:
'comand_code+ string_index+ string_length + string + xorcrc
'For more info refer to Visi Genie reference manual page 8 section 3.1.3.3
'*******************************************************************************
   Local Index_help_a As Byte                               'used to calculate the length of the string
   Dim Tot_command_len As Byte                              'total command length
 
   Tot_command_len = Len(4d_string_tmp) + 4                 'total = string + string length byte + command byte + string index byte used for calculating crc
   Print #debug_port , "total command length =" ; Tot_command_len
   4d_string_tx = 4d_string_tmp                             'copy the string in to variable overlaid at array
   4d_string_tx_arr(1) = Write_str                          '&h02 write string command
   4d_string_tx_arr(2) = 4d_str_indx                        'index of the string
   4d_string_tx_arr(3) = Len(4d_string_tmp)                 'length of the original string
 
   For Index_help_a = 1 To Tot_command_len -1               'we need to xor this and assign at the end
   'the minus (-)1 skip xor of the null termination
      4d_string_tx_arr(tot_command_len) = 4d_string_tx_arr(tot_command_len) Xor 4d_string_tx_arr(index_help_a)
   Next Index_help_a
   Index_help_a = 0
   Select Case Tot_command_len                              ' total command length
      Case 5:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 5     'code +string index+ string length +  1 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 5         'code +string index+ string length +  1 char + crc
      Case 6:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 6     'code +string index+ string length +  2 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 6         'code +string index+ string length +  2 char + crc
      Case 7:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 7     'code +string index+ string length +  3 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 7         'code +string index+ string length +  3 char + crc
      Case 8:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 8     'code +string index+ string length +  4 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 8         'code +string index+ string length +  4 char + crc
      Case 9:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 9     'code +string index+ string length +  5 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) , 9         'code +string index+ string length +  5 char + crc
      Case 10:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 10    'code +string index+ string length +  6 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 10        'code +string index+ string length +  6 char + crc
      Case 11:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 11    'code +string index+ string length +  7 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 11        'code +string index+ string length +  7 char + crc
      Case 12:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 12    'code +string index+ string length +  8 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 12        'code +string index+ string length +  8 char + crc
      Case 13:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 13    'code +string index+ string length +  9 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 13        'code +string index+ string length +  9 char + crc
      Case 14:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 14    'code +string index+ string length +  10 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 14        'code +string index+ string length +  10 char + crc
      Case 15:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 15    'code +string index+ string length +  11 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 15        'code +string index+ string length +  11 char + crc
      Case 16:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 16    'code +string index+ string length +  12 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 16        'code +string index+ string length +  12 char + crc
      Case 17:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 17    'code +string index+ string length +  13 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 17        'code +string index+ string length +  13 char + crc
      Case 18:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 18    'code +string index+ string length +  14 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 18        'code +string index+ string length +  14 char + crc
      Case 19:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 19    'code +string index+ string length +  15 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 19        'code +string index+ string length +  15 char + crc
      Case 20:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 20    'code +string index+ string length +  16 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 20        'code +string index+ string length +  16 char + crc
      Case 21:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 21    'code +string index+ string length +  17 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 21        'code +string index+ string length +  17 char + crc
      Case 22:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 22    'code +string index+ string length +  18 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 22        'code +string index+ string length +  18 char + crc
      Case 23:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 23    'code +string index+ string length +  19 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 23        'code +string index+ string length +  19 char + crc
      Case 24:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 24    'code +string index+ string length +  20 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 24        'code +string index+ string length +  20 char + crc
      Case 25:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 25    'code +string index+ string length +  21 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 25        'code +string index+ string length +  21 char + crc
      Case 26:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 26    'code +string index+ string length +  22 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 26        'code +string index+ string length +  22 char + crc
      Case 27:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 27    'code +string index+ string length +  23 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 27        'code +string index+ string length +  23 char + crc
      Case 28:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 28    'code +string index+ string length +  24 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 28        'code +string index+ string length +  24 char + crc
      Case 29:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 29    'code +string index+ string length +  25 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 29        'code +string index+ string length +  25 char + crc
      Case 30:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 30    'code +string index+ string length +  26 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 30        'code +string index+ string length +  26 char + crc
      Case 31:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 31    'code +string index+ string length +  27 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 31        'code +string index+ string length +  27 char + crc
      Case 32:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 32    'code +string index+ string length +  28 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 32        'code +string index+ string length +  28 char + crc
      Case 33:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 33    'code +string index+ string length +  29 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 33        'code +string index+ string length +  29 char + crc
      Case 34:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 34    'code +string index+ string length +  30 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 34        'code +string index+ string length +  30 char + crc
      Case 35:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 35    'code +string index+ string length +  31 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 35        'code +string index+ string length +  31 char + crc
      Case 36:
         Printbin #debug_port , 4d_string_tx_arr(1) ; 36    'code +string index+ string length +  32 char + crc
         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 36        'code +string index+ string length +  32 char + crc
   End Select
   ACK_NACK_flag.0 = 1                                      'ACK flag set to busy
   While ACK_NACK_flag <> 0                                 'while waiting for response from the display
      Incr 4d_wait_count                                    'just to idicate how long will this take
      Call 4d_uart_rx                                       'check the Uart
      if ACK_NACK_flag.1 = 1 then                           'NAK received form the display
         Printbin #lcd_4d , 4d_arr_tx(1) ; 4                ' reapet previous transmision
         ACK_NACK_flag.1 = 0                                'Clear NACK flag and check again for ACK or NACK
      end if
   Wend
  'Printbin #lcd_4d , 4d_string_tx_arr(1) , Tot_command_len 'code +string index+ string length +  1 char + crc
   Debug 4d_string_tx_arr(1) , Tot_command_len              'code +string index+ string length +  1 char + crc
   4d_wait_count = 0
 
End Sub


And one for the new version of the printbin with variable length:

Code:
Sub 4d_write_str(byval 4d_str_indx As Byte , Byval 4d_string_tmp As String )
'*******************************************************************************
'Syntax: Call 4d_write_str(index hex value , "your text" )
'The body of the command is:
'comand_code + string_index+ string_length + string + xorcrc
'For more info refer to Visi Genie reference manual page 8 section 3.1.3.3
'*******************************************************************************
   Local Index_help_a As Byte                               'used to calculate the lengt of the string
   Dim Tot_command_len As Byte                              'total command length
   Tot_command_len = Len(4d_string_tmp) + 4                 'total = string + string length byte + command byte + string index byte used for calculating crc
   Print #debug_port , "total command length =" ; Tot_command_len
   4d_string_tx = 4d_string_tmp                             'copy the string in to variable overlaid at array
   4d_string_tx_arr(1) = Write_str                          '&h02 write string command
   4d_string_tx_arr(2) = 4d_str_indx                        'index of the string
   4d_string_tx_arr(3) = Len(4d_string_tmp)                 'length of the original string
   For Index_help_a = 1 To Tot_command_len -1               'we need to xor this and assign at the end
   'the minus (-)1 skip xor of the null termination
      4d_string_tx_arr(tot_command_len) = 4d_string_tx_arr(tot_command_len) Xor 4d_string_tx_arr(index_help_a)
   Next Index_help_a
   Index_help_a = 0
   Printbin #debug_port , 4d_string_tx_arr(1) , Tot_command_len       'code +string index+ string length +  1 char + crc
   Printbin #lcd_4d , 4d_string_tx_arr(1) , Tot_command_len 'code +string index+ string length +  1 char + crc
   ACK_NACK_flag.0 = 1                                      'ACK flag set to busy
   While ACK_NACK_flag <> 0                                 'while waiting for response from the display
      Incr 4d_wait_count                                    'just to indicate how long will this take
      Call 4d_uart_rx                                       'check the Uart
      if ACK_NACK_flag.1 = 1 then                           'NAK received from the display
         Printbin #lcd_4d , 4d_arr_tx(1) ; 4                ' repeat previous transmission
         ACK_NACK_flag.1 = 0                                'Clear NACK flag and check again for ACK or NACK
      end if
   Wend
  'Printbin #lcd_4d , 4d_string_tx_arr(1) , Tot_command_len 'code +string index+ string length +  1 char + crc
   Debug 4d_string_tx_arr(1) , Tot_command_len              'code +string index+ string length +  1 char + crc
   4d_wait_count = 0
 
End Sub


I'm planning to tweak the code in the near future.
Currently, sub is waiting for the ACK command from the display, this is a massive time waste.
But that is the manufacturer recommendation not to send more date before ACK is received from the display.

Code:
Printbin #lcd_4d , 4d_arr_tx(1) ; 6                      'print binary  the final result
   'Printbin #debug_port , 4d_arr_tx(1) ; 6                  'print binary  the final result to debug port
   ACK_NACK_flag.0 = 1                                      'ACK flag set to busy
   While ACK_NACK_flag <> 0                                 'while waiting for response from the display
      Incr 4d_wait_count                                    'just to indicate how long will this take
      Call 4d_uart_rx                                       'check the Uart
      if ACK_NACK_flag.1 = 1 then                           'NAK received from the display
         Printbin #lcd_4d , 4d_arr_tx(1) ; 4                ' repeat previous transmission
         ACK_NACK_flag.1 = 0                                'Clear NACK flag and check again for ACK or NACK
      end if
   Wend
         'Print #debug_port , "Waiting for the response counter: " ; 4d_wait_count
   Debug "Waiting for the response counter: " ; 4d_wait_count
   4d_wait_count = 0


Regards
Pawel aka Pikczu
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 871
Location: France

france.gif
PostPosted: Tue Nov 05, 2019 11:46 am    Post subject: Reply with quote

hello
it's impressive ! you win a Guiness !
Wink
jp

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 4824
Location: Holland

blank.gif
PostPosted: Tue Nov 05, 2019 3:44 pm    Post subject: Reply with quote

thank you for the additional info.
Indeed, it is very impressive !
Seems simple enough too.

thanks again for sharing your lib. Very Happy

_________________
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