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); } }
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); }
@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.
@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.