/* Phi-1 shield and phi-menu for Arduino Test program: Phi-menu release for Phi-1 and phi-2 shields 20110312 Programmed by Dr. John Liu Revision: 03/12/2011 Commercial use without authorization is prohibited. Find details of the Phi-1 shield, Phi-2 shield or contact Dr. Liu at http://liudr.wordpress.com/phi-1-shield/ http://liudr.wordpress.com/phi-2-shield/ All rights reserved. Summary: This is part of the 20110312 release of phi-menu for phi-1 shields. Please refer to the ducomentation phi-menu_20110312.pdf at http://liudr.wordpress.com/phi-menu. */ //Utility functions void render_multi_line (int line_number) { } void render_number_in_place(int number) { char msg[11]; sprintf(msg,"%d",number); lcd.print(msg); } void render_00number_in_place(int number) { char msg[11]; sprintf(msg,"%02d",number); lcd.print(msg); } void render_char_in_place(int number) { lcd.write(number); } void render_YN_in_place(int number) { if (number==0) { lcd.print("NO"); } else { lcd.print("YES"); } } //Display strings stored in PROGMEM. Provide the string name stored in PROGMEM to be displayed on the LCD's current cursor position. void msg_lcd(char* msg_line) { char msg_buffer[17]; strcpy_P(msg_buffer,msg_line); lcd.print(msg_buffer); } //Renders bar graphs on 16*2 displays. Two bars each 10 blocks long will be drawn. max_v-1 gets all the bars. Number of blocks is value/max_v*20. void render_double_bar(int value, int max_v) { char msg[7]; int bar1, bar2, extra; byte i,j; long total_bar; total_bar=(20*((long)(value%max_v)))/((long)max_v); bar1=total_bar>=10?10:total_bar; bar2=total_bar>=10?(total_bar%10):0; extra=value/max_v; lcd.setCursor(0,0); for(i=0;i=lower) number-=inc; else number=upper; lcd.setCursor(column,row); lcd.print(msg); lcd.setCursor(column,row); (*update_function)(number); lcd.setCursor(column,row); break; case 3: // Left is pressed *current=number; lcd.noCursor(); return (-3); break; case 4: // Right is pressed *current=number; lcd.noCursor(); return (-4); break; case 5: // Enter is pressed *current=number; lcd.noCursor(); return(1); break; case 6: // Escape is pressed lcd.noCursor(); return (-1); break; default: break; } } } int input_panel3(char* msg, byte length, byte column, byte row, char _start, char _end) /* Alphanumerical input panel for texts up to 16 characters. The option starts with the character _start and ends with character _end The total length will not exceed length. The first letter appears at column, row The function prints the content of the buffer msg before polling for input The function returns number of actual characters The function returns -1 if the input is cancelled. The function fills the buffer after the last character with \0 only if the buffer is not filled. The caller is responsible to fill the character beyond the end of the buffer with \0. */ { byte pointer=0; int temp1, temp2; lcd.setCursor(column,row); lcd.print(msg); while (pointer0) pointer--; else return(-1); //When you are on the left most spot, pressing left one more time equals escape. Comment this line to disable this function. break; case -4: // Right. msg[pointer]=lowByte(temp2); if (pointer