first working version v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Tue, 19 May 2020 16:01:09 +0200
branchv_0
changeset 0a7af46af7903
child 1 6733bd832b61
first working version
.hgignore
Makefile
mt-32-display.cpp
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/.hgignore	Tue May 19 16:01:09 2020 +0200
     1.3 @@ -0,0 +1,4 @@
     1.4 +syntax: glob
     1.5 +
     1.6 +*~
     1.7 +mt-32-display
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/Makefile	Tue May 19 16:01:09 2020 +0200
     2.3 @@ -0,0 +1,10 @@
     2.4 +mt-32-display: mt-32-display.cpp
     2.5 +	g++ -o mt-32-display mt-32-display.cpp
     2.6 +
     2.7 +clean:
     2.8 +	rm -f mt-32-display
     2.9 +
    2.10 +run: mt-32-display
    2.11 +	echo -n "ahoj" | ./mt-32-display
    2.12 +
    2.13 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/mt-32-display.cpp	Tue May 19 16:01:09 2020 +0200
     3.3 @@ -0,0 +1,45 @@
     3.4 +#include <iostream>
     3.5 +#include <iomanip>
     3.6 +
     3.7 +/**
     3.8 + * Translates text from standard input to a hex-formatted System Exclusive (SysEx) message for Roland MT-32,
     3.9 + * which instructs the unit to show given text on the display.
    3.10 + * 
    3.11 + * Roland MT-32 is capable to display 20 characters.
    3.12 + * Longer messages are silently truncated by the MT-32 unit (this software does not check the length).
    3.13 + * 
    3.14 + * The SysEx message contains a checksum.
    3.15 + * If the checksum is wrong, the MT-32 unit shows the "Exc. Checksum error" message for few seconds
    3.16 + * and then returns back to the default screen.
    3.17 + * 
    3.18 + * Usage:
    3.19 + *     amidi --port="hw:2,0,0" --send-hex="$(echo -n '   Run GNU/Linux    ' | ./mt-32-display )"
    3.20 + * 
    3.21 + * @param argc
    3.22 + * @param argv
    3.23 + * @return 
    3.24 + */
    3.25 +int main(int argc, char**argv) {
    3.26 +	std::cout << "f0 41 10 16 12 20 00 00 ";
    3.27 +	std::cout << std::hex << std::setfill('0');
    3.28 +
    3.29 +	int sum = 0;
    3.30 +
    3.31 +	// 20 00 00 = display message
    3.32 +	sum += 0x20;
    3.33 +	sum += 0x00;
    3.34 +	sum += 0x00;
    3.35 +
    3.36 +	for (char ch; std::cin.read(&ch, 1).good();) {
    3.37 +		std::cout << std::setw(2) << ((int) ch) << " ";
    3.38 +		sum += ch;
    3.39 +	}
    3.40 +
    3.41 +	sum %= 128;
    3.42 +	sum = 128 - sum;
    3.43 +	std::cout << std::setw(2) << sum;
    3.44 +	std::cout << " f7";
    3.45 +
    3.46 +	std::cout << std::endl;
    3.47 +	return 0;
    3.48 +}