Error : 5 Line : 161 No more space for BIT [PCF8574_LCD]

Pytania, kody i porady dotyczące nie tylko Bascom.
ODPOWIEDZ
Awatar użytkownika
elektrofil
Posty: 14
Rejestracja: 21 maja 2021, 15:13

Error : 5 Line : 161 No more space for BIT [PCF8574_LCD]

Post autor: elektrofil » 20 cze 2025, 12:53

Witam, z opisu błędu wnioskuję iż zabrakło zmiennych bitowych,nie potrafię naprawić tego błędu. i tutaj zwracam się do kolegów chociażby o wędkę a nie o rybę.
program ma mierzyć przebytą drogę na podstawie danych z gps neo6m.
  1. $regfile = "m328pbdef.dat"
  2. $crystal = 16000000
  3. $baud = 9600
  4. $hwstack = 64
  5. $swstack = 64
  6. $framesize = 64
  7. $lib "i2c_twi.lib"
  8. $lib "lcd_i2c_PCF8574.LIB"
  9.  
  10. Config Submode = New
  11.  
  12.  
  13. Dim Nmea As String * 80
  14. Dim Gpsline As String * 80
  15. Dim Field3 As String * 15
  16. Dim Field5 As String * 15
  17.  
  18. Dim Lat1 As Single , Lon1 As Single
  19. Dim Lat2 As Single , Lon2 As Single
  20. Dim Distance As Single , Totaldistance As Single
  21.  
  22. Dim Deg As Single , Minval As Single
  23. Dim Degstr As String * 10
  24. Dim Minstr As String * 10
  25. Dim Lenstr As Byte
  26. Dim Lensub As Byte
  27.  
  28. Dim Dlat As Single , Dlon As Single
  29. Dim A As Single , C As Single
  30. Dim X As Single
  31. Dim Pi As Single , R As Single
  32.  
  33. Dim P As Byte
  34. Dim Commacount As Byte
  35. Dim Startpos As Byte
  36. Dim Endpos As Byte
  37. Dim Fieldlen As Byte
  38. Dim Backlight As Byte : Backlight = 1
  39. Cls
  40. Cursor Off
  41.  
  42. Open "com1:" For Input As #1
  43.  
  44. Pi = 3.14
  45. R = 6371000
  46.  
  47. Do
  48.     If Eof(1) = 0 Then
  49.         Input #1 , Nmea
  50.         If Mid(nmea , 1 , 6) = "$GPRMC" Then
  51.             Gpsline = Nmea
  52.             Commacount = 0
  53.             Startpos = 1
  54.  
  55.             For P = 1 To Len(gpsline)
  56.                 If Mid(gpsline , P , 1) = "," Then
  57.                     Incr Commacount
  58.                     If Commacount = 3 Then
  59.                         Startpos = P
  60.                         Incr Startpos
  61.                     End If
  62.  
  63.                     If Commacount = 4 Then
  64.                         Endpos = P
  65.                         Decr Endpos
  66.                         Fieldlen = Endpos - Startpos
  67.                         Incr Fieldlen
  68.                         Field3 = Mid(gpsline , Startpos , Fieldlen)
  69.                     End If
  70.  
  71.                     If Commacount = 5 Then
  72.                         Startpos = P
  73.                         Incr Startpos
  74.                     End If
  75.  
  76.                     If Commacount = 6 Then
  77.                         Endpos = P
  78.                         Decr Endpos
  79.                         Fieldlen = Endpos - Startpos
  80.                         Incr Fieldlen
  81.                         Field5 = Mid(gpsline , Startpos , Fieldlen)
  82.                         Exit For
  83.                     End If
  84.                 End If
  85.             Next
  86.  
  87.             If Field3 <> "" And Field5 <> "" Then
  88.                 Lenstr = Len(field3)
  89.                 Lensub = Lenstr
  90.                 Lensub = Lensub - 7
  91.                 Degstr = Left(field3 , Lensub)
  92.                 Minstr = Right(field3 , 7)
  93.                 Deg = Val(degstr)
  94.                 Minval = Val(minstr)
  95.                 Lat2 = Minval / 60
  96.                 Lat2 = Lat2 + Deg
  97.  
  98.                 Lenstr = Len(field5)
  99.                 Lensub = Lenstr
  100.                 Lensub = Lensub - 7
  101.                 Degstr = Left(field5 , Lensub)
  102.                 Minstr = Right(field5 , 7)
  103.                 Deg = Val(degstr)
  104.                 Minval = Val(minstr)
  105.                 Lon2 = Minval / 60
  106.                 Lon2 = Lon2 + Deg
  107.  
  108.                 If Lat1 <> 0 And Lon1 <> 0 Then
  109.                     Lat2 = Lat2 * Pi
  110.                     Lat2 = Lat2 / 180
  111.                     Lat1 = Lat1 * Pi
  112.                     Lat1 = Lat1 / 180
  113.                     Dlat = Lat2 - Lat1
  114.  
  115.                     Lon2 = Lon2 * Pi
  116.                     Lon2 = Lon2 / 180
  117.                     Lon1 = Lon1 * Pi
  118.                     Lon1 = Lon1 / 180
  119.                     Dlon = Lon2 - Lon1
  120.  
  121.                     X = Dlat / 2
  122.                     A = Sin(x)
  123.                     A = A * A
  124.  
  125.                     X = Cos(lat1)
  126.                     X = X * Cos(lat2)
  127.                     Dlon = Dlon / 2
  128.                     X = X * Sin(dlon)
  129.                     X = X * Sin(dlon)
  130.  
  131.                     A = A + X
  132.                     X = 1 - A
  133.                     X = Sqr(x)
  134.                     A = Sqr(a)
  135.                     X = A / X
  136.  
  137.                     C = Atn(x)
  138.                     C = C * 2
  139.  
  140.                     Distance = R * C
  141.                     Totaldistance = Totaldistance + Distance
  142.                 End If
  143.  
  144.                 Lat1 = Lat2
  145.                 Lon1 = Lon2
  146.  
  147.                 Cls
  148.                 Locate 1 , 1
  149.                 Lcd "Dystans (m):"
  150.                 Locate 2 , 1
  151.                 Lcd Fusing(distance , "#.##")
  152.                 Locate 3 , 1
  153.                 Lcd "Calkowity:"
  154.                 Locate 4 , 1
  155.                 Lcd Fusing(totaldistance , "#.##")
  156.             End If
  157.         End If
  158.     End If
  159. Loop
  160.  
  161. End
Awatar użytkownika
niveasoft
Posty: 1313
Rejestracja: 17 sie 2015, 12:13
Kontakt:

Re: Error : 5 Line : 161 No more space for BIT [PCF8574_LCD]

Post autor: niveasoft » 23 cze 2025, 10:47

Pewnie nie widziałeś przykładu do tej biblioteki bo potrzebny jest tam bajt o nazwie "Pcf8574-lcd"
  1.  Dim Pcf8574_lcd As Byte : Pcf8574_lcd = &H7E            'PCF8574 slave address. (&H40,&H42,&H44,&H46,&H48,&H4A,&H4C,&H4E)
  2.  'Dim Backlight As Byte : Backlight = 1                   'LCD backlight control. (0: off, 1: on)
  3.  '$lib "lcd_i2c_PCF8574.LIB"                              'Incorporate the library of I2C LCD PCF8574 Adapter.
  4.  Config Lcd = 16x2
Co do drugiego błedu to "Eof" jest wbudowanym poleceniem Bascom dla AVR DOS i oznacza "End Of File"
Zmień to i się skompiluje.

Osobiscie to bym włączył Config Serialin0 = Buffered , Size = 128 i do tego musisz włączyć przerwania bo nic bez tego nie odbierze Enable Interrupts.
Potem zamiast tego "If Eof(1) = 0 Then" to wstaw "Ischarwaiting(#1) > 0 Then"
ODPOWIEDZ