Mam program, którym odczytywałem kiedyś ID DS18B20 przy użyciu zwykłego wyświetlacza LCD 16X2 i wszystko działało.
Chciałem dziś odczytać tym samym programem ale przy użyciu wyświetlacza OLED i niby odczytuje ID, ale wszystkie 8 części tego numery bardzo szybko wyświetla w jednym miejscu na 2 znakach.
W załączeniu ten mój kod. Prośba do Was o podpowiedź co jest nie tak w tym przypadku
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- $Regfile="m32adef.dat"
- $Crystal=8000000
- $hwstack=40
- $swstack=16
- $framesize=32
- '
- ' * OLED Initial Settings *
- '
- Const Rotate_180 = 0 'OLED screen installation direction (180degree rotation).
- ' (Connector: 0 = Right side, 1 = Left side)
- Const Spi_wire_selection = 4 'Select the number of lines for SPI connection.
- ' (3 = 3-wire: drawing spd low, 4 = 4-wire: drawing spd high)
- '
- $lib "glcdSSD1322-SPI.lib" 'Embedded SSD1322 3.12inch 256x64 SPI library.
- ' Specifies the connection port for OLED. Cs1 = [/CS] , Rst = [/RES] , A0 = [D/C] , Si = [SDIN] , Sclk = [SCLK]
- Config Graphlcd = Color , Cs1 = Portc.6 , Rst = Portc.5 , A0 = Portc.4 , Si = Portc.3 , Sclk = Portc.2 '[Cs1]&[Rst] optional.
- ' Character drawing commands : [Lcdat Y , X , Character , FG , BG]
- ' Y = Y(row) address (0 - 63) , X = X(column) address (0 - 255) , Character = String or variable to display
- ' FG = Foreground Grayscale Value (0 - 15) , BG = Background Grayscale Value (0 - 15) / (0:dark - 15:bright)
- ' Note: Since the SSD1322 writes 4-bit grayscale data in word units, set the X address in 4-dot intervals. (ex. 0,4,8 - 248,252)
- ' Command to draw BGC image data in RLE compressed format : [Showpic X , Y , label]
- ' X = X(column) address (0 - 255), Y = Y (row)address (0 - 63), label = label of image data to display.
- ' See the help for SHOWPIC command.
- ' To create RLE compressed BGC image data from BMP images, use the LCD RGB-8 converter [LCDconvert.exe].
- ' Below is a table that maps 8-bit BGC format RGB8 code (RRRG_GGBB) to a 4-bit grayscale brightness value (0 - 15).
- Const _bgc_r2 = &B0000_1000 'BGC RGB8 code [Red2]
- Const _bgc_r1 = &B0000_0000 'BGC RGB8 code [Red1]
- Const _bgc_r0 = &B0000_0000 'BGC RGB8 code [Red0]
- Const _bgc_g2 = &B0000_0100 'BGC RGB8 code [Green2]
- Const _bgc_g1 = &B0000_0000 'BGC RGB8 code [Green1]
- Const _bgc_g0 = &B0000_0000 'BGC RGB8 code [Green0]
- Const _bgc_b1 = &B0000_0010 'BGC RGB8 code [Blue1]
- Const _bgc_b0 = &B0000_0000 'BGC RGB8 code [Blue0]
- ' By default, the intermediate luminance value for each of the colors R,G,B is the lower 4bits(0-15) of the grayscale luminance value.
- ' Adjust the grayscale to match the color scheme of the original image.
- '
- ' *****************
- ' * Drawing Tests *
- ' *****************
- '
- Glcdcmd &HC1 : Glcddata 30 'Contrast setting. (0-255)
- Glcdcmd &HAF
- Glcdcmd &HA6
- 'Konfiguracja 1-WIRE dla DS18B20
- Config 1wire = PortD.7
- Dim Dsid(8) As Byte
- Dim Dsid1(8) As Byte
- Dsid(1) = 1wsearchfirst()
- Dsid1(1) = 1wsearchnext()
- Dim B As Byte
- Do
- Setfont Color8x8
- Lcdat 5 , 0 , "ID DS18B20 (hex)" , 15 , 0
- If Dsid(8) = Crc8(dsid(1) , 7) Then
- For B = 1 To 8
- Lcdat 20 , 10 , Hex(dsid(b)) , 15 , 0 ' Wyświetlenie ID czujnika DS18B20 w postaci HEX
- Next
- End If
- Loop
- End
- $INCLUDE "color8x8.font"
- $INCLUDE "color16x16.font"
Oto kod działający na OLED:
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- $Regfile="m32adef.dat"
- $Crystal=8000000
- $hwstack=40
- $swstack=16
- $framesize=32
- '
- ' * OLED Initial Settings *
- '
- Const Rotate_180 = 0 'OLED screen installation direction (180degree rotation).
- ' (Connector: 0 = Right side, 1 = Left side)
- Const Spi_wire_selection = 4 'Select the number of lines for SPI connection.
- ' (3 = 3-wire: drawing spd low, 4 = 4-wire: drawing spd high)
- '
- $lib "glcdSSD1322-SPI.lib" 'Embedded SSD1322 3.12inch 256x64 SPI library.
- ' Specifies the connection port for OLED. Cs1 = [/CS] , Rst = [/RES] , A0 = [D/C] , Si = [SDIN] , Sclk = [SCLK]
- Config Graphlcd = Color , Cs1 = Portc.6 , Rst = Portc.5 , A0 = Portc.4 , Si = Portc.3 , Sclk = Portc.2 '[Cs1]&[Rst] optional.
- ' Character drawing commands : [Lcdat Y , X , Character , FG , BG]
- ' Y = Y(row) address (0 - 63) , X = X(column) address (0 - 255) , Character = String or variable to display
- ' FG = Foreground Grayscale Value (0 - 15) , BG = Background Grayscale Value (0 - 15) / (0:dark - 15:bright)
- ' Note: Since the SSD1322 writes 4-bit grayscale data in word units, set the X address in 4-dot intervals. (ex. 0,4,8 - 248,252)
- ' Command to draw BGC image data in RLE compressed format : [Showpic X , Y , label]
- ' X = X(column) address (0 - 255), Y = Y (row)address (0 - 63), label = label of image data to display.
- ' See the help for SHOWPIC command.
- ' To create RLE compressed BGC image data from BMP images, use the LCD RGB-8 converter [LCDconvert.exe].
- ' Below is a table that maps 8-bit BGC format RGB8 code (RRRG_GGBB) to a 4-bit grayscale brightness value (0 - 15).
- Const _bgc_r2 = &B0000_1000 'BGC RGB8 code [Red2]
- Const _bgc_r1 = &B0000_0000 'BGC RGB8 code [Red1]
- Const _bgc_r0 = &B0000_0000 'BGC RGB8 code [Red0]
- Const _bgc_g2 = &B0000_0100 'BGC RGB8 code [Green2]
- Const _bgc_g1 = &B0000_0000 'BGC RGB8 code [Green1]
- Const _bgc_g0 = &B0000_0000 'BGC RGB8 code [Green0]
- Const _bgc_b1 = &B0000_0010 'BGC RGB8 code [Blue1]
- Const _bgc_b0 = &B0000_0000 'BGC RGB8 code [Blue0]
- ' By default, the intermediate luminance value for each of the colors R,G,B is the lower 4bits(0-15) of the grayscale luminance value.
- ' Adjust the grayscale to match the color scheme of the original image.
- '
- ' *****************
- ' * Drawing Tests *
- ' *****************
- '
- Glcdcmd &HC1 : Glcddata 30 'Contrast setting. (0-255)
- Glcdcmd &HAF
- Glcdcmd &HA6
- 'Konfiguracja 1-WIRE dla DS18B20
- Config 1wire = PortD.7
- Dim Dsid(8) As Byte
- Dim Dsid1(8) As Byte
- Dsid(1) = 1wsearchfirst()
- Dsid1(1) = 1wsearchnext()
- Dim B As Byte
- Do
- Setfont Color8x8
- Lcdat 5 , 0 , "ID DS18B20 (hex)" , 15 , 0
- If Dsid(8) = Crc8(dsid(1) , 7) Then
- For B = 1 To 1
- Lcdat 20 , 0 , Hex(dsid(b)) , 15 , 0 ' Wyświetlenie ID czujnika DS18B20 w postaci HEX
- Next
- End If
- For B = 2 To 2
- Lcdat 20 , 20 , Hex(dsid(b)) , 15 , 0
- next
- ' end if
- For B = 3 To 3
- Lcdat 20 , 40 , Hex(dsid(b)) , 15 , 0
- next
- ' end if
- For B = 4 To 4
- Lcdat 20 , 60 , Hex(dsid(b)) , 15 , 0
- next
- ' end if
- For B = 5 To 5
- Lcdat 20 , 80 , Hex(dsid(b)) , 15 , 0
- next
- ' end if
- For B = 6 To 6
- Lcdat 20 , 100 , Hex(dsid(b)) , 15 , 0
- next
- ' end if
- For B = 7 To 7
- Lcdat 20 , 120 , Hex(dsid(b)) , 15 , 0
- next
- ' end if
- For B = 8 To 8
- Lcdat 20 , 140 , Hex(dsid(b)) , 15 , 0
- next
- ' end if
- Loop
- End
- $INCLUDE "color8x8.font"
- $INCLUDE "color16x16.font"
