Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5941
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« on: May 10, 2011, 07:42:42 pm » |
|
|
|
|
« Last Edit: May 20, 2011, 10:36:45 pm by liudr »
|
Logged
|
|
|
|
|
Rome - Italy
Offline
Full Member
Karma: 2
Posts: 246
Arduino UNO "Noob" User
|
 |
« Reply #1 on: May 12, 2011, 09:18:19 am » |
italian food is the best one 
|
|
|
|
|
Logged
|
|
|
|
|
Tennessee
Offline
Newbie
Karma: 0
Posts: 22
|
 |
« Reply #2 on: May 12, 2011, 10:20:32 am » |
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. 
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5941
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #3 on: May 12, 2011, 12:16:08 pm » |
italian food is the best one  I don't know all those shapes but they're all good with the right sauce and meat/shrimp.  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.
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5941
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #4 on: May 12, 2011, 12:24:31 pm » |
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.  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.
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5941
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #5 on: May 17, 2011, 11:11:23 pm » |
New features are added: scrolling text area and yes/no dialog. See OP for the video or here:
|
|
|
|
|
Logged
|
|
|
|
|
North Yorkshire, UK
Offline
Faraday Member
Karma: 104
Posts: 5531
|
 |
« Reply #6 on: May 18, 2011, 02:54:00 am » |
Neat! 
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5941
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #7 on: May 18, 2011, 11:45:04 am » |
Neat!  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.
|
|
|
|
|
Logged
|
|
|
|
|
North Yorkshire, UK
Offline
Faraday Member
Karma: 104
Posts: 5531
|
 |
« Reply #8 on: May 19, 2011, 03:24:26 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Norway
Offline
Sr. Member
Karma: 4
Posts: 422
microscopic quantum convulsions of space-time
|
 |
« Reply #9 on: May 19, 2011, 04:28:41 am » |
Nice! Also nice touch with the scrollbar there! 
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5941
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #10 on: May 19, 2011, 08:28:21 am » |
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(' '); } } }
2. 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; } } }
3. 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
|
|
|
|
|
Logged
|
|
|
|
|
North Yorkshire, UK
Offline
Faraday Member
Karma: 104
Posts: 5531
|
 |
« Reply #11 on: May 20, 2011, 12:54:43 pm » |
Oh I am still here by the way - just haven't had chance to test this yet. It's on my list 
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5941
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #12 on: May 20, 2011, 03:22:03 pm » |
Oh I am still here by the way - just haven't had chance to test this yet. It's on my list  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.
|
|
|
|
|
Logged
|
|
|
|
|
North Yorkshire, UK
Offline
Faraday Member
Karma: 104
Posts: 5531
|
 |
« Reply #13 on: May 20, 2011, 04:37:23 pm » |
Cool - I'll have a play then. I fancy a scrolling menu too  I've got one half coded here somewhere.
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5941
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #14 on: May 20, 2011, 05:24:21 pm » |
Cool - I'll have a play then. I fancy a scrolling menu too  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?
|
|
|
|
|
Logged
|
|
|
|
|
|