diff --git a/README.md b/README.md
index 4df908e..454c2f7 100755
--- a/README.md
+++ b/README.md
@@ -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
@@ -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!
diff --git a/esp32/doorsignEPD/doorsignEPD.ino b/esp32/doorsignEPD/doorsignEPD.ino
index 28757c1..3bb5df7 100644
--- a/esp32/doorsignEPD/doorsignEPD.ino
+++ b/esp32/doorsignEPD/doorsignEPD.ino
@@ -4,7 +4,7 @@
#include
-// 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'
@@ -42,34 +42,44 @@ long sleepIntervalSetbyHeader = 0; //* Changed if the sleep i
#if DISPLAY_TYPE == '1.5'
#include // 1.54" b/w
-bool hasRed = false;
+bool hasColor = false;
String displayType = "1.5";
#endif
#if DISPLAY_TYPE == '2.9'
#include // 2.9" b/w
-bool hasRed = false;
+bool hasColor = false;
String displayType = "2.9";
#endif
#if DISPLAY_TYPE == '4.2'
#include // 4.2" b/w
-bool hasRed = false;
+bool hasColor = false;
String displayType = "4.2";
#endif
#if DISPLAY_TYPE == '4.2bwr'
#include // 4.2" b/w/r
-bool hasRed = true;
+bool hasColor = true;
String displayType = "4.2bwr";
#endif
+#if DISPLAY_TYPE == '4.2bwy'
+#include // 4.2" b/w/y
+bool hasColor = true;
+String displayType = "4.2bwy";
+#endif
#if DISPLAY_TYPE == '7.5'
#include // 7.5" b/w
-bool hasRed = false;
+bool hasColor = false;
String displayType = "7.5";
#endif
#if DISPLAY_TYPE == '7.5bwr'
#include // 7.5" b/w/r
-bool hasRed = true;
+bool hasColor = true;
String displayType = "7.5bwr";
#endif
+#if DISPLAY_TYPE == '7.5bwy'
+#include // 7.5" b/w/y
+bool hasColor = true;
+String displayType = "7.5bwy";
+#endif
#include
#include
#include
@@ -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= 0; b -= 2) {
int bit = bitRead(data[i], b);
int bit2 = bitRead(data[i], b - 1);
@@ -406,4 +416,4 @@ void loop() {
Serial.println("Going to deep sleep now...");
esp_deep_sleep_start();
}
-};
+};
\ No newline at end of file
diff --git a/server/contents/door_sign.php b/server/contents/door_sign.php
index 74ade1d..4598117 100755
--- a/server/contents/door_sign.php
+++ b/server/contents/door_sign.php
@@ -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 );
}
?>
diff --git a/server/contents/harry.php b/server/contents/harry.php
new file mode 100644
index 0000000..05db555
--- /dev/null
+++ b/server/contents/harry.php
@@ -0,0 +1,97 @@
+ $linelenght) {
+ $output = $output.$line."\n";
+ $line = $word;
+ }
+ else {
+ $line = $line." ".$word;
+ }
+ }
+ }
+ $output = $output.$line;
+ return $output;
+}
+
+?>
\ No newline at end of file
diff --git a/server/contents/harry/harry-longneck.png b/server/contents/harry/harry-longneck.png
new file mode 100644
index 0000000..b9046ce
Binary files /dev/null and b/server/contents/harry/harry-longneck.png differ
diff --git a/server/contents/harry/harry-really.png b/server/contents/harry/harry-really.png
new file mode 100644
index 0000000..9b3ded9
Binary files /dev/null and b/server/contents/harry/harry-really.png differ
diff --git a/server/contents/harry/harry-scared.png b/server/contents/harry/harry-scared.png
new file mode 100644
index 0000000..a2925e6
Binary files /dev/null and b/server/contents/harry/harry-scared.png differ
diff --git a/server/contents/harry/harry-tears.png b/server/contents/harry/harry-tears.png
new file mode 100644
index 0000000..5f1c1d4
Binary files /dev/null and b/server/contents/harry/harry-tears.png differ
diff --git a/server/contents/harry/messages.txt b/server/contents/harry/messages.txt
new file mode 100755
index 0000000..05e8dc6
--- /dev/null
+++ b/server/contents/harry/messages.txt
@@ -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
diff --git a/server/contents/harry/qr.png b/server/contents/harry/qr.png
new file mode 100644
index 0000000..0343913
Binary files /dev/null and b/server/contents/harry/qr.png differ
diff --git a/server/example_images/harry.png b/server/example_images/harry.png
new file mode 100644
index 0000000..4ea96d5
Binary files /dev/null and b/server/example_images/harry.png differ
diff --git a/server/fonts/terminus/COPYING b/server/fonts/terminus/COPYING
new file mode 100644
index 0000000..c964194
--- /dev/null
+++ b/server/fonts/terminus/COPYING
@@ -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.
diff --git a/server/fonts/terminus/TerminusTTF-4.46.0.ttf b/server/fonts/terminus/TerminusTTF-4.46.0.ttf
new file mode 100644
index 0000000..eafa3a6
Binary files /dev/null and b/server/fonts/terminus/TerminusTTF-4.46.0.ttf differ
diff --git a/server/fonts/terminus/TerminusTTF-Bold-4.46.0.ttf b/server/fonts/terminus/TerminusTTF-Bold-4.46.0.ttf
new file mode 100644
index 0000000..9dc2aed
Binary files /dev/null and b/server/fonts/terminus/TerminusTTF-Bold-4.46.0.ttf differ
diff --git a/server/harry-talk.php b/server/harry-talk.php
new file mode 100644
index 0000000..61ff1a0
--- /dev/null
+++ b/server/harry-talk.php
@@ -0,0 +1,71 @@
+
+
+Doorsign
+
+
+ Let Harry speak!
+Write your message here and let Harry Hamster speak! You have 52 characters.
+ ");
+}
+else {
+ $writeout = true;
+
+ // check for length
+ if(mb_strlen($_GET['submess']) > 52) {
+ print("Message to long
");
+ $writeout = false;
+ }
+ if (strlen($_GET['name']) > 8) {
+ print("Name to long!
");
+ $writeout = false;
+ }
+
+ // check for to long words
+ $words = explode(' ', $_GET['submess']);
+ foreach ( $words as $word ) {
+ if (mb_strlen( $word ) > 13) {
+ print("You are using to long words. The character per word limit is 13.
");
+ $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("Your message was accepted! Soon it will be shown on the display.");
+ }
+ else {
+ print("I try it again!
");
+ }
+}
+
+?>
+ display content right now:
+
+
+
diff --git a/server/index.php b/server/index.php
index ce94779..3c9ed42 100755
--- a/server/index.php
+++ b/server/index.php
@@ -14,9 +14,11 @@
# 4.2 inches: https://www.waveshare.com/wiki/4.2inch_e-Paper_Module
# 7.5 inches: https://www.waveshare.com/wiki/7.5inch_e-Paper_HAT
const DISPLAYS = array( "7.5"=>array("size"=>"640x384","rotate"=>"false"),
- "7.5bwr"=>array("size"=>"640x384","rotate"=>"false", "red"=>"true"),
+ "7.5bwr"=>array("size"=>"640x384","rotate"=>"false", "color"=>"red"),
+ "7.5bwy"=>array("size"=>"640x384","rotate"=>"false", "color"=>"yellow"),
"4.2"=>array("size"=>"400x300","rotate"=>"false"),
- "4.2bwr"=>array("size"=>"400x300","rotate"=>"false", "red"=>"true"),
+ "4.2bwr"=>array("size"=>"400x300","rotate"=>"false", "color"=>"red"),
+ "4.2bwy"=>array("size"=>"400x300","rotate"=>"false", "color"=>"yellow"),
"2.9"=>array("size"=>"296x128","rotate"=>"true"),
"1.5"=>array("size"=>"200x200","rotate"=>"true")
);
@@ -43,7 +45,16 @@
);
*/
-const THRESHOLDS = array("black" => 150, "red" => 240);
+// Pixel clean fixed width Terminus font
+// for a crisp look deactivate antialising by adding a "-" in front of the color
+// and use the font sizes: 9, 12, 18 or 24
+// imagettftext($im, 9, 0, 10, 10, -$black, $DEFAULT_FONT['regular'], "your text");
+$TERMINUS_FONT = array(
+ "regular"=>realpath("./fonts/terminus/TerminusTTF-4.46.0.ttf"),
+ "bold"=>realpath("./fonts/terminus/TerminusTTF-Bold-4.46.0.ttf")
+);
+
+const THRESHOLDS = array("black" => 150, "color" => 240);
if (!extension_loaded('gd')) {
echo "GD library is not installed. Please install GD on your server (http://php.net/manual/de/image.installation.php)";
@@ -100,6 +111,7 @@ function checkFreeType(){
$background_color = ImageColorAllocate ($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
$red = ImageColorAllocate($im, 0xFF, 0x00, 0x00);
+$yellow = ImageColorAllocate($im, 0xFF, 0xFF, 0x00);
if(is_file($selectedContent)){
@@ -125,13 +137,13 @@ function checkFreeType(){
//$im = imagerotate($im, 180, 0);
//$im = imagerotate($im, 180, 0);
- echo rawImage($im, DISPLAYS[$displayType]['red'] );
+ echo rawImage($im, DISPLAYS[$displayType]['color'] );
}
imagedestroy($im);
-function rawImage($im, $hasRed) {
+function rawImage($im, $highlightColor) {
$bits = "";
$bytes = "";
$pixelcount = 0;
@@ -145,28 +157,44 @@ function rawImage($im, $hasRed) {
$b = $rgb & 0xFF;
$gray = ($r + $g + $b) / 3;
- if($hasRed == "true"){
-
- if(($r >= THRESHOLDS['red']) && ($g < 50) && ($b <50)) {
+ if($highlightColor == "red"){
+ if(($r >= THRESHOLDS['color']) && ($g < 50) && ($b <50)) {
$bits .= "01";
- } else {
+ }
+ else {
if ($gray < THRESHOLDS['black']) {
$bits .= "11";
- }else {
+ }
+ else {
$bits .= "00";
}
}
- $pixelcount = $pixelcount+2;
- }else{
- if ($gray < THRESHOLDS['black']) {
- $bits .= "1";
- }else {
- $bits .= "0";
+ $pixelcount = $pixelcount+2;
}
+ elseif($highlightColor == "yellow"){
+ if(($r >= THRESHOLDS['color'] && $g >= THRESHOLDS['color']) && ($b <50)) {
+ $bits .= "01";
+ }
+ else {
+ if ($gray < THRESHOLDS['black']) {
+ $bits .= "11";
+ }
+ else {
+ $bits .= "00";
+ }
+ }
+ $pixelcount = $pixelcount+2;
+ }
+ else{
+ if ($gray < THRESHOLDS['black']) {
+ $bits .= "1";
+ }
+ else {
+ $bits .= "0";
+ }
$pixelcount++;
}
-
if ($pixelcount % 8 == 0) {
$bytes .= pack('H*', str_pad(base_convert($bits, 2, 16),2, "0", STR_PAD_LEFT));
$bits = "";
@@ -179,4 +207,4 @@ function rawImage($im, $hasRed) {
header("Content-length: $size");
return $bytes;
}
-?>
+?>
\ No newline at end of file