Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving some more memory - solutions #21

Open
KevWal opened this issue Aug 2, 2020 · 0 comments
Open

Saving some more memory - solutions #21

KevWal opened this issue Aug 2, 2020 · 0 comments

Comments

@KevWal
Copy link

KevWal commented Aug 2, 2020

Hi

Great library, thank you for all your work.

A few ways to save more memory - I saved 562 bytes of flash and 530 bytes of flash with these changes through suggestions made to me:

Moved the tables from jt65_merge_sync_vector, jt9_merge_sync_vector, jt4_merge_sync_vector and wspr_sync_vector all to PROGMEM and read back via pgm_read_byte(wspr_sync_vector +i) etc.

In ft8_merge_sync_vector moved costas7x7 and graymap to PROGMEM. Then memcpy_P and pgm_read_byte(&graymap[idx]) to read them back:

`void JTEncode::ft8_merge_sync_vector(uint8_t* symbols, uint8_t* output)
{
static const uint8_t PROGMEM costas7x7[7] = {3, 1, 4, 0, 6, 5, 2};
static const uint8_t PROGMEM graymap[8] = {0, 1, 3, 2, 5, 6, 4, 7};
uint8_t i, j, k, idx;

// Insert Costas sync arrays
memcpy_P(output, costas7x7, 7);
memcpy_P(output + 36, costas7x7, 7);
memcpy_P(output + FT8_SYMBOL_COUNT - 7, costas7x7, 7);

k = 6;
for(j = 0; j < 58; ++j) // 58 data symbols
{
i = 3 * j;
++k;
if(j == 29)
{
k += 7;
}
idx = symbols[i] * 4 + symbols[i + 1] * 2 + symbols[i + 2];
output[k] = pgm_read_byte(&graymap[idx]);
}
}`

If you would rather a pull request I can do that.

Thanks very much
Kevin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant