Phi_prompt new release teaser - scrolling list items

UPDATE:
This is a new render option for list. The highlighted list item is always centered while the list scrolls up and down at button push:

UPDATE:
Here is another teaser showing off scrolling text areas using phi_prompt library that I will release soon. The text area can be any size and be displayed anywhere (no clipping on the display edge!). You also have the option to sacrifice a whole column of characters to display a DOS-looking scroll bar, tailored to the size of your text area and text length! Here you go mowcius!

The top line is just a fixed text output so it doesn't scroll.

ORIGINAL POST
I'm getting phi_prompt ready for a new release with the below additions:

  • Support 20X4 character screen with more flexible “2X2? list mode so you can list M columns by N rows with X characters per row, all M, N, and X are your choice (Done)

  • List your “2X2? list anywhere on a larger screen instead of the basic 16X2 screen (Done)

  • Easy to call “YES/NO” dialog.(Done)

  • Easy to display “YES/NO”, “HIGH/LOW” options for numerical inputs so you don’t have to construct a list and do it the list way.(Planning)

  • Add scrolling texts that scrolls to fit in smaller space (Done)

  • Add floating point number input (Done)

  • Add event function so each time the user changes a number, a function is called to update operations (planning)

  • Add dialog functions to make a dialog. This function creates a complete dialog with various controls and the user uses left and right keys to navigate among the controls and change their values. It is going to look like a dialog on your computer. You make some choices and push yes. (planning)

  • Add multi-line text display. (Done)

The new release will give developers freedom to display lists in m columns by n rows, and customize lists in other rendering modes. It also features auto-scrolling list items for items too long to fit in. See the teaser video below.

italian food is the best one :grin:

Cool stuff! #subscribed

Learning this stuff has made me REALLY respect the guys who develop stuff like smartphones. I used to brag on how much I knew electronics... I dont do that anymore. Nothing like being a noob with 20 years experience. 8)

Nikka93:
italian food is the best one :grin:

I don't know all those shapes but they're all good with the right sauce and meat/shrimp. :slight_smile:

I also tried to auto scroll all items that are too long but that started to look silly and distracting so I am only scrolling the highlighted item. No time for pasta today. It's going to be wraps.

Grendel:
Cool stuff! #subscribed

Learning this stuff has made me REALLY respect the guys who develop stuff like smartphones. I used to brag on how much I knew electronics... I dont do that anymore. Nothing like being a noob with 20 years experience. 8)

Thanks. I will make an effort to expand these features to GLCD this summer. character LCDs are good for basic display but you can't do too much interaction as there's no space. I will also see if I can incorporate a number pad as optional input beside the one I'm using.

New features are added: scrolling text area and yes/no dialog. See OP for the video or here:

Neat! :smiley:

mowcius:
Neat! :smiley:

Thanks mowcius. Once I am happy enough to release what I wrote recently, I can move on to port the functions to GLCD. This will be really interesting and even more useful.

I'd be interested to have a look at what you wrote for the scrolling text function - got a couple of ideas that I'd like to try with the scroll bar.

Nice! Also nice touch with the scrollbar there! :slight_smile:

mowcius:
I'd be interested to have a look at what you wrote for the scrolling text function - got a couple of ideas that I'd like to try with the scroll bar.

mowcius, here they are:

  1. The function that renders "long message", so displaying (including scroll bar) is done here:
void long_msg_lcd(phi_prompt_struct* para)
{
  byte columns=para->step.i/100, rows=para->step.i%100, ch;
  if (para->low.i>=strlen(para->ptr.msg)) ch=0;
  else ch=para->ptr.msg[para->low.i];
  for (byte i=0;i<rows;i++)
  {
    lcd->setCursor(para->col,para->row+i);
    for (byte j=0;j<columns;j++)
    {
      if (ch==0) lcd->write(' ');
      else
      {
        lcd->write(ch);
        ch=para->ptr.msg[para->low.i+i*columns+j+1];
      }
    }
  }
  if (para->option==1)
  {
    byte location=int((((float)para->low.i)/strlen(para->ptr.msg)*(rows*2-2)));
    for (byte i=0;i<rows;i++)
    {
      lcd->setCursor(para->col+columns,para->row+i);
      if (i==0)
      {
        if (location==0) lcd->write(0);
        else lcd->write(1);
      }
      
      else if (i==rows-1)
      {
        if (location==(rows*2-2-1)) lcd->write(5);
        else lcd->write(4);
      }

      else if ((location+1)/2==i)
      {
        if ((location-1)/2*2==location-1) lcd->write(2);
        else lcd->write(3);
      }
      else lcd->write(' ');
      
    }
  }
}
  1. This function interacts with the user (via keypad call wait_on_escape and lcd via the long_message function) so scrolling is done here:
    The reason I called this function text area is to correspond to Java's text area to display text.
