From 247e04036bdc21cff4bd1e670935782a55184c32 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 9 Aug 2022 02:51:44 -0400 Subject: [PATCH] added load_files and show_dir --- cubesatsim/cubesatsim.ino | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 2980ff04..45a48425 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -40,6 +40,10 @@ #include "hardware/adc.h" #include "SSTV-Arduino-Scottie1-Library.h" +// jpg files to be stored in flash storage on Pico (FS 1MB setting) +#include sstv1.h +#include sstv2.h + Adafruit_INA219 ina219_1_0x40; Adafruit_INA219 ina219_1_0x41(0x41); Adafruit_INA219 ina219_1_0x44(0x44); @@ -119,6 +123,8 @@ void setup() { // setup radio depending on mode config_radio(); + + load_files(); /* if (check_for_wifi()) { wifi = true; @@ -3506,3 +3512,43 @@ void parse_payload() { } } } + +void show_dir() { + LittleFS.begin(); + Dir dir = LittleFS.openDir("/"); +// or Dir dir = LittleFS.openDir("/data"); + Serial.println(">"); + while (dir.next()) { + Serial.print(dir.fileName()); + if(dir.fileSize()) { + File f = dir.openFile("r"); + Serial.print(" "); + Serial.println(f.size()); + } + } + Serial.println(">"); +} + +void load_files() { + LittleFS.begin(); + File f; + + f = LittleFS.open("sstv_image_1_320_x_240.jpg", "r"); + Serial.print("Image sstv_image_1_320_x_240.jpg: "); + Serial.println(f); + f.close(); + + f = LittleFS.open("sstv_image_2_320_x_240.jpg", "r"); + Serial.print("Image sstv_image_2_320_x_240.jpg: "); + Serial.println(f); + f.close(); + + f = LittleFS.open("sstv_image_1_320_x_240.jpg", "w+"); + f.write(sstv_image_1_320_x_240, sizeof(sstv_image_1_320_x_240)); + f.close(); + + f = LittleFS.open("sstv_image_2_320_x_240.jpg", "w+"); + f.write(sstv_image_2_320_x_240, sizeof(sstv_image_2_320_x_240)); + f.close(); + + show_dir()}