Add libraries, picocalc notes.

This commit is contained in:
2025-04-01 18:28:52 -07:00
parent 1c3052c977
commit e77a69ce91
598 changed files with 475037 additions and 0 deletions

View File

@@ -0,0 +1,83 @@
/*====================================================================================
This sketch supports for the ESP6266 and ESP32 SPIFFS filing system
Created by Bodmer 15th Jan 2017
==================================================================================*/
//====================================================================================
// Print a SPIFFS directory list (root directory)
//====================================================================================
void listFiles(void) {
Serial.println();
Serial.println("SPIFFS files found:");
#ifdef ESP32
listDir(SPIFFS, "/", true);
#else
fs::Dir dir = SPIFFS.openDir("/"); // Root directory
String line = "=====================================";
Serial.println(line);
Serial.println(" File name Size");
Serial.println(line);
while (dir.next()) {
String fileName = dir.fileName();
Serial.print(fileName);
int spaces = 25 - fileName.length(); // Tabulate nicely
if (spaces < 0) spaces = 1;
while (spaces--) Serial.print(" ");
fs::File f = dir.openFile("r");
Serial.print(f.size()); Serial.println(" bytes");
yield();
}
Serial.println(line);
#endif
Serial.println();
delay(1000);
}
//====================================================================================
#ifdef ESP32
void listDir(fs::FS &fs, const char * dirname, uint8_t levels) {
Serial.printf("Listing directory: %s\n", dirname);
fs::File root = fs.open(dirname);
if (!root) {
Serial.println("Failed to open directory");
return;
}
if (!root.isDirectory()) {
Serial.println("Not a directory");
return;
}
fs::File file = root.openNextFile();
while (file) {
if (file.isDirectory()) {
Serial.print("DIR : ");
String fileName = file.name();
Serial.print(fileName);
if (levels) {
listDir(fs, file.name(), levels - 1);
}
} else {
String fileName = file.name();
Serial.print(" " + fileName);
int spaces = 32 - fileName.length(); // Tabulate nicely
if (spaces < 1) spaces = 1;
while (spaces--) Serial.print(" ");
String fileSize = (String) file.size();
spaces = 8 - fileSize.length(); // Tabulate nicely
if (spaces < 1) spaces = 1;
while (spaces--) Serial.print(" ");
Serial.println(fileSize + " bytes");
}
file = root.openNextFile();
}
}
#endif

View File

@@ -0,0 +1,148 @@
// Created by Bodmer 24th Jan 2017 - Tested in Arduino IDE 1.8.5 esp8266 Core 2.4.0
// The latest Arduino IDE versions support UTF-8 encoding of Unicode characters
// within sketches:
// https://playground.arduino.cc/Code/UTF-8
/*
The library expects strings to be in UTF-8 encoded format:
https://www.fileformat.info/info/unicode/utf8.htm
Creating variables needs to be done with care when using character arrays:
char c = 'µ'; // Wrong
char bad[4] = "5µA"; // Wrong
char good[] = "5µA"; // Good
String okay = "5µA"; // Good
This is because UTF-8 characters outside the basic Latin set occupy more than
1 byte per character! A 16 bit Unicode character occupies 3 bytes!
*/
//====================================================================================
// Libraries
//====================================================================================
// Call up the SPIFFS FLASH filing system this is part of the ESP Core
#include <TFT_eSPI.h> // Hardware-specific library
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
uint16_t bg = TFT_BLACK;
uint16_t fg = TFT_WHITE;
//====================================================================================
// Setup
//====================================================================================
void setup()
{
Serial.begin(115200); // Used for messages and the C array generator
Serial.println("NodeMCU vlw font test!");
if (!SPIFFS.begin()) {
Serial.println("SPIFFS initialisation failed!");
while (1) yield(); // Stay here twiddling thumbs waiting
}
Serial.println("\r\nInitialisation done.");
listFiles(); // Lists the files so you can see what is in the SPIFFS
tft.begin();
tft.setRotation(0); // portrait
fg = TFT_WHITE;
bg = TFT_BLACK;
}
//====================================================================================
// Loop
//====================================================================================
void loop()
{
tft.setTextColor(fg, bg);
//----------------------------------------------------------------------------
// Anti-aliased font test
String test1 = "Hello World";
// Load a smooth font from SPIFFS
tft.loadFont("Final-Frontier-28");
tft.setRotation(0);
// Show all characters on screen with 2 second (2000ms) delay between screens
tft.showFont(2000); // Note: This function moves the cursor position!
tft.fillScreen(bg);
tft.setCursor(0,0);
tft.println(test1);
// Remove font parameters from memory to recover RAM
tft.unloadFont();
delay(2000);
//----------------------------------------------------------------------------
// We can have any random mix of characters in the font
String test2 = "仝倀"; // Unicodes 0x4EDD, 0x5000
tft.loadFont("Unicode-Test-72");
tft.setRotation(1);
// Show all characters on screen with 2 second (2000ms) delay between screens
tft.showFont(2000); // Note: This function moves the cursor position!
tft.fillScreen(bg);
tft.setCursor(0,0);
tft.setTextColor(TFT_CYAN, bg);
tft.println(test2);
tft.setTextColor(TFT_YELLOW, bg);
tft.println("12:00pm");
tft.setTextColor(TFT_MAGENTA, bg);
tft.println("1000Ω");
// Remove font parameters from memory to recover RAM
tft.unloadFont();
delay(2000);
//----------------------------------------------------------------------------
// Latin and Hiragana font mix
String test3 = "こんにちは";
tft.loadFont("Latin-Hiragana-24");
tft.setRotation(0);
// Show all characters on screen with 2 second (2000ms) delay between screens
tft.showFont(2000); // Note: This function moves the cursor position!
tft.fillScreen(bg);
tft.setTextColor(TFT_GREEN, bg);
tft.setCursor(0,0);
tft.println("Konnichiwa");
tft.println(test3);
tft.println();
tft.println("Sayonara");
tft.println("さようなら"); // Sayonara
// Remove font parameters from memory to recover RAM
tft.unloadFont();
delay(2000);
//
//----------------------------------------------------------------------------
}
//====================================================================================