Nokia 3310 Lcd Library for MikroPascal

General discussion on mikroPascal.
Post Reply
Author
Message
poke53280
Posts: 5
Joined: 27 Sep 2014 10:32

Nokia 3310 Lcd Library for MikroPascal

#1 Post by poke53280 » 27 Aug 2015 19:11

I will try for the first time with GLCD in mikropascal.

I have two 3310 Lcds, and I want to use. Because it is more than enough for my project.

Does anybody have the latest version of full 3310 pascal Library ?

I'm not sure, but i think ascii.pas and bitmap.pas required too.

I can use 16f628 or 16f887.

Thank you very much in advance, if you are shared with me.

User avatar
viktor.milovanovic
Posts: 240
Joined: 08 Jun 2015 10:09

Re: Nokia 3310 Lcd Library for MikroPascal

#2 Post by viktor.milovanovic » 28 Aug 2015 15:44

Hello,

There used to be posted some libraries on these topics:
http://www.mikroe.com/forum/viewtopic.php?t=2015
https://www.mikroe.com/forum/viewtopic.php?f=10&t=17259

But it seems the links posted there are dead.
If anyone of the forum users has the library on their desktop and is willing to share, they are more than welcome.

Best regards,

Viktor Milovanovic

poke53280
Posts: 5
Joined: 27 Sep 2014 10:32

Re: Nokia 3310 Lcd Library for MikroPascal

#3 Post by poke53280 » 05 Sep 2015 20:00

viktor.milovanovic, thanks.

Unfortunately dead links, I could not find anywhere.

I'm still waiting this library...

corado
Posts: 399
Joined: 28 Mar 2009 11:03

Re: Nokia 3310 Lcd Library for MikroPascal

#4 Post by corado » 22 Sep 2019 11:26

do you have found any?

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Nokia 3310 Lcd Library for MikroPascal

#5 Post by Dany » 22 Sep 2019 19:24

Hi, I have something, I do know anymore where it came from:

The library:

Code: Select all

unit Nokia_3310_5110;

// interface

procedure InitLcd;
procedure SetContrast(Contrast: byte);
procedure Lcd_clr;
procedure Lcd_command(command_: byte);
procedure Lcd_char(data_: byte);
procedure LCD_Text(var Text: string);
procedure Lcd_CharInvert;
procedure Lcd_CharNormal;
procedure Lcd_CharBold;
procedure Lcd_XY_address(X,Y: byte);
procedure Lcd_ProgressBar(value, max_value: word);
procedure Lcd_SelectionBar(value, max_value: word);
procedure Lcd_show(Ptr: ^const byte );


implementation

var NOKIA_SCL: sbit; sfr; external;
    NOKIA_SDA: sbit; sfr; external;
    NOKIA_DX:  sbit; sfr; external; // commandmode = 0, datamode = 1
    NOKIA_SX:  sbit; sfr; external; // select (enable) = 0
    NOKIA_RST: sbit; sfr; external; // reset = 0

var setting_contrast : byte;
    invert_characters, bold_characters: boolean;

//*******************************************
// CCS Formatted Character Font
// Vertical Character Format
//*******************************************

