Marcelo Costanzo Miranda
/
ST7920_TEST_sem_lib_2
ST7920 Testes
ST7920.h@1:08481151e25e, 2020-12-14 (annotated)
- Committer:
- Marcelocostanzo
- Date:
- Mon Dec 14 19:10:22 2020 +0000
- Revision:
- 1:08481151e25e
Versao de testes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Marcelocostanzo | 1:08481151e25e | 1 | #include "mbed.h" |
Marcelocostanzo | 1:08481151e25e | 2 | |
Marcelocostanzo | 1:08481151e25e | 3 | #define OFF 0 |
Marcelocostanzo | 1:08481151e25e | 4 | #define ON 1 |
Marcelocostanzo | 1:08481151e25e | 5 | |
Marcelocostanzo | 1:08481151e25e | 6 | // Instruction Set 1: (RE=0: Basic Instruction) |
Marcelocostanzo | 1:08481151e25e | 7 | #define DISPLAY_CLEAR 0x01 // Fill DDRAM with "20H" and set DDRAM address counter (AC) to "00H" |
Marcelocostanzo | 1:08481151e25e | 8 | #define RETURN_HOME 0x02 // Set DDRAM address counter (AC) to "00H", and put cursor |
Marcelocostanzo | 1:08481151e25e | 9 | // to origin �Gthe content of DDRAM are not changed |
Marcelocostanzo | 1:08481151e25e | 10 | #define ENTRY_MODE_SET 0x04 // Set cursor position and display shift when doing write or read |
Marcelocostanzo | 1:08481151e25e | 11 | // operation |
Marcelocostanzo | 1:08481151e25e | 12 | #define DISPLAY_CONTROL 0x08 // D=1: Display ON, C=1: Cursor ON, B=1: Character Blink ON |
Marcelocostanzo | 1:08481151e25e | 13 | #define CURSOR_DISPLAY_CONTROL 0x10 // Cursor position and display shift control; the content of |
Marcelocostanzo | 1:08481151e25e | 14 | // DDRAM are not changed |
Marcelocostanzo | 1:08481151e25e | 15 | #define FUNCTION_SET 0x20 // DL=1 8-bit interface, DL=0 4-bit interface |
Marcelocostanzo | 1:08481151e25e | 16 | // RE=1: extended instruction, RE=0: basic instruction |
Marcelocostanzo | 1:08481151e25e | 17 | #define SET_CGRAM_ADDRESS 0x40 // Set CGRAM address to address counter (AC) |
Marcelocostanzo | 1:08481151e25e | 18 | // Make sure that in extended instruction SR=0 |
Marcelocostanzo | 1:08481151e25e | 19 | #define SET_DDRAM_ADDRESS 0x80 // Set DDRAM address to address counter (AC) |
Marcelocostanzo | 1:08481151e25e | 20 | // AC6 is fixed to 0 |
Marcelocostanzo | 1:08481151e25e | 21 | |
Marcelocostanzo | 1:08481151e25e | 22 | // Instruction set 2: (RE=1: extended instruction) |
Marcelocostanzo | 1:08481151e25e | 23 | #define STANDBY 0x01 // Enter standby mode, any other instruction can terminate. |
Marcelocostanzo | 1:08481151e25e | 24 | // COM1�c32 are halted |
Marcelocostanzo | 1:08481151e25e | 25 | #define SCROLL_OR_RAM_ADDR_SEL 0x02 // SR=1: enable vertical scroll position |
Marcelocostanzo | 1:08481151e25e | 26 | // SR=0: enable CGRAM address (basic instruction) |
Marcelocostanzo | 1:08481151e25e | 27 | #define REVERSE_BY_LINE 0x04 // Select 1 out of 4 line (in DDRAM) and decide whether to |
Marcelocostanzo | 1:08481151e25e | 28 | // reverse the display by toggling this instruction |
Marcelocostanzo | 1:08481151e25e | 29 | // R1,R0 initial value is 0,0 |
Marcelocostanzo | 1:08481151e25e | 30 | #define EXTENDED_FUNCTION_SET 0x20 // DL=1 :8-bit interface, DL=0 :4-bit interface |
Marcelocostanzo | 1:08481151e25e | 31 | // RE=1: extended instruction, RE=0: basic instruction |
Marcelocostanzo | 1:08481151e25e | 32 | #define SET_SCROLL_ADDRESS 0x40 // G=1 :graphic display ON, G=0 :graphic display OFF |
Marcelocostanzo | 1:08481151e25e | 33 | #define SET_GRAPHIC_RAM_ADDRESS 0x80 // Set GDRAM address to address counter (AC) |
Marcelocostanzo | 1:08481151e25e | 34 | // Set the vertical address first and followed the horizontal |
Marcelocostanzo | 1:08481151e25e | 35 | // address by consecutive writings |
Marcelocostanzo | 1:08481151e25e | 36 | // Vertical address range: AC5�cAC0, Horizontal address range: AC3�cAC0 |
Marcelocostanzo | 1:08481151e25e | 37 | |
Marcelocostanzo | 1:08481151e25e | 38 | // Parameters regarding Instruction Sets 1 & 2 |
Marcelocostanzo | 1:08481151e25e | 39 | #define DISPLAY_SHIFT_S 0x01 // Set 1, ENTRY_MODE_SET |
Marcelocostanzo | 1:08481151e25e | 40 | #define INCREASE_DECREASE_ID 0x02 // Set 1, ENTRY_MODE_SET |
Marcelocostanzo | 1:08481151e25e | 41 | #define CURSOR_BLINK_ON_B 0x01 // Set 1, DISPLAY_CONTROL |
Marcelocostanzo | 1:08481151e25e | 42 | #define CURSOR_ON_C 0x02 // Set 1, DISPLAY_CONTROL |
Marcelocostanzo | 1:08481151e25e | 43 | #define DISPLAY_ON_D 0x04 // Set 1, DISPLAY_CONTROL |
Marcelocostanzo | 1:08481151e25e | 44 | #define SHIFT_RL 0x04 // Set 1, CURSOR_DISPLAY_CONTROL |
Marcelocostanzo | 1:08481151e25e | 45 | #define CURSOR_SC 0x08 // Set 1, CURSOR_DISPLAY_CONTROL |
Marcelocostanzo | 1:08481151e25e | 46 | #define EXTENDED_INSTRUCTION_RE 0x04 // Set 1, FUNCTION_SET; Set 2, EXTENDED_FUNTION_SET |
Marcelocostanzo | 1:08481151e25e | 47 | #define DATA_LENGTH_DL 0x10 // Set 1, FUNCTION_SET; Set 2, EXTENDED_FUNTION_SET |
Marcelocostanzo | 1:08481151e25e | 48 | #define REVERSE_BY_LINE_R0 0x01 // Set 2, REVERSE_BY_LINE |
Marcelocostanzo | 1:08481151e25e | 49 | #define REVERSE_BY_LINE_R1 0x02 // Set 2, REVERSE_BY_LINE |
Marcelocostanzo | 1:08481151e25e | 50 | #define EN_VERTICAL_SCROLL_SR 0x01 // Set 2, SCROLL_OR_RAM_ADDR_SEL |
Marcelocostanzo | 1:08481151e25e | 51 | #define GRAPHIC_ON_G 0x02 // Set 2, EXTENDED_FUNTION_SET |
Marcelocostanzo | 1:08481151e25e | 52 | |
Marcelocostanzo | 1:08481151e25e | 53 | #define BUSY_FLAG_BF 0x80 |
Marcelocostanzo | 1:08481151e25e | 54 | |
Marcelocostanzo | 1:08481151e25e | 55 | |
Marcelocostanzo | 1:08481151e25e | 56 | void ST7920_Init(void); |
Marcelocostanzo | 1:08481151e25e | 57 | void ST7920_Clear(void); |
Marcelocostanzo | 1:08481151e25e | 58 | void ST7920_SetGraphicsMode(void); |
Marcelocostanzo | 1:08481151e25e | 59 | void ST7920_SetTextMode(void); |
Marcelocostanzo | 1:08481151e25e | 60 | void ST7920_DrawHorizontalLine(uint8_t X, uint8_t Y, uint8_t LEN); |
Marcelocostanzo | 1:08481151e25e | 61 | void ST7920_DrawVerticalLine(uint8_t X, uint8_t Y, uint8_t LEN); |
Marcelocostanzo | 1:08481151e25e | 62 | void ST7920_DisplayString(int Row,int Column,unsigned char *ptr,int length); |