This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Showing posts with label SPI. Show all posts
Showing posts with label SPI. Show all posts

Saturday, November 14, 2015

MAX7219 7-Segment Display

Do you like the 7-segment displays?
This board has a MAX7219, the board has eight digits connected in cascade. The board works at 5V and has SPI interface.
 
Video.

Description of library.

Initializes the MAX7219.

MAX7219_Init(void)
Example:
MAX7219_Init();

Writes a single digit.
MAX7219_WriteDigit(c, digit)

  • c: Sets the 7-segment character.
  • digit: Sets the digit.
Example:
MAX7219_WriteDigit('2', 5);

Writes constant numbers.
MAX7219_ConstDigit(buffer);

  • buffer: Sets the numbers.
Example:
MAX7219_ConstDigit("00001234");

Writes numbers.
MAX7219_Digit(buffer);

  • buffer: Sets the numbers.
Example:
unsigned int i;
char buffer2[20];

i = 25;
sprintf(buffer2, "%8d", i);
MAX7219_Digit(buffer2);

Clears the 8 digits.

MAX7219_Clear(void);
Example:
MAX7219_Clear();

Schematic.


Friday, October 23, 2015

Nokia 5110 LCD Library

The module Nokia 5110 is a monochrome graphic LCD with 48x84 pixels. This LCD has SPI interface and blue backlight. We can buy these modules for less 2 USD.


Module Features.
  • Resolution: 48 x 84 dot matrix panel.
  • Power supply: 3.3V.
  • Interface: SPI.
  • Driver IC: PCD8544.
Video.

Request.
Email contact: armicrocontroller@gmail.com


Description of library.

Initializes the Nokia5110 module.
Nokia5110_Init(void)

Example:
Nokia5110_Init();

Sets font that will be used.
Nokia5110_SetFont(_font, _width, _height, _min, _max)

  •  _font: desired font.
  • _width: sets the width in units of pixels.
  • _height: sets the height in units of pixels.
  • _min: sets the range minimum.
  • _max: sets the range maximum.
Example:
Nokia5110_SetFont(Terminal12x16, 12, 16, 32,127);



  • font name : Terminal12x16
  • width 12 pixels
  • height 16 pixels
  • range: start in character 32, end in  character 127
We can use "GLCD Font Creator" to design new fonts, symbols and icons.
Note: Only fonts with multiples of 8 pixels in height (8, 16, 24, 32 ... )

Writes a char on the Nokia5110.
Nokia5110_WriteChar(c, seg, pag)

  • c: char to be written.
  • seg: sets the segment. Valid values: 0..83
  • pag: sets the page. Valid values: 0..5
Example:
Nokia5110_WriteChar('A', 10, 3);

Prints text constant on Nokia5110.
Nokia5110_ConstText(buffer, seg, pag)

  • buffer: text to be written.
  •  seg: sets the segment. Valid values: 0..83
  • pag: sets the page. Valid values: 0..5
Example:
Nokia5110_ConstText("NOKIA", 0, 0);

Prints text variable on Nokia5110.
Nokia5110_Text(buffer, seg, pag)

  • buffer: text to be written.
  • seg: sets the segment. Valid values: 0..83
  • pag: sets the page. Valid values: 0..5
Example:
unsigned char i;
char buffer2[20];
i = 22;
sprintf(buffer2, "%03d", i);
Nokia5110_Text(buffer2, 0, 3);

Prints text constant on Nokia5110 with scroll.
Nokia5110_ConstTextScroll(buffer)

  • buffer: text to be written.
Example:
Nokia5110_SetFont(Terminal12x16, 12, 16, 32 , 127);
Nokia5110_ResetScroll();
while(1){
Nokia5110_ConstTextScroll("This is a new scroll function  ");
Delay_ms(50);
}

Prints text variable on Nokia5110 with scroll.
Nokia5110_TextScroll(buffer)

  • buffer: text to be written.
Example:
unsigned char i;
char buffer2[20];
i = 22;
sprintf(buffer2, "%03d   ", i);
Nokia5110_SetFont(Terminal12x16, 12, 16, 32 , 127);
Nokia5110_ResetScroll();
while(1){
Nokia5110_TextScroll(buffer2);
Delay_ms(50);
}

Resets the scroll.
Nokia5110_ResetScroll(void)

This function must be called before of a new scroll function.
Example:
Nokia5110_ResetScroll();

Fills Nokia5110 memory.
Nokia5110_FillScreen(pattern)

  • pattern: byte to fill Nokia5110 memory.
Example:
Nokia5110_FillScreen(0xFF);

Displays bitmap on Nokia5110.
Nokia5110_Image(buffer)

  • buffer: image to be displayed.
