Skip to main content
deleted 8 characters in body
Source Link
Sim Son
  • 1.9k
  • 14
  • 21

You do some strange things that I, at least, don't understand (e.g. I don't see what you need posretry for), but you might have a reason for doing so. But you don't reset posretry and pos, which means they will very soon be out of a reasonable range. At some point the int will actually overflow to negative values, which is definitely not going to work!

To make it less complicate, you should write a function that prints the char array shifted by a desired value as a beginning.

The below code is completely untested as I don't have your hardware and I'm aware that it does not include all your desired features. But it should give you an idea of how scrolling can be implemented in principle and it's up to you to improve/fix it.

#define LCD_SIZE 16
#define STR_LEN 12
char str_to_print[STR_LEN]={'T', 'r', 'u', 'e', 't', 'z', 's', 'c', 'h', 'l', 'e', 'r'};

void print_scrolled (uint8_t scrolled_by) {
  for (uint8_t i=0;i<LCD_SIZE;i++) {
    if lcd.set_cursor(scrolled_by>=LCD_SIZEi,0) scrolled_by=0;;
    
   if lcd.set_cursor(i,0scrolled_by>=LCD_SIZE); scrolled_by=0;

    if (scrolled_by<STR_SIZE) lcd.print(str_to_print[scrolled_by]);
    else lcd.print(' ');
    scrolled_by++;
  }
}

You could call it like this:

for (uint8_t i=0;i<STR_LEN;i++) {
  print_scrolled(i);
  delay(500);
}

Once you are familiar with my approach you should be able to enhance it with additional features (end of text coming in from the other side, spaces between end and beginning, etc).

You do some strange things that I, at least, don't understand (e.g. I don't see what you need posretry for), but you might have a reason for doing so. But you don't reset posretry and pos, which means they will very soon be out of a reasonable range. At some point the int will actually overflow to negative values, which is definitely not going to work!

To make it less complicate, you should write a function that prints the char array shifted by a desired value as a beginning.

The below code is completely untested as I don't have your hardware and I'm aware that it does not include all your desired features. But it should give you an idea of how scrolling can be implemented in principle and it's up to you to improve/fix it.

#define LCD_SIZE 16
#define STR_LEN 12
char str_to_print[STR_LEN]={'T', 'r', 'u', 'e', 't', 'z', 's', 'c', 'h', 'l', 'e', 'r'};

void print_scrolled (uint8_t scrolled_by) {
  for (uint8_t i=0;i<LCD_SIZE;i++) {
    if (scrolled_by>=LCD_SIZE) scrolled_by=0;
    
    lcd.set_cursor(i,0);
    if (scrolled_by<STR_SIZE) lcd.print(str_to_print[scrolled_by]);
    else lcd.print(' ');
    scrolled_by++;
  }
}

You could call it like this:

for (uint8_t i=0;i<STR_LEN;i++) {
  print_scrolled(i);
  delay(500);
}

Once you are familiar with my approach you should be able to enhance it with additional features (end of text coming in from the other side, spaces between end and beginning, etc).

You do some strange things that I, at least, don't understand (e.g. I don't see what you need posretry for), but you might have a reason for doing so. But you don't reset posretry and pos, which means they will very soon be out of a reasonable range. At some point the int will actually overflow to negative values, which is definitely not going to work!

To make it less complicate, you should write a function that prints the char array shifted by a desired value as a beginning.

The below code is completely untested as I don't have your hardware and I'm aware that it does not include all your desired features. But it should give you an idea of how scrolling can be implemented in principle and it's up to you to improve/fix it.

#define LCD_SIZE 16
#define STR_LEN 12
char str_to_print[STR_LEN]={'T', 'r', 'u', 'e', 't', 'z', 's', 'c', 'h', 'l', 'e', 'r'};

void print_scrolled (uint8_t scrolled_by) {
  for (uint8_t i=0;i<LCD_SIZE;i++) {
    lcd.set_cursor(i,0);
    if (scrolled_by>=LCD_SIZE) scrolled_by=0;

    if (scrolled_by<STR_SIZE) lcd.print(str_to_print[scrolled_by]);
    else lcd.print(' ');
    scrolled_by++;
  }
}

You could call it like this:

for (uint8_t i=0;i<STR_LEN;i++) {
  print_scrolled(i);
  delay(500);
}

Once you are familiar with my approach you should be able to enhance it with additional features (end of text coming in from the other side, spaces between end and beginning, etc).

added 65 characters in body; deleted 91 characters in body
Source Link
Sim Son
  • 1.9k
  • 14
  • 21

You do some strange things that I, at least, don't understand (e.g. I don't see what you need posretry for), but you might have a reason for doing so. But you don't reset posretry and pos, which means they will very soon be out of a reasonable range. At some point the int will actually overflow to negative values, which is definitely not going to work!

To make it less complicate, you should write a function that prints the char array shifted by a desired value as a beginning.

The below code is completely untested as I don't have your hardware and I'm aware that it does not include all your desired features. Also I expect it to print some characters twice if the char array is shorter that the LCD. But it should give you an idea of how scrolling can be implemented in principle and it's up to you to improve/fix it.

#define LCD_SIZE 16
#define STR_LEN 12
char str_to_print[STR_LEN]={'T', 'r', 'u', 'e', 't', 'z', 's', 'c', 'h', 'l', 'e', 'r'};

void print_scrolled (uint8_t scrolled_by) {
  for (uint8_t i=0;i<LCD_SIZE;i++) {
    if (scrolled_by>=STR_LENscrolled_by>=LCD_SIZE) scrolled_by=0;
    
    lcd.set_cursor(i,0);
    if (scrolled_by<STR_SIZE) lcd.print(str_to_print[scrolled_by]);
    else lcd.print(' ');
    scrolled_by++;
  }
}

You could call it like this:

for (uint8_t i=0;i<STR_LEN;i++) {
  print_scrolled(i);
  delay(500);
}

Once you are familiar with my approach you should be able to enhance it with additional features (end of text coming in from the other side, spaces between end and beginning, etc).

You do some strange things that I, at least, don't understand (e.g. I don't see what you need posretry for), but you might have a reason for doing so. But you don't reset posretry and pos, which means they will very soon be out of a reasonable range. At some point the int will actually overflow to negative values, which is definitely not going to work!

To make it less complicate, you should write a function that prints the char array shifted by a desired value as a beginning.

The below code is completely untested as I don't have your hardware and I'm aware that it does not include all your desired features. Also I expect it to print some characters twice if the char array is shorter that the LCD. But it should give you an idea of how scrolling can be implemented in principle and it's up to you to improve/fix it.

#define LCD_SIZE 16
#define STR_LEN 12
char str_to_print[STR_LEN]={'T', 'r', 'u', 'e', 't', 'z', 's', 'c', 'h', 'l', 'e', 'r'};

void print_scrolled (uint8_t scrolled_by) {
  for (uint8_t i=0;i<LCD_SIZE;i++) {
    if (scrolled_by>=STR_LEN) scrolled_by=0;
    lcd.set_cursor(i,0);
    lcd.print(str_to_print[scrolled_by]);
    scrolled_by++;
  }
}

You could call it like this:

for (uint8_t i=0;i<STR_LEN;i++) {
  print_scrolled(i);
  delay(500);
}

Once you are familiar with my approach you should be able to enhance it with additional features (end of text coming in from the other side, spaces between end and beginning, etc).

You do some strange things that I, at least, don't understand (e.g. I don't see what you need posretry for), but you might have a reason for doing so. But you don't reset posretry and pos, which means they will very soon be out of a reasonable range. At some point the int will actually overflow to negative values, which is definitely not going to work!

To make it less complicate, you should write a function that prints the char array shifted by a desired value as a beginning.

The below code is completely untested as I don't have your hardware and I'm aware that it does not include all your desired features. But it should give you an idea of how scrolling can be implemented in principle and it's up to you to improve/fix it.

#define LCD_SIZE 16
#define STR_LEN 12
char str_to_print[STR_LEN]={'T', 'r', 'u', 'e', 't', 'z', 's', 'c', 'h', 'l', 'e', 'r'};

void print_scrolled (uint8_t scrolled_by) {
  for (uint8_t i=0;i<LCD_SIZE;i++) {
    if (scrolled_by>=LCD_SIZE) scrolled_by=0;
    
    lcd.set_cursor(i,0);
    if (scrolled_by<STR_SIZE) lcd.print(str_to_print[scrolled_by]);
    else lcd.print(' ');
    scrolled_by++;
  }
}

You could call it like this:

for (uint8_t i=0;i<STR_LEN;i++) {
  print_scrolled(i);
  delay(500);
}

