Esempio n. 1
0
void get_restaurant(int i, Restaurant *r) {
  Restaurant buffer[BLOCK_LEN/sizeof(Restaurant)];
  uint32_t block = RESTAURANT_START_BLOCK + i/8;
  uint32_t index = i % 8;

  card.readBlock(block, (uint8_t *) buffer);
  (*r) = buffer[index];
}
Esempio n. 2
0
void setup(void) {
    Serial.begin(9600);

    // If your TFT's plastic wrap has a Red Tab, use the following:
    tft.initR(INITR_REDTAB);   // initialize a ST7735R chip, red tab
    // If your TFT's plastic wrap has a Green Tab, use the following:
    //tft.initR(INITR_GREENTAB); // initialize a ST7735R chip, green tab

    // how much memory have we got left at this point?
    Serial.print("Avail mem (bytes):");
    Serial.println(AVAIL_MEM);

    Serial.print("Initializing SD card...");
    if (!SD.begin(SD_CS)) {
      Serial.println("failed!");
      return;
    }
    Serial.println("OK!");

    // clear to yellow
    tft.fillScreen(tft.Color565(0xff, 0xff, 0x00));

    lcd_image_draw(&map_image, &tft, 0, 0, 0, 0, 128, 128);

    // how much memory have we got left at this point?
    Serial.print("Avail mem (bytes):");
    Serial.println(AVAIL_MEM);

    // test out reading blocks from the SD card
    if (!card.init(SPI_HALF_SPEED, SD_CS)) {
        Serial.println("Raw SD Initialization has failed");
        while (1) {};  // Just wait, stuff exploded.
        }

    // how much memory have we got left at this point?
    Serial.print("Avail mem (bytes):");
    Serial.println(AVAIL_MEM);
 
    uint32_t block_num = 4000000;
    uint32_t start = millis();
    for (int l=0; l<135; l++) {
        card.readBlock( block_num, (uint8_t *) block_buf);
        // Serial.println(block_buf[1].name);
        }
    uint32_t stop = millis();
    //Serial.println(stop - start);
    
    //dump_block((uint8_t *) block_buf, BLOCK_LEN);
    // Serial.println(block_buf[1].name);

    for(int i = 0; i < 1066; i++) {
      printRest(i);
    }
}
Esempio n. 3
0
void ReadSDSector(unsigned long SDS, byte *fileBuffer) {
#ifdef HW_DISK_LED_ENABLE
    digitalWrite(HW_DISK_LED, HIGH);
#endif  // HW_DISK_LED_ENABLE

    if (int error = card.readBlock(SDS, fileBuffer) == 0) {
        SerialUSB.print("SD Card read error: ");
        SerialUSB.println(error, HEX);
    }

#ifdef HW_DISK_LED_ENABLE
    digitalWrite(HW_DISK_LED, LOW);
#endif  // HW_DISK_LED_ENABLE
}