die folgende Abwandlung mit einem konstanten String im Flash: [c] snprintf_P(glstr_Buf,N_TEXTBUF,PSTR("u=%u"),\ *menudata[item].puint8); [/c] Das Struct "menudata" ist etwas komplizierter aufgebaut: [c] // Header #define constflash const __flash enum datatype_e {
// Normale und hervorgehobene Menuepunkte if (selectedItem == item) glcd_putstr_P(PSTR("\033i")); // Hervorgehoben glcd_putstr(glstr_Buf); if (selectedItem == item) glcd_putstr_P(PSTR("\033n")); // Hervorhebung
ACC PUSH PSW PUSH REG7 PUSH REG6 PUSH REG5 PUSH REG4 PUSH REG3 PUSH REG2 PUSH REG1 PUSH REG0 ACALL pstr DB "DPTR : ",00h ACALL padr ACALL pstr DB cr,lf,"R0,R1: ",00h pop DPH POP DPL ACALL padr ACALL pstr DB cr,lf,"R2,R3: ",00h pop DPH POP DPL ACALL padr ACALL pstr DB cr,lf,"R4,R5: ",00h pop DPH POP DPL ACALL padr ACALL pstr DB cr,lf,"R6,R7: ",00h pop DPH POP DPL ACALL padr ACALL pstr DB cr,lf,"PSW,A: ",00h pop DPH POP DPL ACALL padr ACALL pstr DB cr,lf,"B,SP : ",00h pop DPH pop DPL ACALL padr ACALL pstr DB cr,lf,00h ret
CooCox bei. Und so sieht sie aus: [c] /** * @brief Outputs a string on stdout. * * @param pStr String to output. */ signed int puts(const char *pStr) { return fputs(pStr, stdout); } /** * @brief Implementation of fputs using the DBGU as the standard output. Required * for printf(). * * @param pStr String to write. * @param pStream Output stream. * * @return Number of characters written if successful, or -1 if the output * stream is not stdout or stderr. */ signed int
den Grund des Resets aus * * @return none */ void printBootReason(void) { printf_P(PSTR("Reset: ")); if (mcusr_mirror&(1<<WDRF)) { printf_P(PSTR("Watchdog ")); } if (mcusr_mirror&(1<<BORF)) { printf_P(PSTR("Brownout ")); } if (mcusr_mirror&(1<<EXTRF)) { printf_P(PSTR("External ")); } if (mcusr_mirror&(1<<PORF)) { printf_P(PSTR("Power-on ")); } if (mcusr_mirror==0) printf_P(PSTR("unknown ")); printf_P(PSTR("\n")); }
Protosockets kümmern sich um diese Wiedeholung automatisch: [code] PSOCK_SEND_STR_P(&app_state->socket,PSTR("Hello\n")); [/code] Lies das: http://stefanfrings.de/avr_io/protosockets.html
FunctionToCall)(); > }; > > const UartCommand0P b = { "1", nullptr}; Das Problem dürfte eher PSTR sein, das in C++ nicht funktioniert.
Programm betreffen. >> const UartCommand0P b = { "1", nullptr}; > > Das Problem dürfte eher PSTR sein, das in C++ nicht funktioniert. In C geht das auch nicht da PSTR nicht in einer Funktion steht. Zumindest lässt die Fehlermeldung darauf schießen, daß das nicht-compilierbare Codegeschnippsel
angeben, wie stellt man das an weil es sind ja gleichzeitig die "Begrenzer"? strcpy_P(buf_main, PSTR("Das ist "der" Test...")); Danke für jeden Hinweis. Grüße AVRli...
strcpy_P(buf_main, PSTR("Das ist \"der\" Test..."));
ks0108ReadFontData, BLACK); // Set a position ks0108GotoXY(15,10); // Print some text ks0108Puts_P(PSTR("KS0108-Treiber")); // a nice little round rect ks0108DrawRoundRect(5, 5, 117, 20, 8, BLACK); // Once again :) // Select a font ks0108SelectFont(Corsiva_12, ks0108ReadFontData, BLACK); // Set a position ks0108GotoXY(5,30); // Print some text ks0108Puts_P(PSTR("http://www.apetech.de\nmailto:me@apetech.de")); while(1); }
ks0108ReadFontData, BLACK); // Set a position ks0108GotoXY(15,10); // Print some text ks0108Puts_P(PSTR("KS0108-Treiber")); // a nice little round rect ks0108DrawRoundRect(5, 5, 117, 20, 8, BLACK); // Once again :) // Select a font ks0108SelectFont(CORSIVA_12, ks0108ReadFontData, BLACK); //ks0108SelectFont
, PSTR("<td><""a href""=\"/888/1\">AN/AUS</""a></td>")); > > PS: Kann endlich mal jemand diese "Der Beitrag scheint Spam zu > enthalten" meldungen ausschalten? HTML code wird hier doch sowiso nicht >
/c] Bei Soetwas: Constantin schrieb im Beitrag #4071235: > plen = fill_tcp_data_p(buf, plen, PSTR("<td bgcolor='#A9ED61'><form > method=get><input type=submit name=6 > value='ausschalten'></form></td>\r\n")); Staddessen immer so schreiben: > plen = fill_tcp_data(buf, plen, PSTR("<td bgcolor
LCD_CACHE_SIZE ((LCD_VISIBLE_X_RES*LCD_VISIBLE_Y_RES)/8) #endif #define prints(tx) (putromstring(PSTR(tx))) // Anzeige String aus Flashrom: prints("Text"); #define printa(tx) (putramstring(tx)) // Anzeige eines Strings der in einem Array im RAM liegt typedef enum {LCD_CMD=0,LCD_DATA=1} LcdCmdData; typedef
Methode anzusprechen. Ja, dann ist es klar wie das funktioniert. Das F Makro legt den String mittels PSTR in den Flash und castet den Pointer um auf einen _FlashStringHelper Pointer. Und dafür gibt es eine print Methode. Wenns für createChar keine entsprechende Methode gibt (und das bezweifle ich mal
kopiert. Schreib die Funktion als lcd_string(const __flash char *) und ruf sie mit lcd_string(PSTR("123456789")) auf. Nun bleibt der String im Flash und braucht kein RAM.
Bibliothek Funktionen anbietet, die direkt aus dem Programmspeicher lesen. ( meist sb lcd_stringP( PSTR("Hallo"));) Gruß Roland
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
to automatically put a string constant into program memory */ #define uart_puts_P(__s) uart_puts_p(PSTR(__s)) /** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */ extern void uart1_init(unsigned int baudrate); /** @brief Get received byte of USART1 from ringbuffer. (only
>> strcpy_P(buf,PSTR("Linie 2")); > Damit erhalte ich dann folgende Fehler: > undefined reference to `PSTR' Hast du denn die include Datei avr/pgmspace.h eingebunden? http://www.nongnu.org/avr-libc/user-manual/group
Aufruf aus der main.c [c] lcd_init(); lcd_clear(); sei(); set_cursor(0,1); lcd_string_P( PSTR("Wetterstation") ); [/c]
Und ich habe auch noch Probleme mit Deiner Problembeschreibung. Der Aufruf von "lcd_string_P( PSTR("Wetterstation") );" funktioniert völlig einwandfrei. Die Funktion "void lcd_string_P( PGM_P data )" läßt sich einwandfrei kompilieren, auch mit neuen Compilerversionen. In dieser Funktion ist ein
lcd_set_cursor(56,30); // Cursor wird auf Position gesetzt lcd_puts_p(small_font,PSTR("Initialisierung")); // Ausgabe des Wortes for(i=2;i<=56;i++) // Füllen der Progressbar { _delay_ms(35); lcd_fill_rect (57,40,i,4,BLACK); } GPS_available
<avr/pgmspace.h> extern void foo_P (const __memx char *); void hallo (void) { foo_P (PSTR ("Hallo")); } [/c] Der Zeiger, den PSTR zurückliefert, liegt formal im Generic Address Space (RAM), enthält aber eine Flash-Adresse. Für dieses Beispiel erzeugt der Compiler Code wie erwartet, d.h. übergibt an foo_P einen 24-Bit Zeiger aufs Flash. Dummerweise ist das, was PSTR macht, nicht auf Embedded-C abbildbar.
{ //unsigned int i; // war char. Nur geht for-Schleife dann in die Hose bei >255 /* USART_sendmsg(PSTR(" ADC-Init: ")); // Hilfsausgabe USART_sendmsg(PSTR("ADCSRB vor: ")); // Hilfsausgabe USART_Tx_Int(ADCSRB); // Hilfsausgabe USART_sendmsg(PSTR(" ADCSRA vor: ")); // Hilfsausgabe USART_Tx_Int(ADCSRA)