-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4a3b6b3
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(;;); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|