/*------------------------------------------------------------------------------ Copyright: Radig Ulrich Mailto: nobody@example.net Author: Remarks: known Problems: none Version: Description: Programm zur Ansteuerung eines LCD Grundgerüst mit Hinweisen. Hinweis : ------------------------------------------------------------------------------*/ #include "lcd.h" #include "T6963c.h" //oder wie auch immer das Headerfile heisst... #if USE_SER_LCD volatile unsigned char back_light = 0; //------------------------------------------------------------------------------ void lcd_init (void) { T6963cInit(uint8_t Options, uint8_t Mode); Options ???? Mode ???? } //------------------------------------------------------------------------------ #if 0 void lcd_write (char data, char cd) { if(cd) T6963cPutChar((uint8_t)data); // else // unused } #endif //------------------------------------------------------------------------------ void lcd_print_P (unsigned char zeile,unsigned char spalte,const char *Buffer,...) { va_list ap; va_start (ap, Buffer); int format_flag; char str_buffer[10]; char str_null_buffer[10]; char move = 0; char Base = 0; int tmp = 0; char by; char *ptr; //Adresse für die Zeile //Evtl. Anpassung wegen "links Oben" == (0,0) oder (1,1) nötig T6963cSetAddress(T6963C_ADDR_TEXT + (T6963C_TEXT_COLS * (zeile)) + (spalte)); //Ausgabe der Zeichen for(;;) { by = pgm_read_byte(Buffer++); if(by == 0) break; // end of format string if (by == '%') { by = pgm_read_byte(Buffer++); if (isdigit(by)>0) { str_null_buffer[0] = by; str_null_buffer[1] = '\0'; move = atoi(str_null_buffer); by = pgm_read_byte(Buffer++); } switch (by) { case 's': ptr = va_arg(ap,char *); while(*ptr) T6963cPutChar((uint8_t)*ptr++); break; case 'b': Base = 2; goto ConversionLoop; case 'c': //Int to char format_flag = va_arg(ap,int); T6963cPutChar((uint8_t)format_flag); break; case 'i': Base = 10; goto ConversionLoop; case 'o': Base = 8; goto ConversionLoop; case 'x': Base = 16; //**************************** ConversionLoop: //**************************** itoa(va_arg(ap,int),str_buffer,Base); int b = 0; while (str_buffer[b++] != 0) ; b--; if (b < move) { move -= b; for (tmp = 0; tmp < move; tmp++) { str_null_buffer[tmp] = '0'; } //tmp ++; str_null_buffer[tmp] = '\0'; strcat(str_null_buffer,str_buffer); strcpy(str_buffer,str_null_buffer); } lcd_print_str(str_buffer); move = 0; break; } } else { T6963cPutChar((uint8_t)by); } } va_end(ap); } //------------------------------------------------------------------------------ void lcd_print_str (char *Buffer) { while (*Buffer != '\0') { T6963cPutChar((uint8_t)*Buffer++); }; }; //------------------------------------------------------------------------------ void lcd_clear (void) { //Clear Display T6963cClear(); //Set DD-Ram Adresse = 0 T6963cSetAddress(T6963C_ADDR_TEXT); } #endif