Advertisement
Guest User

Untitled

a guest
Aug 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1.  
  2.  
  3. void delay(uint32_t volatile t){
  4.     while(t--){};
  5. };
  6.  
  7. char* const m[2] = {"asdfasdfasdfasdf\n", " s f s f s f s f\n" };
  8.  
  9.     while(1){
  10.        
  11.         lcd.GoToFirstLine();
  12.         lcd.WriteString(m[0]);
  13.         delay(0x30000);
  14.        
  15.         lcd.GoToFirstLine();
  16.         lcd.WriteString(m[1]);
  17.         delay(0x51000);
  18.        
  19.     };
  20.  
  21. void LCD::WriteString(char* str)
  22. {
  23.     for(uint8_t i=0; i<20; i++){
  24.         if(str[i] == '\n')break;
  25.         WriteCGR((uint8_t)(str[i]));
  26.     };
  27. };
  28.  
  29. void LCD::WriteCGR(uint8_t data)
  30. {
  31.     RS_H;
  32.     uint8_t lsb3bit = (data & 0x07) << 5;
  33.     PORTD &=~(0xE0);                   
  34.     PORTD |= lsb3bit;
  35.  
  36.     uint8_t msb5bit = (data & 0xF8) >> 3;
  37.     PORTB &=~(0x1F);
  38.     PORTB = msb5bit;
  39.    
  40.     EN_H;
  41.     Delay(0xff);
  42.     EN_L;
  43.        
  44.     RS_L;
  45. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement