Skip to content

Instantly share code, notes, and snippets.

@yoursunny
Last active June 15, 2026 01:27
Show Gist options
  • Select an option

  • Save yoursunny/5111188acd3e97042f2512f5d33e7c1e to your computer and use it in GitHub Desktop.

Select an option

Save yoursunny/5111188acd3e97042f2512f5d33e7c1e to your computer and use it in GitHub Desktop.
Mom Calendar with Adafruit MagTag https://yoursunny.com/t/2023/mom-calendar/
#include <Adafruit_ThinkInk.h>
#include <WiFi.h>
const char* WIFI_SSID = "ssid";
const char* WIFI_PASS = "passw0rd";
ThinkInk_290_Grayscale4_T5 display(EPD_DC, EPD_RESET, EPD_CS, -1, -1);
static void shutdown()
{
ESP.deepSleep(1800*1000000);
}
void setup() {
// disable speaker, NeoPixel, light sensor
pinMode(SPEAKER_SHUTDOWN, OUTPUT);
digitalWrite(SPEAKER_SHUTDOWN, LOW);
pinMode(NEOPIXEL_POWER, OUTPUT);
digitalWrite(NEOPIXEL_POWER, HIGH);
Serial.begin(115200);
delay(100);
// connect to WiFi
WiFi.persistent(false);
WiFi.begin(WIFI_SSID, WIFI_PASS);
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.printf("WiFi.status %" PRIu8 "\n", WiFi.status());
return shutdown();
}
// NTP sync
configTime(-5*3600, -4*3600, "time.nist.gov", "pool.ntp.org");
struct tm tm;
if (!getLocalTime(&tm, 5000)) {
Serial.println("NTP failed");
return shutdown();
}
time_t t = time(nullptr);
Serial.printf("t=%ld\n", static_cast<long>(t));
// display day count
display.begin(THINKINK_MONO);
display.clearBuffer();
display.setTextSize(10);
display.setTextColor(EPD_GRAY);
display.setCursor(40, 20);
display.print((t - 1781503200) / 86400);
// display weekday
display.setTextSize(8);
display.setCursor(240, 30);
display.print((t - 1781416800) / 86400 % 7);
display.display(true);
delay(2000);
shutdown();
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment