GUI-O Zähler

    Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

    Aufgrund technischer Veränderungen ist der Mailverkehr innerhalb des Forums (Private Nachrichten) nur noch eingeschränkt möglich. Die Einschränkung ist notwendig, um zusätzliche Betriebskosten für das Forum zu vermeiden. Näheres zu den Hintergründen im Thread "Aktuelles zum Forum".Wir bitten um Verständnis.

    Hinweis kann nach Kenntnisnahme deaktiviert werden!

    • GUI-O Zähler

      Hier ist ein einfacher Zähler, der mit Bascom GUI-O für Smartphone und Arduino Nano erstellt wurde.

      Die Kommunikation zwischen Arduino und Smartphone erfolgt über das Bluetooth-Modul HC06.

      Das Display auf der HW ist SSD1306 und auf dem Smartphone.

      Anbei ein Screenshot des Telefons, ein Schema des Youtube-Clips und ein Bascom-Code.


      www.gui-o.com
      play.google.com/store/apps/details?id=com.guio.guioapp

      youtu.be/FNoWI_SyMOg

      BASCOM-Quellcode

      1. ' _____ _
      2. ' / ____| | |
      3. ' | | ___ _ _ _ __ | |_ ___ _ __
      4. ' | | / _ \| | | | '_ \| __/ _ \ '__|
      5. ' | |___| (_) | |_| | | | | || __/ |
      6. ' \_____\___/ \__,_|_| |_|\__\___|_|
      7. '------------------------------------------------------------------------------
      8. ' GUI-O V0.11.16 2021-11 www.gui-o.com
      9. '------------------------------------------------------------------------------
      10. ' .-----------------------.
      11. ' |ATMEGA328 Arduino nano |
      12. ' | |
      13. ' |Clock 16.000000 Hz |
      14. ' |GLCD SSD1306 |
      15. ' |gammda 2021-11-09 |
      16. ' '-----------------------'
      17. '-Hardware connection----------------------------------------------------------
      18. '********************************************************************
      19. '* Bluetooth Arduino Nano SSD1306 *
      20. '* .-------. .-----------. .-----------. *
      21. '* | HC06 | | Mega 328 | | | *
      22. '* | | | | | | *
      23. '* | | | | | | *
      24. '* | | | | | I2C | *
      25. '* | | TX PortC.1 | | '------|----' *
      26. '* | |--------------| | | *
      27. '* | | RX PortC.0 | | SCL-PortC.5 | *
      28. '* '-------' | |---------------| *
      29. '* | | SCL-PortC.4 *
      30. '* | | *
      31. '* Input | | *
      32. '* o------------| | *
      33. '* D3 PinD3 | | *
      34. '* '-----------' *
      35. '********************************************************************
      36. '$sim
      37. $regfile = "m328pdef.dat"
      38. $crystal = 16000000
      39. $baud = 9600
      40. $hwstack = 60
      41. $swstack = 60
      42. $framesize = 60
      43. Config Serialin = Buffered , Size = 120
      44. Open "comc.1:9600,8,n,1" For Output As #1 'software serial port Bluetooth
      45. Open "comc.0:9600,8,n,1" For Input As #2
      46. '===============================================================================
      47. ' ST1306 LCD I2c 128x64 test example
      48. '===============================================================================
      49. Config Scl = Portc.5 ' used i2c pins
      50. Config Sda = Portc.4
      51. Config Twi = 400000 ' i2c speed
      52. I2cinit
      53. $lib "i2c_twi.lbx" ' we do not use software emulated I2C but the TWI
      54. $lib "glcdSSD1306-I2C_V2.lib" ' override the default lib with this special one
      55. Dim _contrast As Byte ' Contrast value of OLED. [0-255]
      56. 'Const Ssd1306_rotate = 0 ' Display rotation. [connection cable is lower side = 0, upper side = 1] rotate display 180 degrees.
      57. Config Graphlcd = Custom , Cols = 128 , Rows = 64 , Lcdname = "SSD1306"
      58. Cls
      59. 'Gettoken LIB declaration (parsing text)----------------------------------------
      60. Dim Sep As Byte
      61. Dim Pozicija As Byte
      62. $lib "GetToken.Lib"
      63. $external Gettoken
      64. Declare Function Gettoken(strinput As String , Byval Bseparator As Byte , Byval Bcount As Byte ) As String
      65. '-Declaration port--------------------------------------------------------------
      66. Config Pind.3 = Input
      67. Set Portd.3
      68. Inp_ Alias Pind.3
      69. '-Logotip picture---------------------------------------------------------------
      70. Cls
      71. Setfont Font8x8
      72. Showpic 0 , 0 , Logoms
      73. Wait 4
      74. '-Define external interrupt INT1------------------------------------------------
      75. Config Int1 = Low Level 'Interruption on Falling
      76. On Int1 Count Nosave
      77. Disable Interrupts
      78. '-Variables---------------------------------------------------------------------
      79. Dim Ii As Dword
      80. Dim Iis As Single
      81. Dim Iist As String * 20
      82. Dim Iisf As String * 20
      83. Dim Bt_key As Byte
      84. Dim Znak As String * 15
      85. Dim Bdata As String * 60
      86. Cls
      87. '-Start definition-------------------------------------------------------------
      88. Setfont Font5x12
      89. Lcdat 1 , 1 , "COUNTER"
      90. Gosub Init_gui ' GUI-O initialization
      91. Iisf = Format(iist , "00000000") 'Counter Zero screen LCD
      92. Setfont Digital14x24
      93. Lcdat 3 , 1 , Iisf
      94. Print#1 , "@lbd TXT:'" ; Iisf ; "'" 'Counter Zero smart phone definition
      95. Enable Interrupts
      96. Enable Int1
      97. '-Main Loop--------------------------------------------------------------------
      98. Main:
      99. Do
      100. Disable Interrupts
      101. Gosub Read_data ' Read information from software seral port
      102. Enable Interrupts
      103. Loop
      104. End 'End application
      105. '--Init GUI-o -----------------------------------------------------------------
      106. '=Initialization objects on Smartphone=========================================
      107. Init_gui:
      108. Disable Int1
      109. Print #1 , "@sls 500"
      110. Print #1 , "@cls"
      111. Print #1 , "@clh"
      112. Print #1 , "@clo"
      113. Print #1 , "@gse COD:0 TSC:39"
      114. Print #1 , "@guis BGC:#696969 ASR:0.449671"
      115. Print #1 , "|SORI UID:sori1 HID:sori ORI:2 SEN:0"
      116. Print #1 , "|BSR UID:bsr2 X:50 Y:50 W:90 H:85 VIS:1 ROT:0 RAD:1.5 BGC:#d3d3d3 SBGC:#d3d3d3 FGC:#d3d3d3 SHE:1 BTH:0.5" 'background rectangle
      117. Print #1 , "|BSR UID:bsr3 X:55 Y:40 W:60 H:40 VIS:1 ROT:0 RAD:2 BGC:#000000 SBGC:#000000 FGC:#000000 SHE:1 BTH:0.5" ' backgroun display
      118. Print #1 , "|LB UID:lbd X:55 Y:40 ALP:0 SHE:1 ROT:0 FGC:#a22200 FSZ:20 FFA:'font2' TXT:'" ; Iisf ; "'" ' counter digital noumber
      119. Print #1 , "|LB UID:lb0 X:15 Y:15 ALP:0 SHE:1 ROT:0 FGC:#000000 FSZ:10 FFA:'font7' TXT:'Counter'" ' name of device
      120. Print #1 , "|LB UID:lbt1 X:9 Y:28 ALP:1 SHE:1 ROT:0 FGC:#0350a2 FSZ:7 FFA:'font0' TXT:'Power'" 'Text power
      121. Print #1 , "|LB UID:lbt2 X:9 Y:40.5 ALP:1 SHE:1 ROT:0 FGC:#0350a2 FSZ:7 FFA:'font0' TXT:'Pulse'" 'text pulse
      122. Print #1 , "|LB UID:lblog X:80 Y:88 ALP:1 SHE:1 ROT:0 URL:1 FGC:#0350a2 FSZ:4 FFA:'font0' TXT:'www.gui-o.com'" 'Text GUI-O home page
      123. Print #1 , "|SI UID:si1 X:21 Y:28 W:2.5 VIS:1 ROT:0 BGC:#B0C4DE FGC:#711700 SHE:1 EN:1" ' LED Power
      124. Print #1 , "|SI UID:si2 X:21 Y:40.5 W:2.5 VIS:1 ROT:0 BGC:#B0C4DE FGC:#711700 SHE:1 EN:0" 'LED Pulse
      125. Print #1 , "|BT UID:bt5 X:80 Y:75 W:8 H:16 SHE:1 ROT:0 RAD:0.5 BGC:#711700 SBGC:#711700 FGC:#FFFFFF FSZ:4 BTH:0 TXT:'RESET' SVAL:'reset'" 'Button reset
      126. Print #1 , "|BT UID:btqt X:13 Y:28 W:10 H:10 SHE:1 ROT:0 RAD:0.5 BGC:#00711700 SBGC:#00711700 FGC:#00FFFFFF FSZ:4 BTH:0 TXT:'Quit app' SVAL:'reset'" 'Button Quit- hidden on text "Counter"
      127. Print #1 , "@hls 200"
      128. Enable Int1
      129. Return
      130. '==============================================================================
      131. 'Reading data from serial port - from GUI-O keys (UID names)
      132. Read_data:
      133. Bt_key = Inkey(#2)
      134. If Bt_key = "@" Then Input #2 , Bdata Noecho
      135. Sep = &H20
      136. Pozicija = 1
      137. Znak = Gettoken(bdata , Sep , Pozicija)
      138. If Znak = "bt5" Then 'Key Reset counter
      139. Ii = 0
      140. Iis = Ii
      141. Iist = Str(ii)
      142. Iisf = Format(iist , "00000000")
      143. Setfont Digital14x24
      144. Lcdat 3 , 1 , Iisf
      145. Print#1 , "@lbd TXT:'" ; Iisf ; "'"
      146. Znak = " "
      147. End If
      148. If Znak = "btqt" Then
      149. Print #1 , "@quitapp" 'Quit application
      150. Znak = " "
      151. End If
      152. If Znak = "init" Then 'Start key Initialization
      153. Gosub Init_gui
      154. Znak = ""
      155. End If
      156. Znak = ""
      157. Bdata = ""
      158. Enable Int1
      159. Return
      160. '-Procedure for interrupt INT1--------------------------------------------------
      161. Count:
      162. Disable Interrupts
      163. Print #1 , "@si2 EN:1"
      164. If Inp_ = 0 Then
      165. Ii = Ii + 1
      166. While Inp_ = 0
      167. Wend
      168. End If
      169. Iist = Str(ii)
      170. Iisf = Format(iist , "00000000")
      171. Setfont Digital14x24
      172. Lcdat 3 , 1 , Iisf
      173. Print#1 , "@lbd TXT:'" ; Iisf ; "'"
      174. Print #1 , "@si2 EN:0"
      175. Enable Interrupts
      176. Return
      177. '-EEprom-----------------------------------------------------------------------
      178. R_eep:
      179. ' Readeeprom Ii , &H10 'In case saving data to EEPROM
      180. Return
      181. '-GLCD fonts / Logo picture----------------------------------------------------
      182. $include "Digital14x24.font"
      183. $include "font5x12.font"
      184. $include "font8x8.font"
      185. Logoms:
      186. $bgf "Logoh2o.bgf"
      187. '------------------------------------------------------------------------------
      Alles anzeigen
      mcselec.com/index2.php?option=…59&page=viewtopic&t=14869
      Dateien