From af32a20f64c4b469d7d7de8aaf2322b3120d578d Mon Sep 17 00:00:00 2001 From: Guido Socher Date: Tue, 17 Jul 2012 00:00:00 +0200 Subject: [PATCH] no functional change adaptation to the new handling of prog_char in avr-libc-1.8 --- README.htm | 7 +++++-- lcd.c | 2 +- lcd.h | 11 ++--------- main.c | 31 ++++++++++++++++--------------- test_dac.c | 15 ++++++++------- test_lcd.c | 17 +++++++++-------- uart.c | 3 ++- uart.h | 11 +++-------- 8 files changed, 46 insertions(+), 51 deletions(-) diff --git a/README.htm b/README.htm index 26cdb3f..0a2061f 100644 --- a/README.htm +++ b/README.htm @@ -199,14 +199,17 @@ digitaldcpower-0.6.3 -- 2010-07-03 Accelerate UART command polling to Script interface (ddcp-script) digitaldcpower-0.6.4 -- 2010-07-11 added ddcp-script interface commands for windows. -digitaldcpower-0.6.5 -- 2011-04-14 There was a fault in the range setting +digitaldcpower-0.6.5 -- 2012-04-14 There was a fault in the range setting for the PWM (ICR1L in dac.c). Thanks to Weitao Li (james) for reporting this. This fault reduced the precision a bit. - -- 2011-04-14 some minor improvemnents in main.c and analog.c to + -- 2012-04-14 some minor improvemnents in main.c and analog.c to regulate the voltage drop over the current measuremtns shunts faster. +digitaldcpower-0.6.6 -- 2012-07-17 Adapt the code to compile clean with the latest + avr-libc (http://www.nongnu.org/avr-libc/changes-1.8.html) + prog_char is now depricated. ------------------------------------------------------------------- vim: set sw=8 ts=8 si et : diff --git a/lcd.c b/lcd.c index 469f18e..b151f68 100644 --- a/lcd.c +++ b/lcd.c @@ -219,7 +219,7 @@ void lcd_puts(const char *s) } -void lcd_puts_p(const prog_char *progmem_s) +void lcd_puts_p(const char *progmem_s ) // note this is how you would declare a variable: const char str_pstr[] PROGMEM = "FLASH STRING"; /* print string from program memory on lcd */ { register char c; diff --git a/lcd.h b/lcd.h index 20f67cd..b7d592a 100644 --- a/lcd.h +++ b/lcd.h @@ -86,18 +86,11 @@ extern void lcd_puts(const char *s); /* print string on lcd (no auto linefeed) * /* if you hard code a string in the program then you need to decalare * it like: char *str =PSTR("hello world"); * and then use lcd_puts_p(str);*/ -extern void lcd_puts_p(const prog_char *progmem_s); /* print string from program memory on lcd (no auto linefeed) */ +extern void lcd_puts_p(const char *progmem_s ); /* print string from program memory on lcd (no auto linefeed) */ +// lcd_puts_p can be used like this: lcd_puts_p(PSTR("hello")) extern void lcd_init(void); /* initialize the LCD. Call this once*/ extern void lcd_reset(void); -/* -** macros for automatically storing string constant in program memory -*/ -#ifndef P -#define P(s) ({static const char c[] __attribute__ ((progmem)) = s;c;}) -#endif -#define lcd_puts_P(__s) lcd_puts_p(P(__s)) - #endif //LCD_H diff --git a/main.c b/main.c index d3b660e..a1205be 100644 --- a/main.c +++ b/main.c @@ -9,6 +9,7 @@ * Clock frequency : Internal clock 8 Mhz *********************************************/ #include +#include #include #include #define F_CPU 8000000UL // 8 MHz @@ -24,7 +25,7 @@ #include "hardware_settings.h" // change this version string when you compile: -#define SWVERSION "ver: ddcp-0.6.4" +#define SWVERSION "ver: ddcp-0.6.6" //#define DEBUGDISP 1 //debug LED: @@ -146,7 +147,7 @@ void delay_ms_uartcheck(uint8_t ms) uartstrpos++; } if (uartstrpos>UARTSTRLEN){ - uart_sendstr_P("\r\nERROR\r\n"); + uart_sendstr_p(PSTR("\r\nERROR\r\n")); uartstrpos=0; // empty buffer uartstr[0]='\0'; // just print prompt uart_has_one_line=1; @@ -212,18 +213,18 @@ static void store_permanent(void){ } delay_ms_uartcheck(1); // check for uart without delay if (changeflag){ - lcd_puts_P("setting stored"); + lcd_puts_p(PSTR("setting stored")); eeprom_write_byte((uint8_t *)0x0,19); // magic number eeprom_write_word((uint16_t *)0x02,set_val[0]); eeprom_write_word((uint16_t *)0x04,set_val[1]); }else{ if (bpress> 2){ // display software version after long press - lcd_puts_P(SWVERSION); + lcd_puts_p(PSTR(SWVERSION)); lcd_gotoxy(0,1); - lcd_puts_P("tuxgraphics.org"); + lcd_puts_p(PSTR("tuxgraphics.org")); }else{ - lcd_puts_P("already stored"); + lcd_puts_p(PSTR("already stored")); } } delay_ms_uartcheck(200); @@ -253,9 +254,9 @@ static uint8_t check_buttons(void){ } // version if (uartstr[0]=='v' && uartstr[1]=='e'){ - uart_sendstr_p(P(" ")); - uart_sendstr_p(P(SWVERSION)); - uart_sendstr_p(P("\r\n")); + uart_sendstr_p(PSTR(" ")); + uart_sendstr_p(PSTR(SWVERSION)); + uart_sendstr_p(PSTR("\r\n")); cmdok=1; } // store @@ -275,18 +276,18 @@ static uint8_t check_buttons(void){ } // help if (uartstr[0]=='h' || uartstr[0]=='H'){ - uart_sendstr_p(P(" Usage: u=V*10|i=mA/10|store|help|version\r\n")); - uart_sendstr_p(P(" Examples:\r\n")); - uart_sendstr_p(P(" set 6V: u=60\r\n")); - uart_sendstr_p(P(" max 200mA: i=20\r\n")); + uart_sendstr_p(PSTR(" Usage: u=V*10|i=mA/10|store|help|version\r\n")); + uart_sendstr_p(PSTR(" Examples:\r\n")); + uart_sendstr_p(PSTR(" set 6V: u=60\r\n")); + uart_sendstr_p(PSTR(" max 200mA: i=20\r\n")); cmdok=1; } if (uartprint_ok){ cmdok=1; - uart_sendstr_p(P(" ok\r\n")); + uart_sendstr_p(PSTR(" ok\r\n")); } if (uartstr[0]!='\0' && cmdok==0){ - uart_sendstr_p(P(" command unknown\r\n")); + uart_sendstr_p(PSTR(" command unknown\r\n")); } uart_sendchar('#'); // marking char for script interface int_to_dispstr(measured_val[1],buf,1); diff --git a/test_dac.c b/test_dac.c index 2ecc682..f09ce3c 100644 --- a/test_dac.c +++ b/test_dac.c @@ -12,6 +12,7 @@ * Clock frequency : Internal clock 8 Mhz *********************************************/ #include +#include #include #define F_CPU 8000000UL // 8 MHz #include @@ -60,7 +61,7 @@ int main(void) delay_ms(500); delay_ms(500); lcd_clrscr(); - lcd_puts_P("pause"); + lcd_puts_p(PSTR("pause")); while (1) { if (dac_dir==1){ dac_val++; @@ -84,20 +85,20 @@ int main(void) if (cnt>1){ lcd_clrscr(); // u+ pressed - lcd_puts_P("up"); + lcd_puts_p(PSTR("up")); dac_dir=1; LEDOFF; } if (cnt<1){ lcd_clrscr(); // u- pressed - lcd_puts_P("down"); + lcd_puts_p(PSTR("down")); dac_dir=-1; LEDON; } if (check_store_button()){ lcd_clrscr(); - lcd_puts_P("pause"); + lcd_puts_p(PSTR("pause")); dac_dir=0; } delay_ms(100); @@ -106,20 +107,20 @@ int main(void) if (cnt>1){ lcd_clrscr(); // u+ pressed - lcd_puts_P("up"); + lcd_puts_p(PSTR("up")); dac_dir=1; LEDOFF; } if (cnt<1){ lcd_clrscr(); // u- pressed - lcd_puts_P("down"); + lcd_puts_p(PSTR("down")); dac_dir=-1; LEDON; } if (check_store_button()){ lcd_clrscr(); - lcd_puts_P("pause"); + lcd_puts_p(PSTR("pause")); dac_dir=0; } delay_ms(100); diff --git a/test_lcd.c b/test_lcd.c index 0799acf..cab63eb 100644 --- a/test_lcd.c +++ b/test_lcd.c @@ -12,6 +12,7 @@ * Clock frequency : Internal clock 8 Mhz *********************************************/ #include +#include #include #define F_CPU 8000000UL // 8 MHz #include @@ -49,39 +50,39 @@ int main(void) check_u_button(&cnt); if (cnt>1){ lcd_clrscr(); - lcd_puts_P("U+ pressed"); + lcd_puts_p(PSTR("U+ pressed")); i=0; } if (cnt<1){ lcd_clrscr(); - lcd_puts_P("U- pressed"); + lcd_puts_p(PSTR("U- pressed")); i=0; } cnt=1; check_i_button(&cnt); if (cnt>1){ lcd_clrscr(); - lcd_puts_P("I+ pressed"); + lcd_puts_p(PSTR("I+ pressed")); i=0; } if (cnt<1){ lcd_clrscr(); - lcd_puts_P("I- pressed"); + lcd_puts_p(PSTR("I- pressed")); i=0; } if (check_store_button()){ lcd_clrscr(); - lcd_puts_P("store"); + lcd_puts_p(PSTR("store")); lcd_gotoxy(0,1); - lcd_puts_P("pressed"); + lcd_puts_p(PSTR("pressed")); i=0; } delay_ms(10); if (i>150){ lcd_clrscr(); - lcd_puts_P("press"); + lcd_puts_p(PSTR("press")); lcd_gotoxy(0,1); - lcd_puts_P("a button"); + lcd_puts_p(PSTR("a button")); i=0; } diff --git a/uart.c b/uart.c index eb7c4e1..5d38a1e 100644 --- a/uart.c +++ b/uart.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "uart.h" #define F_CPU 8000000UL // 8 MHz @@ -58,7 +59,7 @@ void uart_sendstr(char *s) } } -void uart_sendstr_p(const prog_char *progmem_s) +void uart_sendstr_p(const char *progmem_s ) // print string from program memory on rs232 { char c; diff --git a/uart.h b/uart.h index b64b2d3..3ed2534 100644 --- a/uart.h +++ b/uart.h @@ -6,6 +6,7 @@ ***************************************************************************/ #ifndef UART_H #define UART_H +#include #include extern void uart_init(void); @@ -13,7 +14,8 @@ extern void uart_poll_getchar_isr(void); // call this periodically from interrup extern unsigned char uart_getchar_isr_noblock(char *returnval); // get a char from buffer if available extern void uart_sendchar(char c); // blocking, no buffer extern void uart_sendstr(char *s); // blocking, no buffer -extern void uart_sendstr_p(const prog_char *progmem_s); // blocking, no buffer +extern void uart_sendstr_p(const char *progmem_s); // blocking, no buffer +// uart_sendstr_p can be used like this: uart_sendstr_p(PSTR("my string")); /* // you can either use the above _isr functions or one of the // following two but you can not mix them. @@ -22,12 +24,5 @@ extern unsigned char uart_getchar_noblock(char *returnval); extern void uart_flushRXbuf(void); */ -/* -** macros for automatically storing string constant in program memory -*/ -#ifndef P -#define P(s) ({static const char c[] __attribute__ ((progmem)) = s;c;}) -#endif -#define uart_sendstr_P(__s) uart_sendstr_p(P(__s)) #endif /* UART_H */ -- 2.20.1