Closed bales0 closed 2 months ago
Hi, glad to see my project inspires you. So, it was for an MZ-800. Can you give more details about what LCD keypad you use? A link to where you bought may be helpful.
I checked that the keypad is enabled by default in the source: https://github.com/SHARPENTIERS/MZ-SD2CMT/blob/3d14d01e14415129d7c6f805d5cc58e5bc8e473c/Arduino/mz-sd2cmt/mz-sd2cmt.input.h#L3
If you power the Mega through an USB cable plugged to your PC, you can use the serial terminal to get the value whenever you press a button on the keypad. Take note of the value for each button and give them to me. Preferably done without the MZ-800 connected to Mega as it is not a right thing to let USB power the MZ-800 or to let MZ-800 powering the PC USB.
Also, you can join me at https://discord.com/channels/1197483745389854760/1208344566521004073.
Mine was an old version V1 which may have a different order of voltages per key than yours and the source only works for V1. That's the reason I need more details about yours so I can add a new version working with yours.
Hi, than you for reply. Im using this shield (probably China clone): D1 Robot
When I checked RS232 it cycle in strange error:
I have compiled it in Arduino 1.8.5 due to new compiler incompatibility:
I cant see ADC values, but measured voltage: Right: 0V Up: 0.650V Down: 1.508V Left: 2.354V Select: 3.533V
As I understand LCD keypad shield examples, there should be voltage range for each keypress (didnt found it in your code)
BR, Aleš
To get the value, you simply need to use the serial monitor of Arduino IDE.
The order of buttons is the same as V1. Now, I'm not sure how to compute the voltage into BVx value because there is no warranty 1023 will be 5V (or 3.3V as I'm not sure). A long time ago I'm no longer programming in Arduino AVR...
Each pressed button has its voltage. If you press two buttons, you'll get a voltage in-between. My code was done as such as it will only accept one pressed button just for your information, so it will accept them in range [BVx-5, BVx+5] (BV0, BV1, BV2, BV3 and BV4]
What I need is to see what the Mega is reading in its ADC A0 and my code will display it on USB serial. I don't understand the first image. And I cannot open both image to have them bigger as they seem to be private.
"As I understand LCD keypad shield examples, there should be voltage range for each keypress (didnt found it in your code)" They are there in ADC 0-1023 values as expected from Mega : https://github.com/SHARPENTIERS/MZ-SD2CMT/blob/3d14d01e14415129d7c6f805d5cc58e5bc8e473c/Arduino/mz-sd2cmt/mz-sd2cmt.input.keypad.h#L24-L38
You can try to increase "delta" value as it is used to check a button is pressed if its ADC value is in the range [BVx-delta, BVx+delta]. But honestly, you can have those BVx values through the USB serial output whenever you press a button.
Hi, I used terminal to see COM but I can see just this message: " The function decode(&results)) is deprecated and may not work as expected! Just use decode() - without any parameter. The function decode(&results)) is deprecated and may not work as expected! Just use decode() - without any parameter. The function decode(&results)) is deprecated and may not work as expected! Just use decode() - without any parameter. The function decode(&results)) is deprecated and may not work as expected! Just use decode() - without any parameter. The function decode(&results)) is deprecated and may not work as expected! Just use decode() - without any parameter. The function decode(&results)) is deprecated and may not work as expected! Just use decode() - without any parameter. The function decode(&results)) is deprecated and may not work as expected! Just use decode() - without any parameter. "
Hi, based on your hints, I have edited the code (replace decode(results) with decode(), so serial showed keypad ADC (I have changed acordingly ADC values as bellow). Now it shows: " Input device: rotary encoder. Input device: TTP223 KeyPad. MZ-SD2CMT 41601 2000-10-11 10:46 Jason.mzf TTP223: ----||0 0 83 133 1DF 2D0 " But no reaction of LCD. Is is dependent on MOTOR and SENSE values and need to be connected to real MZ CMT port? Selecting next mzf file doesnt work, so thats why I thought that keypad doesnt work.
BR, Ales
Hi, still the keypads dont work. It reads the value from keypad, but doesnt react even I have cjanged the values to the same as from serial monitor.
Sorry, I was so busy with my work that I didn't watch my emails. So in the end, you got values when pressing keys (I see some hexa values). Did you change the values BV0-BV4 according to what you read? Because if you didn't change them, it is normal that there is no feedback to LCD since the difference is bigger than the delta value.
The values should be : static constexpr int BV0 = 0x0000; // TODO: make it configurable at run-time? static constexpr int BV1 = 0x0083; // TODO: make it configurable at run-time? static constexpr int BV2 = 0x0133; // TODO: make it configurable at run-time? static constexpr int BV3 = 0x01DF; // TODO: make it configurable at run-time? static constexpr int BV4 = 0x02D0; // TODO: make it configurable at run-time?
Regarding the LCD, I'm checking the datasheet of your LCD and they have the same pins. Oh, your picture is showing LCD is working. Note that if you select an entry, you can have info on serial port : https://github.com/SHARPENTIERS/MZ-SD2CMT/blob/3d14d01e14415129d7c6f805d5cc58e5bc8e473c/Arduino/mz-sd2cmt/mz-sd2cmt.display.serial.h#L9
Let me check what happens...
In the loop, we get the input code to act accordingly:
You could add serial usb printing to see if a input code is received.
As you can see, there is a call to Display.displayCode(...) so I'm a little surprise you won't get here.
I suppose that you don't have specific issue to access SD (though Storage instance).
As for MOTOR and SENSE, there are used when you call playWAV(); or playMZF();
And yes, you must connect SENSE and MOTOR! I design it as a replacement of the internal tape player, not as an external tape player and yes, MOTOR and SENSE are mandatory. Also, beware the schematic I used has the pin number in a "random" order so you should connect the tape wire according the pin number, not the pin position.
I redraw that part of schematic to have the pin numbers in the right position order:
Also, regarding EX READ and EX WRITE (the two external jacks for an external tape player/recorder) are not used for many reasons:
Sorry, I was so busy with my work that I didn't watch my emails. So in the end, you got values when pressing keys (I see some hexa values). Did you change the values BV0-BV4 according to what you read? Because if you didn't change them, it is normal that there is no feedback to LCD since the difference is bigger than the delta value.
The values should be : static constexpr int BV0 = 0x0000; // TODO: make it configurable at run-time? static constexpr int BV1 = 0x0083; // TODO: make it configurable at run-time? static constexpr int BV2 = 0x0133; // TODO: make it configurable at run-time? static constexpr int BV3 = 0x01DF; // TODO: make it configurable at run-time? static constexpr int BV4 = 0x02D0; // TODO: make it configurable at run-time?
Hi, yes I have changed the values according the information from terminal. Also I have tried to change delta in case the ADC is not stable. But it didnt help.
And yes, you must connect SENSE and MOTOR! I design it as a replacement of the internal tape player, not as an external tape player and yes, MOTOR and SENSE are mandatory. Also, beware the schematic I used has the pin number in a "random" order so you should connect the tape wire according the pin number, not the pin position.
I redraw that part of schematic to have the pin numbers in the right position order:
Also, regarding EX READ and EX WRITE (the two external jacks for an external tape player/recorder) are not used for many reasons:
- using external cassette recorders does not allow the cassette to be reliably saved for playback from another cassette player.
- using external cassette players requires you to calibrate the volume, making this a tedious task with cassettes recorded by different recorders, including the internal one.
- you need a dongle that connects the EX READ, EX WRITE and GND signals to the READ, WRITE and SENSE signals respectively.
- Ultra-fast mode (loading at the speed the Z80 can handle) requires the MOTOR and SENSE signals. For all these reasons, this project can only replace an internal drive, not an external one.
Yes, I understand that this project uses the max speed of communication for FAST load. Thats why I like it and plan to 3D print cover and implement directly to MZ (I have MZ-800 without internal CMT). Just to be sure, communication timing of your SD2CMT is for MZ-700? Will it work with MZ-800 timing?
I asked for MOTOR and SENSE to be sure if your code is not waiting for these signals when browsing SD card or actions from buttons.
In the loop, we get the input code to act accordingly:
You could add serial usb printing to see if a input code is received.
As you can see, there is a call to Display.displayCode(...) so I'm a little surprise you won't get here.
I suppose that you don't have specific issue to access SD (though Storage instance).
As for MOTOR and SENSE, there are used when you call playWAV(); or playMZF();
I have used different SD card and FAT32 and FAT format to check if the issue is not SD card. But didnt help, still no reaction from keypress. Just ADC value from terminal.
Sorry, I was so busy with my work that I didn't watch my emails. So in the end, you got values when pressing keys (I see some hexa values). Did you change the values BV0-BV4 according to what you read? Because if you didn't change them, it is normal that there is no feedback to LCD since the difference is bigger than the delta value.
The values should be : static constexpr int BV0 = 0x0000; // TODO: make it configurable at run-time? static constexpr int BV1 = 0x0083; // TODO: make it configurable at run-time? static constexpr int BV2 = 0x0133; // TODO: make it configurable at run-time? static constexpr int BV3 = 0x01DF; // TODO: make it configurable at run-time? static constexpr int BV4 = 0x02D0; // TODO: make it configurable at run-time?
Yes, used exact these values from terminal. Do you think the problem is the compiler from Arduino? As I understand you have used Visual Studio Code. Maybe this is why I received this error from terminal: "The function decode(&results)) is deprecated and may not work as expected! Just use decode() - without any parameter."
Try to add serial messages after "if (InputReader.readCode(inputCode))" to check whether it really gets the input codes. I don't understand why it doesn't work.
As far as I know, the tape system is totally similar to MZ-700. And you're right it must be checked upon MZ-800 schematics instead.
Checked the doc, the timing is the same.
Try to add serial messages after "if (InputReader.readCode(inputCode))" to check whether it really gets the input codes. I don't understand why it doesn't work.
Hi, Ive added Serial print of InputCode like this (please check if it is right as I do not understand the code): " void loop() { Osp3.setLevel(0);
SerialCode serialCode = SerialCode::none;
InputCode inputCode = InputCode::none;
if (SerialPrompt.readCode(serialCode))
{
// Do something with Serial?
}
if (InputReader.readCode(inputCode))
{
Serial.print(InputReader.readCode(inputCode));
switch (inputCode)
{
case InputCode::right:
rightPressed();
break;
case InputCode::left:
leftPressed();
break;
" But no new information on serial monitor. Just ADC values.
Try to comment/remove those lines: https://github.com/SHARPENTIERS/MZ-SD2CMT/blob/fd4bad282d7dc0027287e2038f02f6aa5ba8421c/Arduino/mz-sd2cmt/mz-sd2cmt.ino#L947-L950
I wonder if they block upon it.
Or maybe one of the input modules is blocking.
But you say you can see hexa codes when pressing which means at least the input loop is working.
Oh your code is not good.
Do something like that:
SerialCode serialCode = SerialCode::none;
InputCode inputCode = InputCode::none;
if (SerialPrompt.readCode(serialCode))
{
// Do something with Serial?
}
if (InputReader.readCode(inputCode))
{
Serial.println(inputCode);
What may happen is that InputReader.readCode(inputCode)
is always returning false. Let me check the condition.
Also, you can disable unused input modules:
by setting them as:
#define HAS_INPUT_KEYPAD 1
#define HAS_INPUT_IRREMOTE 0
#define HAS_INPUT_ROTARY_ENCODER 0
Oh your code is not good.
Do something like that:
SerialCode serialCode = SerialCode::none; InputCode inputCode = InputCode::none; if (SerialPrompt.readCode(serialCode)) { // Do something with Serial? } if (InputReader.readCode(inputCode)) { Serial.println(inputCode);
This I used, but linker shows this error:
exit status 1 no matching function for call to 'HardwareSerial::println(InputCode&)'
Also, you can disable unused input modules:
by setting them as:
#define HAS_INPUT_KEYPAD 1 #define HAS_INPUT_IRREMOTE 0 #define HAS_INPUT_ROTARY_ENCODER 0
This I tried the first day but linker showed:
exit status 1 'DummyInput' is an ambiguous base of 'InputReaderSelector<DummyInput, KeyPadInput, DummyInput>'
What surprised me on terminal is that it shows that Rotary encoder is used: " Input device: rotary encoder. MZ-SD2CMT 0 2024-08-05 18:34 jason/ 133 133 83 84 2D0 1DF 1DF 0 0 "
Also replace with: struct InputReader : InputReaderSelector<KeyPadInput>
Also replace with:
struct InputReader : InputReaderSelector<KeyPadInput>
Now at least monitor doesnt show rotary encoder as input :) " MZ-SD2CMT 0 2024-08-05 18:34 jason/ " But still no reaction from keypress
It makes no sense: you have InputReader.readCode(inputCode)
returning true when serial displays the hexa value. So you should then get another serial message which outputs the numerical value of inputCode.
Replace Serial.println(inputCode);
with Serial.print("InputCode: "); Serial.println(inputCode);
So you should have "InputCode: x" where x is a integer value.
I have to use: if (InputReader.readCode(inputCode)) {
Serial.print("InputCode: ");
Serial.println((InputReader.readCode(inputCode)));
As: Serial.print("InputCode: "); Serial.println(inputCode); return error during compilation
But still no new text in monitor, which as I understand the conditions means that its not met and boolean of keypress is 0.
When I put SerialPrint without condition I got no matter if key is pressed:
InputCode: 0
You don't have to call Serial.println((InputReader.readCode(inputCode)));
this way because you are replaying the button detection but it would always return false because the next reading will find the same key pressed and then return false to avoid too fast repetitive input_code. If you press 'SELECT', it will issue one code then nothing until you release and repress or after a period so holding a key is not flooding too much.
Try Serial.println(int(inputCode));
instead.
Try struct KeyPadInput : InputReaderSelector<LCD16x2KeyPadV1Input>
That project is getting old. Going to vacation from tomorrow. I'll be absent for at least two days. Then I'll try to see if I can update all the source with a more recent Arduino 2.0 and toolchain. It really makes no sense, if you can display an hexa value when pressing a key then InputReader.readCode(inputCode)
will return true and update inputCode. The source I read is not lying about it.
Hi, thanks for new ideas. I will try. Enjoy the vacation!
Gosh! Using Arduino 2.0, I stumble upon many issues. I have numerous errors when compiling. Also notice the toolchain is quite old and stuck to c++11. It looks like their last version is leading to many C++ regressions...
Ok, after some works to make it buildable and uploadable, I seem to get the same issue as you. Looks as if I cannot trust Arduino in the long term... I guess I need some time to solve that mystery.
At least rotary encoder works. I can explore the contents of the µSD.
My bad! I happen to find why keypad is not working. It is true that I wasn't using that screen and keypad that much after having been switching to OLED, rotary encoder and IR remote. And people who built their MZ-SD2CMT before you, weren't using that keypad so you are the only one to discover that bug. Thanks for letting me pinpoint it.
You should remove "bool " before result in https://github.com/SHARPENTIERS/MZ-SD2CMT/blob/fd4bad282d7dc0027287e2038f02f6aa5ba8421c/Arduino/mz-sd2cmt/mz-sd2cmt.input.keypad.h#L95 to get:
result = received_code != InputCode::none;
if (result)
{...
Gosh! Using Arduino 2.0, I stumble upon many issues. I have numerous errors when compiling. Also notice the toolchain is quite old and stuck to c++11. It looks like their last version is leading to many C++ regressions...
Hi, thats why I install "old" version of Arduino 1.8.5 as I have experienced compilation errors with other older projects.
Ok, after some works to make it buildable and uploadable, I seem to get the same issue as you. Looks as if I cannot trust Arduino in the long term... I guess I need some time to solve that mystery.
At least rotary encoder works. I can explore the contents of the µSD.
I thought that not many of us are using simple keypad in this project (and based message from terminal), so I also had plan to order rotary encoder just to try.
My bad! I happen to find why keypad is not working. It is true that I wasn't using that screen and keypad that much after having been switching to OLED, rotary encoder and IR remote. And people who built their MZ-SD2CMT before you, weren't using that keypad so you are the only one to discover that bug. Thanks for letting me pinpoint it.
You should remove "bool " before result in
to get:
result = received_code != InputCode::none; if (result) {...
WAUUU, now it is working as expected! I dont know how to thank you for your invested time to help me. Now it shows Playing... There is no progress, but Im sure it is because it is not connected to MZ800 port. As I think, there should be possible to switch to "normal" mode by RIGHT key. Should it be shown on LCD? It is shown in terminal sometimes when loading. Oh, I can see that "sometime" ULTRAFAST written on terminal is because of doubletap the key. Enable and disable with one keypress. Again THANK YOU. Im looking forward to test with the SHARP! Later I will try to understand the code to the level I would be able to add ULTRAFAST mode switch to be seen on display :-)
Could I have one more ask for help? Im not able to compile MZF2LEP in MinGW and there is no build included in your project. Maybe you have compiled version for Windows to share with me or add here to repository?
It is for creating LEP files. Just using WAV or MZF files should be enough (just dropping them in the SD). I will see it tomorrow.
ULTRAFAST mode is also displayed on both LCD and OLED screens.
EDIT: for some reason, I cannot see anything displayed on the second line. Well, another thing I must check.
It sounds pretty weird to redraw the second line only when not refreshing all. Maybe it should be if (refresh_all)
.
EDIT: yep, OLED is doing the opposite thing so it should be if (refresh_all)
. I checked and it is better.
Hi, yes! Now it shows speed mode. I can see in code STOP, PAUSE, RESUME, is it functional? I have to rest to stop PLAYBACK. Is there a code implemented to eliminate switch bounce? Repeat delay is OK, but bouncing of the keys makes doubleclick occur at 70%. But this is not such a problem, just asking. Tomorrow I will try to connect to MZ800.
I was not using that LCD KEYPAD since I used OLED + Rotary encoder + IR remote because that keypad is a pain in the arse to use. The issue I got is sometimes the pressed key is not acquired.
EDIT: Since I corrected that line, it seems to work better: https://github.com/SHARPENTIERS/MZ-SD2CMT/blob/5d70a8ce874490515b11ab1d42df08c5a77b79b5/Arduino/mz-sd2cmt/mz-sd2cmt.input.keypad.h#L127-L131
By:
else
{
repeat_count = 0;
previous_code = code = InputCode::none;
}
We read the voltage every 10ms, not under. Maybe I should increase that period.
PAUSE and RESUME is because when MOTOR respectively goes 0V and 5V from the MZ side. You can press SELECT during PAUSE to CANCEL the loading. STOP is when you reach the end of your loading (message si "Done in..."). They should work but as long as you connected the tape connector.
Hi, I would like to renew my SHARP MZ-800 with MZ-SD2CMT as I have no cassete player now. Found this great project. Successfuly compile and run on Mega. LCD is showing first file, but it looks like LCD keypad doesnt work. No reaction from key push. Im not able to check the code as Im not experienced, but from first view it looks like there is no routine to read A0 voltage from LCD keypad to decode keypress. Could you please help? Thank you.