» »

[Koda] Lcd od nokie 3310 in pic 18F877

[Koda] Lcd od nokie 3310 in pic 18F877

Azrael ::

V to temo sem prenesel kodo, ki jo je prilepil v temo Lcd od nokie 3310 in pic 18F877
uporabnik Nitro Tech, saj koda izvorno temo neprijetno podaljša in naredi nepregledno,
moderator.

' NOKIA 3310 LCD MODULE
      DEFINE LOADER_USED 1
      DEFINE OSC 20
  
      DC          VAR PortB.6
      DTA         VAR PortB.5
      RST         VAR PortB.7
      CLK         VAR PortB.4
  
      Chr         VAR Byte
      BitMap      VAR Word
      CharCount   VAR Byte
      PosX        VAR Byte
      PosY        VAR Byte
      Column      VAR Byte [6]
      LCDstr      VAR Byte [26]
      LcdData     VAR Byte
  
  PAUSE 100
  GOSUB LCD_INIT
  PAUSE 100
  GOSUB LCD_Clear
  
Start:
  PosX=0:PosY=0:GOSUB LCD_GotoXY

  FOR Chr=0 TO 13
      LOOKUP Chr,["NOKIA LCD TEST"],BitMap
      LCDstr(Chr)=BitMap
  NEXT Chr
  GOSUB LCD_StringOut
  
  PosX=0:PosY=1:GOSUB LCD_GotoXY
  FOR Chr=0 TO 13
      LOOKUP Chr,["   GRAPHICS   "],BitMap
      LCDstr(Chr)=BitMap
  NEXT Chr
  GOSUB LCD_StringOut
  
  PosX=0:PosY=2:GOSUB LCD_GotoXY
  FOR Chr=0 TO 13
      LOOKUP Chr,[" 84X48 PIXELS "],BitMap
      LCDstr(Chr)=BitMap
  NEXT Chr
  GOSUB LCD_StringOut
  
  PosX=0:PosY=3:GOSUB LCD_GotoXY
  FOR Chr=0 TO 13
      LOOKUP Chr,["  CONTROLLED  "],BitMap
      LCDstr(Chr)=BitMap
  NEXT Chr
  GOSUB LCD_Stringout
  
  PosX=0:PosY=4:GOSUB LCD_GotoXY
  FOR Chr=0 TO 13
      LOOKUP Chr,["      BY      "],BitMap
      LCDstr(Chr)=BitMap
  NEXT Chr
  GOSUB LCD_Stringout
  
  PosX=0:PosY=5:GOSUB LCD_GotoXY
  FOR Chr=0 TO 13
      LOOKUP Chr,[" PICBASIC PRO "],BitMap
      LCDstr(Chr)=BitMap
  NEXT Chr
  GOSUB LCD_Stringout
  
Loop:
  PAUSE 2000
  LOW DC
  LcdData= %00001101:GOSUB LCD_ByteOut     ' Invert
  PAUSE 2000
  LcdData= %00001000:GOSUB LCD_ByteOut     ' Blank
  PAUSE 2000
  LcdData= %00001100:GOSUB LCD_ByteOut     ' Normal
  GOTO loop
  
LCD_Init:

  LOW RST :pause 20 : HIGH RST : LOW DC  ' RESET LCD
  
  LcdData= $21: GOSUB LCD_ByteOut        ' LCD EXTENDED COMMANDS
  LcdData= $c8: GOSUB LCD_ByteOut        ' SET LCD Vop (CONTRAST)
  LcdData= $06: GOSUB LCD_ByteOut        ' SET TEMP COEFFICENT
  LcdData= $13: GOSUB LCD_ByteOut        ' LCD BIAS MODE
  LcdData= $20: GOSUB LCD_ByteOut        ' LCD STANDARD COMMANDS
  LcdData= $0c: GOSUB LCD_ByteOut        ' LCD IN NORMAL MODE
RETURN
  
LCD_ByteOut:
  SHIFTOUT DTA,CLK,1,[LcdData]
RETURN
  
LCD_CharOut:
  IF lcddata=32 THEN BitMap=216             ' SPACE
  IF lcddata=42 THEN BitMap=240             ' *
  IF lcddata=43 THEN BitMap=222             ' +
  IF lcddata=45 THEN BitMap=228             ' -
  IF lcddata=46 THEN BitMap=234             ' .
  IF lcddata=58 THEN BitMap=246             ' :
  
  IF LCDData > 47  THEN                     ' Numbers 0-9
     IF lcddata < 59 THEN
        BitMap=6*(lcddata-48)+156
       ELSE                                   ' Capital Letters A-Z
        BitMap=(LcdData-65) * 6
     ENDIF
  ENDIF
  
  FOR Chr=0 TO 5
      READ BitMap+Chr,Column(Chr)
  NEXT Chr
  HIGH DC
  SHIFTOUT DTA,CLK,1,[Column(0),Column(1),Column(2),Column(3),Column(4),Column(5)]
RETURN
  
LCD_StringOut:
  FOR CharCount=0 TO 13
      LcdData=LCDstr(CharCount)
      PAUSE 80
      GOSUB LCD_CharOut
  NEXT CharCount
RETURN
  
LCD_Clear:
  PosX=0:PosY=0:GOSUB LCD_GotoXY
  HIGH DC
  FOR Chr=1 TO 252
      LcdData=0:GOSUB LCD_ByteOut
      LcdData=0:GOSUB LCD_ByteOut
  NEXT Chr
RETURN
  
LCD_GotoXY:
  LOW DC
  LcdData=%01000000 | PosY :GOSUB LCD_ByteOut
  LcdData=%10000000 | PosX :GOSUB LCD_ByteOut
RETURN

'=============================================================================
' Font tabela

CData $00,$00,$00,$00,$00,$00	'stevilka nič
CData $FF,$FF,$FF,$FF,$FF,$FF	'stevilka ena
CData $07,$07,$07,$00,$00,$00	'stevilka dva
'in tako naprej...

' Če hočeš prikazati kakšen alfanumerični znak rabiš še font tabelo z njihovimi hex kodami, ki pa je cela predolga da bi jo tukaj objavljal.
'=====================================================================
END

Nekoč je bil Slo-tech.
  • zaklenil: Azrael ()


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

[Java] Zasnova shoot em up igre

Oddelek: Programiranje
111200 (879) PecenkA
»

Leteče luči; AT90S2313, AT89C2051

Oddelek: Elektrotehnika in elektronika
122492 (2313) Red_Mamba
»

[Win32 API]Popup menu v taskbaru

Oddelek: Programiranje
6949 (906) 64202
»

Drop down meni!

Oddelek: Izdelava spletišč
101953 (1706) ACE
»

Collision detection

Oddelek: Programiranje
81937 (1689) Senitel

Več podobnih tem