Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * lcd.c
- *
- * Created on: Nov 4, 2019
- * Author: Student_CLL
- */
- #include "lcd.h"
- void init_lcd()
- {
- setPort(&DDRC, 0xff);
- setPort(&DDRB, 0xff);
- for(int i=0;i<4;i++)
- CommandLCD(0x38);
- CommandLCD(0x08);
- CommandLCD(0x01);
- CommandLCD(0x06);
- CommandLCD(0x0E);
- }
- void CommandLCD(uint8_t comm)
- {
- setPort(&PORTB, 0b00000001);
- _delay_ms(5);
- setPort(&PORTC, comm);
- _delay_ms(5);
- setPort(&PORTB, 0x00);
- _delay_ms(5);
- }
- void WriteLCD(uint8_t caracter)
- {
- setPort(&PORTB, 0b00000011);
- _delay_ms(5);
- setPort(&PORTC, caracter);
- _delay_ms(5);
- setPort(&PORTB, 0x00);
- _delay_ms(5);
- }
- void PlaceCursor(uint8_t poz, uint8_t lin)
- {
- uint8_t pozitie = 0x80;
- pozitie |= poz;
- pozitie |= (lin-1)<<6;
- CommandLCD(pozitie);
- }
- void ClearLCD()
- {
- CommandLCD(0x01);
- }
- void afisare_string(char sir[], uint8_t col, uint8_t lin)
- {
- if(strlen(sir) + col > 15)
- PlaceCursor(col-strlen(sir)+1, lin);
- else
- PlaceCursor(col, lin);
- for(int i=0; sir[i] != '\0'; i++)
- WriteLCD(sir[i]);
- }
- void problema2()
- {
- afisare_string("am",0,1);
- afisare_string("afisat",15,1);
- afisare_string("un",0,2);
- afisare_string("text",15,2);
- }
- void problema3()
- {
- for(int i = 0; i<10;i++)
- {
- PlaceCursor(0,1);
- WriteLCD(i+'0');
- PlaceCursor(2,1);
- WriteLCD(i+'0');
- PlaceCursor(1,2);
- WriteLCD(i+'0');
- PlaceCursor(3,2);
- WriteLCD(i+'0');
- _delay_ms(1000);
- }
- }
- void problema4()
- {
- uint8_t ora = 0;
- uint8_t minut = 0;
- }
- void scade_ora(uint8_t *ora)
- {
- (*ora)--;
- if(*ora<0)
- *ora = 23;
- }
- void creste_ora(uint8_t *ora)
- {
- (*ora)++;
- if(*ora>23)
- *ora = 0;
- }
- void scade_minut(uint8_t *ora, uint8_t *minut)
- {
- (*minut)--;
- if(*minut<0)
- {
- *minut = 59;
- scade_ora(ora);
- }
- }
- void creste_minut(uint8_t *ora, uint8_t *minut)
- {
- (*minut)++;
- if(*minut>59)
- {
- *minut = 0;
- creste_ora(ora);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement