# Changes
- Fix Visual glitch in Clear Screen - Add Long Time Screenshot - Try fix sd card issue (still not working)
This commit is contained in:
parent
abffaf43ec
commit
7b79c20b8f
@ -48,7 +48,7 @@ include(cmake/pico_sdk_import.cmake)
|
||||
project(Test LANGUAGES C CXX ASM)
|
||||
|
||||
# Disable std::format note during compiling
|
||||
add_compile_options(-Wno-psabi)
|
||||
add_compile_options(-Wno-psabi -Os)
|
||||
|
||||
# Initialise the Raspberry Pi Pico SDK
|
||||
pico_sdk_init()
|
||||
|
@ -60,9 +60,9 @@ Ausgabe über usb ins terminal (minicom)
|
||||
| --- | ---- | ---- |
|
||||
| 1 | GND | 38 |
|
||||
| 2 | VCC | 36 |
|
||||
| 3 | MISO | 21 |
|
||||
| 4 | SDA/MOSI | 25 |
|
||||
| 5 | SCK | 24 |
|
||||
| 3 | MISO | 16 |
|
||||
| 4 | SDA/MOSI | 15 |
|
||||
| 5 | SCK | 14 |
|
||||
| 6 | CS | 9 |
|
||||
|
||||
### HTTP Fehler
|
||||
@ -90,3 +90,7 @@ Auf Pin13 Gibt es die möglichkeit einen reboot auszulösen, welchen man z.B nut
|
||||
SD Karten erweiterung funktioniert noch nicht.
|
||||
|
||||
Die Idee dahinter ist, daten auf der SD Karte zu speichern und dadurch eine größere Zeitspane auf der Seite anzeigen zu können, ohne das die Daten bei einem Reboot verloren gehen und ohne Limitation durch die größe des RAM Chips
|
||||
|
||||
### Final
|
||||
|
||||