Example:
Nokia5110_Image(truck);

Displays an image on a desired location.
Nokia5110_Icon(buffer, seg, pag, _width, _height)

  • buffer: image to be displayed.
  • seg: sets the segment. Valid values: 0..83
  • pag: sets the page. Valid values: 0..5
  • _width sets the width of the image.
  • _height sets the height of the image.
Example:
Nokia5110_Icon(icon1,25,2,32,32);

Inverts the RAM memory.
Nokia5110_InvertRam(seg1, pag1, seg2, pag2)

  • seg1 sets the start segment. Valid values: 0..83
  • pag1 sets the start page. Valid values: 0..5
  • seg2 sets the end segment. Valid values: 0..83
  • pag2 sets the end page. Valid values: 0..5
Example:
Nokia5110_InvertRam(0, 0, 83, 5);

Draws a Pixel on Nokia5110.

Nokia5110_Pixel(x, y, color)

  • x: x position. Valid values: 0..83
  • y: y position. Valid values: 0..47
  • color: color parameter. Valid values: 1,2,3
Example:
Nokia5110_Pixel(40, 40, BLACK);

Draws a Line on Nokia5110.
Nokia5110_Line(x1, y1, x2, y2, color)
 

  • x1: x coordinate of the line start. Valid values: 0..83
  • y1: y coordinate of the line start. Valid values: 0..47
  • x2: x coordinate of the line end. Valid values: 0..83
  • y2: y coordinate of the line end. Valid values: 0..47
  • color: color parameter. Valid values: 1,2,3
Example:
Nokia5110_Line(0, 0, 83, 47, BLACK);

Draws a rectangle on Nokia5110.
Nokia5110_Rectangle(x1, y1, x2, y2, color)

  • x1: x coordinate of the upper left rectangle corner. Valid values: 0..83 
  • y1: y coordinate of the upper left rectangle corner. Valid values: 0..47
  • x2: x coordinate of the lower right rectangle corner. Valid values: 0..83
  • y2: y coordinate of the lower right rectangle corner. Valid values: 0..47
  • color: color parameter. Valid values: 1,2,3
Example:
Nokia5110_Rectangle(10, 10, 70, 40, BLACK);

Draws a circle on Nokia5110.
Nokia5110_Circle(x1, y1, radius, color)

  • x1: x coordinate of the circle center. Valid values: 0..83
  • y1: y coordinate of the circle center. Valid values: 0..47
  • radius: radius size
  • color: color parameter. Valid values: 1,2,3
Example:
Nokia5110_Circle(41, 23, 5, Black);


Connection.



Sunday, December 28, 2014

Library for 128x64 graphical display OLED. Driver SSD1306.

OK. Now you need a best display for your projects!. Yeah, this display is your best choice. We have got the update 2.0 now.
  
Module Features.
  • Resolution: 128 x 64 dot matrix panel.
  • Power supply: 3.3V ~ 5V
  • Interface: SPI
  • Driver IC: SSD1306
  • Light color: Yellow+blue
Request.
Email contact: armicrocontroller@gmail.com


What version do I need?
The version 1.0 is ideal for microcontroller with few ROM memory, this library has not got graphics functions.

The version 2.0 includes graphic functions and a new scroll function, ideal for projects like mp3 players. This library needs a little more of ROM memory. This version is FREE!.


Description of library.

Initializes the OLED module.
Oled_Init(void)
Example:
Oled_Init();


Sets font that will be used.
Oled_SetFont(_font, _width, _height, _min, _max)
  •  _font: desired font.
  • _width: sets the width in units of pixels.
  • _height: sets the height in units of pixels. 
  • _min: sets the range minimum.
  • _max: sets the range maximum. 
Example:
Oled_SetFont(Terminal12x16, 12, 16, 32, 127);


  • font name : Terminal12x16
  • width 12 pixels
  • height 16 pixels
  • range: start in character 32, end in  character 127
We can use "GLCD Font Creator" to design new fonts, symbols and icons.
Note: Only fonts with multiples of 8 pixels in height (8, 16, 24, 32 ... )


Writes a char on the OLED.
Oled_WriteChar(c, seg, pag)

  • c: char to be written.
  • seg: sets the segment. Valid values: 0..127
  • pag: sets the page. Valid values: 0..7
Example
Oled_WriteChar('A', 10, 3);

Prints text constant on OLED.
Oled_ConstText(buffer, seg, pag)

  • buffer: text to be written.
  • seg: sets the segment. Valid values: 0..127
  • pag: sets the page. Valid values: 0..7
Example:
Oled_ConstText("OLED 128x64", 0, 4);