const CharFont: array[256] of array[5] of byte =
      (
      ($00,$fe,$81,$fe,$00),         // 0         [$0]
      ($00,$fe,$c1,$fe,$00),         // 1         [$1]
      ($00,$fe,$e1,$fe,$00),         // 2         [$2]
      ($00,$fe,$f1,$fe,$00),         // 3         [$3]
      ($00,$fe,$f9,$fe,$00),         // 4         [$4]
      ($00,$fe,$fd,$fe,$00),         // 5         [$5]
      ($00,$fe,$ff,$fe,$00),         // 6         [$6]
      ($18,$1f,$c1,$f8,$08),         // 7         [$7]
      ($18,$42,$3c,$81,$7e),         // 8         [$8]
      ($32,$2a,$e7,$2a,$32),         // 9         [$9]
      ($e2,$51,$e2,$64,$92),         // 10         [$a]
      ($f5,$91,$65,$61,$95),         // 11         [$b]
      ($5c,$62,$02,$62,$5c),         // 12         [$c]
      ($fa,$00,$f0,$90,$fe),         // 13         [$d]
      ($fe,$92,$00,$fe,$02),         // 14         [$e]
      ($7c,$7c,$6c,$7c,$7c),         // 15         [$f]
      ($00,$fe,$7c,$38,$10),         // 16         [$10]
      ($10,$38,$7c,$fe,$00),         // 17         [$11]
      ($40,$70,$7c,$70,$40),         // 18         [$12]
      ($04,$1c,$7c,$1c,$04),         // 19         [$13]
      ($88,$cc,$ee,$cc,$88),         // 20         [$14]
      ($22,$66,$ee,$66,$22),         // 21         [$15]
      ($38,$7c,$7c,$7c,$38),         // 22         [$16]
      ($3e,$3e,$3e,$3e,$3e),         // 23         [$17]
      ($20,$70,$a8,$20,$3e),         // 24         [$18]
      ($08,$04,$fe,$04,$08),         // 25         [$19]
      ($20,$40,$fe,$40,$20),         // 26         [$1a]
      ($10,$10,$54,$38,$10),         // 27         [$1b]
      ($10,$38,$54,$10,$10),         // 28         [$1c]
      ($80,$88,$94,$a2,$80),         // 29         [$1d]
      ($80,$a2,$94,$88,$80),         // 30         [$1e]
      ($fe,$82,$82,$84,$f8),         // 31         [$1f]
      ($00,$00,$00,$00,$00),         // 32         [$20]
      ($00,$00,$be,$00,$00),         // 33         [$21]
      ($00,$0e,$00,$0e,$00),         // 34         [$22]
      ($28,$fe,$28,$fe,$28),         // 35         [$23]
      ($48,$54,$fe,$54,$24),         // 36         [$24]
      ($46,$26,$10,$c8,$c4),         // 37         [$25]
      ($6c,$92,$aa,$44,$a0),         // 38         [$26]
      ($00,$00,$0a,$06,$00),         // 39         [$27]
      ($00,$38,$44,$82,$00),         // 40         [$28]
      ($00,$82,$44,$38,$00),         // 41         [$29]
      ($28,$10,$7c,$10,$28),         // 42         [$2a]
      ($10,$10,$7c,$10,$10),         // 43         [$2b]
      ($00,$a0,$60,$00,$00),         // 44         [$2c]
      ($10,$10,$10,$10,$10),         // 45         [$2d]
      ($00,$c0,$c0,$00,$00),         // 46         [$2e]
      ($40,$20,$10,$08,$04),         // 47         [$2f]
      ($7c,$a2,$92,$8a,$7c),         // 48         [$30]
      ($00,$84,$fe,$80,$00),         // 49         [$31]
      ($84,$c2,$a2,$92,$8c),         // 50         [$32]
      ($42,$82,$8a,$96,$62),         // 51         [$33]
      ($30,$28,$24,$fe,$20),         // 52         [$34]
      ($4e,$8a,$8a,$8a,$72),         // 53         [$35]
      ($78,$94,$92,$92,$60),         // 54         [$36]
      ($06,$02,$e2,$12,$0e),         // 55         [$37]
      ($6c,$92,$92,$92,$6c),         // 56         [$38]
      ($0c,$92,$92,$52,$3c),         // 57         [$39]
      ($00,$cc,$cc,$00,$00),         // 58         [$3a]
      ($00,$ac,$6c,$00,$00),         // 59         [$3b]
      ($10,$28,$44,$82,$00),         // 60         [$3c]
      ($28,$28,$28,$28,$28),         // 61         [$3d]
      ($00,$82,$44,$28,$10),         // 62         [$3e]
      ($04,$02,$a2,$12,$0c),         // 63         [$3f]
      ($64,$92,$f2,$82,$7c),         // 64         [$40]
      ($f8,$24,$22,$24,$f8),         // 65         [$41]
      ($fe,$92,$92,$92,$6c),         // 66         [$42]
      ($7c,$82,$82,$82,$44),         // 67         [$43]
      ($fe,$82,$82,$44,$38),         // 68         [$44]
      ($fe,$92,$92,$92,$82),         // 69         [$45]
      ($fe,$12,$12,$12,$02),         // 70         [$46]
      ($7c,$82,$92,$92,$f4),         // 71         [$47]
      ($fe,$10,$10,$10,$fe),         // 72         [$48]
      ($00,$82,$fe,$82,$00),         // 73         [$49]
      ($40,$80,$82,$7e,$02),         // 74         [$4a]
      ($fe,$10,$28,$44,$82),         // 75         [$4b]
      ($fe,$80,$80,$80,$80),         // 76         [$4c]
      ($fe,$04,$18,$04,$fe),         // 77         [$4d]
      ($fe,$08,$10,$20,$fe),         // 78         [$4e]
      ($7c,$82,$82,$82,$7c),         // 79         [$4f]
      ($fe,$12,$12,$12,$0c),         // 80         [$50]
      ($7c,$82,$a2,$42,$bc),         // 81         [$51]
      ($fe,$12,$32,$52,$8c),         // 82         [$52]
      ($4c,$92,$92,$92,$64),         // 83         [$53]
      ($02,$02,$fe,$02,$02),         // 84         [$54]
      ($7e,$80,$80,$80,$7e),         // 85         [$55]
      ($3e,$40,$80,$40,$3e),         // 86         [$56]
      ($fe,$40,$30,$40,$fe),         // 87         [$57]
      ($c6,$28,$10,$28,$c6),         // 88         [$58]
      ($0e,$10,$e0,$10,$0e),         // 89         [$59]
      ($c2,$a2,$92,$8a,$86),         // 90         [$5a]
      ($00,$fe,$82,$82,$00),         // 91         [$5b]
      ($04,$08,$10,$20,$40),         // 92         [$5c]
      ($00,$82,$82,$fe,$00),         // 93         [$5d]
      ($08,$04,$02,$04,$08),         // 94         [$5e]
      ($80,$80,$80,$80,$80),         // 95         [$5f]
      ($00,$02,$04,$08,$00),         // 96         [$60]
      ($40,$a8,$a8,$a8,$f0),         // 97         [$61]
      ($fe,$90,$88,$88,$70),         // 98         [$62]
      ($70,$88,$88,$88,$40),         // 99         [$63]
      ($70,$88,$88,$90,$fe),         // 100         [$64]
      ($70,$a8,$a8,$a8,$30),         // 101         [$65]
      ($10,$fc,$12,$02,$04),         // 102         [$66]
      ($10,$a8,$a8,$a8,$78),         // 103         [$67]
      ($fe,$10,$08,$08,$f0),         // 104         [$68]
      ($00,$90,$fa,$80,$00),         // 105         [$69]
      ($40,$80,$88,$7a,$00),         // 106         [$6a]
      ($00,$fe,$20,$50,$88),         // 107         [$6b]
      ($00,$82,$fe,$80,$00),         // 108         [$6c]
      ($f8,$08,$f0,$08,$f8),         // 109         [$6d]
      ($f8,$10,$08,$08,$f0),         // 110         [$6e]
      ($70,$88,$88,$88,$70),         // 111         [$6f]
      ($f8,$28,$28,$28,$10),         // 112         [$70]
      ($08,$14,$14,$18,$fc),         // 113         [$71]
      ($f8,$10,$08,$08,$10),         // 114         [$72]
      ($90,$a8,$a8,$a8,$40),         // 115         [$73]
      ($08,$7e,$88,$80,$40),         // 116         [$74]
      ($78,$80,$80,$40,$f8),         // 117         [$75]
      ($38,$40,$80,$40,$38),         // 118         [$76]
      ($78,$80,$60,$80,$78),         // 119         [$77]
      ($88,$50,$20,$50,$88),         // 120         [$78]
      ($18,$a0,$a0,$a0,$78),         // 121         [$79]
      ($88,$c8,$a8,$98,$88),         // 122         [$7a]
      ($00,$10,$6c,$82,$00),         // 123         [$7b]
      ($00,$00,$fe,$00,$00),         // 124         [$7c]
      ($00,$82,$6c,$10,$00),         // 125         [$7d]
      ($04,$02,$04,$08,$04),         // 126         [$7e]
      ($f0,$88,$84,$88,$f0),         // 127         [$7f]
      ($00,$00,$00,$00,$00),         // 128         [$80]
      ($fe,$ff,$33,$ff,$fe),         // 129         [$81]
      ($ff,$ff,$db,$ff,$76),         // 130         [$82]
      ($7e,$ff,$c3,$c3,$c3),         // 131         [$83]
      ($ff,$ff,$c3,$ff,$7e),         // 132         [$84]
      ($ff,$ff,$db,$db,$c3),         // 133         [$85]
      ($ff,$ff,$1b,$1b,$03),         // 134         [$86]
      ($7e,$ff,$d3,$f7,$76),         // 135         [$87]
      ($ff,$ff,$18,$ff,$ff),         // 136         [$88]
      ($00,$ff,$ff,$ff,$00),         // 137         [$89]
      ($60,$e0,$c0,$ff,$7f),         // 138         [$8a]
      ($ff,$ff,$3c,$f7,$e3),         // 139         [$8b]
      ($ff,$ff,$c0,$c0,$c0),         // 140         [$8c]
      ($ff,$07,$1c,$07,$ff),         // 141         [$8d]
      ($ff,$3f,$7e,$fc,$ff),         // 142         [$8e]
      ($7e,$ff,$c3,$ff,$7e),         // 143         [$8f]
      ($ff,$ff,$33,$3f,$1e),         // 144         [$90]
      ($7e,$ff,$e3,$7f,$be),         // 145         [$91]
      ($ff,$ff,$3b,$ef,$c6),         // 146         [$92]
      ($ce,$df,$db,$fb,$73),         // 147         [$93]
      ($03,$ff,$ff,$ff,$03),         // 148         [$94]
      ($7f,$ff,$c0,$ff,$7f),         // 149         [$95]
      ($3f,$7f,$e0,$7f,$3f),         // 150         [$96]
      ($ff,$e0,$38,$e0,$ff),         // 151         [$97]
      ($c7,$ff,$38,$ff,$c7),         // 152         [$98]
      ($0f,$1f,$f0,$1f,$0f),         // 153         [$99]
      ($e3,$f3,$db,$cf,$c7),         // 154         [$9a]
      ($00,$00,$00,$00,$00),         // 155         [$9b]
      ($00,$00,$00,$00,$00),         // 156         [$9c]
      ($00,$00,$00,$00,$00),         // 157         [$9d]
      ($00,$00,$00,$00,$00),         // 158         [$9e]
      ($00,$00,$00,$00,$00),         // 159         [$9f]
      ($00,$00,$00,$00,$00),         // 160         [$a0]
      ($00,$00,$00,$00,$00),         // 161         [$a1]
      ($00,$00,$00,$00,$00),         // 162         [$a2]
      ($00,$00,$00,$00,$00),         // 163         [$a3]
      ($00,$00,$00,$00,$00),         // 164         [$a4]
      ($00,$00,$00,$00,$00),         // 165         [$a5]
      ($00,$00,$00,$00,$00),         // 166         [$a6]
      ($00,$00,$00,$00,$00),         // 167         [$a7]
      ($00,$00,$00,$00,$00),         // 168         [$a8]
      ($00,$00,$00,$00,$00),         // 169         [$a9]
      ($00,$00,$00,$00,$00),         // 170         [$aa]
      ($00,$00,$00,$00,$00),         // 171         [$ab]
      ($00,$00,$00,$00,$00),         // 172         [$ac]
      ($00,$00,$00,$00,$00),         // 173         [$ad]
      ($00,$00,$00,$00,$00),         // 174         [$ae]
      ($00,$00,$00,$00,$00),         // 175         [$af]
      ($00,$00,$00,$00,$00),         // 176         [$b0]
      ($00,$00,$00,$00,$00),         // 177         [$b1]
      ($00,$00,$00,$00,$00),         // 178         [$b2]
      ($00,$00,$00,$00,$00),         // 179         [$b3]
      ($00,$00,$00,$00,$00),         // 180         [$b4]
      ($00,$00,$00,$00,$00),         // 181         [$b5]
      ($00,$00,$00,$00,$00),         // 182         [$b6]
      ($00,$00,$00,$00,$00),         // 183         [$b7]
      ($00,$00,$00,$00,$00),         // 184         [$b8]
      ($00,$00,$00,$00,$00),         // 185         [$b9]
      ($00,$00,$00,$00,$00),         // 186         [$ba]
      ($00,$00,$00,$00,$00),         // 187         [$bb]
      ($00,$00,$00,$00,$00),         // 188         [$bc]
      ($00,$00,$00,$00,$00),         // 189         [$bd]
      ($00,$00,$00,$00,$00),         // 190         [$be]
      ($00,$00,$00,$00,$00),         // 191         [$bf]
      ($00,$00,$00,$00,$00),         // 192         [$c0]
      ($00,$00,$00,$00,$00),         // 193         [$c1]
      ($00,$00,$00,$00,$00),         // 194         [$c2]
      ($00,$00,$00,$00,$00),         // 195         [$c3]
      ($00,$00,$00,$00,$00),         // 196         [$c4]
      ($00,$00,$00,$00,$00),         // 197         [$c5]
      ($00,$00,$00,$00,$00),         // 198         [$c6]
      ($00,$00,$00,$00,$00),         // 199         [$c7]
      ($00,$00,$00,$00,$00),         // 200         [$c8]
      ($00,$00,$00,$00,$00),         // 201         [$c9]
      ($00,$00,$00,$00,$00),         // 202         [$ca]
      ($00,$00,$00,$00,$00),         // 203         [$cb]
      ($00,$00,$00,$00,$00),         // 204         [$cc]
      ($00,$00,$00,$00,$00),         // 205         [$cd]
      ($00,$00,$00,$00,$00),         // 206         [$ce]
      ($00,$00,$00,$00,$00),         // 207         [$cf]
      ($00,$00,$00,$00,$00),         // 208         [$d0]
      ($00,$00,$00,$00,$00),         // 209         [$d1]
      ($00,$00,$00,$00,$00),         // 210         [$d2]
      ($00,$00,$00,$00,$00),         // 211         [$d3]
      ($00,$00,$00,$00,$00),         // 212         [$d4]
      ($00,$00,$00,$00,$00),         // 213         [$d5]
      ($00,$00,$00,$00,$00),         // 214         [$d6]
      ($00,$00,$00,$00,$00),         // 215         [$d7]
      ($00,$00,$00,$00,$00),         // 216         [$d8]
      ($00,$00,$00,$00,$00),         // 217         [$d9]
      ($00,$00,$00,$00,$00),         // 218         [$da]
      ($00,$00,$00,$00,$00),         // 219         [$db]
      ($00,$00,$00,$00,$00),         // 220         [$dc]
      ($00,$00,$00,$00,$00),         // 221         [$dd]
      ($00,$00,$00,$00,$00),         // 222         [$de]
      ($00,$00,$00,$00,$00),         // 223         [$df]
      ($00,$00,$00,$00,$00),         // 224         [$e0]
      ($00,$00,$00,$00,$00),         // 225         [$e1]
      ($00,$00,$00,$00,$00),         // 226         [$e2]
      ($00,$00,$00,$00,$00),         // 227         [$e3]
      ($00,$00,$00,$00,$00),         // 228         [$e4]
      ($00,$00,$00,$00,$00),         // 229         [$e5]
      ($00,$00,$00,$00,$00),         // 230         [$e6]
      ($00,$00,$00,$00,$00),         // 231         [$e7]
      ($00,$00,$00,$00,$00),         // 232         [$e8]
      ($04,$54,$50,$14,$44),         // 233         [$e9]
      ($00,$00,$00,$00,$00),         // 234         [$ea]
      ($00,$00,$00,$00,$00),         // 235         [$eb]
      ($10,$22,$10,$22,$10),         // 236         [$ec]
      ($10,$22,$20,$22,$10),         // 237         [$ed]
      ($20,$22,$20,$22,$20),         // 238         [$ee]
      ($40,$22,$20,$22,$40),         // 239         [$ef]
      ($60,$ff,$f9,$df,$60),         // 240         [$f0]
      ($0c,$1f,$fc,$1f,$0c),         // 241         [$f1]
      ($00,$00,$00,$00,$00),         // 242         [$f2]
      ($00,$00,$00,$00,$00),         // 243         [$f3]
      ($00,$00,$00,$00,$00),         // 244         [$f4]
      ($00,$00,$00,$00,$00),         // 245         [$f5]
      ($00,$00,$00,$00,$00),         // 246         [$f6]
      ($00,$00,$00,$00,$00),         // 247         [$f7]
      ($00,$00,$00,$00,$00),         // 248         [$f8]
      ($fe,$7b,$ff,$7b,$fe),         // 249         [$f9]
      ($fe,$7a,$fe,$7a,$fe),         // 250         [$fa]
      ($fc,$78,$fc,$78,$fc),         // 251         [$fb]
      ($f8,$78,$f8,$78,$f8),         // 252         [$fc]
      ($f0,$70,$f0,$70,$f0),         // 253         [$fd]
      ($e0,$60,$e0,$60,$e0),         // 254         [$fe]
      ($c0,$40,$c0,$40,$c0)          // 255         [$ff]
      )
      ;

