Buffer and PROGMEM
hello, i'm working 128x64 lcd screen , using adafruit library adafruit_ssd1306
in code, initialized screen adafruit splash screen. it's pretty hefty burden on memory, having on start up. below how byte array stored in library:
my question is, can byte array of buffer, bytes, moved progmem better storage? @ save dynamic memory?
i tried using
but didn't save memory @ all. it's giving me "invalid conversion" warning
in code, initialized screen adafruit splash screen. it's pretty hefty burden on memory, having on start up. below how byte array stored in library:
code: [select]
static uint8_t buffer[ssd1306_lcdheight * ssd1306_lcdwidth / 8] = {
0x00, 0x00, blah blah lots of hex codes, 0x00
};
void adafruit_ssd1306::display(void) {
(uint16_t i=0; i<(ssd1306_lcdwidth*ssd1306_lcdheight/8); i++) {
fastspiwrite(buffer[i]);
//ssd1306_data(buffer[i]);
}
}
my question is, can byte array of buffer, bytes, moved progmem better storage? @ save dynamic memory?
i tried using
code: [select]
const uint8_t intro[ssd1306_lcdheight * ssd1306_lcdwidth / 8] progmem = { 0x00 etc};
static uint8_t buffer[ssd1306_lcdheight * ssd1306_lcdwidth / 8] = {intro};
but didn't save memory @ all. it's giving me "invalid conversion" warning
hello, i'm working 128x64 lcd screen , using adafruit library adafruit_ssd1306here's snippet program of mine. array of infrared remote codes stored in progmem, show how other type of data:
in code, initialized screen adafruit splash screen. it's pretty hefty burden on memory, having on start up. below how byte array stored in library:
code: [select]
///////////////////////////////////////////////////////////////////////////////
// sony camera shutter release code 0xb4b8f (focus , shoot)
///////////////////////////////////////////////////////////////////////////////
static const uint16_t shutter[] progmem = {
// header
0x8060, 0x0018,
// data
0x8030, 0x0018, 0x8018, 0x0018, 0x8030, 0x0018, 0x8030, 0x0018, // b
0x8018, 0x0018, 0x8030, 0x0018, 0x8018, 0x0018, 0x8018, 0x0018, // 4
0x8030, 0x0018, 0x8018, 0x0018, 0x8030, 0x0018, 0x8030, 0x0018, // b
0x8030, 0x0018, 0x8018, 0x0018, 0x8018, 0x0018, 0x8018, 0x0018, // 8
0x8030, 0x0018, 0x8030, 0x0018, 0x8030, 0x0018, 0x8030, 0x01c8, // f
// end of data block
0x0000
};
note storing uint16_t values, whereas need uint8_t... change it.
also note have read data using "pgm_read_byte (pointer + index)" instead of accessing array directly sram:
code: [select]
uint8_t array_size = sizeof (array) / sizeof (*array); // uint16_t if array > 255 elements
uint8_t index; // uint16_t if array > 255 elements
uint16_t data; // same type data in array
for (index = 0; index < array_size; index++) {
data = pgm_read_word(array + index); // pgm_read_byte 8 bit data!
// send data wherever
}
hope helps.
Arduino Forum > Using Arduino > Programming Questions > Buffer and PROGMEM
arduino
Comments
Post a Comment