Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ With Get-Parameter 'scale' you adjust size of the text. Set 'debug' to true to g
* `door_sign_csv` (list of people working in a room, information taken from a csv file or google spreadsheet)
* `static_image` (showing a random image (scaled to display size) from server/contents/static_image. Just put your image here)
* `weather_station` (showing demo temperature an weather with icons)
* `harry` (simple shoutbox script - allows users to post their own message on the display!)

## Dependencies

Expand All @@ -35,4 +36,5 @@ This repository is part of article "Ausdauernde Infotafel" from German computer
+ add better examples with real data (like ical-calendar)

## New functions
Support for red-black-white display!
+ Support for black-white-yellow (bwy) displays! (4.2bwy works, 7.5bwy is untested)
+ Support for red-black-white display!
28 changes: 19 additions & 9 deletions esp32/doorsignEPD/doorsignEPD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <Basecamp.hpp>

// Define your display type here: 2.9, 4.2 (bw and bwr) or 7.5 (bw or bwr) inches are supported:
// Define your display type here: 2.9, 4.2 (bw, bwr or bwy) or 7.5 (bw, bwr or bwy) inches are supported:
// Default: 4.2bwr
#define DISPLAY_TYPE '4.2bwr'

Expand Down Expand Up @@ -42,34 +42,44 @@ long sleepIntervalSetbyHeader = 0; //* Changed if the sleep i

