Vielleich braucht ja wer diese Möglichkeit. Ich wollte mein Display in Portät Darstellung mit Text füllen.
Hab keine Funktion gefunden die dieses Display dazu bewegt es so darzustellen.
Hab auf eine Softwarelösung zurückgegriffen. Nachteil , sehr langsam.
Bei mir macht das nichts, ich benutze es nur um Spannungen anzuzeigen.
Original ist von Evert Dekker
Alles anzeigen
Hab keine Funktion gefunden die dieses Display dazu bewegt es so darzustellen.
Hab auf eine Softwarelösung zurückgegriffen. Nachteil , sehr langsam.
Bei mir macht das nichts, ich benutze es nur um Spannungen anzuzeigen.
Original ist von Evert Dekker
BASCOM-Quellcode
- ' Insanity
- ' Grafikdisplay KS108
- ' By Evert Dekker 2007 GraphicFont@Evertdekker dotje com
- $regfile = "m1284pdef.dat"
- $crystal = 20000000
- $hwstack = 128
- $swstack = 128
- $framesize = 64
- ' Spannungsteiler mit 15k zu 1k
- Const Spannungs_Fakor = 0.04
- ' Für Singlebearbeitung
- Config Single = SCIENTIFIC , Digits = 1
- 'Bibliothek für KS0108
- $lib "glcdKS108.lib"
- Config Graphlcd = 128 * 64sed , Dataport = Portc , Controlport = Portd , Ce = 5 , Ce2 = 4 , Cd = 1 , Rd = 2 , Reset = 0 , Enable = 3
- CLS
- Declare Sub Lcdtext(byval S As String , Byval Xoffset As Byte , Byval Yoffset As Byte , Byval Fontset As Byte , Byval Inverse As Byte , Byval Rotation As Byte)
- 'Lcdtest String , Xoffset , Yoffset , Fontset , Inverse , Rotation
- Wait 1
- ' Pulsweitenmodulation
- Config Timer2 = Pwm , Compare B Pwm = Clear Down , Prescale = 1
- Dim Analogwert As Integer
- Dim Dummy as String*10
- Dim Ergebnis as Single
- Declare Function Analog(byval Kanal As Byte , Byval Anzahl As Word ) As Word
- ' Analog
- Config Adc = Single , Prescaler = Auto , Reference = Internal_2.56
- Start Adc
- 'PWM - Displaybeleuchtung
- Config Portd.6 = Output
- 'LED
- Config Portd.7 = Output
- Portd.7 = 1 ' LED
- Pwm2b = 100
- Showpic 25 , 0 , Logo
- wait 2
- Cls
- Do
- Call LCDtext("Spannungs ",125,1,2,0,1)
- Call LCDtext(" Test",115,1,2,0,1)
- Analogwert = Analog(1,500)
- Call LCDtext("U1 =",100,1,2,0,1)
- Ergebnis = Analogwert * Spannungs_Fakor
- Dummy = " " + Str(Ergebnis,1)
- Dummy = Right(Dummy,4)+"V"
- Call LCDtext(Dummy,100,32,2,0,1)
- Analogwert = Analog(2,500)
- Call LCDtext("U2 =",85,1,2,0,1)
- Ergebnis = Analogwert * Spannungs_Fakor
- Dummy = " " + Str(Ergebnis,1)
- Dummy = Right(Dummy,4)+"V"
- Call LCDtext(Dummy,85,32,2,0,1)
- Analogwert = Analog(3,500)
- Call LCDtext("U3 =",70,1,2,0,1)
- Ergebnis = Analogwert * Spannungs_Fakor
- Dummy = " " + Str(Ergebnis,1)
- Dummy = Right(Dummy,4)+"V"
- Call LCDtext(Dummy,70,32,2,0,1)
- Analogwert = Analog(4,500)
- Call LCDtext("U4 =",55,1,2,0,1)
- Ergebnis = Analogwert * Spannungs_Fakor
- Dummy = " " + Str(Ergebnis,1)
- Dummy = Right(Dummy,4)+"V"
- Call LCDtext(Dummy,55,32,2,0,1)
- Analogwert = Analog(5,500)
- Call LCDtext("U5 =",40,1,2,0,1)
- Ergebnis = Analogwert * Spannungs_Fakor
- Dummy = " " + Str(Ergebnis,1)
- Dummy = Right(Dummy,4)+"V"
- Call LCDtext(Dummy,40,32,2,0,1)
- Call LCDtext("Me",10,50,2,0,1)
- Toggle Portd.7
- Loop
- End
- Function Analog(kanal , Anzahl)
- Local Xschleife As Word
- Local Xanalogmesswert As Word
- Local Xanalogmesswert_summe As Long
- Local Xanalog_mittel As Long
- If Anzahl =< 0 Then Anzahl = 1
- Xanalogmesswert_summe = 0
- For Xschleife = 1 To Anzahl
- Xanalogmesswert = Getadc(kanal)
- Xanalogmesswert_summe = Xanalogmesswert_summe + Xanalogmesswert
- Next
- Xanalog_mittel = Xanalogmesswert_summe / Anzahl
- Xanalogmesswert = Xanalog_mittel
- Analog = Xanalogmesswert
- End Function
- ' Routine Original von
- '------------------------------------------------------------------
- ' GRAPHIC FONT
- ' Use the Bascom font file's for all the graphic display's,
- ' include inverted and/or rotated text.
- ' By Evert Dekker 2007 GraphicFont@Evertdekker dotje com
- ' Created with Bascom-Avr: 1.11.8.8
- '------------------------------------------------------------------
- ' Habs angepasst das es mit 2.0.83 läuft
- Sub Lcdtext(byval S As String , Xoffset As Byte , Yoffset As Byte , Fontset As Byte , Inverse As Byte , Rotation As Byte)
- Local Tempstring As String * 1 , Temp As Byte 'Dim local the variables
- Local A As Byte , Pixels As Byte , Count As Byte , Carcount As Byte , Lus As Byte
- Local Row As Byte , Byteseach As Byte , Blocksize As Byte , Dummy As Byte
- Local Colums As Byte , Columcount As Byte , Rowcount As Byte , Stringsize As Byte
- Local Xpos As Byte , Ypos As Byte , Pixel As Byte , Pixelcount As Byte
- If Inverse > 1 Then Inverse = 0 'Inverse can't be greater then 1
- If Rotation > 3 Then Rotation = 0 'There are only 4 rotation's
- Stringsize = Len(s) - 1 'Size of the text string -1 because we must start with 0
- For Carcount = 0 To Stringsize 'Loop for the numbers of caracters that must be displayed
- If Fontset = 1 Then Restore Font8x8 'Add or remove here fontset's that you need or not,
- If Fontset = 2 Then Restore Font6x8 'If you dont know the name, open the font file in wordpad, and there it is,
- If Fontset = 3 Then Restore Font5x5 'right on top.
- Temp = Carcount + 1 'Cut the text string in seperate caracters
- Tempstring = Mid(s , Temp , 1)
- Read Row : Read Byteseach : Read Blocksize : Read Dummy 'Read the first 4 bytes from the font file
- Temp = Asc(tempstring) - 32 'Font files start with caracter 32
- For Lus = 1 To Temp 'Do dummie read to point to the correct line in the fontfile
- For Count = 1 To Blocksize
- Read Pixels
- Next Count
- Next Lus
- Colums = Blocksize / Row 'Calculate the numbers of colums
- Row = Row * 8 'Row is always 8 pixels high = 1 byte, so working with row in steps of 8.
- Row = Row - 1 'Want to start with row=0 instead of 1
- Colums = Colums - 1 'Same for the colums
- Select Case Rotation
- Case 0 '0 degrees rotation
- For Rowcount = 0 To Row Step 8 'Loop for numbers of rows
- A = Rowcount + Yoffset
- For Columcount = 0 To Colums 'Loop for numbers of Colums
- Read Pixels : If Inverse = 1 Then Toggle Pixels 'Read the byte from the file and if inverse = true then invert de byte
- Xpos = Columcount 'Do some calculation to get the caracter on the correct Xposition
- Temp = Carcount * Byteseach
- Xpos = Xpos + Temp
- Xpos = Xpos + Xoffset
- For PixelCount = 0 To 7 'Loop for 8 pixels to be set or not
- Ypos = A + PixelCount 'Each pixel on his own spot
- Pixel = Pixels.0 'Set the pixel (or not)
- Pset Xpos , Ypos , Pixel 'Finaly we can set the pixel
- Shift Pixels , Right 'Shift the byte 1 bit to the right so the next pixel comes availible
- incr Pixel
- Next
- Next Columcount
- Next Rowcount
- Case 1 '90 degrees rotation
- For Rowcount = Row To 0 Step -8 'Loop is now counting down
- A = Rowcount + Xoffset
- A = A - 15 'Correction to set Xpos on Xoffset with rotation
- For Columcount = 0 To Colums
- Read Pixels : If Inverse = 1 Then Toggle Pixels
- Xpos = Columcount
- Temp = Carcount * Byteseach
- Xpos = Xpos + Temp
- Xpos = Xpos + Yoffset 'We want that Xoffset is still Xoffset, so we need here the change from x to y
- For Pixelcount = 7 To 0 Step -1
- Ypos = A + Pixelcount
- Pixel = Pixels.0
- Pset Ypos , Xpos , Pixel
- Shift Pixels , Right
- incr Pixel
- Next
- Next Columcount
- Next Rowcount
- Case 2 '180 degrees rotation
- For Rowcount = Row To 0 Step -8
- A = Rowcount + Yoffset
- A = A - 7 'Correction to set Xpos on Xoffset with rotation
- For Columcount = Colums To 0 Step -1
- Read Pixels : If Inverse = 1 Then Toggle Pixels
- Xpos = Columcount
- Temp = Carcount * Byteseach
- Xpos = Xpos - Temp
- Xpos = Xpos - 8 'Correction to set Xpos on Xoffset with rotation
- Xpos = Xpos + Xoffset
- For Pixelcount = 7 To 0 Step -1
- Ypos = A + Pixelcount
- Pixel = Pixels.0
- Pset Xpos , Ypos , Pixel
- Shift Pixels , Right
- incr Pixel
- Next
- Next Columcount
- Next Rowcount
- Case 3 '270 degrees rotation
- For Rowcount = 0 To Row Step 8
- A = Rowcount + Xoffset
- For Columcount = Colums To 0 Step -1
- Read Pixels : If Inverse = 1 Then Toggle Pixels
- Xpos = Columcount
- Temp = Carcount * Byteseach
- Xpos = Xpos - Temp
- Xpos = Xpos - 8 'Correction to set Xpos on Xoffset with rotation
- Xpos = Xpos + Yoffset
- For Pixelcount = 0 To 7
- Ypos = A + Pixelcount
- Pixel = Pixels.0
- Pset Ypos , Xpos , Pixel
- Shift Pixels , Right
- incr Pixel
- Next
- Next Columcount
- Next Rowcount
- End Select
- Next Carcount
- End Sub 'End of this amazing subroutine
- Logo:
- $bgf "Ich_SW.bgf"
- $include "Font8x8.font"
- $include "Font6x8.font"
- $include "Font5x5.font"