Seeed-Studio / Grove_Gesture

Seeed Arduino library for Grove Gesture Sensor(PAJ7620U2) and Smart IR Gesture Sensor.
MIT License
50 stars 34 forks source link

progmem fix saves 440 bytes of dynamic memory. #6

Closed Jaycar-Electronics closed 3 years ago

Jaycar-Electronics commented 3 years ago

Changing the structure of the array removes it from global dynamic memory and places in PROGMEM.

it is better to store this data in ROM so that it saves space for program. Change Program Space data / variable space
Before 4628 (14%) from 32kb 1110 bytes (54%)
After 5066 (15%) from 32kb 690 bytes (33%)

this means programs can include more things, such as when using screens, as more of the dynamic memory is saved to handle bigger objects and data.

Pillar1989 commented 3 years ago

PROGMEM ? @Jaycar-Electronics What platform are you testing?

Jaycar-Electronics commented 3 years ago

ah good point, this is for atmega / arduino based code.

Pillar1989 commented 3 years ago

So it is better to add a macro definition to determine whether it is an AVR platform or not, because arduino also has platforms such as ARM and ESP. @Jaycar-Electronics

Jaycar-Electronics commented 3 years ago

yep, added now; ESP32 and ESP8266 both have macros for PROGMEM and will compile successfully. anything else will just use dynamic version.

Pillar1989 commented 3 years ago

Thanks