|
||||
|
BIN
doku/bilderoderso/over-time.png
Normal file
BIN
doku/bilderoderso/over-time.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 387 KiB |
@ -1,25 +1,27 @@
|
||||
#include "hw_config.h"
|
||||
|
||||
/* SDIO Interface */
|
||||
static sd_sdio_if_t sdio_if = {
|
||||
/*
|
||||
Pins CLK_gpio, D1_gpio, D2_gpio, and D3_gpio are at offsets from pin
|
||||
D0_gpio. The offsets are determined by sd_driver\SDIO\rp2040_sdio.pio.
|
||||
CLK_gpio = (D0_gpio + SDIO_CLK_PIN_D0_OFFSET) % 32;
|
||||
As of this writing, SDIO_CLK_PIN_D0_OFFSET is 30,
|
||||
which is -2 in mod32 arithmetic, so:
|
||||
CLK_gpio = D0_gpio -2.
|
||||
D1_gpio = D0_gpio + 1;
|
||||
D2_gpio = D0_gpio + 2;
|
||||
D3_gpio = D0_gpio + 3;
|
||||
*/
|
||||
.CMD_gpio = 3,
|
||||
.D0_gpio = 4,
|
||||
.baud_rate = 125 * 1000 * 1000 / 6 // 20833333 Hz
|
||||
#include "diskio.h"
|
||||
#include "ff.h" // FatFs
|
||||
#include "hardware/spi.h"
|
||||
|
||||
// 1. SPI hardware + pin config
|
||||
static spi_t spi1_config = {
|
||||
.hw_inst = spi1,
|
||||
.sck_gpio = 10,
|
||||
.mosi_gpio = 11,
|
||||
.miso_gpio = 12,
|
||||
.baud_rate = 10 * 1000 * 1000 // 10 MHz is safe to start
|
||||
};
|
||||
|
||||
/* Hardware Configuration of the SD Card socket "object" */
|
||||
static sd_card_t sd_card = {.type = SD_IF_SDIO, .sdio_if_p = &sdio_if};
|
||||
// 2. SPI interface for SD card
|
||||
static sd_spi_if_t spi_if = {
|
||||
.spi = &spi1_config,
|
||||
.ss_gpio = 9,
|
||||
.set_drive_strength = false // set to true and configure if needed
|
||||
};
|
||||
|
||||
static sd_card_t sd_card = {
|
||||
.type = SD_IF_SPI, .spi_if_p = &spi_if, .use_card_detect = false};
|
||||
|
||||
/**
|
||||
* @brief Get the number of SD cards.
|
||||
|
@ -52,7 +52,7 @@ constexpr uint PinSda = 19;
|
||||
|
||||
TFT tft(PinCs, PinDc, PinRst, PinSck, PinSda);
|
||||
|
||||
#define ClearScreen(c) tft.DrawRect(0, 0, 127, 159, c)
|
||||
#define ClearScreen(c) tft.DrawRect(0, 0, 128, 160, c)
|
||||
|
||||
void DrawChar(uint8_t x, uint8_t y, char c, uint16_t fg, uint16_t bg) {
|
||||
if (c < 0 || c > 255) return;
|
||||
@ -185,31 +185,56 @@ void list_average(float *avg_temp, float *avg_humidity) {
|
||||
bme280_ctx *ctx;
|
||||
|
||||
int init_fs() {
|
||||
printf("Init FS\n");
|
||||
FATFS fs;
|
||||
FRESULT fr = f_mount(&fs, "", 1);
|
||||
if (fr != FR_OK) {
|
||||
printf("f_mount error: %s\n", FRESULT_str(fr));
|
||||
if (!sd_init_driver()) {
|
||||
err("SD driver init failed.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
sd_card_t *sd = sd_get_by_num(0);
|
||||
if (!sd) {
|
||||
err("sd_get_by_num returned NULL");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!sd_card_detect(sd)) {
|
||||
err("SD card detect failed.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *drive_prefix = sd_get_drive_prefix(sd);
|
||||
if (!drive_prefix) {
|
||||
err("sd_get_drive_prefix returned NULL");
|
||||
return 1;
|
||||
}
|
||||
sleep_ms(1000);
|
||||
FRESULT res = f_mount(&sd->state.fatfs, "0:", 1);
|
||||
if (res != FR_OK) {
|
||||
err(std::format("f_mount failed\nerror code: {}", (int)res).c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
FIL fil;
|
||||
const char *fn = "test.txt";
|
||||
fr = f_open(&fil, fn, FA_OPEN_APPEND | FA_WRITE);
|
||||
FRESULT fr = f_open(&fil, fn, FA_OPEN_APPEND | FA_WRITE);
|
||||
if (fr != FR_OK) {
|
||||
printf("f_open error: %s\n", FRESULT_str(fr));
|
||||
err("f_open failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (f_printf(&fil, "Hello World!\n") < 0) {
|
||||
printf("Failed to write!");
|
||||
err("Failed to write to file");
|
||||
f_close(&fil);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fr = f_close(&fil);
|
||||
if (fr != FR_OK) {
|
||||
printf("f_close error: %s\n", FRESULT_str(fr));
|
||||
err("f_close failed");
|
||||
return 1;
|
||||
}
|
||||
f_unmount("");
|
||||
|
||||
f_unmount(drive_prefix);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -228,10 +253,6 @@ int main() {
|
||||
tft.WriteData16(boot_image[i]);
|
||||
}
|
||||
|
||||
// if (init_fs() != 0) {
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
/// NO WIFI CHECK ///
|
||||
gpio_init(PinNoWifi);
|
||||
gpio_pull_down(PinNoWifi);
|
||||
@ -254,6 +275,9 @@ int main() {
|
||||
sleep_ms(2000);
|
||||
}
|
||||
ClearScreen(0xffff);
|
||||
// if (init_fs() != 0) {
|
||||
// err("FS Init Error");
|
||||
// }
|
||||
|
||||
ctx = bme280_init(I2C_PORT, I2C_SDA, I2C_SCL);
|
||||
if (use_wifi) {
|
||||
|
Loading…
Reference in New Issue
Block a user