// local procedures

procedure Send_byte(data_: byte);
var
    bitcount: byte;
begin
  NOKIA_SX := 0; // enable serial input
  bitcount := 8;
  while (bitcount > 0) do            //data is transmitted with LSB first
  begin
    NOKIA_SCL := 0;
    //Delay_Us(1);
    NOKIA_SDA := Data_.7;
    //Delay_us(1);
    NOKIA_SCL := 1;
    //Delay_Us(1);
    data_ := data_ shl 1;            //shift the byte one bit to the left
    dec(bitcount);
  end;
  NOKIA_SX := 1; // disable (reset) serial input
end;

procedure Lcd_command (command_: byte);
begin
  NOKIA_DX := 0;                     //nokia display control-mode
  Send_byte(command_);
end;

procedure Lcd_data (data_: byte);
begin
  NOKIA_DX := 1;                     //nokia display data-mode
  Send_byte(data_);
end;

procedure InitLcd;
begin
  Setting_Contrast := $40; // default contrast

  NOKIA_SCL := 0;
  NOKIA_SDA := 0;
  NOKIA_SX := 1;
  NOKIA_DX := 0;

  NOKIA_RST := 0;                    //nokia display reset
  Delay_Ms(10);
  NOKIA_RST := 1;

  Lcd_command($21);                  //horizontal_addressing, go into extended instruction set mode
  Lcd_command(setting_contrast or $80); //C5, set LCD Vop (80=lowest contrast voltage, FF=highest)
  Lcd_command($06);                  //set temp coef.
  Lcd_command($13);                  //set bias

  Lcd_command($20);                  //basic instruction set, horizontal addr. mode
  Lcd_command($0c);                  //display in normal mode
