Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct
- {
- int d0, d1, d2, d3, d4, d5, d6, d7;
- int is_4bits;
- } lcd_module;
- void lcd_attach(lcd_module* lcd)
- {
- if (lcd->is_4bits)
- {
- // Attach 4 bits
- }
- else
- {
- // Attach 8 bits
- }
- }
- void lcd_send_cmd(lcd_module* lcd, int cmd)
- {
- if (lcd->is_4bits)
- {
- // Send 4 bits command
- }
- else
- {
- // Send 8 bits command
- }
- }
- int main(void)
- {
- lcd_module lcd4;
- lcd_module lcd8;
- // Setup
- lcd4.d4 = 1;
- lcd4.is_4bits = 1;
- lcd8.d0 = 2;
- lcd8.is_4bits = 0;
- // Etc
- // Attach
- lcd_attach(&lcd4);
- lcd_attach(&lcd8);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement