方法:
使用avr-libc提供的宏定义:
#define pgm_read_float_near(address_short) __LPM_float((uint16_t)(address_short)) //Read a float from the program space with a 16-bit (near) address. //Note //The address is a byte address. The address is in the program space.
使用方式:
PROGMEM float pi=3.141592653; // constant value in flash float diameter = 24.332154; // variable user value float circumference = diameter * pgm_read_float_near(&pi);
原文链接:Stackexchange