end;


procedure Lcd_Char(data_: byte);
begin
  if (bold_characters) then
  begin
    if ((data_ >= 'A') and (data_ <= 'Z')) then data_ := data_ + $40;
  end;

  if (not invert_characters) then
  begin
    Lcd_data(CharFont[data_][0]);
    Lcd_data(CharFont[data_][1]);
    Lcd_data(CharFont[data_][2]);
    Lcd_data(CharFont[data_][3]);
    Lcd_data(CharFont[data_][4]);
    Lcd_data($00);
  end
  else
  begin
    Lcd_data($FF - CharFont[data_][0]);
    Lcd_data($FF - CharFont[data_][1]);
    Lcd_data($FF - CharFont[data_][2]);
    Lcd_data($FF - CharFont[data_][3]);
    Lcd_data($FF - CharFont[data_][4]);
    Lcd_data($FF);
  end;
end;

procedure LCD_Text(var Text: string);
var Ptr: ^byte;
begin
  Ptr := @text;
  while Ptr^ > 0 do
  begin
    Lcd_Char(Ptr^);
    inc(Ptr);
  end;
end;

procedure SetContrast(Contrast: byte);
begin
  Setting_Contrast := Contrast;         // add command
  Lcd_command($21);                     //horizontal_addressing, go into extended instruction set mode
  Lcd_command(setting_contrast or $80); //C5, set LCD Vop (80=lowest contrast voltage, FF=highest)
  Lcd_command($20);                     //basic instruction set, horizontal addr. mode
  Lcd_command($0c);                     //display in normal mode
