mirror of
https://github.com/crankyoldgit/IRremoteESP8266.git
synced 2026-01-12 00:05:10 +08:00
Finally convince the compiler to store the text strings into flash. Saves approx 2k of Global ram, for a trade-off of between ~0-0.5k of extra flash space used. e.g. _(updated)_ * IRMQTTServer example code: - Before: RAM: [===== ] 54.1% (used 44344 bytes from 81920 bytes) Flash: [===== ] 54.2% (used 566209 bytes from 1044464 bytes) Bin file size = 570368 - After: RAM: [===== ] 51.3% (used 41992 bytes from 81920 bytes) Flash: [===== ] 54.2% (used 566201 bytes from 1044464 bytes) Bin file size = 570352 * IRrecvDumpV2 example code: - Before: RAM: [==== ] 37.9% (used 31044 bytes from 81920 bytes) Flash: [==== ] 35.6% (used 372025 bytes from 1044464 bytes) Bin file size = 376176 - After: RAM: [==== ] 35.5% (used 29072 bytes from 81920 bytes) Flash: [==== ] 35.7% (used 372525 bytes from 1044464 bytes) Bin file size = 376672 Fixes #1614 Fixes #1493 Co-authored with @mcspr
52 lines
1.5 KiB
Bash
Executable File
52 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
export INPUT="IRtext.cpp"
|
|
export OUTPUT="IRtext.h"
|
|
|
|
if [[ ! -f ${INPUT} ]]; then
|
|
echo "Can't read file '${INPUT}'. Aborting!"
|
|
exit 1
|
|
fi
|
|
# Current year
|
|
export YEAR=$(date "+%Y")
|
|
# Header
|
|
cat >${OUTPUT} << EOF
|
|
// Copyright 2019-${YEAR} - David Conran (@crankyoldgit)
|
|
// This header file is to be included in files **other than** 'IRtext.cpp'.
|
|
//
|
|
// WARNING: Do not edit this file! This file is automatically generated by
|
|
// '../tools/generate_irtext_h.sh'.
|
|
|
|
#ifndef IRTEXT_H_
|
|
#define IRTEXT_H_
|
|
|
|
#include "i18n.h"
|
|
|
|
// Constant text to be shared across all object files.
|
|
// This means there is only one copy of the character/string/text etc.
|
|
|
|
#ifdef ESP8266
|
|
class __FlashStringHelper;
|
|
#define IRTEXT_CONST_PTR_CAST(PTR)\\
|
|
reinterpret_cast<const __FlashStringHelper*>(PTR)
|
|
#define IRTEXT_CONST_PTR(NAME) const __FlashStringHelper* const NAME
|
|
#else // ESP8266
|
|
#define IRTEXT_CONST_PTR_CAST(PTR) PTR
|
|
#define IRTEXT_CONST_PTR(NAME) const char* const NAME
|
|
#endif // ESP8266
|
|
|
|
EOF
|
|
|
|
# Parse and output contents of INPUT file.
|
|
sed 's/ PROGMEM//' ${INPUT} | egrep "^(const )?char" | cut -f1 -d= |
|
|
sed 's/ $/;/;s/^/extern /' | sort -u >> ${OUTPUT}
|
|
egrep '^\s{,10}IRTEXT_CONST_STRING\(' ${INPUT} | cut -f2 -d\( | cut -f1 -d, |
|
|
sed 's/^/extern IRTEXT_CONST_PTR\(/;s/$/\);/' | sort -u >> ${OUTPUT}
|
|
egrep '^\s{,10}IRTEXT_CONST_BLOB_DECL\(' ${INPUT} |
|
|
cut -f2 -d\( | cut -f1 -d\) |
|
|
sed 's/^/extern IRTEXT_CONST_PTR\(/;s/$/\);/' | sort -u >> ${OUTPUT}
|
|
# Footer
|
|
cat >> ${OUTPUT} << EOF
|
|
|
|
#endif // IRTEXT_H_
|
|
EOF
|