Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Juerd committed May 26, 2024
0 parents commit 4a3b6b3
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
3 changes: 3 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This software may be redistributed under the terms of the GPL, LGPL, modified BSD, or Artistic license, or any of the other OSI approved licenses listed at http://www.opensource.org/licenses/alphabetical. Distribution is allowed under all of these licenses, or any smaller subset of multiple or just one of these licenses.

When using a packaged version, please refer to the package metadata to see under which license terms it was distributed. Alternatively, a distributor may choose to replace the LICENSE section of the documentation and/or include a LICENSE file to reflect the license(s) they chose to redistribute under.
5 changes: 5 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Stuurt bij het opstarten een printopdracht naar de printer en is dus bedoeld om
te worden gebruikt in combinatie met een circuitje dat de ESP32 S2 aanzet en
lang genoeg (ongeveer een seconde) aan houdt.

Gemaakt voor een "S2 Mini".
64 changes: 64 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include <Arduino.h>
#include <WiFi.h>
#include <NTPClient.h>
#include <WiFiUdp.h>

WiFiUDP ntpUDP;

IPAddress printer(10,42,8,10);
IPAddress myip(10,42,8,9);
IPAddress mymask(255,255,0,0);
IPAddress gw(10,42,42,1);
IPAddress ntp(10,42,42,1);
IPAddress dns(10,42,42,1);
NTPClient ntpclient(ntpUDP, ntp);

void setup() {
Serial.begin(115200);
Serial.println("Hallo wereld!");
WiFi.config(myip, dns, gw, mymask);
WiFi.begin("revspace-pub", "");
setenv("TZ","CET-1CEST,M3.5.0/2,M10.5.0/3",1);
tzset();
}

void loop() {
while (WiFi.status() != WL_CONNECTED ) {
Serial.println("Connecting to WiFi...");
delay(10);
}
ntpclient.update();
unsigned long time = ntpclient.getEpochTime();

struct tm *ptm = localtime((time_t *) &time);

char date[11];
snprintf(date, sizeof(date), "%04d-%02d-%02d",
ptm->tm_year + 1900,
ptm->tm_mon + 1,
ptm->tm_mday
);

Serial.println("Connecting to printer...");

WiFiClient client;
if (client.connect(printer, 9100)) {
client.print("\eia"); client.write('\0');
client.print(
"\e@"
"\ea\x01"
"\ek\x0b"
);
client.print("\eX0\x43"); client.write('\0');
client.print("gratis meuk\n");
client.print("\eX0\x64"); client.write('\0');
client.print(date);
client.print("\f");
client.stop();
Serial.println("Date sent to printer.");
};

Serial.println("Halting.");

for(;;);
}
16 changes: 16 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[platformio]
src_dir = .

[env]
platform = https://github.com/platformio/platform-espressif32.git
board = featheresp32-s2
board_build.partitions = default.csv
framework = arduino
targets = upload
monitor_speed = 115200
lib_deps =
NTPClient

[env:serial]
upload_protocol = esptool

0 comments on commit 4a3b6b3

Please sign in to comment.