end;

procedure Lcd_clr;
var bytecounter: word;
begin
  Lcd_XY_address(0,0);
  bytecounter := 612;                // originally 504, but the extra values just wrap around and cause no harm!
                                     // some non-original displays seem to have larger display memory than standard
  while ByteCounter > 0 do
  begin
    Lcd_data($00);
    dec(ByteCounter);
  end;
end;

procedure Lcd_CharInvert;
begin
  invert_characters := TRUE;
end;

procedure Lcd_CharNormal;
begin
  bold_characters := FALSE;
  invert_characters := FALSE;
end;

procedure Lcd_CharBold;
begin
  bold_characters := TRUE;
end;

procedure Lcd_XY_address(X, Y: byte);
begin
  Lcd_command($80 + (6 * X));        //set X-address
  Lcd_command($40 + Y);              //set Y-address
end;

//a conventional progressbar, that is empty at 0% and full at 100%
procedure Lcd_ProgressBar(value, max_value: word);
const bar_total_size = 82;
var lp, size: word;
begin
  size := (value * bar_total_size) / max_value;

  Lcd_data($7E);
  
  lp := 0;
  while (Lp < bar_total_Size) do
  begin
    if ((lp < size) or (max_value = 0))
    then Lcd_data($7E)
    else Lcd_data($42);
    inc(Lp);
  end;
  
  Lcd_data($7E);
