filter ASCII characters v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Tue, 19 May 2020 17:04:22 +0200
branchv_0
changeset 2 a84830179027
parent 1 6733bd832b61
child 3 51a8362261a9
filter ASCII characters
mt-32-display.cpp
--- a/mt-32-display.cpp	Tue May 19 16:03:25 2020 +0200
+++ b/mt-32-display.cpp	Tue May 19 17:04:22 2020 +0200
@@ -28,8 +28,16 @@
  * If the checksum is wrong, the MT-32 unit shows the "Exc. Checksum error" message for few seconds
  * and then returns back to the default screen.
  * 
- * Usage:
+ * Only printable ASCII characters are supported. Other characters (bytes) are replaced by "."
+ * 
+ * Some characters are displayed differently:
+ *   ASCII   MT-32
+ *       ~   →
+ *       \   ¥
+ * 
+ * Usage examples:
  *     amidi --port="hw:2,0,0" --send-hex="$(echo -n '   Run GNU/Linux    ' | ./mt-32-display )"
+ *     while read message; do amidi --port="hw:2,0,0" --send-hex="$(echo -n "$message" | ./mt-32-display )"; done
  * 
  * @param argc
  * @param argv
@@ -47,6 +55,7 @@
 	sum += 0x00;
 
 	for (char ch; std::cin.read(&ch, 1).good();) {
+		if (ch < 32 || ch > 126) ch = '.';
 		std::cout << std::setw(2) << ((int) ch) << " ";
 		sum += ch;
 	}