#if DISPLAY_TYPE == '1.5'
#include <GxGDEP015OC1/GxGDEP015OC1.cpp> // 1.54" b/w
bool hasRed = false;
bool hasColor = false;
String displayType = "1.5";
#endif
#if DISPLAY_TYPE == '2.9'
#include <GxGDEH029A1/GxGDEH029A1.cpp> // 2.9" b/w
bool hasRed = false;
bool hasColor = false;
String displayType = "2.9";
#endif
#if DISPLAY_TYPE == '4.2'
#include <GxGDEW042T2/GxGDEW042T2.cpp> // 4.2" b/w
bool hasRed = false;
bool hasColor = false;
String displayType = "4.2";
#endif
#if DISPLAY_TYPE == '4.2bwr'
#include <GxGDEW042Z15/GxGDEW042Z15.cpp> // 4.2" b/w/r
bool hasRed = true;
bool hasColor = true;
String displayType = "4.2bwr";
#endif
#if DISPLAY_TYPE == '4.2bwy'
#include <GxGDEW042Z15/GxGDEW042Z15.cpp> // 4.2" b/w/y
bool hasColor = true;
String displayType = "4.2bwy";
#endif
#if DISPLAY_TYPE == '7.5'
#include <GxGDEW075T8/GxGDEW075T8.cpp> // 7.5" b/w
bool hasRed = false;
bool hasColor = false;
String displayType = "7.5";
#endif
#if DISPLAY_TYPE == '7.5bwr'
#include <GxGDEW075Z09/GxGDEW075Z09.cpp> // 7.5" b/w/r
bool hasRed = true;
bool hasColor = true;
String displayType = "7.5bwr";
#endif
#if DISPLAY_TYPE == '7.5bwy'
#include <GxGDEW075Z09/GxGDEW075Z09.cpp> // 7.5" b/w/y
bool hasColor = true;
String displayType = "7.5bwy";
#endif
#include <GxIO/GxIO_SPI/GxIO_SPI.cpp>
#include <GxIO/GxIO.cpp>
#include <Fonts/FreeMonoBold9pt7b.h>
Expand Down Expand Up @@ -192,7 +202,7 @@ void drawPixels(char *data, size_t len, boolean start){
Serial.println(String("Printing ") + len + " Bytes to the screen");
for (size_t i=0; i<len; i++){

if (hasRed == true) {
if (hasColor == true) {
for (int b = 7; b >= 0; b -= 2) {
int bit = bitRead(data[i], b);
int bit2 = bitRead(data[i], b - 1);
Expand Down Expand Up @@ -406,4 +416,4 @@ void loop() {
Serial.println("Going to deep sleep now...");
esp_deep_sleep_start();
}
};
};
16 changes: 13 additions & 3 deletions server/contents/door_sign.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@
const ROOM = 'Raum 267';
const PERSONS = array("John Doe", "Jane Doe", "Otto Normalverbraucher");

// if display has a color, use it!
$fontSize = $scale;
if(DISPLAYS[$displayType]['color'] == "red") {
$fontcolor = $red;
}
elseif (DISPLAYS[$displayType]['color'] == "yellow") {
$fontcolor = $yellow;
}
else {
$fontcolor = $black;
}

$cursorY += $fontSize*1.5;
imagettftext($im, $fontSize, 0, 10, $cursorY, $red, $DEFAULT_FONT['bold'], ROOM);
imagettftext($im, $fontSize, 0, 10, $cursorY, $fontcolor, $DEFAULT_FONT['bold'], ROOM);
$cursorY += 5;
imageline ($im , 10 , $cursorY , $displayWidth - 20, $cursorY , $black );

$fontSize = 0.5*$scale;
$fontSize = 18;
foreach(PERSONS as $person){
$cursorY = $cursorY+$fontSize*1.5;
imagettftext($im, $fontSize, 0, 20, $cursorY, $black, $DEFAULT_FONT['regular'], $person );
imagettftext($im, $fontSize, 0, 20, $cursorY, -$black, $TERMINUS_FONT['regular'], $person );
}

?>
97 changes: 97 additions & 0 deletions server/contents/harry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php
/**
* Harrys Shoutbox - let harry hamster talk!
* the last 3 messages are shown to the public
*
* Be sure, that the message file (./contents/harry/messages.txt)
* is writeable by the webserver, on you need to linux:
* sudo chown www-data messages.txt
* sudo chmod 774 messages.txt
*
* New messages can be postet via harry-talk.php in main dir.
*/

/**
* show qr-code public on display?
*
* you may add your qr-code (./contents/harry/qr.png) which points to
* harry-talk.php on your server, so users can upload messages
* use https://www.the-qrcode-generator.com/ and download the png
* scaling from 200x200 to 67x67 is done by this script
*/
$showQr = true;

// how long the display sleeps in seconds - to show user the next update time
$deepSleepSeconds = 300;

// for harry you need a big display
if($displayHeight < 300 || $displayWidth < 400 ) {
echo "Bad news for you, you need a bigger display. :(";
exit;
}

// read message file
$messages = file("./contents/harry/messages.txt");

// place harry
$harry = imagecreatefrompng("./contents/harry/harry-scared.png"); # choose your harry (see images in folder harry)
imagecopy($im, $harry, 0, $displayHeight-imagesy($harry)-16, 0, 0, imagesx($harry), imagesy($harry));

// place bubble, qr code and status
imagerectangle($im, 80, 1, $displayWidth-2, $displayHeight-17, $black);
imagerectangle($im, 81, 0, $displayWidth-3, $displayHeight-16, $black);

imageline($im, 80, $displayHeight-90, 80, $displayHeight-100, $white);
imageline($im, 81, $displayHeight-90, 81, $displayHeight-100, $white);
imageline($im, 80, $displayHeight-90, 70, $displayHeight-100, $black);
imageline($im, 79, $displayHeight-90, 69, $displayHeight-100, $black);
imageline($im, 80, $displayHeight-100, 70, $displayHeight-100, $black);
imageline($im, 79, $displayHeight-101, 69, $displayHeight-101, $black);

if ($showQr == true) {
imagettftext($im, 9, 0, 10, 15, -$black, $TERMINUS_FONT['regular'], "Let Harry\n speak:");
$qr = imagecreatefrompng("./contents/harry/qr.png");
$qr = imagescale($qr, 67, 67);
imagecopy($im, $qr, 5, 35, 0, 0, imagesx($qr), imagesy($qr));
}

imagefilledrectangle($im, 0, $displayHeight-13, $displayWidth, $displayHeight, $black);
imagettftext($im, 9, 0, 1, $displayHeight-3, -$white, $TERMINUS_FONT['regular'], "updated:".date("d.m.y H:i",time())." | next update:".date("H:i",time()+$deepSleepSeconds)." | Harry © by Tim 2017");

// write messages
$i=0;
foreach ($messages as $message){
$msg = explode(";", $message);
imagettftext($im, 18, 0, 85, 20+($i*98), -$black, $TERMINUS_FONT['bold'], fittext($msg[0], floor(($displayWidth-95)/12)));
imagettftext($im, 9, 0, $displayWidth-180, 83+($i*98), -$black, $TERMINUS_FONT['regular'], $msg[1]);
$i++;
}

/**
* functions
*/

// fit text into lines
function fittext($text, $linelenght) {
$words = explode(' ', $text);
$output = "";
$line = "";
foreach ( $words as $word ) {
if (strlen($line) == 0) {
$line = $word;
}
else {
if (strlen( $line." ".$word ) > $linelenght) {
$output = $output.$line."\n";
$line = $word;
}
else {
$line = $line." ".$word;
}
}
}
$output = $output.$line;
return $output;
}

?>
Binary file added server/contents/harry/harry-longneck.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added server/contents/harry/harry-really.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added server/contents/harry/harry-scared.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added server/contents/harry/harry-tears.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions server/contents/harry/messages.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Only 52 characters? FAKE NEWS!!!;Trump - 11.03.2018 16:36
This is a shoutbox, so shout!;Admin - 11.03.2018 16:32
Look at my horse, my horse is amazing!;Sir! - 11.03.2018 16:30
Binary file added server/contents/harry/qr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added server/example_images/harry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 97 additions & 0 deletions server/fonts/terminus/COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
Copyright (c) 2010 Dimitar Toshkov Zhekov,
with Reserved Font Name "Terminus Font".

Copyright (c) 2011 Tilman Blumenbach,
with Reserved Font Name "Terminus (TTF)".

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file added server/fonts/terminus/TerminusTTF-4.46.0.ttf
Binary file not shown.
Binary file not shown.
71 changes: 71 additions & 0 deletions server/harry-talk.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<html lang="en-EN">
<head>
<title>Doorsign</title>
</head>
<body>
<h1>Let Harry speak!</h1>
<?php
// list of bad words - 'feel like a little dictator' option
// don't remove '/;/' from filtering list or evil things might
// happen to your dictatorship uhm... I mean csv file... ;)
$badWords = array('/\bkim\b/i','/fuck/i','/;/');

if (!isset($_GET['submess']) || !isset($_GET['name'])) {
print("<p>Write your message here and let Harry Hamster speak! You have 52 characters.</p>
<form action=\"harry-talk.php\">
your message:<br><textarea name=\"submess\" rows=\"3\" cols=\"24\" maxlength=\"52\" autofocus required wrap=\"soft\"></textarea><br>
your name: <input type=\"text\" name=\"name\" maxlength=\"8\" size=\"8\" required><br>
<input type=\"submit\" value=\"Let Harry speak!\">
</form>");
}
else {
$writeout = true;

// check for length
if(mb_strlen($_GET['submess']) > 52) {
print("<p>Message to long</p>");
$writeout = false;
}
if (strlen($_GET['name']) > 8) {
print("<p>Name to long!</p>");
$writeout = false;
}

// check for to long words
$words = explode(' ', $_GET['submess']);
foreach ( $words as $word ) {
if (mb_strlen( $word ) > 13) {
print("<p>You are using to long words. The character per word limit is 13.</p>");
$writeout = false;
}
}

// if everything is fine write message to file
if ($writeout == true) {

// some filtering I'm sure I've been missing something...
$message = trim($_GET['submess']);
$name = $_GET['name'];
$message = preg_replace($badWords, "*", $message);
$message = str_replace(array("\r", "\n"), '', $message);
$name = preg_replace($badWords, "*", $name);
$name = str_replace(array("\r", "\n"), '', $name);

$messinput = file("./contents/harry/messages.txt");
$fp = fopen("./contents/harry/messages.txt", "w");
fwrite($fp, $message.";".$name." - ".date("d.m.Y H:i")."\n");
fwrite($fp, $messinput[0]);
fwrite($fp, $messinput[1]);
fclose($fp);
print("</p>Your message was accepted! Soon it will be shown on the display.</p>");
}
else {
print("<p><a href=\"harry-talk.php\">I try it again!</a></p>");
}
}

?>
<h2>display content right now:<h2>
<img src="index.php?debug=true&content=harry&display=4.2">
<p>
</body>
Loading