end;

//this bar has a block that moves, the bar will never be filled completely, compare it to a slider in Windows
procedure Lcd_SelectionBar(value, max_value: word);
begin
end;

procedure Lcd_show(Ptr: ^const byte);
var Cnt: word;
    Val_: byte;
begin
  LCD_XY_ADDRESS(0,0);
  for Cnt := 0 to 503 do
  begin
    Val_ := Ptr^;
    inc(Ptr);
    LCD_Data(Val_);
  end;
end;

end.
A using program:

Code: Select all

program Proto_Nokia_3310_5110;

{ Declarations section }

uses Nokia_3310_5110, mikroE_bmp;

var NOKIA_SCL: sbit at LATA.0; sfr;
    NOKIA_SDA: sbit at LATA.1; sfr;
    NOKIA_DX:  sbit at LATA.2; sfr; // commandmode = 0, datamode = 1
    NOKIA_SX:  sbit at LATA.3; sfr; // select (enable) = 0
    NOKIA_RST: sbit at LATA.4; sfr; // reset = 0

    NOKIA_LED: sbit at LATA.5; sfr;

    Tmp: byte;

begin
  { Main program }
  SWDTEN_bit := 0; // no watchdog

  Adcon1 := $0f;
  CmCon  := $07;

  TRISA.0 := 0; // for LCD SCL
  TRISA.1 := 0; // for LCD SDA
  TRISA.2 := 0; // for LCD DX
  TRISA.3 := 0; // for LCD SX
  TRISA.4 := 0; // for LCD RST
  TrisA.5 := 0; // for LCD background light

  Delay_ms(100);

  InitLcd;
  Lcd_clr;

  SetContrast($40);

  LCD_CharNormal;
  //LCD_CharBold;
  //LCD_CharInvert;

  Lcd_XY_address(0,0);
  Lcd_Char('A');
  Lcd_Char('B');

  LCD_XY_address(0,1);
  Lcd_Char('C');
  Lcd_Char('D');

  LCD_XY_address(0,2);
  Lcd_Char('E');
  Lcd_Char('F');

  LCD_CharInvert;
  LCD_XY_address(0,3);
  Lcd_Text('Test Invers');
  LCD_CharNormal;


  LCD_XY_address(0,4);
  Lcd_Text('Line 4');

  LCD_XY_address(0,5);
  Lcd_Text('Line 5');


  delay_ms(500);

  {
  for Tmp := 0 to 100 do
  begin
    LCD_XY_ADDRESS(0,0);
    Lcd_ProgressBar(Tmp, 100);
    delay_ms(10);
  end;
  }

  Nokia_Led := 1;


  LCD_XY_ADDRESS(0,1);
  Lcd_ProgressBar(90, 100);

  while true do
  begin
    delay_ms(1500);
    LCD_Show(@mikro_bmp);
    
    delay_ms(1500);
    LCD_Show(@screen_1541_III);

    delay_ms(1500);
    LCD_Show(@screen_1541_III_DTV);
  end;

  {
  while true do // give background 50% duty cycle
  begin
    Nokia_Led := not Nokia_led;
    delay_ms(1);
  end;
  }

end.
The bitmap file for above:

Code: Select all

unit MikroE_bmp;

const mikro_bmp: array[504] of byte  = (
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  0, 255, 255,   0, 255, 255, 255,   7,  71,  99,  99,  99,
 99,  99,  99,  99, 103,   7, 143, 255, 255,  63,  63,  31,
 15,  15,   7,   7,   7,   3,   3,   3,   3,   3,   3,   3,
  3,   3,   7,   7,   7,  15,  15,  31,  31,  63, 255, 255,
255, 255, 255, 255, 255,   0, 255, 255,   0,   0,   0,   0,
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,

  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  0, 255, 255,   0, 255, 255, 255,  14,  12,  12,  28,  60,
 60,  60,  60,  60, 252, 254, 255,   3,   0,   0,   0,   0,
  0,   0,   0,   0,   0,   0,   0, 248, 254, 254, 254, 252,
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   1,
 15, 255, 255, 255, 255,   0, 255, 255,   0,   0,   0,   0,
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,

  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  0, 255, 255,   0, 255, 255, 255,  34, 102,   6,   6,  30,
 14,   6,   6,  34, 255, 255, 255,   0,   0,   0,   0,   0,
  0,   0,   0,   0,   0,   0,   0,   1,   3,   3,   3,   3,
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  0, 255, 255, 255, 255,   0, 255, 255,   0,   0,   0,   0,
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,

  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  0, 255, 255,   0, 255, 255, 255, 196, 254, 222, 198, 198,
198, 198, 198, 198, 255, 255, 255,   0,   0,   0,   0,   0,
  0,   0,   0,   0,   0,   0,   0, 254, 255, 255, 255, 255,
255,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,
  7, 255, 255, 255, 255,   0, 255, 255,   0,   0,   0,   0,
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,

  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  0, 255, 255,   0, 255, 255, 255,  16,  24,  24,  24,  24,
 24,  24,  24,  24,  27,  63, 255, 224, 128,   0,   0,   0,
  0,   0,   0,   0,   0,   0,   0,  15,  63, 127,  63,  63,
 15,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 128,
240, 255, 255, 255, 255,   0, 255, 255,   0,   0,   0,   0,
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,

  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  0, 255, 255,   0, 255, 255, 255, 224, 227, 227, 227, 227,
227, 227, 227, 227, 227, 227, 227, 227, 231, 238, 252, 248,
248, 240, 240, 224, 224, 224, 224, 224, 224, 224, 224, 224,
224, 224, 224, 224, 224, 240, 240, 248, 252, 254, 255, 255,
255, 255, 255, 255, 255,   0, 255, 255,   0,   0,   0,   0,  //255, 255, 255, 255, 127, 128, 255, 255,   0,   0,   0,   0,
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
);