Prints text variable on OLED.
Oled_Text(buffer, seg, pag)

  • buffer: text to be written.
  • seg: sets the segment. Valid values: 0..127
  • pag: sets the page. Valid values: 0..7
Example:
unsigned char i;
char buffer2[20];
i = 22;
sprintf(buffer2, "%03d", i);
Oled_Text(buffer2, 0, 3);


Prints text constant on OLED with scroll.
Oled_ConstTextScroll(buffer)

  • buffer: text to be written.
Example:
Oled_SetFont(Terminal12x16, 12, 16, 32 , 127);
Oled_ResetScroll();
while(1){
Oled_ConstTextScroll("This is a new scroll function  ");
Delay_ms(50);
}


Prints text variable on OLED with scroll.
Oled_TextScroll(buffer)

  • buffer: text to be written.
Example:
unsigned char i;
char buffer2[20];
i = 22;
sprintf(buffer2, "%03d   ", i);
Oled_SetFont(Terminal12x16, 12, 16, 32 , 127);
Oled_ResetScroll();
while(1){
Oled_TextScroll(buffer2);
Delay_ms(50);
}


Resets the scroll.
Oled_ResetScroll(void)
This function must be called before of a new scroll function.
Example:
Oled_ResetScroll();


Fills OLED memory.
Oled_FillScreen(pattern)

  • pattern: byte to fill OLED memory.
Example:
Oled_FillScreen(0xFF);


Displays bitmap on OLED.
void Oled_Image(buffer)

  • buffer: image to be displayed.
Example:
Oled_Image(truck_bmp);


Displays an image on a desired location.
Oled_Icon(buffer, seg, pag, _width, _height)

  • buffer: image to be displayed.
  • seg: sets the segment. Valid values: 0..127
  • pag: sets the page. Valid values: 0..7
  • _width sets the width of the image.
  • _height sets the height of the image.
Example:
Oled_Icon(icon1, 20, 3, 32, 32);


Inverts the RAM memory.
Oled_InvertRam(seg1, pag1, seg2, pag2)

  • seg1 sets the start segment. Valid values: 0..127
  • pag1 sets the start page. Valid values: 0..7
  • seg2 sets the end segment. Valid values: 0..127
  • pag2 sets the end page. Valid values: 0..7
Example:
Oled_InvertRam(0, 0, 127, 7);


Draws a Pixel on OLED.
Oled_Pixel(x, y, color)

  • x: x position. Valid values: 0..127
  • y: y position. Valid values: 0..63
  • color: color parameter. Valid values: 1,2,3
Example:
Oled_Pixel(40, 40, BLACK);


Draws a Line on OLED.
Oled_Line(x1, y1, x2, y2, color)

  • x1: x coordinate of the line start. Valid values: 0..127
  • y1: y coordinate of the line start. Valid values: 0..63
  • x2: x coordinate of the line end. Valid values: 0..127
  • y2: y coordinate of the line end. Valid values: 0..63
  • color: color parameter. Valid values: 1,2,3
Example:
Oled_Line(0, 16, 127, 50, BLACK);

 
Draws a rectangle on OLED.
Oled_Rectangle(x1, y1, x2, y2, color)

  • x1: x coordinate of the upper left rectangle corner. Valid values: 0..127 
  • y1: y coordinate of the upper left rectangle corner. Valid values: 0..63
  • x2: x coordinate of the lower right rectangle corner. Valid values: 0..127
  • y2: y coordinate of the lower right rectangle corner. Valid values: 0..63
  • color: color parameter. Valid values: 1,2,3
Example:
Oled_Rectangle(16, 16, 112, 46, BLACK);

 
Draws a circle on OLED.
Oled_Circle(x1, y1, radius, color)

  • x1: x coordinate of the circle center. Valid values: 0..127
  • y1: y coordinate of the circle center. Valid values: 0..63
  • radius: radius size
  • color: color parameter. Valid values: 1,2,3
Example:
Oled_Circle(63, 31, 5, BLACK);


Schematic.


New driver V4.0 optimized for SPI and I2C interface.
 
Features.
  • Easy integration.
  • SPI and I2C fast refresh. 
  • 4 modes of rotation. 
  • MCC support.
  • New functions.
  • Microchip and STM32 support.
Displays supported.
  • SSD1306            96x16
  • SSD1306            128x32
  • SSD1306            128x64
  • SSD1309            128x64
  • SH1106              132x64
  • SH1107              64x128
  • UC1609C          192x64
  • ST7565R           128x64
  • NOKIA5110       84x48 
 How to port the library using MPLABX with MCC.
 
 
How to select a display.
 

 How to configure the library to be used on the I2C interface.