Графический LCD дисплей

790,00 рублей

Наличие товара: Товара нет в наличии

Графический LCD дисплей 128х64 точки. Синяя подсветка.

Графический LCD дисплей на базе контроллера ST7920.

Разрешение 128х64

Размер 93 х 70 х 13 мм.

Размер точки 0.48 х 0.48 мм.

Синяя подсветка.

Описание параллельного интерфейса:

1

VSS

0V

общий

2

VDD

+5V

+питания

3

V0

-

регулировка контрастности

4

RS

H/L

RS=H:shows data RS=L:controls instruction

5

R/W

H/L

R/W+H,E=H,data was read DB7-DB0

R/w=L,E=H=L:the data of DB7-DB0 was written to IR or DR

6

E

H/L

Enable pin

7-14

DB0-DB7

H/L

Data line

15

PSB

H/L

PSB=H,parallel mode,PSB=L,serial mode

16

NC

-

Empty pin

17

/RESET

H/L

Reset terminal,low level valid

18

Voult

-

Module drives voltage output terminal

19

A

+5V

+ питания подсветки

20

K

0V

- питания подсветки

 

Последовательного интерфейса (SPI)

Pin number

definition

level

Function specification

1

VSS

0V

Power supply negative

2

VDD

+5V

Power supply positive

3

V0

-

Contrast control

4

CS

H/L

Chip selection terminal,high level valid

5

SID

H/L

Serial data input terminal

6

CLK

H/L

Serial synchronous clock

15

PSB

H/L

PSB=H,parallel mode,PSB=L,serial mode

17

/RESET

H/L

Reset terminal,low level valid

19

A

+5V

Backlight power supply positive

20

K

0V

Backlight power supply negative

 

 

Код примера использования с Arduino:

/*
 * Drive an ST7920 LCD module via the serial interface.
 *
 * Data sheets:
 * - 12864ZB module http://read.pudn.com/downloads135/doc/573419/7920.pdf
 *   (in Chinese, but Google Translate is helpful)
 * - st7920 
 *   LCD controller http://www.crystalfontz.com/controllers/ST7920.pdf
 * - 328p MCU 
 *    http://www.atmel.com/dyn/resources/prod_documents/doc8271.pdf
 *
 * Configuration
 * LCD | 328/Arduino
 * ------------------------
 * GND | GND
 * VCC | 5V
 * E   | SCLK == PB5 == D13
 * RW  | MOSI == PB3 == D11
 * RST | PB0 == D8
 * RS  | 5V
 * A   | 390R to 5V
 * K   | GND
 *
 * Also bridged JP1 and JP2 to use onboard pot for contrast control.
 *
 * The trickiest part of getting this right was the control of the reset
 * pin. I found it quite finicky, and needing to be cycled just-so.
 */

#include 
#include 
#include 
#include 

void spi_init(void) {
   // SPI enable, master mode, clock idle high, sample data on trailing 
   // edge, Clock Frequency = Fosc / 8 = 2MHz
   SPCR = 0b01011101;
   SPSR = 0b00000001;

   // Set SS, MISO and PB0 as outputs
   DDRB = 0xff;
   PORTB = 0x1; // set PB0 - nonreset
}

void spi_send(int8_t b) {
   SPDR = b;
   while (!(SPSR & 0x80)) {
       // busy wait
   }
}

void lcd_instruction(int8_t ins) {
   spi_send(0b11111000); // 5 1 bits, RS = 0, RW = 0
   spi_send(ins & 0xf0);
   spi_send(ins << 4);     
   _delay_us(72); 
}  

void lcd_data(int8_t data) {
     spi_send(0b11111010); // 5 1 bits, RS = 1, RW = 0
     spi_send(data & 0xf0);
     spi_send(data << 4);
     _delay_us(72);
}  

void lcd_set_cursor(int8_t line, int8_t col) {
     // Contrary to the data sheet, the starting addresses for lines 
     // 0, 1, 2 and 3 are 80, 90, 88 and 98
     uint8_t d = 0x80 + col;
     if (line & 1) {
         d |= 0x10;
     }
     if (line & 2) {
         d |= 0x8;
     }
     lcd_instruction(d); 
}  

// Clears the screen 
void lcd_clear() {
     lcd_instruction(0b00000001); // clear
     _delay_ms(2); // Needs 1.62ms delay 
}  

// Reset, as per page 34 of 7920 data sheet 
void lcd_reset() {
      // Bring (PB0) low, then high
     PORTB &= ~0x01;
     _delay_ms(1);
     PORTB |= 0x01;
     _delay_ms(10);
     lcd_instruction(0b00110000); // 8 bit data, basic instructions
     lcd_instruction(0b00110000); // 8 bit data, basic instructions
     lcd_instruction(0b00001100); // display on
     lcd_clear();
     lcd_instruction(0b00000110); // increment, no shift 
}  

static char string_1[] PROGMEM = "Hello, World!";  

void lcd_send_str_p(PGM_P p) {
     uint8_t b;
     while (b = pgm_read_byte(p), b) {
         lcd_data(b);
         p++;
     } 
}  

int main(int argc, char **argv) {
     spi_init();
     _delay_ms(10);
     lcd_reset();
     uint8_t i = 0;
     while (1) {
       lcd_instruction(0x80);
       for (uint8_t c = 0; c < 64; c++) {
           lcd_data(39;139; + (c >> 4));
       }

       _delay_ms(1000);
       lcd_clear();

       lcd_instruction(0x80);
       for (uint8_t c = 0; c < 64; c++) {
           lcd_data(39;A39; + (c >> 4));
       }
       _delay_ms(1000);
       lcd_clear();

       lcd_set_cursor(i, i);
       lcd_send_str_p(string_1);
       i = (i + 1) & 3;
       _delay_ms(1000);

   }
}