const screen_1541_III:  array[504] of byte  = ( 			// Image Array Table Name, Width, Height In Lines, 506 bytes*/
0x00,0xe0,0x20,0xa0,0xa0,0xa0,0x20,0xa0,0xa0,0xa0,0x20,0xa0,0xa0,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xfc,0x04,0x04,0x84,0x04,0xf4,0x94,0x64,0x04,0xf4,0xa4,0xe4,0x04,0x74,0x44,0xf4,0x44,0x04,0x04,0xfc,0xfc,0x00,0x00,0x00,0x10,0xf0,0x10,0x00,0xf0,0x50,0x10,0x00,0xe0,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xff,0x00,0x43,0x30,0x0b,0x00,0x5b,0x68,0x03,0x78,0x4b,0x32,0x00,0x00,0xff,0x00,0x20,0x20,0xa8,0x70,0x20,0x00,0xfe,0xff,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xce,0x86,0x86,0x86,0xce,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xff,0xfe,0x00,0x70,0x88,0x71,0x01,0xf9,0x00,0xf9,0x01,0xf9,0x00,0x70,0x89,0x71,0x00,0xf8,0x00,0x20,0x20,0xa8,0x70,0x20,0x00,0xf8,0xfe,0xff,0x8f,0x07,0x03,0x03,0x07,0x07,0x07,0xd8,0xd8,0xd8,0xd8,0x88,0x00,
0x00,0x1f,0x10,0x1e,0x10,0x1e,0x10,0x1e,0x10,0x1e,0x10,0x1e,0x10,0x1e,0x10,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x43,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x0f,0x0f,0x0e,0x0e,0x0f,0x0f,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0x00,0xe0,0xb0,0x10,0xf0,0x00,0xf0,0x10,0xd0,0x50,0x50,0x70,0x00,0x80,0xe0,0x10,0xf0,0x00,0x00,0x00,0xe0,0xb0,0x10,0xf0,0x00,0x00,0x00,0x00,0x00,0x70,0xd0,0x10,0xd0,0x50,0xd0,0x10,0xd0,0x50,0xd0,0x10,0xd0,0x70,0x00,0x00,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,
0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0x00,0x00,0xff,0x80,0xff,0x00,0x77,0x94,0xa5,0xbd,0x83,0x7e,0x00,0x3f,0x20,0x2f,0xe9,0x84,0xec,0x18,0x00,0xff,0x80,0xff,0x00,0x0e,0x0a,0x0a,0x0e,0xe0,0xbf,0x80,0xbf,0xa0,0xbf,0x80,0xbf,0xa0,0xbf,0x80,0xbf,0xe0,0x00,0x00,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee,
0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0x00,0x00,0x7c,0x50,0x20,0x0c,0x50,0x3c,0x00,0x00,0x00,0x20,0x40,0x3c,0x00,0x40,0x00,0x7c,0x44,0x38,0x00,0x7c,0x54,0x00,0x7c,0x14,0x68,0x00,0x38,0x44,0x38,0x00,0x38,0x44,0x54,0x34,0x00,0x7c,0x54,0x00,0x7c,0x54,0x00,0x00,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd);

