1 | #ifndef DISPLAY_HEADER
|
2 | #define DISPLAY_HEADER
|
3 |
|
4 | #define Set_Lower_Column_Start_Address_CMD 0x00
|
5 | #define Set_Higher_Column_Start_Address_CMD 0x10
|
6 | #define Set_Memory_Addressing_Mode_CMD 0x20
|
7 | #define Set_Column_Address_CMD 0x21
|
8 | #define Set_Page_Address_CMD 0x22
|
9 | #define Set_Display_Start_Line_CMD 0x40
|
10 | #define Set_Contrast_Control_CMD 0x81
|
11 | #define Set_Charge_Pump_CMD 0x8D
|
12 | #define Set_Segment_Remap_CMD 0xA0
|
13 | #define Set_Entire_Display_ON_CMD 0xA4
|
14 | #define Set_Normal_or_Inverse_Display_CMD 0xA6
|
15 | #define Set_Multiplex_Ratio_CMD 0xA8
|
16 | #define Set_Display_ON_or_OFF_CMD 0xAE
|
17 | #define Set_Page_Start_Address_CMD 0xB0
|
18 | #define Set_COM_Output_Scan_Direction_CMD 0xC0
|
19 | #define Set_Display_Offset_CMD 0xD3
|
20 | #define Set_Display_Clock_CMD 0xD5
|
21 | #define Set_Pre_charge_Period_CMD 0xD9
|
22 | #define Set_Common_HW_Config_CMD 0xDA
|
23 | #define Set_VCOMH_Level_CMD 0xDB
|
24 | #define Set_NOP_CMD 0xE3
|
25 |
|
26 | #define Horizontal_Addressing_Mode 0x00
|
27 | #define Vertical_Addressing_Mode 0x01
|
28 | #define Page_Addressing_Mode 0x02
|
29 |
|
30 | #define Disable_Charge_Pump 0x00
|
31 | #define Enable_Charge_Pump 0x04
|
32 |
|
33 | #define Column_Address_0_Mapped_to_SEG0 0x00
|
34 | #define Column_Address_0_Mapped_to_SEG127 0x01
|
35 |
|
36 | #define Normal_Display 0x00
|
37 | #define Entire_Display_ON 0x01
|
38 |
|
39 | #define Non_Inverted_Display 0x00
|
40 | #define Inverted_Display 0x01
|
41 |
|
42 | #define Display_OFF 0x00
|
43 | #define Display_ON 0x01
|
44 |
|
45 | #define Scan_from_COM0_to_63 0x00
|
46 | #define Scan_from_COM63_to_0 0x08
|
47 |
|
48 | #define x_size 128
|
49 | #define x_max x_size
|
50 | #define x_min 0
|
51 | #define y_size 64
|
52 | #define y_max 8
|
53 | #define y_min 0
|
54 |
|
55 | #define ON 1
|
56 | #define OFF 0
|
57 |
|
58 | #define YES 1
|
59 | #define NO 0
|
60 |
|
61 | #define HIGH 1
|
62 | #define LOW 0
|
63 |
|
64 | #define ROUND 1
|
65 | #define SQUARE 0
|
66 |
|
67 | #define DAT 1
|
68 | #define CMD 0
|
69 |
|
70 | #define buffer_size (x_max * y_max)
|
71 |
|
72 |
|
73 | uint8_t buffer[buffer_size];
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | inline void DISPLAY_CTRL_RST(uint8_t level)
|
79 | {
|
80 | if (level) PORTD.OUT |= (1<<PIN5_bp);
|
81 | else PORTD.OUT &= ~(1<<PIN5_bp);
|
82 | }
|
83 | inline void DISPLAY_CTRL_DC(uint8_t level)
|
84 | {
|
85 | if (level) PORTD.OUT |= (1<<PIN4_bp);
|
86 | else PORTD.OUT &= ~(1<<PIN4_bp);
|
87 | }
|
88 | inline void DISPLAY_CTRL_RW(uint8_t level)
|
89 | {
|
90 | if (level) PORTD.OUT |= (1<<PIN3_bp);
|
91 | else PORTD.OUT &= ~(1<<PIN3_bp);
|
92 | }
|
93 | inline void DISPLAY_CTRL_ERD(uint8_t level)
|
94 | {
|
95 | if (level) PORTD.OUT |= (1<<PIN2_bp);
|
96 | else PORTD.OUT &= ~(1<<PIN2_bp);
|
97 | }
|
98 | inline void DISPLAY_CTRL_CS(uint8_t level)
|
99 | {
|
100 | if (level) PORTB.OUT |= (1<<PIN0_bp);
|
101 | else PORTB.OUT &= ~(1<<PIN0_bp);
|
102 | }
|
103 |
|
104 |
|
105 | void swap(int16_t *a, int16_t *b);
|
106 | void OLED_write(uint8_t value, uint8_t type);
|
107 | inline void OLED_reset_sequence();
|
108 | inline void OLED_init();
|
109 | void OLED_gotoxy(uint8_t x_pos, uint8_t y_pos);
|
110 | void OLED_fill(uint8_t bmp_data);
|
111 | void OLED_clear_screen();
|
112 | void OLED_clear_buffer();
|
113 | void OLED_cursor(uint8_t x_pos, uint8_t y_pos);
|
114 | void OLED_print_Image(const uint8_t *bmp, uint8_t pixel);
|
115 | void OLED_draw_bitmap(uint8_t xb, uint8_t yb, uint8_t xe, uint8_t ye, uint8_t *bmp_img);
|
116 | void OLED_print_char(uint8_t x_pos, uint8_t y_pos, uint8_t ch);
|
117 | void OLED_print_string(uint8_t x_pos, uint8_t y_pos, uint8_t *ch);
|
118 | void OLED_print_chr(uint8_t x_pos, uint8_t y_pos, int16_t value);
|
119 | void OLED_print_int(uint8_t x_pos, uint8_t y_pos, int32_t value);
|
120 | void OLED_print_decimal(uint8_t x_pos, uint8_t y_pos, uint16_t value, uint8_t points);
|
121 | void OLED_print_float(uint8_t x_pos, uint8_t y_pos, float value, uint8_t points);
|
122 | void Draw_Pixel(uint8_t x_pos, uint8_t y_pos, uint8_t colour);
|
123 | void Draw_Line(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t colour);
|
124 | void Draw_V_Line(int16_t x1, int16_t y1, int16_t y2, uint8_t colour);
|
125 | void Draw_H_Line(int16_t x1, int16_t x2, int16_t y1, uint8_t colour);
|
126 | void Draw_Triangle(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t x3, int16_t y3, uint8_t fill, uint16_t colour);
|
127 | void Draw_Rectangle(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t fill, uint8_t colour, uint8_t type);
|
128 | void Draw_Circle(int16_t xc, int16_t yc, int16_t radius, uint8_t fill, uint8_t colour);
|
129 | #endif
|