We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f1e41e3 commit e8e30caCopy full SHA for e8e30ca
restaurant.cpp
@@ -1,14 +1,22 @@
1
#include <SD.h>
2
-#include "Restaurant.h"
+#include "restaurant.h"
3
4
#define BLOCK_LEN 512
5
#define RESTAURANT_START_BLOCK 4000000
6
7
+uint32_t cachedBlockNumber;
8
+Restaurant buffer[BLOCK_LEN/sizeof(Restaurant)];
9
+
10
void getRestaurant(int i, Restaurant *r, Sd2Card *card) {
- Restaurant buffer[BLOCK_LEN/sizeof(Restaurant)];
- uint32_t block = RESTAURANT_START_BLOCK + i/8;
11
+ uint32_t blockNumber = RESTAURANT_START_BLOCK + i/8;
12
13
+ if(blockNumber != cachedBlockNumber) {
14
+ card->readBlock(blockNumber, (uint8_t *) buffer);
15
+ cachedBlockNumber = blockNumber;
16
+ }
17
18
uint32_t index = i % 8;
19
- card->readBlock(block, (uint8_t *) buffer);
20
(*r) = buffer[index];
21
}
22
0 commit comments