lcd_i2c_setCursor f...
 
Notifications
Clear all

lcd_i2c_setCursor function for LCD 20x04

6 Posts
2 Users
0 Likes
382 Views
luke514
(@luke514)
Posts: 4
New Member
Topic starter
 

I just started programming, I am using a 20x04 LCD with STM32F407G and I need the classic function "lcd_i2c_setCursor (row, col);". I am not able to implement it by modifying the one already in the 16x02 display library.

 So I am asking if you can redirect/send me to a post or link where this function is explained for 20x04 or if someone already has it and can attach the code so that I can "copy-paste" it into my project.

 Or if there is a way to modify the function "lcd_i2c_setCursor (row, col);" that I have for the 16x02 LCD ... we can modify it here together:

void lcd16x2_i2c_setCursor(uint8_t row, uint8_t col)
{
  uint8_t maskData;
  maskData = (col)&0x0F;
  if(row==0)
  {
    maskData |= (0x80);
    lcd16x2_i2c_sendCommand(maskData);
  }
  else
  {
    maskData |= (0xc0);
    lcd16x2_i2c_sendCommand(maskData);
  }
}
 
Posted : 15/07/2022 2:59 pm
admin
(@admin)
Posts: 8
Active Member Admin
 

 

void lcd_put_cur(int row, int col)
{
    switch (row)
    {
        case 0:
            col |= 0x00;
            break;
        case 1:
            col |= 0x40;
            break;
        case 2:
            col |= 0x14;
            break;
        case 3:
            col |= 0x54;
            break;			
    }

    lcd_send_cmd (col);
}
 
Posted : 16/07/2022 5:19 pm
luke514
(@luke514)
Posts: 4
New Member
Topic starter
 

@admin Thank you for your reply 👍 

I added your function "lcd_put_cur" and tried to simulate this in the main:

(for my comfort I indicate the rows not from 0 to 3 but from 1 to 4 I find myself better visually when I'm using "lcd_send_string")

lcd_put_cur(0,0);
  lcd_send_string("row 1 col 1");
  HAL_Delay(1000);

  lcd_put_cur(1,1);
  lcd_send_string("row 2 col 2");
  HAL_Delay(1000);

  lcd_put_cur(2,2);
  lcd_send_string("row 3 col 3");
  HAL_Delay(1000);

  lcd_put_cur(3,3);
  lcd_send_string("row 4 col 4");
  HAL_Delay(1000);

But on the LCD I display the picture that I will attach in the next post also in response to your 16/07/2022 comment ... because I can't attach the whole project or more than two files here.

I am starting to think that there might be some problems for example in the function "lcd_send_cmd" or "lcd_send_string" ... so I'm attaching the lcd.c library of the LCD. If you can check for any problems, I am very grateful.

 

 

 
Posted : 17/07/2022 2:29 pm
luke514
(@luke514)
Posts: 4
New Member
Topic starter
 

@admin Thank you for your reply 👍 

I implemented the function you wrote and simulated in the main this:

(for my comfort, I'm printing with "lcd_send_string" by indicating the lines from 0 to 3 but from 1 to 4)

lcd_clear();


  lcd_put_cur(0,0);
  lcd_send_string("row 1 col 1");
  HAL_Delay(1000);

  lcd_put_cur(1,1);
  lcd_send_string("row 2 col 2");
  HAL_Delay(1000);

  lcd_put_cur(2,2);
  lcd_send_string("row 3 col 3");
  HAL_Delay(1000);

  lcd_put_cur(3,3);
  lcd_send_string("row 4 col 4");
  HAL_Delay(1000);

I am attaching what I display in the LCD.

Unfortunately, I can't attach the entire project or more than one file at a time, so I'll reply again to your comment of July 16, 2022 by attaching the "lcd.c" library I'm using ... because I start to think that there is something wrong for example in the function "lcd_send_cmd" or somewhere in the library.

 

 

 
Posted : 17/07/2022 2:40 pm
luke514
(@luke514)
Posts: 4
New Member
Topic starter
 

@admin 

Here is the library "lcd.c" that I am using. If you can take a look at it I would be very grateful

 
Posted : 17/07/2022 2:43 pm
admin
(@admin)
Posts: 8
Active Member Admin
 

@luke514 the website have a separate tutorial for it.

https://controllerstech.com/lcd-20x4-using-i2c-with-stm32/

 
Posted : 17/07/2022 3:03 pm
Share:

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add controllerstech.com to your ad blocking whitelist or disable your adblocking software.

×