Once you are familiar with my approach you should be able to enhance it with additional features (end of text coming in from the other side, spaces between end and beginning, etc).

added 128 characters in body
Source Link
Sim Son
  • 1.9k
  • 14
  • 21

You do some strange things that I, at least, don't understand (e.g. I don't see what you need posretry for), but you might have a reason for doing so. But you don't reset posretry and pos, which means they will very soon be out of a reasonable range. At some point the int will actually overflow to negative values, which is definitely not going to work!

To make it less complicate, you should write a function that prints the char array shifted by a desired value as a beginning.

The below code is completely untested as I don't have your hardware and I'm aware that it does not include all your desired features. Also I expect it to print some characters twice if the char array is shorter that the LCD. But it should give you an idea of how scrolling can be implemented in principle and it's up to you to improve/fix it.

#define LCD_SIZE 16
#define STR_LEN 12
char str_to_print[STR_LEN]={'T', 'r', 'u', 'e', 't', 'z', 's', 'c', 'h', 'l', 'e', 'r'};

void print_scrolled (uint8_t scrolled_by) {
  for (uint8_t i=0;i<LCD_SIZE;i++) {
    if (scrolled_by>=STR_LEN) scrolled_by=0;
    lcd.set_cursor(i,0);
    lcd.print(str_to_print[scrolled_by]);
    scrolled_by++;
  }
}

You could call it like this:

for (uint8_t i=0;i<STR_LEN;i++) {
  print_scrolled(i);
  delay(500);
}

Once you are familiar with my approach you should be able to enhance it with additional features (end of text coming in from the other side, spaces between end and beginning, etc).

You do some strange things that I, at least, don't understand (e.g. I don't see what you need posretry for), but you might have a reason for doing so. But you don't reset posretry and pos, which means they will very soon be out of a reasonable range. At some point the int will actually overflow to negative values, which is definitely not going to work!

To make it less complicate, you should write a function that prints the char array shifted by a desired value as a beginning.

The below code is completely untested as I don't have your hardware and I'm aware that it does not include all your desired features. But it should give you an idea of how scrolling can be implemented in principle.

#define LCD_SIZE 16
#define STR_LEN 12
char str_to_print[STR_LEN]={'T', 'r', 'u', 'e', 't', 'z', 's', 'c', 'h', 'l', 'e', 'r'};

void print_scrolled (uint8_t scrolled_by) {
  for (uint8_t i=0;i<LCD_SIZE;i++) {
    if (scrolled_by>=STR_LEN) scrolled_by=0;
    lcd.set_cursor(i,0);
    lcd.print(str_to_print[scrolled_by]);
    scrolled_by++;
  }
}

You could call it like this:

for (uint8_t i=0;i<STR_LEN;i++) {
  print_scrolled(i);
  delay(500);
}

Once you are familiar with my approach you should be able to enhance it with additional features (end of text coming in from the other side, spaces between end and beginning, etc).

You do some strange things that I, at least, don't understand (e.g. I don't see what you need posretry for), but you might have a reason for doing so. But you don't reset posretry and pos, which means they will very soon be out of a reasonable range. At some point the int will actually overflow to negative values, which is definitely not going to work!

To make it less complicate, you should write a function that prints the char array shifted by a desired value as a beginning.

The below code is completely untested as I don't have your hardware and I'm aware that it does not include all your desired features. Also I expect it to print some characters twice if the char array is shorter that the LCD. But it should give you an idea of how scrolling can be implemented in principle and it's up to you to improve/fix it.

#define LCD_SIZE 16
#define STR_LEN 12
char str_to_print[STR_LEN]={'T', 'r', 'u', 'e', 't', 'z', 's', 'c', 'h', 'l', 'e', 'r'};

void print_scrolled (uint8_t scrolled_by) {
  for (uint8_t i=0;i<LCD_SIZE;i++) {
    if (scrolled_by>=STR_LEN) scrolled_by=0;
    lcd.set_cursor(i,0);
    lcd.print(str_to_print[scrolled_by]);
    scrolled_by++;
  }
}

You could call it like this:

for (uint8_t i=0;i<STR_LEN;i++) {
  print_scrolled(i);
  delay(500);
}

Once you are familiar with my approach you should be able to enhance it with additional features (end of text coming in from the other side, spaces between end and beginning, etc).

Source Link
Sim Son
  • 1.9k
  • 14
  • 21
Loading