简体   繁体   English

如何从嵌套的 PROGMEM 数组中读取 uint32_t 值?

[英]How do I read uint32_t values out of a nested PROGMEM array?

I have an array of 16x16 matrices of uint32_t values: const uint32_t sprites[][16][16] PROGMEM = { ... };我有一个 uint32_t 值的 16x16 矩阵数组: const uint32_t sprites[][16][16] PROGMEM = { ... }; I'm trying to read out the values with pgm_read_dword(sprites + (submode * 256 + row * 16 + column) * sizeof(uint32_t)) , but am getting turned around and confused about how the address math works.我正在尝试使用pgm_read_dword(sprites + (submode * 256 + row * 16 + column) * sizeof(uint32_t))读出值,但我转身并对地址数学的工作方式感到困惑。 In this, submode maps to the matrix index.在这种情况下, submode映射到矩阵索引。 submode , row , and column are all declared as uint8_t , in case it helps at all. submoderowcolumn都声明为uint8_t ,以防万一它有帮助。

How do I correctly calculate the address for pgm_read_dword ?如何正确计算pgm_read_dword的地址?

Is pgm_read_dword even how I want to try to read out uint32_t values? pgm_read_dword甚至是我想尝试读出uint32_t值的方式吗? I'm immediately passing the output to a method that expects that type.我立即将输出传递给需要该类型的方法。

根据评论中的 datafiddler,它就像调用pgm_read_dword(&sprites[submode][row][column])并让编译器处理偏移计算一样简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM