void string_write(char *mystring) { int i; //get_current_address(); //printf("writing string\n"); for (i=0; i<strlen(mystring); i++) { char_write(mystring[i]); //get_current_address(); } }
//write a substring to the LCD void string_write_numchars(char *mystring, int num_chars) { int i; get_current_address(); //printf("writing string\n"); for (i=0; i<num_chars; i++) { if (i >= strlen(mystring)) break; char_write(mystring[i]); get_current_address(); } }
int main (int argc, char *argv[]) { DDRB = 0xFF; cli(); //Init usart InitUSART(); //Enable Global Interrupts. Sets SREG Interrupt bit. sei(); //Intitialize LCD. Set Blinking cursor. lcd_cursor(); //_delay_ms(10000); while(1){ holder = getChar(); if (holder != '\0') char_write(holder); } return 0; //should never get here. }
int hypcnwrite(int dev, io_req_t ior) { return char_write(&hypcn_tty, ior); }
bool IVCONV::stlb_write ( FILE *fileout ) /******************************************************************************/ /* Purpose: STLB_WRITE writes a binary STL (stereolithography) file. Example: 80 byte string = header containing nothing in particular 4 byte int = number of faces For each face: 3 4-byte floats = components of normal vector to face; 3 4-byte floats = coordinates of first node; 3 4-byte floats = coordinates of second node; 3 4-byte floats = coordinates of third and final node; 2-byte int = attribute, whose value is 0. Discussion: The polygons in an STL file should only be triangular. This routine will try to automatically decompose higher-order polygonal faces into suitable triangles, without actually modifying the internal graphics data. Modified: 24 May 1999 Author: John Burkardt */ { short int attribute = 0; char c; int i; int icor3; int iface; int jvert; int face_num2; /* 80 byte Header. */ for ( i = 0; i < 80; ++i ) { c = ' '; bytes_num = bytes_num + char_write ( fileout, c ); } /* Number of faces. */ face_num2 = 0; for ( iface = 0; iface < face_num; iface++ ) { face_num2 = face_num2 + face_order[iface] - 2; } bytes_num = bytes_num + long_int_write ( fileout, face_num2 ); /* For each (triangular) face, components of normal vector, coordinates of three vertices, 2 byte "attribute". */ for ( iface = 0; iface < face_num; iface++ ) { for ( jvert = 2; jvert < face_order[iface]; jvert++ ) { for ( i = 0; i < 3; ++i ) { bytes_num = bytes_num + float_write ( fileout, face_normal[iface][i] ); } icor3 = face[0][iface]; for ( i = 0; i < 3; ++i ) { bytes_num = bytes_num + float_write ( fileout, cor3[icor3][i] ); } icor3 = face[jvert-1][iface]; for ( i = 0; i < 3; ++i ) { bytes_num = bytes_num + float_write ( fileout, cor3[icor3][i] ); } icor3 = face[jvert][iface]; for ( i = 0; i < 3; ++i ) { bytes_num = bytes_num + float_write ( fileout, cor3[icor3][i] ); } bytes_num = bytes_num + short_int_write ( fileout, attribute ); } } /* Report. */ printf ( "\n" ); printf ( "STLB_WRITE - Wrote %d bytes.\n", bytes_num ); if ( face_num != face_num2 ) { printf ( " Number of faces in original data was %d.\n", face_num ); printf ( " Number of triangular faces in decomposed data is %d.\n", face_num2 ); } return true; }
/** * Writes text on the screen with the alignment selected */ void screen_write(char string_to_write[],short alignment) { unsigned int word_length=0; short times=0; int max_x_position, x_position,y_position; unsigned int lines=0; int i=0,j=0,y_pos=0; if((alignment!=ALIGN_LEFT_TOP)&&(alignment!=ALIGN_CENTRE_TOP)&&(alignment!=ALIGN_RIGHT_TOP)) { while(string_to_write[i]!='\0') { if(string_to_write[i]=='\n') { lines++; } i++; } } if((alignment==ALIGN_LEFT_CENTRE)||(alignment==ALIGN_CENTRE_CENTRE)||(alignment==ALIGN_RIGHT_CENTRE)) { y_pos=set_Y_position_centre(lines); } else { if((alignment==ALIGN_LEFT_BOTTOM)||(alignment==ALIGN_CENTRE_BOTTOM)||(alignment==ALIGN_RIGHT_BOTTOM)) { y_pos=set_Y_position_bottom(lines); } else { lcd_write(COMMAND,0x40); } } i=0; //Set (0,0) lcd_write(COMMAND,0x80); while(string_to_write[i]!='\0') { while(string_to_write[i]!='\0'&&string_to_write[i]!='\n'&&word_length<84) { word_length=word_length+get_character_length(string_to_write[i]); i++; } switch (alignment) { case ALIGN_LEFT_TOP: { break; } case ALIGN_RIGHT_TOP: { lcd_write(COMMAND,0xD3-word_length); break; } case ALIGN_CENTRE_TOP: { lcd_write(COMMAND,(0xA9)-(word_length/2)); break; } case ALIGN_LEFT_CENTRE: { lcd_write(COMMAND,0x80); break; } case ALIGN_RIGHT_CENTRE: { lcd_write(COMMAND,0xD3-word_length); break; } case ALIGN_CENTRE_CENTRE: { lcd_write(COMMAND,(0xA9)-(word_length/2)); break; } case ALIGN_LEFT_BOTTOM: { lcd_write(COMMAND,0x80); break; } case ALIGN_RIGHT_BOTTOM: { lcd_write(COMMAND,0xD3-word_length); break; } case ALIGN_CENTRE_BOTTOM: { lcd_write(COMMAND,(0xA9)-(word_length/2)); break; } case ALIGN_RANDOM: { //This case is for one line text such as "welcome" srand(time(NULL)); y_position=rand()%5; lcd_write(COMMAND,0x40+y_position); max_x_position=84-word_length; srand(time(NULL)); x_position=(rand()%(max_x_position)); lcd_write(COMMAND,0x80+x_position); break; } } while(j<i) { char_write(string_to_write[j]); j++; } if(string_to_write[i]!='\0') { i++; } word_length=0; lcd_write(COMMAND,0x80); if(y_pos==5) { y_pos=0; } else { y_pos++; } lcd_write(COMMAND,0x40|y_pos); } }