const screen_1541_III_DTV:  array[504] of byte  = ( 		// Image Array Table Name, Width, Height In Lines, 506 bytes*/
0x00,0xe0,0x20,0xa0,0xa0,0xa0,0x20,0xa0,0xa0,0xa0,0x20,0xa0,0xa0,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xfc,0x04,0x04,0x84,0x04,0xf4,0x94,0x64,0x04,0xf4,0xa4,0xe4,0x04,0x74,0x44,0xf4,0x44,0x04,0x04,0xfc,0xfc,0x00,0x00,0x00,0x10,0xf0,0x10,0x00,0xf0,0x50,0x10,0x00,0xe0,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x20,0xa0,0x40,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0xff,0x00,0x43,0x30,0x0b,0x00,0x5b,0x68,0x03,0x78,0x4b,0x32,0x00,0x00,0xff,0x00,0x20,0x20,0xa8,0x70,0x20,0x00,0xfe,0xff,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xce,0x86,0x86,0x86,0xce,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xff,0xfe,0x00,0x70,0x88,0x71,0x01,0xf9,0x00,0xf9,0x01,0xf9,0x00,0x70,0x89,0x71,0x00,0xf8,0x00,0x20,0x20,0xa8,0x70,0x20,0x00,0x00,0x00,0x00,0x00,0x03,0x04,0xf8,0x08,0xf8,0x04,0x03,0x00,0x00,0x00,0x00,0x00,
0x00,0x1f,0x10,0x1e,0x10,0x1e,0x10,0x1e,0x10,0x1e,0x10,0x1e,0x10,0x1e,0x10,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x43,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x00,0x00,0x00,0x40,0x40,0x40,0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x20,0x20,0x40,0x40,0x80,0x80,0x80,0x40,0x40,0x5c,0x42,0x23,0x23,0x13,0x52,0x53,0x52,0x53,0x42,0x43,0x43,0x43,0x62,0x3c,0x00,
0xd0,0xd0,0xd0,0x00,0x00,0x00,0xe0,0xb0,0x10,0xf0,0x00,0xf0,0x10,0xd0,0x50,0x50,0x70,0x00,0x80,0xe0,0x10,0xf0,0x00,0x00,0x00,0xe0,0xb0,0x10,0xf0,0x00,0x00,0x00,0x00,0x00,0x70,0xd0,0x10,0xd0,0x50,0xd0,0x10,0xd0,0x50,0xd0,0x10,0xd0,0x70,0x00,0x00,0x00,0x00,0x00,0xf0,0x10,0xd0,0x50,0x90,0x20,0xc0,0x00,0x70,0x50,0xd0,0x10,0xd0,0x50,0x70,0x00,0x70,0x90,0x70,0x80,0x00,0x80,0x70,0x90,0x70,0x00,0x00,0x00,0xd0,0xd0,0xd0,0xd0,
0xee,0xee,0xee,0x00,0x00,0x00,0x00,0xff,0x80,0xff,0x00,0x77,0x94,0xa5,0xbd,0x83,0x7e,0x00,0x3f,0x20,0x2f,0xe9,0x84,0xec,0x18,0x00,0xff,0x80,0xff,0x00,0x0e,0x0a,0x0a,0x0e,0xe0,0xbf,0x80,0xbf,0xa0,0xbf,0x80,0xbf,0xa0,0xbf,0x80,0xbf,0xe0,0x00,0x00,0x00,0x00,0x00,0xff,0x80,0xbf,0xa0,0x9f,0x40,0x3f,0x00,0x00,0x00,0xff,0x80,0xff,0x00,0x00,0x00,0x00,0x0f,0x70,0x8f,0xb0,0x8f,0x70,0x0f,0x00,0x00,0x00,0x00,0xee,0xee,0xee,0xee,
0xfd,0xfd,0xfd,0x00,0x4c,0x74,0x00,0x38,0x44,0x38,0x00,0x78,0x14,0x00,0x3c,0x50,0x00,0x3c,0x40,0x20,0x40,0x3c,0x00,0x78,0x14,0x78,0x00,0x7c,0x14,0x68,0x00,0x7c,0x54,0x00,0x00,0x00,0x00,0x00,0x7c,0x54,0x28,0x00,0x0c,0x70,0x0c,0x00,0x00,0x00,0x20,0x40,0x3c,0x00,0x40,0x00,0x7c,0x44,0x38,0x00,0x7c,0x54,0x00,0x7c,0x14,0x68,0x00,0x38,0x44,0x38,0x00,0x38,0x44,0x54,0x34,0x00,0x7c,0x54,0x00,0x7c,0x54,0x00,0xfd,0xfd,0xfd,0xfd);

implementation

end.
The project file:

Code: Select all

[DEVICE]
Name=P18F2550
Clock=48000000
[MEMORY_MODEL]
Value=0
[BUILD_TYPE]
Value=0
[ACTIVE_TAB]
Value=..\..\Libraries\LCD\Uses\Nokia_3310_5110.mpas
[USE_EEPROM]
Value=0
[USE_HEAP]
Value=0
[HEAP_SIZE]
Value=2000
[EEPROM_DEFINITION]
Value=
[FILES]
Count=3
File0=Proto_Nokia_3310_5110.mpas
File1=..\..\Libraries\LCD\Uses\Nokia_3310_5110.mpas
File2=MikroE_bmp.mpas
[BINARIES]
Count=0
[IMAGES]
Count=0
ActiveImageIndex=-1
[OPENED_FILES]
Count=4
File0=Proto_Nokia_3310_5110.mpas
File1=..\..\Libraries\LCD\Uses\Nokia_3310_5110.mpas
File2=MikroE_bmp.mpas
File3=Proto_Nokia_3310_5110.lst
[EEPROM]
Count=0
[ACTIVE_COMMENTS_FILES]
Count=0
[OTHER_FILES]
Count=0
[SEARCH_PATH]
Count=4
Path0=C:\Users\Public\Documents\Mikroelektronika\mikroPascal PRO for PIC\defs\
Path1=C:\Users\Public\Documents\Mikroelektronika\mikroPascal PRO for PIC\uses\P18\
Path2=C:\PIC Projects PRO compiler\Prototyping\Nokia_3310_5110\
Path3=C:\PIC Projects PRO compiler\Libraries\LCD\Uses\
[HEADER_PATH]
Count=0
[HEADERS]
Count=0
[PLDS]
Count=0
[Useses]
Count=0
[EXPANDED NODES]
Node1=Sources
Count=1
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Post Reply

Return to “mikroPascal General”