int text_area(phi_prompt_struct *para)
{
  byte columns=para->step.i/100, rows=para->step.i%100, ch;
  long_msg_lcd(para);
  while(true)
  {
    byte temp1=wait_on_escape(50);
    switch (temp1)
    {
      case 1:
      if (para->low.i+columns<para->high.i)
      {
        para->low.i+=columns;
        long_msg_lcd(para);
      }
      break;
      
      case 2:
      if (para->low.i-columns>=0)
      {
        para->low.i-=columns;
        long_msg_lcd(para);
      }
      break;
      case 3: // Left is pressed
      return(-3);
      break;
      
      case 4: // Right is pressed
      return(-4);
      break;
      
      case 5: // Enter is pressed
      return(1);
      break;
      
      case 6: // Escape is pressed
      return (-1);
      break;
      
      default:
      break;
    }
  }
}
  1. Here's the struct in case you need it to understand the code:
    It tells you what each field holds besides comments inline with the code.
union buffer_pointer
{
int *i_buffer;
float * f_buffer;
char ** list;
char* msg;
};

union four_bytes
{
int i;
long l;
float f;
byte b;
char c;
};

struct phi_prompt_struct
{
  buffer_pointer ptr;
  four_bytes low; // Lower limit for text panel (.c), integers (.i) and floats (.f) and default item for list (.i)
  four_bytes high; // Upper limit for text panel (.c), integers (.i) and floats (.f) and last item for list (.i)
  four_bytes step;// Step size for integers (.i) and integer/decimal for floats (.i), such as 302 means 3 digits before decimal and 2 digits after.
  byte col; // Which column to display input
  byte row; // Which row to display input
  byte width; // Maximal number of character on integers, floats, a list item, and total allowed input characters for text panel
  int option; // What display options to choose
//  LiquidCrystal *lcd; // Which display to use. Removed in second release
//  phi_buttons **btns; // Which series of buttons to use. Removed in second release
  void (*update_function)(phi_prompt_struct *); // This is not being used in this version but reserved for future releases.
}; //22 bytes

Oh I am still here by the way - just haven't had chance to test this yet. It's on my list :slight_smile:

mowcius:
Oh I am still here by the way - just haven't had chance to test this yet. It's on my list :slight_smile:

I'll post the new library that includes all these and example code. Everything I planned for will either get released or wait for the next release. I feel like back in the early 90's programming in DOS except I am no longer using ASM, which is good for my age.

Cool - I'll have a play then. I fancy a scrolling menu too :slight_smile: I've got one half coded here somewhere.

mowcius:
Cool - I'll have a play then. I fancy a scrolling menu too :slight_smile: I've got one half coded here somewhere.

Do you mean a menu with highlighted item always in the middle and a key press scrolls all contents up or down one line at a time, instead of the following?

One more thing: do you want a list that wraps around itself so the highlighted item is always displayed in the middle:

10.
1.
2.High lighted item
3.
4.

Or do you want a list that starts from this:

1. High lighted item
2.
3.

Then it ends with this:

8.
9.
10. High lighted item

OK, one new list render version is out:
(Initially attached the wrong video)

Or do you want a list that starts from this:

1. High lighted item



Then it ends with this:


  1. High lighted item

Yeah that's what I meant. Then with a scroll bar like on your text view. I was thinking of just using the flashing cursor to show which is selected, then you don't miss out on another character by using an arrow/bullet down the side.

Now the right video is attached :sweat_smile:

Right, if I lose the dot I can save a character, but now I have scrolling items I can be less strict on space saving now. Doing flashing cursor is certainly easy but I don't know if GLCD has corresponding function when porting to GLCD. I'll give it a shot at flashing cursor though.

Here is a new draft for display options, any more input?

Display options:

Bit 0 – Arrow or dot. The first column of the list is a dot if it is not highlighted or an arrow if it is highlighted. This is very useful if you display more than one item on your list.
Bit 1 – index list 1 thru 0. This draws an index (1234567890) at column and row, encoded in step.i as column100+row. The highlighted item is indicated on the index as a special character, right now as “^”. In later version of the library, I might make this customizable.
Bit 2 – an index current/total, such as 5/12. This is drawn at column and row, encoded in step.i as column
100+row. The highlighted item is the number before the slash while the total list item is after the slash.
Bit 3 – auto scroll. This enables auto scrolling of list items that are too long to fit within given display width. Not enabling this option results in truncated display of first few characters that will fit within given display width.

Bit 4 – flashing cursor. This turns on a flashing black box enabled by the display. The cursor is at the beginning of the list item highlighted.
Bit 5 – Center choice. The highlighted item will always be centered in the display when possible (odd number of rows to display and plenty of items before and after the highlighted item). The list will scroll automatically to center the choice you might make.
Bit 6 – Scrolling bar. This displays a scrolling bar on the right side of the list. It looks like a DOS editor and is only useful for multi-line of list items. Make sure that you don't have anything immediately to the right of the list or run out of screen space.
Bit 7 – Reserved. This is reserved for future options and should not be used.